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 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
286 // cache. | 286 // cache. |
287 new_tab_incognito_html_ = NULL; | 287 new_tab_incognito_html_ = NULL; |
288 new_tab_html_ = NULL; | 288 new_tab_html_ = NULL; |
289 new_tab_css_ = NULL; | 289 new_tab_css_ = NULL; |
290 } | 290 } |
291 | 291 |
292 void NTPResourceCache::CreateNewTabIncognitoHTML() { | 292 void NTPResourceCache::CreateNewTabIncognitoHTML() { |
293 base::DictionaryValue localized_strings; | 293 base::DictionaryValue localized_strings; |
294 localized_strings.SetString("title", | 294 localized_strings.SetString("title", |
295 l10n_util::GetStringUTF16(IDS_NEW_TAB_TITLE)); | 295 l10n_util::GetStringUTF16(IDS_NEW_TAB_TITLE)); |
296 int new_tab_message_ids = IDS_NEW_TAB_OTR_MESSAGE; | 296 int new_tab_description_ids = IDS_NEW_TAB_OTR_DESCRIPTION; |
| 297 int new_tab_heading_ids = IDS_NEW_TAB_OTR_HEADING; |
| 298 int new_tab_link_ids = IDS_NEW_TAB_OTR_LEARN_MORE_LINK; |
| 299 int new_tab_warning_ids = IDS_NEW_TAB_OTR_MESSAGE_WARNING; |
297 int new_tab_html_idr = IDR_INCOGNITO_TAB_HTML; | 300 int new_tab_html_idr = IDR_INCOGNITO_TAB_HTML; |
298 const char* new_tab_link = kLearnMoreIncognitoUrl; | 301 const char* new_tab_link = kLearnMoreIncognitoUrl; |
299 | 302 |
300 // TODO(altimofeev): consider implementation without 'if def' usage. | 303 // TODO(altimofeev): consider implementation without 'if def' usage. |
301 #if defined(OS_CHROMEOS) | 304 #if defined(OS_CHROMEOS) |
302 if (profile_->IsGuestSession()) { | 305 if (profile_->IsGuestSession()) { |
303 new_tab_message_ids = IDS_NEW_TAB_GUEST_SESSION_MESSAGE; | 306 new_tab_description_ids = IDS_NEW_TAB_GUEST_SESSION_DESCRIPTION; |
| 307 new_tab_heading_ids = IDS_NEW_TAB_GUEST_SESSION_HEADING; |
| 308 new_tab_link_ids = IDS_NEW_TAB_GUEST_SESSION_LEARN_MORE_LINK; |
304 new_tab_html_idr = IDR_GUEST_SESSION_TAB_HTML; | 309 new_tab_html_idr = IDR_GUEST_SESSION_TAB_HTML; |
305 new_tab_link = kLearnMoreGuestSessionUrl; | 310 new_tab_link = kLearnMoreGuestSessionUrl; |
306 | 311 |
307 policy::BrowserPolicyConnectorChromeOS* connector = | 312 policy::BrowserPolicyConnectorChromeOS* connector = |
308 g_browser_process->platform_part()->browser_policy_connector_chromeos(); | 313 g_browser_process->platform_part()->browser_policy_connector_chromeos(); |
309 std::string enterprise_domain = connector->GetEnterpriseDomain(); | 314 std::string enterprise_domain = connector->GetEnterpriseDomain(); |
310 if (!enterprise_domain.empty()) { | 315 if (!enterprise_domain.empty()) { |
311 // Device is enterprise enrolled. | 316 // Device is enterprise enrolled. |
312 localized_strings.SetString("enterpriseInfoVisible", "true"); | 317 localized_strings.SetString("enterpriseInfoVisible", "true"); |
313 base::string16 enterprise_info = l10n_util::GetStringFUTF16( | 318 base::string16 enterprise_info = l10n_util::GetStringFUTF16( |
314 IDS_DEVICE_OWNED_BY_NOTICE, | 319 IDS_DEVICE_OWNED_BY_NOTICE, |
315 base::UTF8ToUTF16(enterprise_domain)); | 320 base::UTF8ToUTF16(enterprise_domain)); |
316 localized_strings.SetString("enterpriseInfoMessage", enterprise_info); | 321 localized_strings.SetString("enterpriseInfoMessage", enterprise_info); |
317 localized_strings.SetString("learnMore", | 322 localized_strings.SetString("learnMore", |
318 l10n_util::GetStringUTF16(IDS_LEARN_MORE)); | 323 l10n_util::GetStringUTF16(IDS_LEARN_MORE)); |
319 localized_strings.SetString("enterpriseInfoHintLink", | 324 localized_strings.SetString("enterpriseInfoHintLink", |
320 GetUrlWithLang(GURL(chrome::kLearnMoreEnterpriseURL))); | 325 GetUrlWithLang(GURL(chrome::kLearnMoreEnterpriseURL))); |
321 } else { | 326 } else { |
322 localized_strings.SetString("enterpriseInfoVisible", "false"); | 327 localized_strings.SetString("enterpriseInfoVisible", "false"); |
323 } | 328 } |
324 } | 329 } |
325 #endif | 330 #endif |
326 | 331 |
327 localized_strings.SetString("content", | 332 if (profile_->IsGuestSession()) { |
328 l10n_util::GetStringFUTF16(new_tab_message_ids, | 333 localized_strings.SetString("guestTabDescription", |
329 GetUrlWithLang(GURL(new_tab_link)))); | 334 l10n_util::GetStringUTF16(new_tab_description_ids)); |
330 localized_strings.SetString("extensionsmessage", | 335 localized_strings.SetString("guestTabHeading", |
331 l10n_util::GetStringFUTF16( | 336 l10n_util::GetStringUTF16(new_tab_heading_ids)); |
332 IDS_NEW_TAB_OTR_EXTENSIONS_MESSAGE, | 337 } else { |
333 base::ASCIIToUTF16(chrome::kChromeUIExtensionsURL))); | 338 localized_strings.SetString("incognitoTabDescription", |
| 339 l10n_util::GetStringUTF16(new_tab_description_ids)); |
| 340 localized_strings.SetString("incognitoTabHeading", |
| 341 l10n_util::GetStringUTF16(new_tab_heading_ids)); |
| 342 localized_strings.SetString("incognitoTabWarning", |
| 343 l10n_util::GetStringUTF16(new_tab_warning_ids)); |
| 344 } |
| 345 |
| 346 localized_strings.SetString("learnMore", |
| 347 l10n_util::GetStringUTF16(new_tab_link_ids)); |
| 348 localized_strings.SetString("learnMoreLink", |
| 349 GetUrlWithLang(GURL(new_tab_link))); |
| 350 |
334 bool bookmark_bar_attached = profile_->GetPrefs()->GetBoolean( | 351 bool bookmark_bar_attached = profile_->GetPrefs()->GetBoolean( |
335 prefs::kShowBookmarkBar); | 352 prefs::kShowBookmarkBar); |
336 localized_strings.SetBoolean("bookmarkbarattached", bookmark_bar_attached); | 353 localized_strings.SetBoolean("bookmarkbarattached", bookmark_bar_attached); |
337 | 354 |
338 webui::SetFontAndTextDirection(&localized_strings); | 355 webui::SetFontAndTextDirection(&localized_strings); |
339 | 356 |
340 static const base::StringPiece incognito_tab_html( | 357 static const base::StringPiece incognito_tab_html( |
341 ResourceBundle::GetSharedInstance().GetRawDataResource( | 358 ResourceBundle::GetSharedInstance().GetRawDataResource( |
342 new_tab_html_idr)); | 359 new_tab_html_idr)); |
343 | 360 |
344 std::string full_html = webui::GetI18nTemplateHtml( | 361 std::string full_html = webui::GetI18nTemplateHtml( |
345 incognito_tab_html, &localized_strings); | 362 incognito_tab_html, &localized_strings); |
346 | 363 |
347 new_tab_incognito_html_ = base::RefCountedString::TakeString(&full_html); | 364 new_tab_incognito_html_ = base::RefCountedString::TakeString(&full_html); |
348 } | 365 } |
349 | 366 |
350 void NTPResourceCache::CreateNewTabGuestHTML() { | 367 void NTPResourceCache::CreateNewTabGuestHTML() { |
351 base::DictionaryValue localized_strings; | 368 base::DictionaryValue localized_strings; |
352 localized_strings.SetString("title", | 369 localized_strings.SetString("title", |
353 l10n_util::GetStringUTF16(IDS_NEW_TAB_TITLE)); | 370 l10n_util::GetStringUTF16(IDS_NEW_TAB_TITLE)); |
354 const char* new_tab_link = kLearnMoreGuestSessionUrl; | 371 const char* new_tab_link = kLearnMoreGuestSessionUrl; |
355 localized_strings.SetString("content", | 372 int guest_tab_description_ids = IDS_NEW_TAB_GUEST_SESSION_DESCRIPTION; |
356 l10n_util::GetStringFUTF16(IDS_NEW_TAB_GUEST_SESSION_MESSAGE, | 373 int guest_tab_heading_ids = IDS_NEW_TAB_GUEST_SESSION_HEADING; |
357 GetUrlWithLang(GURL(new_tab_link)))); | 374 int guest_tab_link_ids = IDS_NEW_TAB_GUEST_SESSION_LEARN_MORE_LINK; |
| 375 |
| 376 localized_strings.SetString("guestTabDescription", |
| 377 l10n_util::GetStringUTF16(guest_tab_description_ids)); |
| 378 localized_strings.SetString("guestTabHeading", |
| 379 l10n_util::GetStringUTF16(guest_tab_heading_ids)); |
| 380 localized_strings.SetString("learnMore", |
| 381 l10n_util::GetStringUTF16(guest_tab_link_ids)); |
| 382 localized_strings.SetString("learnMoreLink", |
| 383 GetUrlWithLang(GURL(new_tab_link))); |
358 | 384 |
359 webui::SetFontAndTextDirection(&localized_strings); | 385 webui::SetFontAndTextDirection(&localized_strings); |
360 | 386 |
361 static const base::StringPiece guest_tab_html( | 387 static const base::StringPiece guest_tab_html( |
362 ResourceBundle::GetSharedInstance().GetRawDataResource( | 388 ResourceBundle::GetSharedInstance().GetRawDataResource( |
363 IDR_GUEST_TAB_HTML)); | 389 IDR_GUEST_TAB_HTML)); |
364 | 390 |
365 std::string full_html = webui::GetI18nTemplateHtml( | 391 std::string full_html = webui::GetI18nTemplateHtml( |
366 guest_tab_html, &localized_strings); | 392 guest_tab_html, &localized_strings); |
367 | 393 |
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
707 // Get our template. | 733 // Get our template. |
708 static const base::StringPiece new_tab_theme_css( | 734 static const base::StringPiece new_tab_theme_css( |
709 ResourceBundle::GetSharedInstance().GetRawDataResource( | 735 ResourceBundle::GetSharedInstance().GetRawDataResource( |
710 IDR_NEW_TAB_4_THEME_CSS)); | 736 IDR_NEW_TAB_4_THEME_CSS)); |
711 | 737 |
712 // Create the string from our template and the replacements. | 738 // Create the string from our template and the replacements. |
713 std::string css_string; | 739 std::string css_string; |
714 css_string = ReplaceStringPlaceholders(new_tab_theme_css, subst, NULL); | 740 css_string = ReplaceStringPlaceholders(new_tab_theme_css, subst, NULL); |
715 new_tab_css_ = base::RefCountedString::TakeString(&css_string); | 741 new_tab_css_ = base::RefCountedString::TakeString(&css_string); |
716 } | 742 } |
OLD | NEW |