OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/ui/webui/ntp/ntp_resource_cache.h" | 5 #include "chrome/browser/ui/webui/ntp/ntp_resource_cache.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
317 } | 317 } |
318 | 318 |
319 localized_strings.SetString("learnMore", | 319 localized_strings.SetString("learnMore", |
320 l10n_util::GetStringUTF16(new_tab_link_ids)); | 320 l10n_util::GetStringUTF16(new_tab_link_ids)); |
321 localized_strings.SetString("learnMoreLink", new_tab_link); | 321 localized_strings.SetString("learnMoreLink", new_tab_link); |
322 | 322 |
323 bool bookmark_bar_attached = | 323 bool bookmark_bar_attached = |
324 profile_->GetPrefs()->GetBoolean(bookmarks::prefs::kShowBookmarkBar); | 324 profile_->GetPrefs()->GetBoolean(bookmarks::prefs::kShowBookmarkBar); |
325 localized_strings.SetBoolean("bookmarkbarattached", bookmark_bar_attached); | 325 localized_strings.SetBoolean("bookmarkbarattached", bookmark_bar_attached); |
326 | 326 |
327 webui::SetFontAndTextDirection(&localized_strings); | 327 const std::string& app_locale = g_browser_process->GetApplicationLocale(); |
| 328 webui::SetLoadTimeDataDefaults(app_locale, &localized_strings); |
328 | 329 |
329 static const base::StringPiece incognito_tab_html( | 330 static const base::StringPiece incognito_tab_html( |
330 ResourceBundle::GetSharedInstance().GetRawDataResource( | 331 ResourceBundle::GetSharedInstance().GetRawDataResource( |
331 new_tab_html_idr)); | 332 new_tab_html_idr)); |
332 | 333 |
333 std::string full_html = webui::GetI18nTemplateHtml( | 334 std::string full_html = webui::GetI18nTemplateHtml( |
334 incognito_tab_html, &localized_strings); | 335 incognito_tab_html, &localized_strings); |
335 | 336 |
336 new_tab_incognito_html_ = base::RefCountedString::TakeString(&full_html); | 337 new_tab_incognito_html_ = base::RefCountedString::TakeString(&full_html); |
337 } | 338 } |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
370 #endif | 371 #endif |
371 | 372 |
372 localized_strings.SetString("guestTabDescription", | 373 localized_strings.SetString("guestTabDescription", |
373 l10n_util::GetStringUTF16(guest_tab_description_ids)); | 374 l10n_util::GetStringUTF16(guest_tab_description_ids)); |
374 localized_strings.SetString("guestTabHeading", | 375 localized_strings.SetString("guestTabHeading", |
375 l10n_util::GetStringUTF16(guest_tab_heading_ids)); | 376 l10n_util::GetStringUTF16(guest_tab_heading_ids)); |
376 localized_strings.SetString("learnMore", | 377 localized_strings.SetString("learnMore", |
377 l10n_util::GetStringUTF16(guest_tab_link_ids)); | 378 l10n_util::GetStringUTF16(guest_tab_link_ids)); |
378 localized_strings.SetString("learnMoreLink", guest_tab_link); | 379 localized_strings.SetString("learnMoreLink", guest_tab_link); |
379 | 380 |
380 webui::SetFontAndTextDirection(&localized_strings); | 381 const std::string& app_locale = g_browser_process->GetApplicationLocale(); |
| 382 webui::SetLoadTimeDataDefaults(app_locale, &localized_strings); |
381 | 383 |
382 static const base::StringPiece guest_tab_html( | 384 static const base::StringPiece guest_tab_html( |
383 ResourceBundle::GetSharedInstance().GetRawDataResource(guest_tab_ids)); | 385 ResourceBundle::GetSharedInstance().GetRawDataResource(guest_tab_ids)); |
384 | 386 |
385 std::string full_html = webui::GetI18nTemplateHtml( | 387 std::string full_html = webui::GetI18nTemplateHtml( |
386 guest_tab_html, &localized_strings); | 388 guest_tab_html, &localized_strings); |
387 | 389 |
388 new_tab_guest_html_ = base::RefCountedString::TakeString(&full_html); | 390 new_tab_guest_html_ = base::RefCountedString::TakeString(&full_html); |
389 } | 391 } |
390 | 392 |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
456 load_time_data.SetBoolean("shouldShowSyncLogin", | 458 load_time_data.SetBoolean("shouldShowSyncLogin", |
457 NTPLoginHandler::ShouldShow(profile_)); | 459 NTPLoginHandler::ShouldShow(profile_)); |
458 load_time_data.SetString("otherSessions", | 460 load_time_data.SetString("otherSessions", |
459 l10n_util::GetStringUTF16(IDS_NEW_TAB_OTHER_SESSIONS_LABEL)); | 461 l10n_util::GetStringUTF16(IDS_NEW_TAB_OTHER_SESSIONS_LABEL)); |
460 load_time_data.SetString("otherSessionsEmpty", | 462 load_time_data.SetString("otherSessionsEmpty", |
461 l10n_util::GetStringUTF16(IDS_NEW_TAB_OTHER_SESSIONS_EMPTY)); | 463 l10n_util::GetStringUTF16(IDS_NEW_TAB_OTHER_SESSIONS_EMPTY)); |
462 load_time_data.SetString("otherSessionsLearnMoreUrl", | 464 load_time_data.SetString("otherSessionsLearnMoreUrl", |
463 l10n_util::GetStringUTF16(IDS_NEW_TAB_OTHER_SESSIONS_LEARN_MORE_URL)); | 465 l10n_util::GetStringUTF16(IDS_NEW_TAB_OTHER_SESSIONS_LEARN_MORE_URL)); |
464 load_time_data.SetString("learnMore", | 466 load_time_data.SetString("learnMore", |
465 l10n_util::GetStringUTF16(IDS_LEARN_MORE)); | 467 l10n_util::GetStringUTF16(IDS_LEARN_MORE)); |
| 468 const std::string& app_locale = g_browser_process->GetApplicationLocale(); |
466 load_time_data.SetString("webStoreLink", | 469 load_time_data.SetString("webStoreLink", |
467 google_util::AppendGoogleLocaleParam( | 470 google_util::AppendGoogleLocaleParam( |
468 GURL(extension_urls::GetWebstoreLaunchURL()), | 471 GURL(extension_urls::GetWebstoreLaunchURL()), app_locale).spec()); |
469 g_browser_process->GetApplicationLocale()).spec()); | |
470 load_time_data.SetString("appInstallHintText", | 472 load_time_data.SetString("appInstallHintText", |
471 l10n_util::GetStringUTF16(IDS_NEW_TAB_APP_INSTALL_HINT_LABEL)); | 473 l10n_util::GetStringUTF16(IDS_NEW_TAB_APP_INSTALL_HINT_LABEL)); |
472 load_time_data.SetBoolean("isDiscoveryInNTPEnabled", | 474 load_time_data.SetBoolean("isDiscoveryInNTPEnabled", |
473 NewTabUI::IsDiscoveryInNTPEnabled()); | 475 NewTabUI::IsDiscoveryInNTPEnabled()); |
474 load_time_data.SetString("collapseSessionMenuItemText", | 476 load_time_data.SetString("collapseSessionMenuItemText", |
475 l10n_util::GetStringUTF16(IDS_NEW_TAB_OTHER_SESSIONS_COLLAPSE_SESSION)); | 477 l10n_util::GetStringUTF16(IDS_NEW_TAB_OTHER_SESSIONS_COLLAPSE_SESSION)); |
476 load_time_data.SetString("expandSessionMenuItemText", | 478 load_time_data.SetString("expandSessionMenuItemText", |
477 l10n_util::GetStringUTF16(IDS_NEW_TAB_OTHER_SESSIONS_EXPAND_SESSION)); | 479 l10n_util::GetStringUTF16(IDS_NEW_TAB_OTHER_SESSIONS_EXPAND_SESSION)); |
478 load_time_data.SetString("restoreSessionMenuItemText", | 480 load_time_data.SetString("restoreSessionMenuItemText", |
479 l10n_util::GetStringUTF16(IDS_NEW_TAB_OTHER_SESSIONS_OPEN_ALL)); | 481 l10n_util::GetStringUTF16(IDS_NEW_TAB_OTHER_SESSIONS_OPEN_ALL)); |
(...skipping 27 matching lines...) Expand all Loading... |
507 } | 509 } |
508 | 510 |
509 #if defined(OS_CHROMEOS) | 511 #if defined(OS_CHROMEOS) |
510 load_time_data.SetString("expandMenu", | 512 load_time_data.SetString("expandMenu", |
511 l10n_util::GetStringUTF16(IDS_NEW_TAB_CLOSE_MENU_EXPAND)); | 513 l10n_util::GetStringUTF16(IDS_NEW_TAB_CLOSE_MENU_EXPAND)); |
512 #endif | 514 #endif |
513 | 515 |
514 NewTabPageHandler::GetLocalizedValues(profile_, &load_time_data); | 516 NewTabPageHandler::GetLocalizedValues(profile_, &load_time_data); |
515 NTPLoginHandler::GetLocalizedValues(profile_, &load_time_data); | 517 NTPLoginHandler::GetLocalizedValues(profile_, &load_time_data); |
516 | 518 |
517 webui::SetFontAndTextDirection(&load_time_data); | 519 webui::SetLoadTimeDataDefaults(app_locale, &load_time_data); |
518 | 520 |
519 // Control fade and resize animations. | 521 // Control fade and resize animations. |
520 load_time_data.SetBoolean("anim", | 522 load_time_data.SetBoolean("anim", |
521 gfx::Animation::ShouldRenderRichAnimation()); | 523 gfx::Animation::ShouldRenderRichAnimation()); |
522 | 524 |
523 ui::ThemeProvider* tp = ThemeServiceFactory::GetForProfile(profile_); | 525 ui::ThemeProvider* tp = ThemeServiceFactory::GetForProfile(profile_); |
524 int alignment = tp->GetDisplayProperty( | 526 int alignment = tp->GetDisplayProperty( |
525 ThemeProperties::NTP_BACKGROUND_ALIGNMENT); | 527 ThemeProperties::NTP_BACKGROUND_ALIGNMENT); |
526 load_time_data.SetString("themegravity", | 528 load_time_data.SetString("themegravity", |
527 (alignment & ThemeProperties::ALIGN_RIGHT) ? "right" : ""); | 529 (alignment & ThemeProperties::ALIGN_RIGHT) ? "right" : ""); |
(...skipping 16 matching lines...) Expand all Loading... |
544 if (bubble_promo.CanShow()) { | 546 if (bubble_promo.CanShow()) { |
545 load_time_data.SetString("bubblePromoText", | 547 load_time_data.SetString("bubblePromoText", |
546 bubble_promo.promo_text()); | 548 bubble_promo.promo_text()); |
547 DVLOG(1) << "Bubble promo:" << bubble_promo.promo_text(); | 549 DVLOG(1) << "Bubble promo:" << bubble_promo.promo_text(); |
548 } | 550 } |
549 } | 551 } |
550 | 552 |
551 // Determine whether to show the menu for accessing tabs on other devices. | 553 // Determine whether to show the menu for accessing tabs on other devices. |
552 bool show_other_sessions_menu = | 554 bool show_other_sessions_menu = |
553 should_show_other_devices_menu_ && | 555 should_show_other_devices_menu_ && |
554 !base::CommandLine::ForCurrentProcess()->HasSwitch( | 556 !base::CommandLine::ForCurrentProcess()->HasSwitch( |
555 switches::kDisableNTPOtherSessionsMenu); | 557 switches::kDisableNTPOtherSessionsMenu); |
556 load_time_data.SetBoolean("showOtherSessionsMenu", show_other_sessions_menu); | 558 load_time_data.SetBoolean("showOtherSessionsMenu", show_other_sessions_menu); |
557 load_time_data.SetBoolean( | 559 load_time_data.SetBoolean( |
558 "isUserSignedIn", | 560 "isUserSignedIn", |
559 SigninManagerFactory::GetForProfile(profile_)->IsAuthenticated()); | 561 SigninManagerFactory::GetForProfile(profile_)->IsAuthenticated()); |
560 | 562 |
561 // Load the new tab page appropriate for this build. | 563 // Load the new tab page appropriate for this build. |
562 base::StringPiece new_tab_html(ResourceBundle::GetSharedInstance(). | 564 base::StringPiece new_tab_html(ResourceBundle::GetSharedInstance(). |
563 GetRawDataResource(IDR_NEW_TAB_4_HTML)); | 565 GetRawDataResource(IDR_NEW_TAB_4_HTML)); |
564 std::string full_html = | 566 std::string full_html = |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
718 // Get our template. | 720 // Get our template. |
719 static const base::StringPiece new_tab_theme_css( | 721 static const base::StringPiece new_tab_theme_css( |
720 ResourceBundle::GetSharedInstance().GetRawDataResource( | 722 ResourceBundle::GetSharedInstance().GetRawDataResource( |
721 IDR_NEW_TAB_4_THEME_CSS)); | 723 IDR_NEW_TAB_4_THEME_CSS)); |
722 | 724 |
723 // Create the string from our template and the replacements. | 725 // Create the string from our template and the replacements. |
724 std::string css_string; | 726 std::string css_string; |
725 css_string = ReplaceStringPlaceholders(new_tab_theme_css, subst, NULL); | 727 css_string = ReplaceStringPlaceholders(new_tab_theme_css, subst, NULL); |
726 new_tab_css_ = base::RefCountedString::TakeString(&css_string); | 728 new_tab_css_ = base::RefCountedString::TakeString(&css_string); |
727 } | 729 } |
OLD | NEW |