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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 #if defined(OS_CHROMEOS) | 74 #if defined(OS_CHROMEOS) |
75 "https://www.google.com/support/chromeos/bin/answer.py?answer=95464"; | 75 "https://www.google.com/support/chromeos/bin/answer.py?answer=95464"; |
76 #else | 76 #else |
77 "https://www.google.com/support/chrome/bin/answer.py?answer=95464"; | 77 "https://www.google.com/support/chrome/bin/answer.py?answer=95464"; |
78 #endif | 78 #endif |
79 | 79 |
80 // The URL for the Learn More page shown on guest session new tab. | 80 // The URL for the Learn More page shown on guest session new tab. |
81 const char kLearnMoreGuestSessionUrl[] = | 81 const char kLearnMoreGuestSessionUrl[] = |
82 "https://www.google.com/support/chromeos/bin/answer.py?answer=1057090"; | 82 "https://www.google.com/support/chromeos/bin/answer.py?answer=1057090"; |
83 | 83 |
84 base::string16 GetUrlWithLang(const GURL& url) { | |
85 return base::ASCIIToUTF16(google_util::AppendGoogleLocaleParam(url).spec()); | |
86 } | |
87 | |
88 std::string SkColorToRGBAString(SkColor color) { | 84 std::string SkColorToRGBAString(SkColor color) { |
89 // We convert the alpha using DoubleToString because StringPrintf will use | 85 // We convert the alpha using DoubleToString because StringPrintf will use |
90 // locale specific formatters (e.g., use , instead of . in German). | 86 // locale specific formatters (e.g., use , instead of . in German). |
91 return base::StringPrintf( | 87 return base::StringPrintf( |
92 "rgba(%d,%d,%d,%s)", | 88 "rgba(%d,%d,%d,%s)", |
93 SkColorGetR(color), | 89 SkColorGetR(color), |
94 SkColorGetG(color), | 90 SkColorGetG(color), |
95 SkColorGetB(color), | 91 SkColorGetB(color), |
96 base::DoubleToString(SkColorGetA(color) / 255.0).c_str()); | 92 base::DoubleToString(SkColorGetA(color) / 255.0).c_str()); |
97 } | 93 } |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
307 localized_strings.SetString("incognitoTabDescription", | 303 localized_strings.SetString("incognitoTabDescription", |
308 l10n_util::GetStringUTF16(new_tab_description_ids)); | 304 l10n_util::GetStringUTF16(new_tab_description_ids)); |
309 localized_strings.SetString("incognitoTabHeading", | 305 localized_strings.SetString("incognitoTabHeading", |
310 l10n_util::GetStringUTF16(new_tab_heading_ids)); | 306 l10n_util::GetStringUTF16(new_tab_heading_ids)); |
311 localized_strings.SetString("incognitoTabWarning", | 307 localized_strings.SetString("incognitoTabWarning", |
312 l10n_util::GetStringUTF16(new_tab_warning_ids)); | 308 l10n_util::GetStringUTF16(new_tab_warning_ids)); |
313 } | 309 } |
314 | 310 |
315 localized_strings.SetString("learnMore", | 311 localized_strings.SetString("learnMore", |
316 l10n_util::GetStringUTF16(new_tab_link_ids)); | 312 l10n_util::GetStringUTF16(new_tab_link_ids)); |
317 localized_strings.SetString("learnMoreLink", | 313 localized_strings.SetString("learnMoreLink", GURL(new_tab_link).spec()); |
318 GetUrlWithLang(GURL(new_tab_link))); | |
319 | 314 |
320 bool bookmark_bar_attached = profile_->GetPrefs()->GetBoolean( | 315 bool bookmark_bar_attached = profile_->GetPrefs()->GetBoolean( |
321 prefs::kShowBookmarkBar); | 316 prefs::kShowBookmarkBar); |
322 localized_strings.SetBoolean("bookmarkbarattached", bookmark_bar_attached); | 317 localized_strings.SetBoolean("bookmarkbarattached", bookmark_bar_attached); |
323 | 318 |
324 webui::SetFontAndTextDirection(&localized_strings); | 319 webui::SetFontAndTextDirection(&localized_strings); |
325 | 320 |
326 static const base::StringPiece incognito_tab_html( | 321 static const base::StringPiece incognito_tab_html( |
327 ResourceBundle::GetSharedInstance().GetRawDataResource( | 322 ResourceBundle::GetSharedInstance().GetRawDataResource( |
328 new_tab_html_idr)); | 323 new_tab_html_idr)); |
(...skipping 25 matching lines...) Expand all Loading... |
354 if (!enterprise_domain.empty()) { | 349 if (!enterprise_domain.empty()) { |
355 // Device is enterprise enrolled. | 350 // Device is enterprise enrolled. |
356 localized_strings.SetString("enterpriseInfoVisible", "true"); | 351 localized_strings.SetString("enterpriseInfoVisible", "true"); |
357 base::string16 enterprise_info = l10n_util::GetStringFUTF16( | 352 base::string16 enterprise_info = l10n_util::GetStringFUTF16( |
358 IDS_DEVICE_OWNED_BY_NOTICE, | 353 IDS_DEVICE_OWNED_BY_NOTICE, |
359 base::UTF8ToUTF16(enterprise_domain)); | 354 base::UTF8ToUTF16(enterprise_domain)); |
360 localized_strings.SetString("enterpriseInfoMessage", enterprise_info); | 355 localized_strings.SetString("enterpriseInfoMessage", enterprise_info); |
361 localized_strings.SetString("enterpriseLearnMore", | 356 localized_strings.SetString("enterpriseLearnMore", |
362 l10n_util::GetStringUTF16(IDS_LEARN_MORE)); | 357 l10n_util::GetStringUTF16(IDS_LEARN_MORE)); |
363 localized_strings.SetString("enterpriseInfoHintLink", | 358 localized_strings.SetString("enterpriseInfoHintLink", |
364 GetUrlWithLang(GURL(chrome::kLearnMoreEnterpriseURL))); | 359 GURL(chrome::kLearnMoreEnterpriseURL).spec()); |
365 } else { | 360 } else { |
366 localized_strings.SetString("enterpriseInfoVisible", "false"); | 361 localized_strings.SetString("enterpriseInfoVisible", "false"); |
367 } | 362 } |
368 #endif | 363 #endif |
369 | 364 |
370 localized_strings.SetString("guestTabDescription", | 365 localized_strings.SetString("guestTabDescription", |
371 l10n_util::GetStringUTF16(guest_tab_description_ids)); | 366 l10n_util::GetStringUTF16(guest_tab_description_ids)); |
372 localized_strings.SetString("guestTabHeading", | 367 localized_strings.SetString("guestTabHeading", |
373 l10n_util::GetStringUTF16(guest_tab_heading_ids)); | 368 l10n_util::GetStringUTF16(guest_tab_heading_ids)); |
374 localized_strings.SetString("learnMore", | 369 localized_strings.SetString("learnMore", |
375 l10n_util::GetStringUTF16(guest_tab_link_ids)); | 370 l10n_util::GetStringUTF16(guest_tab_link_ids)); |
376 localized_strings.SetString("learnMoreLink", | 371 localized_strings.SetString("learnMoreLink", |
377 GetUrlWithLang(GURL(guest_tab_link))); | 372 GURL(guest_tab_link).spec()); |
378 | 373 |
379 webui::SetFontAndTextDirection(&localized_strings); | 374 webui::SetFontAndTextDirection(&localized_strings); |
380 | 375 |
381 static const base::StringPiece guest_tab_html( | 376 static const base::StringPiece guest_tab_html( |
382 ResourceBundle::GetSharedInstance().GetRawDataResource(guest_tab_ids)); | 377 ResourceBundle::GetSharedInstance().GetRawDataResource(guest_tab_ids)); |
383 | 378 |
384 std::string full_html = webui::GetI18nTemplateHtml( | 379 std::string full_html = webui::GetI18nTemplateHtml( |
385 guest_tab_html, &localized_strings); | 380 guest_tab_html, &localized_strings); |
386 | 381 |
387 new_tab_guest_html_ = base::RefCountedString::TakeString(&full_html); | 382 new_tab_guest_html_ = base::RefCountedString::TakeString(&full_html); |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
456 NTPLoginHandler::ShouldShow(profile_)); | 451 NTPLoginHandler::ShouldShow(profile_)); |
457 load_time_data.SetString("otherSessions", | 452 load_time_data.SetString("otherSessions", |
458 l10n_util::GetStringUTF16(IDS_NEW_TAB_OTHER_SESSIONS_LABEL)); | 453 l10n_util::GetStringUTF16(IDS_NEW_TAB_OTHER_SESSIONS_LABEL)); |
459 load_time_data.SetString("otherSessionsEmpty", | 454 load_time_data.SetString("otherSessionsEmpty", |
460 l10n_util::GetStringUTF16(IDS_NEW_TAB_OTHER_SESSIONS_EMPTY)); | 455 l10n_util::GetStringUTF16(IDS_NEW_TAB_OTHER_SESSIONS_EMPTY)); |
461 load_time_data.SetString("otherSessionsLearnMoreUrl", | 456 load_time_data.SetString("otherSessionsLearnMoreUrl", |
462 l10n_util::GetStringUTF16(IDS_NEW_TAB_OTHER_SESSIONS_LEARN_MORE_URL)); | 457 l10n_util::GetStringUTF16(IDS_NEW_TAB_OTHER_SESSIONS_LEARN_MORE_URL)); |
463 load_time_data.SetString("learnMore", | 458 load_time_data.SetString("learnMore", |
464 l10n_util::GetStringUTF16(IDS_LEARN_MORE)); | 459 l10n_util::GetStringUTF16(IDS_LEARN_MORE)); |
465 load_time_data.SetString("webStoreLink", | 460 load_time_data.SetString("webStoreLink", |
466 GetUrlWithLang(GURL(extension_urls::GetWebstoreLaunchURL()))); | 461 google_util::AppendGoogleLocaleParam( |
| 462 GURL(extension_urls::GetWebstoreLaunchURL())).spec()); |
467 load_time_data.SetString("appInstallHintText", | 463 load_time_data.SetString("appInstallHintText", |
468 l10n_util::GetStringUTF16(IDS_NEW_TAB_APP_INSTALL_HINT_LABEL)); | 464 l10n_util::GetStringUTF16(IDS_NEW_TAB_APP_INSTALL_HINT_LABEL)); |
469 load_time_data.SetBoolean("isDiscoveryInNTPEnabled", | 465 load_time_data.SetBoolean("isDiscoveryInNTPEnabled", |
470 NewTabUI::IsDiscoveryInNTPEnabled()); | 466 NewTabUI::IsDiscoveryInNTPEnabled()); |
471 load_time_data.SetString("collapseSessionMenuItemText", | 467 load_time_data.SetString("collapseSessionMenuItemText", |
472 l10n_util::GetStringUTF16(IDS_NEW_TAB_OTHER_SESSIONS_COLLAPSE_SESSION)); | 468 l10n_util::GetStringUTF16(IDS_NEW_TAB_OTHER_SESSIONS_COLLAPSE_SESSION)); |
473 load_time_data.SetString("expandSessionMenuItemText", | 469 load_time_data.SetString("expandSessionMenuItemText", |
474 l10n_util::GetStringUTF16(IDS_NEW_TAB_OTHER_SESSIONS_EXPAND_SESSION)); | 470 l10n_util::GetStringUTF16(IDS_NEW_TAB_OTHER_SESSIONS_EXPAND_SESSION)); |
475 load_time_data.SetString("restoreSessionMenuItemText", | 471 load_time_data.SetString("restoreSessionMenuItemText", |
476 l10n_util::GetStringUTF16(IDS_NEW_TAB_OTHER_SESSIONS_OPEN_ALL)); | 472 l10n_util::GetStringUTF16(IDS_NEW_TAB_OTHER_SESSIONS_OPEN_ALL)); |
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
720 // Get our template. | 716 // Get our template. |
721 static const base::StringPiece new_tab_theme_css( | 717 static const base::StringPiece new_tab_theme_css( |
722 ResourceBundle::GetSharedInstance().GetRawDataResource( | 718 ResourceBundle::GetSharedInstance().GetRawDataResource( |
723 IDR_NEW_TAB_4_THEME_CSS)); | 719 IDR_NEW_TAB_4_THEME_CSS)); |
724 | 720 |
725 // Create the string from our template and the replacements. | 721 // Create the string from our template and the replacements. |
726 std::string css_string; | 722 std::string css_string; |
727 css_string = ReplaceStringPlaceholders(new_tab_theme_css, subst, NULL); | 723 css_string = ReplaceStringPlaceholders(new_tab_theme_css, subst, NULL); |
728 new_tab_css_ = base::RefCountedString::TakeString(&css_string); | 724 new_tab_css_ = base::RefCountedString::TakeString(&css_string); |
729 } | 725 } |
OLD | NEW |