diff options
Diffstat (limited to 'chromium/chrome/browser/resources/ntp4')
21 files changed, 98 insertions, 904 deletions
diff --git a/chromium/chrome/browser/resources/ntp4/apps_page.css b/chromium/chrome/browser/resources/ntp4/apps_page.css index bd2e9ccc6c5..de0f83a4681 100644 --- a/chromium/chrome/browser/resources/ntp4/apps_page.css +++ b/chromium/chrome/browser/resources/ntp4/apps_page.css @@ -23,7 +23,7 @@ /* Active gets applied right before .suppress-active, so to avoid flicker * we need to make the scale go back to normal without an animation. */ .app-contents.suppress-active { - -webkit-transition-duration: 0; + -webkit-transition-duration: 0ms; } .app-contents > span { @@ -107,7 +107,6 @@ border-radius: 2px; border-top-width: 2px; bottom: 90px; - font-family: Arial, Helvetica, sans-serif; height: 120px; left: 50%; margin-left: -300px; diff --git a/chromium/chrome/browser/resources/ntp4/apps_page.js b/chromium/chrome/browser/resources/ntp4/apps_page.js index 952619a4ec9..bdbefcb66f4 100644 --- a/chromium/chrome/browser/resources/ntp4/apps_page.js +++ b/chromium/chrome/browser/resources/ntp4/apps_page.js @@ -11,7 +11,6 @@ cr.define('ntp', function() { NTP_APPS_COLLAPSED: 1, NTP_APPS_MENU: 2, NTP_MOST_VISITED: 3, - NTP_RECENTLY_CLOSED: 4, NTP_APP_RE_ENABLE: 16, NTP_WEBSTORE_FOOTER: 18, NTP_WEBSTORE_PLUS_ICON: 19, @@ -49,12 +48,9 @@ cr.define('ntp', function() { this.launch_.addEventListener('activate', this.onLaunch_.bind(this)); menu.appendChild(cr.ui.MenuItem.createSeparator()); - if (loadTimeData.getBoolean('enableStreamlinedHostedApps')) - this.launchRegularTab_ = this.appendMenuItem_('applaunchtypetab'); - else - this.launchRegularTab_ = this.appendMenuItem_('applaunchtyperegular'); + this.launchRegularTab_ = this.appendMenuItem_('applaunchtyperegular'); this.launchPinnedTab_ = this.appendMenuItem_('applaunchtypepinned'); - if (!cr.isMac) + if (loadTimeData.getBoolean('enableNewBookmarkApps') || !cr.isMac) this.launchNewWindow_ = this.appendMenuItem_('applaunchtypewindow'); this.launchFullscreen_ = this.appendMenuItem_('applaunchtypefullscreen'); @@ -67,12 +63,20 @@ cr.define('ntp', function() { this.launchTypeMenuSeparator_ = cr.ui.MenuItem.createSeparator(); menu.appendChild(this.launchTypeMenuSeparator_); this.options_ = this.appendMenuItem_('appoptions'); - this.details_ = this.appendMenuItem_('appdetails'); this.uninstall_ = this.appendMenuItem_('appuninstall'); + + if (loadTimeData.getBoolean('canShowAppInfoDialog')) { + this.appinfo_ = this.appendMenuItem_('appinfodialog'); + this.appinfo_.addEventListener('activate', + this.onShowAppInfo_.bind(this)); + } else { + this.details_ = this.appendMenuItem_('appdetails'); + this.details_.addEventListener('activate', + this.onShowDetails_.bind(this)); + } + this.options_.addEventListener('activate', this.onShowOptions_.bind(this)); - this.details_.addEventListener('activate', - this.onShowDetails_.bind(this)); this.uninstall_.addEventListener('activate', this.onUninstall_.bind(this)); @@ -131,20 +135,21 @@ cr.define('ntp', function() { this.launch_.textContent = app.appData.title; - var launchTypeRegularTab = this.launchRegularTab_; + var launchTypeWindow = this.launchNewWindow_; this.forAllLaunchTypes_(function(launchTypeButton, id) { launchTypeButton.disabled = false; launchTypeButton.checked = app.appData.launch_type == id; - // Streamlined hosted apps should only show the "Open as tab" button. + // If bookmark apps are enabled, only show the "Open as window" button. launchTypeButton.hidden = app.appData.packagedApp || - (loadTimeData.getBoolean('enableStreamlinedHostedApps') && - launchTypeButton != launchTypeRegularTab); + (loadTimeData.getBoolean('enableNewBookmarkApps') && + launchTypeButton != launchTypeWindow); }); this.launchTypeMenuSeparator_.hidden = app.appData.packagedApp; this.options_.disabled = !app.appData.optionsUrl || !app.appData.enabled; - this.details_.disabled = !app.appData.detailsUrl; + if (this.details_) + this.details_.disabled = !app.appData.detailsUrl; this.uninstall_.disabled = !app.appData.mayDisable; if (cr.isMac) { @@ -168,11 +173,11 @@ cr.define('ntp', function() { var pressed = e.currentTarget; var app = this.app_; var targetLaunchType = pressed; - // Streamlined hosted apps can only toggle between open as window and open - // as tab. - if (loadTimeData.getBoolean('enableStreamlinedHostedApps')) { - targetLaunchType = this.launchRegularTab_.checked ? - this.launchNewWindow_ : this.launchRegularTab_; + // When bookmark apps are enabled, hosted apps can only toggle between + // open as window and open as tab. + if (loadTimeData.getBoolean('enableNewBookmarkApps')) { + targetLaunchType = this.launchNewWindow_.checked ? + this.launchRegularTab_ : this.launchNewWindow_; } this.forAllLaunchTypes_(function(launchTypeButton, id) { if (launchTypeButton == targetLaunchType) { @@ -197,6 +202,9 @@ cr.define('ntp', function() { onCreateShortcut_: function(e) { chrome.send('createAppShortcut', [this.app_.appData.id]); }, + onShowAppInfo_: function(e) { + chrome.send('showAppInfo', [this.app_.appData.id]); + } }; /** diff --git a/chromium/chrome/browser/resources/ntp4/compiled_resources.gyp b/chromium/chrome/browser/resources/ntp4/compiled_resources.gyp index 455c47e876e..ed029528de0 100644 --- a/chromium/chrome/browser/resources/ntp4/compiled_resources.gyp +++ b/chromium/chrome/browser/resources/ntp4/compiled_resources.gyp @@ -39,9 +39,7 @@ 'page_list_view.js', 'nav_dot.js', 'other_sessions.js', - 'suggestions_page.js', 'new_tab.js', - 'recently_closed.js', ], 'externs': ['<(CLOSURE_DIR)/externs/chrome_send_externs.js'], }, diff --git a/chromium/chrome/browser/resources/ntp4/dot_list.js b/chromium/chrome/browser/resources/ntp4/dot_list.js index f445ed30add..da6ef01c28a 100644 --- a/chromium/chrome/browser/resources/ntp4/dot_list.js +++ b/chromium/chrome/browser/resources/ntp4/dot_list.js @@ -25,7 +25,6 @@ cr.define('ntp', function() { DotList.prototype = { __proto__: HTMLUListElement.prototype, - /** @override */ decorate: function() { this.addEventListener('keydown', this.onKeyDown_.bind(this)); navDots = this.getElementsByClassName('dot'); diff --git a/chromium/chrome/browser/resources/ntp4/footer_menu.css b/chromium/chrome/browser/resources/ntp4/footer_menu.css index 7e0f6689253..a4ecd586fd2 100644 --- a/chromium/chrome/browser/resources/ntp4/footer_menu.css +++ b/chromium/chrome/browser/resources/ntp4/footer_menu.css @@ -136,7 +136,7 @@ html[dir='rtl'] .footer-menu-item { } .recent-window { - background-image: url('images/closed_window.png'); + background-image: url(images/closed_window.png); } /* TODO(estade): find a better color for active. */ @@ -148,7 +148,7 @@ html[dir='rtl'] .footer-menu-item { .disclosure-triangle { -webkit-margin-start: 2px; - -webkit-mask-image: url('images/disclosure_triangle_mask.png'); + -webkit-mask-image: url(images/disclosure_triangle_mask.png); background-color: #7F7F7F; display: inline-block; height: 9px; diff --git a/chromium/chrome/browser/resources/ntp4/guest_tab.html b/chromium/chrome/browser/resources/ntp4/guest_tab.html index 1530af1cb6b..9c1150a09e6 100644 --- a/chromium/chrome/browser/resources/ntp4/guest_tab.html +++ b/chromium/chrome/browser/resources/ntp4/guest_tab.html @@ -1,19 +1,19 @@ -<!DOCTYPE html> -<html i18n-values="dir:textdirection"> +<!doctype html> +<html i18n-values="dir:textdirection;lang:language"> <head> <meta charset="utf-8"> <title i18n-content="title"></title> +<link rel="stylesheet" href="chrome://resources/css/text_defaults.css"> <link rel="stylesheet" href="incognito_and_guest_tab.css"> <script> // Until themes can clear the cache, force-reload the theme stylesheet. document.write('<link id="guestthemecss" rel="stylesheet" ' + - 'href="chrome://theme/css/guest_new_tab_theme.css?' + + 'href="chrome://theme/css/incognito_new_tab_theme.css?' + Date.now() + '">'); </script> </head> <body> -<div class="content" - i18n-values=".style.fontFamily:fontfamily;.style.fontSize:fontsize"> +<div class="content"> <h1 i18n-content="guestTabHeading"></h1> <p> <span i18n-content="guestTabDescription"></span> @@ -25,7 +25,7 @@ document.write('<link id="guestthemecss" rel="stylesheet" ' + <script> function themeChanged() { document.getElementById('guestthemecss').href = - 'chrome://theme/css/guest_new_tab_theme.css?' + Date.now(); + 'chrome://theme/css/incognito_new_tab_theme.css?' + Date.now(); } </script> </html> diff --git a/chromium/chrome/browser/resources/ntp4/incognito_tab.css b/chromium/chrome/browser/resources/ntp4/incognito_tab.css index e3b44f1857a..875d0b55651 100644 --- a/chromium/chrome/browser/resources/ntp4/incognito_tab.css +++ b/chromium/chrome/browser/resources/ntp4/incognito_tab.css @@ -9,8 +9,8 @@ .icon { -webkit-margin-start: 25px; content: -webkit-image-set( - url('../../../browser/resources/ntp4/images/incognito_icon.png') 1x, - url('../../../browser/resources/ntp4/images/2x/incognito_icon.png') 2x); + url(../../../browser/resources/ntp4/images/incognito_icon.png) 1x, + url(../../../browser/resources/ntp4/images/2x/incognito_icon.png) 2x); float: right; height: 128px; margin-bottom: 10px; diff --git a/chromium/chrome/browser/resources/ntp4/incognito_tab.html b/chromium/chrome/browser/resources/ntp4/incognito_tab.html index 7a4c8e34eae..276d854b1d9 100644 --- a/chromium/chrome/browser/resources/ntp4/incognito_tab.html +++ b/chromium/chrome/browser/resources/ntp4/incognito_tab.html @@ -1,8 +1,11 @@ -<!DOCTYPE html> -<html i18n-values="dir:textdirection;bookmarkbarattached:bookmarkbarattached"> +<!doctype html> +<html i18n-values="dir:textdirection; + bookmarkbarattached:bookmarkbarattached; + lang:language"> <head> <meta charset="utf-8"> <title i18n-content="title"></title> +<link rel="stylesheet" href="chrome://resources/css/text_defaults.css"> <link rel="stylesheet" href="incognito_and_guest_tab.css"> <link rel="stylesheet" href="incognito_tab.css"> <script> @@ -13,8 +16,7 @@ document.write('<link id="incognitothemecss" rel="stylesheet" ' + </script> </head> <body> -<div class="content" - i18n-values=".style.fontFamily:fontfamily;.style.fontSize:fontsize"> +<div class="content"> <div class="icon"></div> <span> <h1 i18n-content="incognitoTabHeading"></h1> diff --git a/chromium/chrome/browser/resources/ntp4/most_visited_page.css b/chromium/chrome/browser/resources/ntp4/most_visited_page.css index d1f15d17349..0bc0abce378 100644 --- a/chromium/chrome/browser/resources/ntp4/most_visited_page.css +++ b/chromium/chrome/browser/resources/ntp4/most_visited_page.css @@ -156,7 +156,7 @@ html[dir='rtl'] .most-visited .favicon { /* The thumbnail gets a shadow when clicked, but not when the click is on the * close button. */ .most-visited:active .close-button:not(:active) + .thumbnail .thumbnail-shield { - -webkit-box-shadow: inset 0 1px 10px rgba(0, 0, 0, 0.2); + box-shadow: inset 0 1px 10px rgba(0, 0, 0, 0.2); } .thumbnail-wrapper { diff --git a/chromium/chrome/browser/resources/ntp4/most_visited_page.js b/chromium/chrome/browser/resources/ntp4/most_visited_page.js index 0edb54af4a4..4f6cbd17a38 100644 --- a/chromium/chrome/browser/resources/ntp4/most_visited_page.js +++ b/chromium/chrome/browser/resources/ntp4/most_visited_page.js @@ -370,7 +370,7 @@ cr.define('ntp', function() { /** * Array of most visited data objects. - * @type {Array.<PageData>} + * @type {Array<PageData>} */ get data() { return this.data_; diff --git a/chromium/chrome/browser/resources/ntp4/new_guest_tab_theme.css b/chromium/chrome/browser/resources/ntp4/new_guest_tab_theme.css deleted file mode 100644 index b4d1df12dbd..00000000000 --- a/chromium/chrome/browser/resources/ntp4/new_guest_tab_theme.css +++ /dev/null @@ -1,22 +0,0 @@ -/* Copyright 2013 The Chromium Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -html { - background-attachment: fixed; - background-color: $2; - background-image: url(chrome://theme/IDR_THEME_NTP_BACKGROUND?$1); - background-position: $3; - background-repeat: $5; - height: 100%; - overflow: auto; -} - -#attribution-img { - content: url(chrome://theme/IDR_THEME_NTP_ATTRIBUTION?$1); -} - -html[bookmarkbarattached='true'] { - background-position: $4; -} diff --git a/chromium/chrome/browser/resources/ntp4/new_tab.css b/chromium/chrome/browser/resources/ntp4/new_tab.css index ca7caf500a1..3aa2ac2d869 100644 --- a/chromium/chrome/browser/resources/ntp4/new_tab.css +++ b/chromium/chrome/browser/resources/ntp4/new_tab.css @@ -80,8 +80,8 @@ html[dir='rtl'] #notification-container { background-color: transparent; /* TODO(estade): this should animate between states. */ background-image: -webkit-image-set( - url('../../../../ui/resources/default_100_percent/close_2.png') 1x, - url('../../../../ui/resources/default_200_percent/close_2.png') 2x); + url(../../../../ui/resources/default_100_percent/close_2.png) 1x, + url(../../../../ui/resources/default_200_percent/close_2.png) 2x); border: 0; cursor: default; display: inline-block; @@ -93,15 +93,15 @@ html[dir='rtl'] #notification-container { .close-button:hover, .close-button:focus { background-image: -webkit-image-set( - url('../../../../ui/resources/default_100_percent/close_2_hover.png') 1x, - url('../../../../ui/resources/default_200_percent/close_2_hover.png') 2x); + url(../../../../ui/resources/default_100_percent/close_2_hover.png) 1x, + url(../../../../ui/resources/default_200_percent/close_2_hover.png) 2x); } .close-button:active { background-image: -webkit-image-set( - url('../../../../ui/resources/default_100_percent/close_2_pressed.png') + url(../../../../ui/resources/default_100_percent/close_2_pressed.png) 1x, - url('../../../../ui/resources/default_200_percent/close_2_pressed.png') + url(../../../../ui/resources/default_200_percent/close_2_pressed.png) 2x); } @@ -143,8 +143,7 @@ body.bare-minimum #card-slider-frame { } /* For themes that right-align their images, we flip the attribution to the - * left to avoid conflicts. We also do this for bare-minimum mode since there - * can be conflicts with the recently closed menu. */ + * left to avoid conflicts. */ html[themegravity='right'] #attribution, body.bare-minimum #attribution, html[dir='rtl'] #attribution { @@ -230,9 +229,9 @@ body.bare-minimum #dot-list { /* Login Status. **************************************************************/ #login-container { - -webkit-box-shadow: none; background: transparent none; border: none; + box-shadow: none; color: inherit; cursor: pointer; font: inherit; @@ -253,6 +252,10 @@ html[dir='rtl'] #login-container { right: auto; } +#login-container [is='action-link'] { + -webkit-margin-start: 0; +} + .login-status-icon { -webkit-padding-end: 37px; background-position: right center; @@ -264,11 +267,6 @@ html[dir='rtl'] .login-status-icon { background-position-x: left; } -.profile-name:hover, -.link-span { - text-decoration: underline; -} - #login-status-bubble-contents { font-size: 1.1em; } @@ -300,8 +298,8 @@ html[dir='rtl'] .login-status-icon { #trash { -webkit-padding-start: 10px; - -webkit-transition: top 200ms, opacity 0; - -webkit-transition-delay: 0, 200ms; + -webkit-transition: top 200ms, opacity 0ms; + -webkit-transition-delay: 0ms, 200ms; color: #222; height: 100%; opacity: 0; @@ -317,8 +315,8 @@ html[dir='rtl'] #trash { } #footer.showing-trash-mode #trash { - -webkit-transition-delay: 0, 0; - -webkit-transition-duration: 0, 200ms; + -webkit-transition-delay: 0ms, 0ms; + -webkit-transition-duration: 0ms, 200ms; opacity: 0.75; top: 0; } @@ -390,7 +388,6 @@ html[dir='rtl'] #footer.showing-trash-mode #trash.drag-target .lid { #chrome-web-store-link { -webkit-order: 3; -webkit-padding-end: 12px; - /* Match transition delay of recently closed button. */ -webkit-transition-delay: 100ms; color: inherit; cursor: pointer; @@ -403,7 +400,7 @@ html[dir='rtl'] #footer.showing-trash-mode #trash.drag-target .lid { #chrome-web-store-title { -webkit-padding-end: 36px; -webkit-padding-start: 15px; - background: url('chrome://theme/IDR_WEBSTORE_ICON_24') right 50% no-repeat; + background: url(chrome://theme/IDR_WEBSTORE_ICON_24) right 50% no-repeat; display: inline-block; line-height: 49px; } @@ -434,7 +431,7 @@ html[dir='rtl'] #chrome-web-store-title { /* In trash mode, hide the menus and web store link. */ #footer.showing-trash-mode .menu-container { - -webkit-transition-delay: 0; + -webkit-transition-delay: 0ms; opacity: 0; visibility: hidden; } @@ -450,10 +447,6 @@ html[dir='rtl'] #chrome-web-store-title { min-width: -webkit-min-content; } -#recently-closed-menu-button { - -webkit-order: 1; -} - #other-sessions-menu-button { -webkit-order: 0; } diff --git a/chromium/chrome/browser/resources/ntp4/new_tab.html b/chromium/chrome/browser/resources/ntp4/new_tab.html index bb8b82b9595..4cac17a1381 100644 --- a/chromium/chrome/browser/resources/ntp4/new_tab.html +++ b/chromium/chrome/browser/resources/ntp4/new_tab.html @@ -1,10 +1,9 @@ -<!DOCTYPE html> -<html i18n-values=" - dir:textdirection; - hasattribution:hasattribution; - themegravity:themegravity; - bookmarkbarattached:bookmarkbarattached;" - class="starting-up"> +<!doctype html> +<html class="starting-up" i18n-values="dir:textdirection; + hasattribution:hasattribution; + themegravity:themegravity; + bookmarkbarattached:bookmarkbarattached; + lang:language"> <head> <meta charset="utf-8"> <title i18n-content="title"></title> @@ -20,6 +19,7 @@ <!-- It's important that this be the first script loaded. --> <script src="logging.js"></script> +<link rel="stylesheet" href="chrome://resources/css/text_defaults.css"> <link rel="stylesheet" href="../../../../ui/webui/resources/css/bubble.css"> <link rel="stylesheet" href="../../../../ui/webui/resources/css/expandable_bubble.css"> <link rel="stylesheet" href="../../../../ui/webui/resources/css/menu.css"> @@ -27,7 +27,6 @@ <link rel="stylesheet" href="../../../../ui/webui/resources/css/trash.css"> <link rel="stylesheet" href="../../../../ui/webui/resources/css/widgets.css"> <link rel="stylesheet" href="apps_page.css"> -<link rel="stylesheet" href="chrome://newtab/suggestions_page.css"> <link rel="stylesheet" href="most_visited_page.css"> <link rel="stylesheet" href="nav_dot.css"> <link rel="stylesheet" href="new_tab.css"> @@ -66,11 +65,10 @@ <script src="nav_dot.js"></script> <script src="new_tab.js"></script> -<script src="recently_closed.js"></script> <script src="other_sessions.js"></script> </head> -<body i18n-values=".style.fontFamily:fontfamily;.style.fontSize:fontsize"> +<body> <div id="notification-container" class="inactive" hidden> <div id="notification"> <span></span> @@ -123,11 +121,6 @@ <span i18n-content="otherSessions"></span> <div class="disclosure-triangle"></div> </button> - <button id="recently-closed-menu-button" - class="footer-menu-button custom-appearance" hidden> - <span i18n-content="recentlyclosed"></span> - <div class="disclosure-triangle"></div> - </button> <a id="chrome-web-store-link"> <span id="chrome-web-store-title" i18n-content="webStoreTitleShort"> </span> @@ -143,12 +136,12 @@ </div> </div> - <button id="login-container" class="custom-appearance" hidden> + <div id="login-container" hidden> <div id="login-status-header-container" class="login-status-row"> <div id="login-status-header"></div> </div> <div id="login-status-sub-header"></div> - </button> + </div> </body> <!-- A div to hold all the templates, and in the darkness bind them. --> diff --git a/chromium/chrome/browser/resources/ntp4/new_tab.js b/chromium/chrome/browser/resources/ntp4/new_tab.js index e77f4e8a0e9..4c1ac76f31e 100644 --- a/chromium/chrome/browser/resources/ntp4/new_tab.js +++ b/chromium/chrome/browser/resources/ntp4/new_tab.js @@ -137,8 +137,6 @@ cr.define('ntp', function() { function() { chrome.send('onLearnMore'); }); } } - if (loadTimeData.getBoolean('isDiscoveryInNTPEnabled')) - sectionsToWaitFor++; measureNavDots(); // Load the current theme colors. @@ -150,14 +148,6 @@ cr.define('ntp', function() { notificationContainer.addEventListener( 'webkitTransitionEnd', onNotificationTransitionEnd); - if (loadTimeData.getBoolean('showRecentlyClosed')) { - cr.ui.decorate(getRequiredElement('recently-closed-menu-button'), - ntp.RecentMenuButton); - chrome.send('getRecentlyClosedTabs'); - } else { - $('recently-closed-menu-button').hidden = true; - } - if (loadTimeData.getBoolean('showOtherSessionsMenu')) { otherSessionsButton = /** @type {!ntp.OtherSessionsMenuButton} */( getRequiredElement('other-sessions-menu-button')); @@ -179,21 +169,6 @@ cr.define('ntp', function() { chrome.send('getMostVisited'); } - if (loadTimeData.getBoolean('isDiscoveryInNTPEnabled')) { - var suggestionsScript = document.createElement('script'); - suggestionsScript.src = 'suggestions_page.js'; - suggestionsScript.onload = function() { - newTabView.appendTilePage(new ntp.SuggestionsPage(), - loadTimeData.getString('suggestions'), - false, - (newTabView.appsPages.length > 0) ? - newTabView.appsPages[0] : null); - chrome.send('getSuggestions'); - cr.dispatchSimpleEvent(document, 'sectionready', true, true); - }; - document.querySelector('head').appendChild(suggestionsScript); - } - if (!loadTimeData.getBoolean('showWebStoreIcon')) { var webStoreIcon = $('chrome-web-store-link'); // Not all versions of the NTP have a footer, so this may not exist. @@ -257,8 +232,7 @@ cr.define('ntp', function() { chrome.send('bubblePromoViewed'); } - var loginContainer = getRequiredElement('login-container'); - loginContainer.addEventListener('click', showSyncLoginUI); + $('login-container').addEventListener('click', showSyncLoginUI); if (loadTimeData.getBoolean('shouldShowSyncLogin')) chrome.send('initializeSyncLogin'); @@ -298,8 +272,6 @@ cr.define('ntp', function() { startTime = Date.now(); }); - - cr.ui.FocusManager.disableMouseFocusOnButtons(); } /** @@ -440,7 +412,7 @@ cr.define('ntp', function() { * Shows the notification bubble. * @param {string|Node} message The notification message or node to use as * message. - * @param {Array.<{text: string, action: function()}>} links An array of + * @param {Array<{text: string, action: function()}>} links An array of * records describing the links in the notification. Each record should * have a 'text' attribute (the display string) and an 'action' attribute * (a function to run when the link is activated). @@ -549,13 +521,8 @@ cr.define('ntp', function() { notificationContainer.hidden = true; } - function setRecentlyClosedTabs(dataItems) { - $('recently-closed-menu-button').dataItems = dataItems; - layoutFooter(); - } - /** - * @param {Array.<PageData>} data + * @param {Array<PageData>} data * @param {boolean} hasBlacklistedUrls */ function setMostVisitedPages(data, hasBlacklistedUrls) { @@ -563,10 +530,6 @@ cr.define('ntp', function() { cr.dispatchSimpleEvent(document, 'sectionready', true, true); } - function setSuggestionsPages(data, hasBlacklistedUrls) { - newTabView.suggestionsPage.data = data; - } - /** * Set the dominant color for a node. This will be called in response to * getFaviconDominantColor. The node represented by |id| better have a setter @@ -590,24 +553,21 @@ cr.define('ntp', function() { * @param {boolean} isUserSignedIn Indicates if the user is signed in or not. */ function updateLogin(loginHeader, loginSubHeader, iconURL, isUserSignedIn) { - if (loginHeader || loginSubHeader) { - $('login-container').hidden = false; + /** @const */ var showLogin = loginHeader || loginSubHeader; + + $('login-container').hidden = !showLogin; + $('card-slider-frame').classList.toggle('showing-login-area', !!showLogin); + + if (showLogin) { + // TODO(dbeam): we should use .textContent instead to mitigate XSS. $('login-status-header').innerHTML = loginHeader; $('login-status-sub-header').innerHTML = loginSubHeader; - $('card-slider-frame').classList.add('showing-login-area'); - - if (iconURL) { - $('login-status-header-container').style.backgroundImage = url(iconURL); - $('login-status-header-container').classList.add('login-status-icon'); - } else { - $('login-status-header-container').style.backgroundImage = 'none'; - $('login-status-header-container').classList.remove( - 'login-status-icon'); - } - } else { - $('login-container').hidden = true; - $('card-slider-frame').classList.remove('showing-login-area'); + + var headerContainer = $('login-status-header-container'); + headerContainer.classList.toggle('login-status-icon', !!iconURL); + headerContainer.style.backgroundImage = iconURL ? url(iconURL) : 'none'; } + if (shouldShowLoginBubble) { window.setTimeout(loginBubble.show.bind(loginBubble), 0); chrome.send('loginMessageSeen'); @@ -778,8 +738,6 @@ cr.define('ntp', function() { setBookmarkBarAttached: setBookmarkBarAttached, setForeignSessions: setForeignSessions, setMostVisitedPages: setMostVisitedPages, - setSuggestionsPages: setSuggestionsPages, - setRecentlyClosedTabs: setRecentlyClosedTabs, setFaviconDominantColor: setFaviconDominantColor, showNotification: showNotification, themeChanged: themeChanged, diff --git a/chromium/chrome/browser/resources/ntp4/new_tab_theme.css b/chromium/chrome/browser/resources/ntp4/new_tab_theme.css index 888eebd6a7c..a7b1888784f 100644 --- a/chromium/chrome/browser/resources/ntp4/new_tab_theme.css +++ b/chromium/chrome/browser/resources/ntp4/new_tab_theme.css @@ -25,8 +25,7 @@ body { } #attribution, -[is='action-link'], -.link-span { +[is='action-link'] { color: $21; /* COLOR_NTP_TEXT_LIGHT */ } diff --git a/chromium/chrome/browser/resources/ntp4/other_sessions.js b/chromium/chrome/browser/resources/ntp4/other_sessions.js index 38fec9d8752..bc118185082 100644 --- a/chromium/chrome/browser/resources/ntp4/other_sessions.js +++ b/chromium/chrome/browser/resources/ntp4/other_sessions.js @@ -12,7 +12,7 @@ * modifiedTime: string, * name: string, * tag: string, - * windows: Array.<WindowData>}} + * windows: Array<WindowData>}} * @see chrome/browser/ui/webui/ntp/foreign_session_handler.cc */ var SessionData; @@ -72,8 +72,8 @@ cr.define('ntp', function() { decorate: function() { MenuButton.prototype.decorate.call(this); this.menu = new Menu; + this.menu.menuItemSelector = '[role=menuitem]'; // before decoration cr.ui.decorate(this.menu, Menu); - this.menu.menuItemSelector = '[role=menuitem]'; this.menu.classList.add('footer-menu'); this.menu.addEventListener('contextmenu', this.onContextMenu_.bind(this), true); @@ -257,7 +257,7 @@ cr.define('ntp', function() { * foreign sessions, or tab sync is disabled for this profile. * |isTabSyncEnabled| makes it possible to distinguish between the cases. * - * @param {Array.<SessionData>} sessionList Array of objects describing the + * @param {Array<SessionData>} sessionList Array of objects describing the * sessions from other devices. * @param {boolean} isTabSyncEnabled Is tab sync enabled for this profile? */ diff --git a/chromium/chrome/browser/resources/ntp4/page_list_view.js b/chromium/chrome/browser/resources/ntp4/page_list_view.js index 0fac274274d..fa1513b9bd3 100644 --- a/chromium/chrome/browser/resources/ntp4/page_list_view.js +++ b/chromium/chrome/browser/resources/ntp4/page_list_view.js @@ -86,12 +86,6 @@ cr.define('ntp', function() { appsPages: undefined, /** - * The Suggestions page. - * @type {!Element|undefined} - */ - suggestionsPage: undefined, - - /** * The Most Visited page. * @type {!Element|undefined} */ @@ -273,11 +267,6 @@ cr.define('ntp', function() { this.mostVisitedPage = page; } - if (typeof ntp.SuggestionsPage != 'undefined' && - page instanceof ntp.SuggestionsPage) { - this.suggestionsPage = page; - } - // If we're appending an AppsPage and it's a temporary page, animate it. var animate = page instanceof ntp.AppsPage && page.classList.contains('temporary'); @@ -350,7 +339,7 @@ cr.define('ntp', function() { * Note that calls to this function can occur at any time, not just in * response to a getApps request. For example, when a user * installs/uninstalls an app on another synchronized devices. - * @param {{apps: Array.<AppInfo>, appPageNames: Array.<string>}} data + * @param {{apps: Array<AppInfo>, appPageNames: Array<string>}} data * An object with all the data on available applications. */ getAppsCallback: function(data) { @@ -536,19 +525,6 @@ cr.define('ntp', function() { this.tilePages.length - 1)); this.cardSlider.setCards(Array.prototype.slice.call(this.tilePages), pageNo); - // The shownPage property was potentially saved from a previous webui that - // didn't have the same set of pages as the current one. So we cascade - // from suggestions, to most visited and then to apps because we can have - // an page with apps only (e.g., chrome://apps) or one with only the most - // visited, but not one with only suggestions. And we alwayd default to - // most visited first when previously shown page is not availabel anymore. - // If most visited isn't there either, we go to apps. - if (this.shownPage == loadTimeData.getInteger('suggestions_page_id')) { - if (this.suggestionsPage) - this.cardSlider.selectCardByValue(this.suggestionsPage); - else - this.shownPage = loadTimeData.getInteger('most_visited_page_id'); - } if (this.shownPage == loadTimeData.getInteger('most_visited_page_id')) { if (this.mostVisitedPage) this.cardSlider.selectCardByValue(this.mostVisitedPage); @@ -692,8 +668,6 @@ cr.define('ntp', function() { } else if (page.classList.contains('most-visited-page')) { this.setShownPage_( loadTimeData.getInteger('most_visited_page_id'), 0); - } else if (page.classList.contains('suggestions-page')) { - this.setShownPage_(loadTimeData.getInteger('suggestions_page_id'), 0); } else { console.error('unknown page selected'); } diff --git a/chromium/chrome/browser/resources/ntp4/recently_closed.js b/chromium/chrome/browser/resources/ntp4/recently_closed.js deleted file mode 100644 index cd804df0d29..00000000000 --- a/chromium/chrome/browser/resources/ntp4/recently_closed.js +++ /dev/null @@ -1,122 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -/** - * @fileoverview The recently closed menu: button, model data, and menu. - */ - -cr.define('ntp', function() { - 'use strict'; - - /** - * Returns the text used for a recently closed window. - * @param {number} numTabs Number of tabs in the window. - * @return {string} The text to use. - */ - function formatTabsText(numTabs) { - if (numTabs == 1) - return loadTimeData.getString('closedwindowsingle'); - return loadTimeData.getStringF('closedwindowmultiple', numTabs); - } - - var Menu = cr.ui.Menu; - var MenuItem = cr.ui.MenuItem; - var MenuButton = cr.ui.MenuButton; - var RecentMenuButton = cr.ui.define('button'); - - RecentMenuButton.prototype = { - __proto__: MenuButton.prototype, - - decorate: function() { - MenuButton.prototype.decorate.call(this); - this.menu = new Menu; - cr.ui.decorate(this.menu, Menu); - this.menu.classList.add('footer-menu'); - document.body.appendChild(this.menu); - - this.needsRebuild_ = true; - this.anchorType = cr.ui.AnchorType.ABOVE; - this.invertLeftRight = true; - }, - - /** - * Shows the menu, first rebuilding it if necessary. - * TODO(estade): the right of the menu should align with the right of the - * button. - * @override - */ - showMenu: function(shouldSetFocus) { - if (this.needsRebuild_) { - this.menu.textContent = ''; - this.dataItems_.forEach(this.addItem_, this); - this.needsRebuild_ = false; - } - - MenuButton.prototype.showMenu.apply(this, arguments); - }, - - /** - * Sets the menu model data. - * @param {Array} dataItems Array of objects that describe the apps. - */ - set dataItems(dataItems) { - this.dataItems_ = dataItems; - this.needsRebuild_ = true; - this.hidden = !dataItems.length; - }, - - /** - * Adds an app to the menu. - * @param {Object} data An object encapsulating all data about the app. - * @private - */ - addItem_: function(data) { - var isWindow = data.type == 'window'; - var a = this.ownerDocument.createElement('a'); - a.className = 'footer-menu-item'; - if (isWindow) { - a.href = ''; - a.classList.add('recent-window'); - a.textContent = formatTabsText(data.tabs.length); - a.title = data.tabs.map(function(tab) { return tab.title; }).join('\n'); - } else { - a.href = data.url; - a.style.backgroundImage = getFaviconImageSet(data.url); - a.textContent = data.title; - } - - function onActivated(e) { - ntp.logTimeToClick('RecentlyClosed'); - chrome.send('recordAppLaunchByURL', - [encodeURIComponent(data.url), - ntp.APP_LAUNCH.NTP_RECENTLY_CLOSED]); - var index = Array.prototype.indexOf.call(a.parentNode.children, a); - var orig = e.originalEvent; - var button = 0; - if (orig instanceof MouseEvent) - button = orig.button; - var params = [data.sessionId, - index, - button, - orig.altKey, - orig.ctrlKey, - orig.metaKey, - orig.shiftKey]; - chrome.send('reopenTab', params); - - e.preventDefault(); - e.stopPropagation(); - } - a.addEventListener('activate', onActivated); - a.addEventListener('click', function(e) { e.preventDefault(); }); - - this.menu.appendChild(a); - cr.ui.decorate(a, MenuItem); - }, - }; - - return { - RecentMenuButton: RecentMenuButton, - }; -}); diff --git a/chromium/chrome/browser/resources/ntp4/suggestions_page.css b/chromium/chrome/browser/resources/ntp4/suggestions_page.css deleted file mode 100644 index 747d206777b..00000000000 --- a/chromium/chrome/browser/resources/ntp4/suggestions_page.css +++ /dev/null @@ -1,109 +0,0 @@ -/* Copyright (c) 2012 The Chromium Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. */ - -.suggestions { - position: absolute; - z-index: 0; -} - -.suggestions { - -webkit-box-orient: vertical; - display: -webkit-box; - position: absolute; - text-decoration: none; -} - -.suggestions:focus { - outline: none; -} - -.suggestions .close-button { - -webkit-transition: opacity 150ms; - opacity: 0; - position: absolute; - right: 0; - top: 0; - z-index: 5; -} - -html[dir=rtl] .suggestions .close-button { - left: 0; - right: auto; -} - -.suggestions:hover .close-button { - -webkit-transition-delay: 500ms; - opacity: 1; -} - -.suggestions .close-button:hover { - -webkit-transition: none; -} - -.suggestions .favicon { - -webkit-margin-start: 5px; - background: no-repeat left 50%; - bottom: 7px; - box-sizing: border-box; - display: block; - height: 16px; - position: absolute; - width: 16px; -} - -html[dir='rtl'] .suggestions .favicon { - background-position-x: right; -} - -.suggestions .color-stripe { - border-bottom-left-radius: 3px 3px; - border-bottom-right-radius: 3px 3px; - /* Matches height of title plus height of score. */ - bottom: 36px; - height: 3px; - position: absolute; - width: 100%; - z-index: 10; -} - -.suggestions .title { - display: block; - height: 18px; - overflow: hidden; - text-align: center; - text-overflow: ellipsis; - white-space: nowrap; -} - -.suggestions .score { - display: block; - height: 18px; - overflow: hidden; - text-align: center; -} - -.suggestions:focus .thumbnail, -.suggestions:hover .thumbnail { - opacity: 0.95; -} - -.suggestions:focus .thumbnail-shield, -.suggestions:hover .thumbnail-shield, -.suggestions:active .thumbnail-shield { - background: -webkit-linear-gradient(rgba(255, 255, 255, 0), - rgba(255, 255, 255, 0) 80%, - rgba(255, 255, 255, 0.9)); -} - -/* The thumbnail gets lighter when clicked, but not when the click is on the - * close button. */ -.suggestions:active .close-button:not(:active) + .thumbnail { - opacity: 0.9; -} - -/* The thumbnail gets a shadow when clicked, but not when the click is on the - * close button. */ -.suggestions:active .close-button:not(:active) + .thumbnail .thumbnail-shield { - -webkit-box-shadow: inset 0 1px 10px rgba(0, 0, 0, 0.2); -} diff --git a/chromium/chrome/browser/resources/ntp4/suggestions_page.js b/chromium/chrome/browser/resources/ntp4/suggestions_page.js deleted file mode 100644 index 6dc5ecdd14b..00000000000 --- a/chromium/chrome/browser/resources/ntp4/suggestions_page.js +++ /dev/null @@ -1,478 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -cr.define('ntp', function() { - 'use strict'; - - var TilePage = ntp.TilePage; - - /** - * A counter for generating unique tile IDs. - */ - var tileID = 0; - - /** - * Creates a new Suggestions page object for tiling. - * @constructor - * @extends {HTMLAnchorElement} - */ - function Suggestion() { - var el = cr.doc.createElement('a'); - el.__proto__ = Suggestion.prototype; - el.initialize(); - - return el; - } - - Suggestion.prototype = { - __proto__: HTMLAnchorElement.prototype, - - initialize: function() { - this.reset(); - - this.addEventListener('click', this.handleClick_); - this.addEventListener('keydown', this.handleKeyDown_); - }, - - get index() { - assert(this.tile); - return this.tile.index; - }, - - get data() { - return this.data_; - }, - - /** - * Clears the DOM hierarchy for this node, setting it back to the default - * for a blank thumbnail. TODO(georgey) make it a template. - */ - reset: function() { - this.className = 'suggestions filler real'; - this.innerHTML = - '<span class="thumbnail-wrapper fills-parent">' + - '<div class="close-button"></div>' + - '<span class="thumbnail fills-parent">' + - // thumbnail-shield provides a gradient fade effect. - '<div class="thumbnail-shield fills-parent"></div>' + - '</span>' + - '<span class="favicon"></span>' + - '</span>' + - '<div class="color-stripe"></div>' + - '<span class="title"></span>' + - '<span class="score"></span>'; - - this.querySelector('.close-button').title = - loadTimeData.getString('removethumbnailtooltip'); - - this.tabIndex = -1; - this.data_ = null; - this.removeAttribute('id'); - this.title = ''; - }, - - /** - * Update the appearance of this tile according to |data|. - * @param {{score: number, url: string, title: string, direction: string, - * filler: boolean}} data A dictionary of relevant data for the page. - * @see chrome/browser/ui/webui/ntp/suggestions_source_top_sites.cc - * @see chrome/browser/ui/webui/ntp/most_visited_handler.cc - */ - updateForData: function(data) { - if (this.classList.contains('blacklisted') && data) { - // Animate appearance of new tile. - this.classList.add('new-tile-contents'); - } - this.classList.remove('blacklisted'); - - if (!data || data.filler) { - if (this.data_) - this.reset(); - return; - } - - var id = tileID++; - this.id = 'suggestions-tile-' + id; - this.data_ = data; - this.classList.add('focusable'); - - var faviconDiv = this.querySelector('.favicon'); - var faviconUrl = 'chrome://favicon/size/16@1x/' + data.url; - faviconDiv.style.backgroundImage = url(faviconUrl); - chrome.send('getFaviconDominantColor', [faviconUrl, this.id]); - - var title = this.querySelector('.title'); - title.textContent = data.title; - title.dir = data.direction; - - var score = this.querySelector('.score'); - score.textContent = data.score; - - // Sets the tooltip. - this.title = data.title; - - var thumbnailUrl; - thumbnailUrl = data.urlImage ? data.urlImage : - 'chrome://thumb/' + data.url; - - this.querySelector('.thumbnail').style.backgroundImage = - url(thumbnailUrl); - - this.href = data.url; - - this.classList.remove('filler'); - }, - - /** - * Sets the color of the favicon dominant color bar. - * @param {string} color The css-parsable value for the color. - */ - set stripeColor(color) { - this.querySelector('.color-stripe').style.backgroundColor = color; - }, - - /** - * Handles a click on the tile. - * @param {Event} e The click event. - */ - handleClick_: function(e) { - if (e.target.classList.contains('close-button')) { - this.blacklist_(); - e.preventDefault(); - } else { - // Records the index of this tile. - chrome.send('metricsHandler:recordInHistogram', - ['NewTabPage.SuggestedSite', this.index, 8]); - chrome.send('suggestedSitesAction', - [ntp.NtpFollowAction.CLICKED_TILE]); - } - }, - - /** - * Allow blacklisting suggestions site using the keyboard. - * @param {Event} e The keydown event. - */ - handleKeyDown_: function(e) { - if (!cr.isMac && e.keyCode == 46 || // Del - cr.isMac && e.metaKey && e.keyCode == 8) { // Cmd + Backspace - this.blacklist_(); - } - }, - - /** - * Permanently removes a page from Suggestions. - */ - blacklist_: function() { - this.showUndoNotification_(); - chrome.send('blacklistURLFromSuggestions', [this.data_.url]); - this.reset(); - chrome.send('getSuggestions'); - this.classList.add('blacklisted'); - }, - - /** - * Shows notification that you can undo blacklisting. - */ - showUndoNotification_: function() { - var data = this.data_; - var self = this; - var doUndo = function() { - chrome.send('removeURLsFromSuggestionsBlacklist', [data.url]); - self.updateForData(data); - }; - - var undo = { - action: doUndo, - text: loadTimeData.getString('undothumbnailremove'), - }; - - var undoAll = { - action: function() { - chrome.send('clearSuggestionsURLsBlacklist'); - }, - text: loadTimeData.getString('restoreThumbnailsShort'), - }; - - ntp.showNotification( - loadTimeData.getString('thumbnailremovednotification'), - [undo, undoAll]); - }, - - /** - * Set the size and position of the suggestions tile. - * @param {number} size The total size of |this|. - * @param {number} x The x-position. - * @param {number} y The y-position. - */ - setBounds: function(size, x, y) { - this.style.width = size + 'px'; - this.style.height = heightForWidth(size) + 'px'; - - this.style.left = x + 'px'; - this.style.right = x + 'px'; - this.style.top = y + 'px'; - }, - - /** - * Returns whether this element can be 'removed' from chrome (i.e. whether - * the user can drag it onto the trash and expect something to happen). - * @return {boolean} True, since suggestions pages can always be - * blacklisted. - */ - canBeRemoved: function() { - return true; - }, - - /** - * Removes this element from chrome, i.e. blacklists it. - */ - removeFromChrome: function() { - this.blacklist_(); - this.parentNode.classList.add('finishing-drag'); - }, - - /** - * Called when a drag of this tile has ended (after all animations have - * finished). - */ - finalizeDrag: function() { - this.parentNode.classList.remove('finishing-drag'); - }, - - /** - * Called when a drag is starting on the tile. Updates dataTransfer with - * data for this tile (for dragging outside of the NTP). - * @param {DataTransfer} dataTransfer The drag event data store. - */ - setDragData: function(dataTransfer) { - dataTransfer.setData('Text', this.data_.title); - dataTransfer.setData('URL', this.data_.url); - }, - }; - - var suggestionsPageGridValues = { - // The fewest tiles we will show in a row. - minColCount: 2, - // The suggestions we will show in a row. - maxColCount: 4, - - // The smallest a tile can be. - minTileWidth: 122, - // The biggest a tile can be. 212 (max thumbnail width) + 2. - maxTileWidth: 214, - - // The padding between tiles, as a fraction of the tile width. - tileSpacingFraction: 1 / 8, - }; - TilePage.initGridValues(suggestionsPageGridValues); - - /** - * Calculates the height for a Suggestion tile for a given width. The size - * is based on the thumbnail, which should have a 212:132 ratio. - * @return {number} The height. - */ - function heightForWidth(width) { - // The 2s are for borders, the 36 is for the title and score. - return (width - 2) * 132 / 212 + 2 + 36; - } - - var THUMBNAIL_COUNT = 8; - - /** - * Creates a new SuggestionsPage object. - * @constructor - * @extends {TilePage} - */ - function SuggestionsPage() { - var el = new TilePage(suggestionsPageGridValues); - el.__proto__ = SuggestionsPage.prototype; - el.initialize(); - - return el; - } - - SuggestionsPage.prototype = { - __proto__: TilePage.prototype, - - initialize: function() { - this.classList.add('suggestions-page'); - this.data_ = null; - this.suggestionsTiles_ = this.getElementsByClassName('suggestions real'); - - this.addEventListener('carddeselected', this.handleCardDeselected_); - this.addEventListener('cardselected', this.handleCardSelected_); - }, - - /** - * Create blank (filler) tiles. - * @private - */ - createTiles_: function() { - for (var i = 0; i < THUMBNAIL_COUNT; i++) { - this.appendTile(new Suggestion(), false); - } - }, - - /** - * Update the tiles after a change to |this.data_|. - */ - updateTiles_: function() { - for (var i = 0; i < THUMBNAIL_COUNT; i++) { - var page = this.data_[i]; - var tile = this.suggestionsTiles_[i]; - - if (i >= this.data_.length) - tile.reset(); - else - tile.updateForData(page); - } - }, - - /** - * Handles the 'card deselected' event (i.e. the user clicked to another - * pane). - * @param {Event} e The CardChanged event. - */ - handleCardDeselected_: function(e) { - if (!document.documentElement.classList.contains('starting-up')) { - chrome.send('suggestedSitesAction', - [ntp.NtpFollowAction.CLICKED_OTHER_NTP_PANE]); - } - }, - - /** - * Handles the 'card selected' event (i.e. the user clicked to select the - * Suggested pane). - * @param {Event} e The CardChanged event. - */ - handleCardSelected_: function(e) { - if (!document.documentElement.classList.contains('starting-up')) - chrome.send('suggestedSitesSelected'); - }, - - /** - * Array of suggestions data objects. - * @type {Array} - */ - get data() { - return this.data_; - }, - set data(data) { - var startTime = Date.now(); - - // The first time data is set, create the tiles. - if (!this.data_) { - this.createTiles_(); - this.data_ = data.slice(0, THUMBNAIL_COUNT); - } else { - this.data_ = refreshData(this.data_, data); - } - - this.updateTiles_(); - this.updateFocusableElement(); - logEvent('suggestions.layout: ' + (Date.now() - startTime)); - }, - - /** @override */ - shouldAcceptDrag: function(e) { - return false; - }, - - /** @override */ - heightForWidth: heightForWidth, - }; - - /** - * Executed once the NTP has loaded. Checks if the Suggested pane is - * shown or not. If it is shown, the 'suggestedSitesSelected' message is sent - * to the C++ code, to record the fact that the user has seen this pane. - */ - SuggestionsPage.onLoaded = function() { - if (ntp.getCardSlider() && - ntp.getCardSlider().currentCardValue && - ntp.getCardSlider().currentCardValue.classList - .contains('suggestions-page')) { - chrome.send('suggestedSitesSelected'); - } - }; - - /** - * We've gotten additional data for Suggestions page. Update our old data with - * the new data. The ordering of the new data is not important, except when a - * page is pinned. Thus we try to minimize re-ordering. - * @param {Array} oldData The current Suggestions page list. - * @param {Array} newData The new Suggestions page list. - * @return {Array} The merged page list that should replace the current page - * list. - */ - function refreshData(oldData, newData) { - oldData = oldData.slice(0, THUMBNAIL_COUNT); - newData = newData.slice(0, THUMBNAIL_COUNT); - - // Copy over pinned sites directly. - for (var i = 0; i < newData.length; i++) { - if (newData[i].pinned) { - oldData[i] = newData[i]; - // Mark the entry as 'updated' so we don't try to update again. - oldData[i].updated = true; - // Mark the newData page as 'used' so we don't try to re-use it. - newData[i].used = true; - } - } - - // Look through old pages; if they exist in the newData list, keep them - // where they are. - for (var i = 0; i < oldData.length; i++) { - if (!oldData[i] || oldData[i].updated) - continue; - - for (var j = 0; j < newData.length; j++) { - if (newData[j].used) - continue; - - if (newData[j].url == oldData[i].url) { - // The background image and other data may have changed. - oldData[i] = newData[j]; - oldData[i].updated = true; - newData[j].used = true; - break; - } - } - } - - // Look through old pages that haven't been updated yet; replace them. - for (var i = 0; i < oldData.length; i++) { - if (oldData[i] && oldData[i].updated) - continue; - - for (var j = 0; j < newData.length; j++) { - if (newData[j].used) - continue; - - oldData[i] = newData[j]; - oldData[i].updated = true; - newData[j].used = true; - break; - } - - if (oldData[i] && !oldData[i].updated) - oldData[i] = null; - } - - // Clear 'updated' flags so this function will work next time it's called. - for (var i = 0; i < THUMBNAIL_COUNT; i++) { - if (oldData[i]) - oldData[i].updated = false; - } - - return oldData; - } - - return { - SuggestionsPage: SuggestionsPage, - refreshData: refreshData, - }; -}); - -document.addEventListener('ntpLoaded', ntp.SuggestionsPage.onLoaded); diff --git a/chromium/chrome/browser/resources/ntp4/tile_page.js b/chromium/chrome/browser/resources/ntp4/tile_page.js index 0f7d430072b..bc773672823 100644 --- a/chromium/chrome/browser/resources/ntp4/tile_page.js +++ b/chromium/chrome/browser/resources/ntp4/tile_page.js @@ -287,7 +287,7 @@ cr.define('ntp', function() { onDragCloneTransitionEnd_: function(e) { if (this.classList.contains('dragging') && (e.propertyName == 'left' || e.propertyName == 'top' || - e.propertyName == '-webkit-transform')) { + e.propertyName == 'transform')) { this.finalizeDrag_(); } }, @@ -1132,7 +1132,9 @@ cr.define('ntp', function() { * @param {Event} e The mousewheel event. */ handleMouseWheel: function(e) { - if (e.wheelDeltaY == 0) + // The ctrl-wheel should triggle the zoom in/out actions in Chromium for + // all pages. + if (e.wheelDeltaY == 0 || e.ctrlKey) return false; this.content_.scrollTop -= e.wheelDeltaY / 3; |