| 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 29 matching lines...) Expand all Loading... |
| 509 } | 511 } |
| 510 | 512 |
| 511 #if defined(OS_CHROMEOS) | 513 #if defined(OS_CHROMEOS) |
| 512 load_time_data.SetString("expandMenu", | 514 load_time_data.SetString("expandMenu", |
| 513 l10n_util::GetStringUTF16(IDS_NEW_TAB_CLOSE_MENU_EXPAND)); | 515 l10n_util::GetStringUTF16(IDS_NEW_TAB_CLOSE_MENU_EXPAND)); |
| 514 #endif | 516 #endif |
| 515 | 517 |
| 516 NewTabPageHandler::GetLocalizedValues(profile_, &load_time_data); | 518 NewTabPageHandler::GetLocalizedValues(profile_, &load_time_data); |
| 517 NTPLoginHandler::GetLocalizedValues(profile_, &load_time_data); | 519 NTPLoginHandler::GetLocalizedValues(profile_, &load_time_data); |
| 518 | 520 |
| 519 webui::SetFontAndTextDirection(&load_time_data); | 521 webui::SetLoadTimeDataDefaults(app_locale, &load_time_data); |
| 520 | 522 |
| 521 // Control fade and resize animations. | 523 // Control fade and resize animations. |
| 522 load_time_data.SetBoolean("anim", | 524 load_time_data.SetBoolean("anim", |
| 523 gfx::Animation::ShouldRenderRichAnimation()); | 525 gfx::Animation::ShouldRenderRichAnimation()); |
| 524 | 526 |
| 525 ui::ThemeProvider* tp = ThemeServiceFactory::GetForProfile(profile_); | 527 ui::ThemeProvider* tp = ThemeServiceFactory::GetForProfile(profile_); |
| 526 int alignment = tp->GetDisplayProperty( | 528 int alignment = tp->GetDisplayProperty( |
| 527 ThemeProperties::NTP_BACKGROUND_ALIGNMENT); | 529 ThemeProperties::NTP_BACKGROUND_ALIGNMENT); |
| 528 load_time_data.SetString("themegravity", | 530 load_time_data.SetString("themegravity", |
| 529 (alignment & ThemeProperties::ALIGN_RIGHT) ? "right" : ""); | 531 (alignment & ThemeProperties::ALIGN_RIGHT) ? "right" : ""); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 546 if (bubble_promo.CanShow()) { | 548 if (bubble_promo.CanShow()) { |
| 547 load_time_data.SetString("bubblePromoText", | 549 load_time_data.SetString("bubblePromoText", |
| 548 bubble_promo.promo_text()); | 550 bubble_promo.promo_text()); |
| 549 DVLOG(1) << "Bubble promo:" << bubble_promo.promo_text(); | 551 DVLOG(1) << "Bubble promo:" << bubble_promo.promo_text(); |
| 550 } | 552 } |
| 551 } | 553 } |
| 552 | 554 |
| 553 // Determine whether to show the menu for accessing tabs on other devices. | 555 // Determine whether to show the menu for accessing tabs on other devices. |
| 554 bool show_other_sessions_menu = | 556 bool show_other_sessions_menu = |
| 555 should_show_other_devices_menu_ && | 557 should_show_other_devices_menu_ && |
| 556 !base::CommandLine::ForCurrentProcess()->HasSwitch( | 558 !base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 557 switches::kDisableNTPOtherSessionsMenu); | 559 switches::kDisableNTPOtherSessionsMenu); |
| 558 load_time_data.SetBoolean("showOtherSessionsMenu", show_other_sessions_menu); | 560 load_time_data.SetBoolean("showOtherSessionsMenu", show_other_sessions_menu); |
| 559 load_time_data.SetBoolean( | 561 load_time_data.SetBoolean( |
| 560 "isUserSignedIn", | 562 "isUserSignedIn", |
| 561 SigninManagerFactory::GetForProfile(profile_)->IsAuthenticated()); | 563 SigninManagerFactory::GetForProfile(profile_)->IsAuthenticated()); |
| 562 | 564 |
| 563 // Load the new tab page appropriate for this build. | 565 // Load the new tab page appropriate for this build. |
| 564 base::StringPiece new_tab_html(ResourceBundle::GetSharedInstance(). | 566 base::StringPiece new_tab_html(ResourceBundle::GetSharedInstance(). |
| 565 GetRawDataResource(IDR_NEW_TAB_4_HTML)); | 567 GetRawDataResource(IDR_NEW_TAB_4_HTML)); |
| 566 std::string full_html = | 568 std::string full_html = |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 720 // Get our template. | 722 // Get our template. |
| 721 static const base::StringPiece new_tab_theme_css( | 723 static const base::StringPiece new_tab_theme_css( |
| 722 ResourceBundle::GetSharedInstance().GetRawDataResource( | 724 ResourceBundle::GetSharedInstance().GetRawDataResource( |
| 723 IDR_NEW_TAB_4_THEME_CSS)); | 725 IDR_NEW_TAB_4_THEME_CSS)); |
| 724 | 726 |
| 725 // Create the string from our template and the replacements. | 727 // Create the string from our template and the replacements. |
| 726 std::string css_string; | 728 std::string css_string; |
| 727 css_string = ReplaceStringPlaceholders(new_tab_theme_css, subst, NULL); | 729 css_string = ReplaceStringPlaceholders(new_tab_theme_css, subst, NULL); |
| 728 new_tab_css_ = base::RefCountedString::TakeString(&css_string); | 730 new_tab_css_ = base::RefCountedString::TakeString(&css_string); |
| 729 } | 731 } |
| OLD | NEW |