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 <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
(...skipping 28 matching lines...) Expand all Loading... |
39 #include "content/public/browser/browser_thread.h" | 39 #include "content/public/browser/browser_thread.h" |
40 #include "content/public/browser/notification_service.h" | 40 #include "content/public/browser/notification_service.h" |
41 #include "grit/browser_resources.h" | 41 #include "grit/browser_resources.h" |
42 #include "grit/chromium_strings.h" | 42 #include "grit/chromium_strings.h" |
43 #include "grit/generated_resources.h" | 43 #include "grit/generated_resources.h" |
44 #include "grit/locale_settings.h" | 44 #include "grit/locale_settings.h" |
45 #include "grit/theme_resources.h" | 45 #include "grit/theme_resources.h" |
46 #include "ui/base/animation/animation.h" | 46 #include "ui/base/animation/animation.h" |
47 #include "ui/base/l10n/l10n_util.h" | 47 #include "ui/base/l10n/l10n_util.h" |
48 #include "ui/base/resource/resource_bundle.h" | 48 #include "ui/base/resource/resource_bundle.h" |
| 49 #include "ui/base/resource/resource_handle.h" |
49 #include "ui/base/theme_provider.h" | 50 #include "ui/base/theme_provider.h" |
50 #include "ui/gfx/color_utils.h" | 51 #include "ui/gfx/color_utils.h" |
51 #include "ui/gfx/sys_color_change_listener.h" | 52 #include "ui/gfx/sys_color_change_listener.h" |
52 | 53 |
53 #if defined(OS_MACOSX) | 54 #if defined(OS_MACOSX) |
54 #include "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_constants.h" | 55 #include "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_constants.h" |
55 #elif defined(TOOLKIT_GTK) | 56 #elif defined(TOOLKIT_GTK) |
56 #include "chrome/browser/ui/gtk/bookmarks/bookmark_bar_gtk.h" | 57 #include "chrome/browser/ui/gtk/bookmarks/bookmark_bar_gtk.h" |
57 #endif | 58 #endif |
58 | 59 |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
289 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME), | 290 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME), |
290 ASCIIToUTF16(chrome::kChromeUIExtensionsURL))); | 291 ASCIIToUTF16(chrome::kChromeUIExtensionsURL))); |
291 bool bookmark_bar_attached = profile_->GetPrefs()->GetBoolean( | 292 bool bookmark_bar_attached = profile_->GetPrefs()->GetBoolean( |
292 prefs::kShowBookmarkBar); | 293 prefs::kShowBookmarkBar); |
293 localized_strings.SetBoolean("bookmarkbarattached", bookmark_bar_attached); | 294 localized_strings.SetBoolean("bookmarkbarattached", bookmark_bar_attached); |
294 | 295 |
295 ChromeURLDataManager::DataSource::SetFontAndTextDirection(&localized_strings); | 296 ChromeURLDataManager::DataSource::SetFontAndTextDirection(&localized_strings); |
296 | 297 |
297 static const base::StringPiece incognito_tab_html( | 298 static const base::StringPiece incognito_tab_html( |
298 ResourceBundle::GetSharedInstance().GetRawDataResource( | 299 ResourceBundle::GetSharedInstance().GetRawDataResource( |
299 new_tab_html_idr)); | 300 new_tab_html_idr, ui::ResourceHandle::kScaleFactorNone)); |
300 | 301 |
301 std::string full_html = jstemplate_builder::GetI18nTemplateHtml( | 302 std::string full_html = jstemplate_builder::GetI18nTemplateHtml( |
302 incognito_tab_html, &localized_strings); | 303 incognito_tab_html, &localized_strings); |
303 | 304 |
304 new_tab_incognito_html_ = base::RefCountedString::TakeString(&full_html); | 305 new_tab_incognito_html_ = base::RefCountedString::TakeString(&full_html); |
305 } | 306 } |
306 | 307 |
307 void NTPResourceCache::CreateNewTabHTML() { | 308 void NTPResourceCache::CreateNewTabHTML() { |
308 // TODO(estade): these strings should be defined in their relevant handlers | 309 // TODO(estade): these strings should be defined in their relevant handlers |
309 // (in GetLocalizedValues) and should have more legible names. | 310 // (in GetLocalizedValues) and should have more legible names. |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
440 // Determine whether to show the menu for accessing tabs on other devices. | 441 // Determine whether to show the menu for accessing tabs on other devices. |
441 bool show_other_sessions_menu = !CommandLine::ForCurrentProcess()->HasSwitch( | 442 bool show_other_sessions_menu = !CommandLine::ForCurrentProcess()->HasSwitch( |
442 switches::kDisableNTPOtherSessionsMenu); | 443 switches::kDisableNTPOtherSessionsMenu); |
443 load_time_data.SetBoolean("showOtherSessionsMenu", | 444 load_time_data.SetBoolean("showOtherSessionsMenu", |
444 show_other_sessions_menu); | 445 show_other_sessions_menu); |
445 load_time_data.SetBoolean("isUserSignedIn", | 446 load_time_data.SetBoolean("isUserSignedIn", |
446 !prefs->GetString(prefs::kGoogleServicesUsername).empty()); | 447 !prefs->GetString(prefs::kGoogleServicesUsername).empty()); |
447 | 448 |
448 // Load the new tab page appropriate for this build | 449 // Load the new tab page appropriate for this build |
449 base::StringPiece new_tab_html(ResourceBundle::GetSharedInstance(). | 450 base::StringPiece new_tab_html(ResourceBundle::GetSharedInstance(). |
450 GetRawDataResource(IDR_NEW_TAB_4_HTML)); | 451 GetRawDataResource(IDR_NEW_TAB_4_HTML, |
| 452 ui::ResourceHandle::kScaleFactorNone)); |
451 jstemplate_builder::UseVersion2 version2; | 453 jstemplate_builder::UseVersion2 version2; |
452 std::string full_html = | 454 std::string full_html = |
453 jstemplate_builder::GetI18nTemplateHtml(new_tab_html, &load_time_data); | 455 jstemplate_builder::GetI18nTemplateHtml(new_tab_html, &load_time_data); |
454 new_tab_html_ = base::RefCountedString::TakeString(&full_html); | 456 new_tab_html_ = base::RefCountedString::TakeString(&full_html); |
455 } | 457 } |
456 | 458 |
457 void NTPResourceCache::CreateNewTabIncognitoCSS() { | 459 void NTPResourceCache::CreateNewTabIncognitoCSS() { |
458 ui::ThemeProvider* tp = ThemeServiceFactory::GetForProfile(profile_); | 460 ui::ThemeProvider* tp = ThemeServiceFactory::GetForProfile(profile_); |
459 DCHECK(tp); | 461 DCHECK(tp); |
460 | 462 |
(...skipping 10 matching lines...) Expand all Loading... |
471 | 473 |
472 // Colors. | 474 // Colors. |
473 subst.push_back(SkColorToRGBAString(color_background)); // $2 | 475 subst.push_back(SkColorToRGBAString(color_background)); // $2 |
474 subst.push_back(GetNewTabBackgroundCSS(tp, false)); // $3 | 476 subst.push_back(GetNewTabBackgroundCSS(tp, false)); // $3 |
475 subst.push_back(GetNewTabBackgroundCSS(tp, true)); // $4 | 477 subst.push_back(GetNewTabBackgroundCSS(tp, true)); // $4 |
476 subst.push_back(GetNewTabBackgroundTilingCSS(tp)); // $5 | 478 subst.push_back(GetNewTabBackgroundTilingCSS(tp)); // $5 |
477 | 479 |
478 // Get our template. | 480 // Get our template. |
479 static const base::StringPiece new_tab_theme_css( | 481 static const base::StringPiece new_tab_theme_css( |
480 ResourceBundle::GetSharedInstance().GetRawDataResource( | 482 ResourceBundle::GetSharedInstance().GetRawDataResource( |
481 IDR_NEW_INCOGNITO_TAB_THEME_CSS)); | 483 IDR_NEW_INCOGNITO_TAB_THEME_CSS, ui::ResourceHandle::kScaleFactorNone)); |
482 | 484 |
483 // Create the string from our template and the replacements. | 485 // Create the string from our template and the replacements. |
484 std::string full_css = ReplaceStringPlaceholders( | 486 std::string full_css = ReplaceStringPlaceholders( |
485 new_tab_theme_css, subst, NULL); | 487 new_tab_theme_css, subst, NULL); |
486 | 488 |
487 new_tab_incognito_css_ = base::RefCountedString::TakeString(&full_css); | 489 new_tab_incognito_css_ = base::RefCountedString::TakeString(&full_css); |
488 } | 490 } |
489 | 491 |
490 void NTPResourceCache::CreateNewTabCSS() { | 492 void NTPResourceCache::CreateNewTabCSS() { |
491 ui::ThemeProvider* tp = ThemeServiceFactory::GetForProfile(profile_); | 493 ui::ThemeProvider* tp = ThemeServiceFactory::GetForProfile(profile_); |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
566 color_section_header_rule_light)); // $19 | 568 color_section_header_rule_light)); // $19 |
567 subst.push_back(SkColorToRGBAString( | 569 subst.push_back(SkColorToRGBAString( |
568 SkColorSetA(color_section_header_rule, 0))); // $20 | 570 SkColorSetA(color_section_header_rule, 0))); // $20 |
569 subst.push_back(SkColorToRGBAString(color_text_light)); // $21 | 571 subst.push_back(SkColorToRGBAString(color_text_light)); // $21 |
570 subst.push_back(SkColorToRGBComponents(color_section_border)); // $22 | 572 subst.push_back(SkColorToRGBComponents(color_section_border)); // $22 |
571 subst.push_back(SkColorToRGBComponents(color_text)); // $23 | 573 subst.push_back(SkColorToRGBComponents(color_text)); // $23 |
572 | 574 |
573 // Get our template. | 575 // Get our template. |
574 static const base::StringPiece new_tab_theme_css( | 576 static const base::StringPiece new_tab_theme_css( |
575 ResourceBundle::GetSharedInstance().GetRawDataResource( | 577 ResourceBundle::GetSharedInstance().GetRawDataResource( |
576 IDR_NEW_TAB_4_THEME_CSS)); | 578 IDR_NEW_TAB_4_THEME_CSS, ui::ResourceHandle::kScaleFactorNone)); |
577 | 579 |
578 // Create the string from our template and the replacements. | 580 // Create the string from our template and the replacements. |
579 std::string css_string; | 581 std::string css_string; |
580 css_string = ReplaceStringPlaceholders(new_tab_theme_css, subst, NULL); | 582 css_string = ReplaceStringPlaceholders(new_tab_theme_css, subst, NULL); |
581 new_tab_css_ = base::RefCountedString::TakeString(&css_string); | 583 new_tab_css_ = base::RefCountedString::TakeString(&css_string); |
582 } | 584 } |
OLD | NEW |