Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2759)

Unified Diff: chrome/browser/resources/ntp4/new_tab.js

Issue 10141005: switch ntp to jstemplate v2 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix test once and for all Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/resources/ntp4/new_tab.html ('k') | chrome/browser/resources/ntp4/other_sessions.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/ntp4/new_tab.js
diff --git a/chrome/browser/resources/ntp4/new_tab.js b/chrome/browser/resources/ntp4/new_tab.js
index c43484431c31cbf94abc6a0c36e2f0fd249dd901..9ca130e6fdf79c2e6e2148a5b409606fe796b97e 100644
--- a/chrome/browser/resources/ntp4/new_tab.js
+++ b/chrome/browser/resources/ntp4/new_tab.js
@@ -26,12 +26,6 @@ cr.define('ntp', function() {
var notificationContainer;
/**
- * Object for accessing localized strings.
- * @type {!LocalStrings}
- */
- var localStrings = new LocalStrings;
-
- /**
* If non-null, an info bubble for showing messages to the user. It points at
* the Most Visited label, and is used to draw more attention to the
* navigation dot UI.
@@ -76,7 +70,7 @@ cr.define('ntp', function() {
function NewTabView() {
var pageSwitcherStart = null;
var pageSwitcherEnd = null;
- if (templateData.showApps) {
+ if (loadTimeData.getValue('showApps')) {
pageSwitcherStart = getRequiredElement('page-switcher-start');
pageSwitcherEnd = getRequiredElement('page-switcher-end');
}
@@ -103,7 +97,7 @@ cr.define('ntp', function() {
* Invoked at startup once the DOM is available to initialize the app.
*/
function onLoad() {
- sectionsToWaitFor = templateData.showApps ? 2 : 1;
+ sectionsToWaitFor = loadTimeData.getBoolean('showApps') ? 2 : 1;
measureNavDots();
// Load the current theme colors.
@@ -118,10 +112,10 @@ cr.define('ntp', function() {
cr.ui.decorate($('recently-closed-menu-button'), ntp.RecentMenuButton);
chrome.send('getRecentlyClosedTabs');
- if (templateData.showOtherSessionsMenu) {
+ if (loadTimeData.getBoolean('showOtherSessionsMenu')) {
otherSessionsButton = getRequiredElement('other-sessions-menu-button');
cr.ui.decorate(otherSessionsButton, ntp.OtherSessionsMenuButton);
- otherSessionsButton.initialize(templateData.isUserSignedIn);
+ otherSessionsButton.initialize(loadTimeData.getBoolean('isUserSignedIn'));
}
var mostVisited = new ntp.MostVisitedPage();
@@ -130,16 +124,16 @@ cr.define('ntp', function() {
if (document.body.classList.contains('bare-minimum'))
mostVisited.appendFooter(getRequiredElement('footer'));
newTabView.appendTilePage(mostVisited,
- localStrings.getString('mostvisited'),
+ loadTimeData.getString('mostvisited'),
false);
chrome.send('getMostVisited');
- if (templateData.isSuggestionsPageEnabled) {
+ if (loadTimeData.getBoolean('isSuggestionsPageEnabled')) {
var suggestions_script = document.createElement('script');
suggestions_script.src = 'suggestions_page.js';
suggestions_script.onload = function() {
newTabView.appendTilePage(new ntp.SuggestionsPage(),
- localStrings.getString('suggestions'),
+ loadTimeData.getString('suggestions'),
false,
(newTabView.appsPages.length > 0) ?
newTabView.appsPages[0] : null);
@@ -148,9 +142,9 @@ cr.define('ntp', function() {
document.querySelector('head').appendChild(suggestions_script);
}
- var webstoreLink = localStrings.getString('webStoreLink');
- if (templateData.isWebStoreExperimentEnabled) {
- var url = appendParam(webstoreLink, 'utm_source', 'chrome-ntp-launcher');
+ var webStoreLink = loadTimeData.getString('webStoreLink');
+ if (loadTimeData.getBoolean('isWebStoreExperimentEnabled')) {
+ var url = appendParam(webStoreLink, 'utm_source', 'chrome-ntp-launcher');
$('chrome-web-store-href').href = url;
$('chrome-web-store-href').addEventListener('click',
onChromeWebStoreButtonClick);
@@ -158,12 +152,12 @@ cr.define('ntp', function() {
$('footer-content').classList.add('enable-cws-experiment');
}
- if (templateData.appInstallHintEnabled) {
- var url = appendParam(webstoreLink, 'utm_source', 'chrome-ntp-plus-icon');
+ if (loadTimeData.getBoolean('appInstallHintEnabled')) {
+ var url = appendParam(webStoreLink, 'utm_source', 'chrome-ntp-plus-icon');
$('app-install-hint-template').href = url;
}
- if (localStrings.getString('login_status_message')) {
+ if (loadTimeData.getString('login_status_message')) {
loginBubble = new cr.ui.Bubble;
loginBubble.anchorNode = $('login-container');
loginBubble.setArrowLocation(cr.ui.ArrowLocation.TOP_END);
@@ -172,8 +166,6 @@ cr.define('ntp', function() {
loginBubble.deactivateToDismissDelay = 2000;
loginBubble.setCloseButtonVisible(false);
- $('login-status-learn-more').href =
- localStrings.getString('login_status_url');
$('login-status-advanced').onclick = function() {
chrome.send('showAdvancedLoginUI');
};
@@ -185,7 +177,7 @@ cr.define('ntp', function() {
// The anchor node won't be updated until updateLogin is called so don't
// show the bubble yet.
shouldShowLoginBubble = true;
- } else if (localStrings.getString('ntp4_intro_message')) {
+ } else if (loadTimeData.valueExists('ntp4_intro_message')) {
infoBubble = new cr.ui.Bubble;
infoBubble.anchorNode = newTabView.mostVisitedPage.navigationDot;
infoBubble.setArrowLocation(cr.ui.ArrowLocation.BOTTOM_START);
@@ -197,8 +189,11 @@ cr.define('ntp', function() {
var bubbleContent = $('ntp4-intro-bubble-contents');
infoBubble.content = bubbleContent;
- var learnMoreLink = infoBubble.querySelector('a');
- learnMoreLink.href = localStrings.getString('ntp4_intro_url');
+ bubbleContent.querySelector('div > div').innerHTML =
+ loadTimeData.getString('ntp4_intro_message');
+
+ var learnMoreLink = bubbleContent.querySelector('a');
+ learnMoreLink.href = loadTimeData.getString('ntp4_intro_url');
learnMoreLink.onclick = infoBubble.hide.bind(infoBubble);
infoBubble.show();
@@ -216,8 +211,8 @@ cr.define('ntp', function() {
newTabView.cardSlider.currentCardValue.navigationDot.classList.add(
'selected');
- var promo = localStrings.getString('serverpromo');
- if (promo) {
+ if (loadTimeData.valueExists('serverpromo')) {
+ var promo = loadTimeData.getString('serverpromo');
var tags = ['IMG'];
var attrs = {
src: function(node, value) {
@@ -291,7 +286,7 @@ cr.define('ntp', function() {
*/
function measureNavDots() {
var measuringDiv = $('fontMeasuringDiv');
- measuringDiv.textContent = localStrings.getString('mostvisited');
+ measuringDiv.textContent = loadTimeData.getString('mostvisited');
// The 4 is for border and padding.
var pxWidth = Math.max(measuringDiv.clientWidth * 1.15 + 4, 80);
@@ -311,7 +306,6 @@ cr.define('ntp', function() {
opt_hasAttribution);
}
- updateLogo();
updateAttribution();
}
@@ -320,17 +314,6 @@ cr.define('ntp', function() {
}
/**
- * Sets the proper image for the logo at the bottom left.
- */
- function updateLogo() {
- var imageId = 'IDR_PRODUCT_LOGO';
- if (document.documentElement.getAttribute('customlogo') == 'true')
- imageId = 'IDR_CUSTOM_PRODUCT_LOGO';
-
- $('logo-img').src = 'chrome://theme/' + imageId + '?' + Date.now();
- }
-
- /**
* Attributes the attribution image at the bottom left.
*/
function updateAttribution() {
« no previous file with comments | « chrome/browser/resources/ntp4/new_tab.html ('k') | chrome/browser/resources/ntp4/other_sessions.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698