diff options
Diffstat (limited to 'chrome/browser/resources/ntp4')
-rw-r--r-- | chrome/browser/resources/ntp4/app_launcher_promo.png | 0 | ||||
-rw-r--r-- | chrome/browser/resources/ntp4/apps_page.css | 62 | ||||
-rw-r--r-- | chrome/browser/resources/ntp4/new_tab.html | 11 | ||||
-rw-r--r-- | chrome/browser/resources/ntp4/new_tab.js | 13 | ||||
-rw-r--r-- | chrome/browser/resources/ntp4/page_list_view.js | 64 |
5 files changed, 134 insertions, 16 deletions
diff --git a/chrome/browser/resources/ntp4/app_launcher_promo.png b/chrome/browser/resources/ntp4/app_launcher_promo.png new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/chrome/browser/resources/ntp4/app_launcher_promo.png diff --git a/chrome/browser/resources/ntp4/apps_page.css b/chrome/browser/resources/ntp4/apps_page.css index dbea2ba..bd2e9cc 100644 --- a/chrome/browser/resources/ntp4/apps_page.css +++ b/chrome/browser/resources/ntp4/apps_page.css @@ -99,3 +99,65 @@ .app .invisible { visibility: hidden; } + +#app-launcher-promo { + background-color: white; + border: 1px solid lightgray; + border-bottom-width: 3px; + border-radius: 2px; + border-top-width: 2px; + bottom: 90px; + font-family: Arial, Helvetica, sans-serif; + height: 120px; + left: 50%; + margin-left: -300px; + position: fixed; + width: 600px; +} + +#app-launcher-promo > .close-button { + position: absolute; + right: 10px; + top: 10px; + width: 14px; +} + +.apps-promo-text { + color: #222; + font-size: 16px; + left: 30px; + line-height: 24px; + position: absolute; + top: 30px; +} + +.apps-promo-learn-more { + background-color: rgb(77, 144, 254); + border: 1px solid rgb(47, 91, 183); + border-radius: 2px; + color: white; + cursor: default; + font-size: 11px; + font-weight: bold; + height: 27px; + left: 30px; + line-height: 27px; + padding: 0 8px; + position: absolute; + text-align: center; + text-decoration: none; + top: 70px; + width: 90px; +} + +.apps-promo-learn-more:hover { + background-image: -webkit-linear-gradient( + top, rgb(77, 144, 254), rgb(53, 122, 232)); + border: 1px solid rgb(47, 91, 183); +} + +#app-launcher-promo > img { + bottom: 0; + position: absolute; + right: 30px; +} diff --git a/chrome/browser/resources/ntp4/new_tab.html b/chrome/browser/resources/ntp4/new_tab.html index e5bb3e3..99f8fa7 100644 --- a/chrome/browser/resources/ntp4/new_tab.html +++ b/chrome/browser/resources/ntp4/new_tab.html @@ -93,6 +93,17 @@ </div> </div> + <div id="app-launcher-promo" hidden> + <div class="apps-promo-text" i18n-content="appsPromoTitle"></div> + <a href="https://chrome.google.com/webstore/launcher" + class="apps-promo-learn-more" i18n-content="learn_more"> + </a> + <img src="app_launcher_promo.png"> + <button class="close-button custom-appearance" + id="app-launcher-promo-close-button"> + </button> + </div> + <div id="footer"> <div id="footer-border"></div> <div id="footer-content"> diff --git a/chrome/browser/resources/ntp4/new_tab.js b/chrome/browser/resources/ntp4/new_tab.js index a930f2f..a0da4fe 100644 --- a/chrome/browser/resources/ntp4/new_tab.js +++ b/chrome/browser/resources/ntp4/new_tab.js @@ -127,8 +127,13 @@ cr.define('ntp', function() { sectionsToWaitFor = 0; if (loadTimeData.getBoolean('showMostvisited')) sectionsToWaitFor++; - if (loadTimeData.getBoolean('showApps')) + if (loadTimeData.getBoolean('showApps')) { sectionsToWaitFor++; + if (loadTimeData.getBoolean('showAppLauncherPromo')) { + $('app-launcher-promo-close-button').addEventListener('click', + function() { chrome.send('stopShowingAppLauncherPromo'); }); + } + } if (loadTimeData.getBoolean('isDiscoveryInNTPEnabled')) sectionsToWaitFor++; measureNavDots(); @@ -627,6 +632,11 @@ cr.define('ntp', function() { return newTabView.appsPrefChangedCallback.apply(newTabView, arguments); } + function appLauncherPromoPrefChangeCallback() { + return newTabView.appLauncherPromoPrefChangeCallback.apply(newTabView, + arguments); + } + function appsReordered() { return newTabView.appsReordered.apply(newTabView, arguments); } @@ -670,6 +680,7 @@ cr.define('ntp', function() { appMoved: appMoved, appRemoved: appRemoved, appsPrefChangeCallback: appsPrefChangeCallback, + appLauncherPromoPrefChangeCallback: appLauncherPromoPrefChangeCallback, enterRearrangeMode: enterRearrangeMode, getAppsCallback: getAppsCallback, getAppsPageIndex: getAppsPageIndex, diff --git a/chrome/browser/resources/ntp4/page_list_view.js b/chrome/browser/resources/ntp4/page_list_view.js index 8fd5940..b95825c 100644 --- a/chrome/browser/resources/ntp4/page_list_view.js +++ b/chrome/browser/resources/ntp4/page_list_view.js @@ -218,7 +218,7 @@ cr.define('ntp', function() { * * @param {TilePage} page The page element. * @param {string} title The title of the tile page. - * @param {bool} titleIsEditable If true, the title can be changed. + * @param {boolean} titleIsEditable If true, the title can be changed. * @param {TilePage} opt_refNode Optional reference node to insert in front * of. * When opt_refNode is falsey, |page| will just be appended to the end of @@ -412,6 +412,7 @@ cr.define('ntp', function() { this.appsLoaded_ = true; cr.dispatchSimpleEvent(document, 'sectionready', true, true); } + this.updateAppLauncherPromoHiddenState_(); }, /** @@ -475,6 +476,25 @@ cr.define('ntp', function() { }, /** + * Callback invoked by chrome whenever the app launcher promo pref changes. + * @param {boolean} show Identifies if we should show or hide the promo. + */ + appLauncherPromoPrefChangeCallback: function(show) { + loadTimeData.overrideValues({showAppLauncherPromo: show}); + this.updateAppLauncherPromoHiddenState_(); + }, + + /** + * Updates the hidden state of the app launcher promo based on the page + * shown and load data content. + */ + updateAppLauncherPromoHiddenState_: function() { + $('app-launcher-promo').hidden = + !loadTimeData.getBoolean('showAppLauncherPromo') || + this.shownPage != loadTimeData.getInteger('apps_page_id'); + }, + + /** * Invoked whenever the pages in apps-page-list have changed so that * the Slider knows about the new elements. */ @@ -483,20 +503,33 @@ cr.define('ntp', function() { this.tilePages.length - 1)); this.cardSlider.setCards(Array.prototype.slice.call(this.tilePages), pageNo); - switch (this.shownPage) { - case loadTimeData.getInteger('apps_page_id'): - this.cardSlider.selectCardByValue( - this.appsPages[Math.min(this.shownPageIndex, - this.appsPages.length - 1)]); - break; - case loadTimeData.getInteger('most_visited_page_id'): - if (this.mostVisitedPage) - this.cardSlider.selectCardByValue(this.mostVisitedPage); - break; - case loadTimeData.getInteger('suggestions_page_id'): - if (this.suggestionsPage) - this.cardSlider.selectCardByValue(this.suggestionsPage); - break; + // 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); + else + this.shownPage = loadTimeData.getInteger('apps_page_id'); + } + if (this.shownPage == loadTimeData.getInteger('apps_page_id') && + loadTimeData.getBoolean('showApps')) { + this.cardSlider.selectCardByValue( + this.appsPages[Math.min(this.shownPageIndex, + this.appsPages.length - 1)]); + } else if (this.mostVisitedPage) { + this.shownPage = loadTimeData.getInteger('most_visited_page_id'); + this.cardSlider.selectCardByValue(this.mostVisitedPage); } }, @@ -651,6 +684,7 @@ cr.define('ntp', function() { this.shownPage = shownPage; this.shownPageIndex = shownPageIndex; chrome.send('pageSelected', [this.shownPage, this.shownPageIndex]); + this.updateAppLauncherPromoHiddenState_(); }, /** |