Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(139)

Side by Side Diff: chrome/browser/ui/webui/ntp/ntp_resource_cache.cc

Issue 10387010: Select theme resources from ResourceBundle at requested scale factor. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge with master. Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 27 matching lines...) Expand all
38 #include "chrome/common/url_constants.h" 38 #include "chrome/common/url_constants.h"
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/layout.h"
48 #include "ui/base/resource/resource_bundle.h" 49 #include "ui/base/resource/resource_bundle.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
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME), 285 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME),
285 ASCIIToUTF16(chrome::kChromeUIExtensionsURL))); 286 ASCIIToUTF16(chrome::kChromeUIExtensionsURL)));
286 bool bookmark_bar_attached = profile_->GetPrefs()->GetBoolean( 287 bool bookmark_bar_attached = profile_->GetPrefs()->GetBoolean(
287 prefs::kShowBookmarkBar); 288 prefs::kShowBookmarkBar);
288 localized_strings.SetBoolean("bookmarkbarattached", bookmark_bar_attached); 289 localized_strings.SetBoolean("bookmarkbarattached", bookmark_bar_attached);
289 290
290 ChromeURLDataManager::DataSource::SetFontAndTextDirection(&localized_strings); 291 ChromeURLDataManager::DataSource::SetFontAndTextDirection(&localized_strings);
291 292
292 static const base::StringPiece incognito_tab_html( 293 static const base::StringPiece incognito_tab_html(
293 ResourceBundle::GetSharedInstance().GetRawDataResource( 294 ResourceBundle::GetSharedInstance().GetRawDataResource(
294 new_tab_html_idr)); 295 new_tab_html_idr, ui::SCALE_FACTOR_NONE));
295 296
296 std::string full_html = jstemplate_builder::GetI18nTemplateHtml( 297 std::string full_html = jstemplate_builder::GetI18nTemplateHtml(
297 incognito_tab_html, &localized_strings); 298 incognito_tab_html, &localized_strings);
298 299
299 new_tab_incognito_html_ = base::RefCountedString::TakeString(&full_html); 300 new_tab_incognito_html_ = base::RefCountedString::TakeString(&full_html);
300 } 301 }
301 302
302 void NTPResourceCache::CreateNewTabHTML() { 303 void NTPResourceCache::CreateNewTabHTML() {
303 // TODO(estade): these strings should be defined in their relevant handlers 304 // TODO(estade): these strings should be defined in their relevant handlers
304 // (in GetLocalizedValues) and should have more legible names. 305 // (in GetLocalizedValues) and should have more legible names.
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
420 // Determine whether to show the menu for accessing tabs on other devices. 421 // Determine whether to show the menu for accessing tabs on other devices.
421 bool show_other_sessions_menu = !CommandLine::ForCurrentProcess()->HasSwitch( 422 bool show_other_sessions_menu = !CommandLine::ForCurrentProcess()->HasSwitch(
422 switches::kDisableNTPOtherSessionsMenu); 423 switches::kDisableNTPOtherSessionsMenu);
423 load_time_data.SetBoolean("showOtherSessionsMenu", 424 load_time_data.SetBoolean("showOtherSessionsMenu",
424 show_other_sessions_menu); 425 show_other_sessions_menu);
425 load_time_data.SetBoolean("isUserSignedIn", 426 load_time_data.SetBoolean("isUserSignedIn",
426 !prefs->GetString(prefs::kGoogleServicesUsername).empty()); 427 !prefs->GetString(prefs::kGoogleServicesUsername).empty());
427 428
428 // Load the new tab page appropriate for this build 429 // Load the new tab page appropriate for this build
429 base::StringPiece new_tab_html(ResourceBundle::GetSharedInstance(). 430 base::StringPiece new_tab_html(ResourceBundle::GetSharedInstance().
430 GetRawDataResource(IDR_NEW_TAB_4_HTML)); 431 GetRawDataResource(IDR_NEW_TAB_4_HTML,
432 ui::SCALE_FACTOR_NONE));
431 jstemplate_builder::UseVersion2 version2; 433 jstemplate_builder::UseVersion2 version2;
432 std::string full_html = 434 std::string full_html =
433 jstemplate_builder::GetI18nTemplateHtml(new_tab_html, &load_time_data); 435 jstemplate_builder::GetI18nTemplateHtml(new_tab_html, &load_time_data);
434 new_tab_html_ = base::RefCountedString::TakeString(&full_html); 436 new_tab_html_ = base::RefCountedString::TakeString(&full_html);
435 } 437 }
436 438
437 void NTPResourceCache::CreateNewTabIncognitoCSS() { 439 void NTPResourceCache::CreateNewTabIncognitoCSS() {
438 ui::ThemeProvider* tp = ThemeServiceFactory::GetForProfile(profile_); 440 ui::ThemeProvider* tp = ThemeServiceFactory::GetForProfile(profile_);
439 DCHECK(tp); 441 DCHECK(tp);
440 442
(...skipping 10 matching lines...) Expand all
451 453
452 // Colors. 454 // Colors.
453 subst.push_back(SkColorToRGBAString(color_background)); // $2 455 subst.push_back(SkColorToRGBAString(color_background)); // $2
454 subst.push_back(GetNewTabBackgroundCSS(tp, false)); // $3 456 subst.push_back(GetNewTabBackgroundCSS(tp, false)); // $3
455 subst.push_back(GetNewTabBackgroundCSS(tp, true)); // $4 457 subst.push_back(GetNewTabBackgroundCSS(tp, true)); // $4
456 subst.push_back(GetNewTabBackgroundTilingCSS(tp)); // $5 458 subst.push_back(GetNewTabBackgroundTilingCSS(tp)); // $5
457 459
458 // Get our template. 460 // Get our template.
459 static const base::StringPiece new_tab_theme_css( 461 static const base::StringPiece new_tab_theme_css(
460 ResourceBundle::GetSharedInstance().GetRawDataResource( 462 ResourceBundle::GetSharedInstance().GetRawDataResource(
461 IDR_NEW_INCOGNITO_TAB_THEME_CSS)); 463 IDR_NEW_INCOGNITO_TAB_THEME_CSS, ui::SCALE_FACTOR_NONE));
462 464
463 // Create the string from our template and the replacements. 465 // Create the string from our template and the replacements.
464 std::string full_css = ReplaceStringPlaceholders( 466 std::string full_css = ReplaceStringPlaceholders(
465 new_tab_theme_css, subst, NULL); 467 new_tab_theme_css, subst, NULL);
466 468
467 new_tab_incognito_css_ = base::RefCountedString::TakeString(&full_css); 469 new_tab_incognito_css_ = base::RefCountedString::TakeString(&full_css);
468 } 470 }
469 471
470 void NTPResourceCache::CreateNewTabCSS() { 472 void NTPResourceCache::CreateNewTabCSS() {
471 ui::ThemeProvider* tp = ThemeServiceFactory::GetForProfile(profile_); 473 ui::ThemeProvider* tp = ThemeServiceFactory::GetForProfile(profile_);
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
546 color_section_header_rule_light)); // $19 548 color_section_header_rule_light)); // $19
547 subst.push_back(SkColorToRGBAString( 549 subst.push_back(SkColorToRGBAString(
548 SkColorSetA(color_section_header_rule, 0))); // $20 550 SkColorSetA(color_section_header_rule, 0))); // $20
549 subst.push_back(SkColorToRGBAString(color_text_light)); // $21 551 subst.push_back(SkColorToRGBAString(color_text_light)); // $21
550 subst.push_back(SkColorToRGBComponents(color_section_border)); // $22 552 subst.push_back(SkColorToRGBComponents(color_section_border)); // $22
551 subst.push_back(SkColorToRGBComponents(color_text)); // $23 553 subst.push_back(SkColorToRGBComponents(color_text)); // $23
552 554
553 // Get our template. 555 // Get our template.
554 static const base::StringPiece new_tab_theme_css( 556 static const base::StringPiece new_tab_theme_css(
555 ResourceBundle::GetSharedInstance().GetRawDataResource( 557 ResourceBundle::GetSharedInstance().GetRawDataResource(
556 IDR_NEW_TAB_4_THEME_CSS)); 558 IDR_NEW_TAB_4_THEME_CSS, ui::SCALE_FACTOR_NONE));
557 559
558 // Create the string from our template and the replacements. 560 // Create the string from our template and the replacements.
559 std::string css_string; 561 std::string css_string;
560 css_string = ReplaceStringPlaceholders(new_tab_theme_css, subst, NULL); 562 css_string = ReplaceStringPlaceholders(new_tab_theme_css, subst, NULL);
561 new_tab_css_ = base::RefCountedString::TakeString(&css_string); 563 new_tab_css_ = base::RefCountedString::TakeString(&css_string);
562 } 564 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698