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

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

Issue 23614007: Use the normal Google logo for managed users for --enable-instant-extended-api (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed mac compile failure Created 7 years, 3 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 <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "apps/app_launcher.h" 10 #include "apps/app_launcher.h"
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 // If web contents are being inverted because the system is in high-contrast 120 // If web contents are being inverted because the system is in high-contrast
121 // mode, any system theme colors we use must be inverted too to cancel out. 121 // mode, any system theme colors we use must be inverted too to cancel out.
122 return gfx::IsInvertedColorScheme() ? 122 return gfx::IsInvertedColorScheme() ?
123 color_utils::InvertColor(color) : color; 123 color_utils::InvertColor(color) : color;
124 } 124 }
125 125
126 // Get the CSS string for the background position on the new tab page for the 126 // Get the CSS string for the background position on the new tab page for the
127 // states when the bar is attached or detached. 127 // states when the bar is attached or detached.
128 std::string GetNewTabBackgroundCSS(const ui::ThemeProvider* theme_provider, 128 std::string GetNewTabBackgroundCSS(const ui::ThemeProvider* theme_provider,
129 bool bar_attached) { 129 bool bar_attached) {
130 int alignment;
131 theme_provider->GetDisplayProperty(
132 ThemeProperties::NTP_BACKGROUND_ALIGNMENT, &alignment);
133
134 // TODO(glen): This is a quick workaround to hide the notused.png image when 130 // TODO(glen): This is a quick workaround to hide the notused.png image when
135 // no image is provided - we don't have time right now to figure out why 131 // no image is provided - we don't have time right now to figure out why
136 // this is painting as white. 132 // this is painting as white.
137 // http://crbug.com/17593 133 // http://crbug.com/17593
138 if (!theme_provider->HasCustomImage(IDR_THEME_NTP_BACKGROUND)) { 134 if (!theme_provider->HasCustomImage(IDR_THEME_NTP_BACKGROUND)) {
139 return "-64px"; 135 return "-64px";
140 } 136 }
141 137
138 int alignment = theme_provider->GetDisplayProperty(
139 ThemeProperties::NTP_BACKGROUND_ALIGNMENT);
140
142 if (bar_attached) 141 if (bar_attached)
143 return ThemeProperties::AlignmentToString(alignment); 142 return ThemeProperties::AlignmentToString(alignment);
144 143
145 if (alignment & ThemeProperties::ALIGN_TOP) { 144 if (alignment & ThemeProperties::ALIGN_TOP) {
146 // The bar is detached, so we must offset the background by the bar size 145 // The bar is detached, so we must offset the background by the bar size
147 // if it's a top-aligned bar. 146 // if it's a top-aligned bar.
148 int offset = chrome::kNTPBookmarkBarHeight; 147 int offset = chrome::kNTPBookmarkBarHeight;
149 148
150 if (alignment & ThemeProperties::ALIGN_LEFT) 149 if (alignment & ThemeProperties::ALIGN_LEFT)
151 return "left " + base::IntToString(-offset) + "px"; 150 return "left " + base::IntToString(-offset) + "px";
152 else if (alignment & ThemeProperties::ALIGN_RIGHT) 151 else if (alignment & ThemeProperties::ALIGN_RIGHT)
153 return "right " + base::IntToString(-offset) + "px"; 152 return "right " + base::IntToString(-offset) + "px";
154 return "center " + base::IntToString(-offset) + "px"; 153 return "center " + base::IntToString(-offset) + "px";
155 } 154 }
156 155
157 return ThemeProperties::AlignmentToString(alignment); 156 return ThemeProperties::AlignmentToString(alignment);
158 } 157 }
159 158
160 // How the background image on the new tab page should be tiled (see tiling 159 // How the background image on the new tab page should be tiled (see tiling
161 // masks in theme_service.h). 160 // masks in theme_service.h).
162 std::string GetNewTabBackgroundTilingCSS( 161 std::string GetNewTabBackgroundTilingCSS(
163 const ui::ThemeProvider* theme_provider) { 162 const ui::ThemeProvider* theme_provider) {
164 int repeat_mode; 163 int repeat_mode = theme_provider->GetDisplayProperty(
165 theme_provider->GetDisplayProperty( 164 ThemeProperties::NTP_BACKGROUND_TILING);
166 ThemeProperties::NTP_BACKGROUND_TILING, &repeat_mode);
167 return ThemeProperties::TilingToString(repeat_mode); 165 return ThemeProperties::TilingToString(repeat_mode);
168 } 166 }
169 167
170 } // namespace 168 } // namespace
171 169
172 NTPResourceCache::NTPResourceCache(Profile* profile) 170 NTPResourceCache::NTPResourceCache(Profile* profile)
173 : profile_(profile), is_swipe_tracking_from_scroll_events_enabled_(false), 171 : profile_(profile), is_swipe_tracking_from_scroll_events_enabled_(false),
174 should_show_apps_page_(NewTabUI::ShouldShowApps()), 172 should_show_apps_page_(NewTabUI::ShouldShowApps()),
175 should_show_most_visited_page_(true), 173 should_show_most_visited_page_(true),
176 should_show_other_devices_menu_(true), 174 should_show_other_devices_menu_(true),
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
499 #endif 497 #endif
500 498
501 NewTabPageHandler::GetLocalizedValues(profile_, &load_time_data); 499 NewTabPageHandler::GetLocalizedValues(profile_, &load_time_data);
502 NTPLoginHandler::GetLocalizedValues(profile_, &load_time_data); 500 NTPLoginHandler::GetLocalizedValues(profile_, &load_time_data);
503 501
504 webui::SetFontAndTextDirection(&load_time_data); 502 webui::SetFontAndTextDirection(&load_time_data);
505 503
506 // Control fade and resize animations. 504 // Control fade and resize animations.
507 load_time_data.SetBoolean("anim", ui::Animation::ShouldRenderRichAnimation()); 505 load_time_data.SetBoolean("anim", ui::Animation::ShouldRenderRichAnimation());
508 506
509 int alignment;
510 ui::ThemeProvider* tp = ThemeServiceFactory::GetForProfile(profile_); 507 ui::ThemeProvider* tp = ThemeServiceFactory::GetForProfile(profile_);
511 tp->GetDisplayProperty(ThemeProperties::NTP_BACKGROUND_ALIGNMENT, 508 int alignment = tp->GetDisplayProperty(
512 &alignment); 509 ThemeProperties::NTP_BACKGROUND_ALIGNMENT);
513 load_time_data.SetString("themegravity", 510 load_time_data.SetString("themegravity",
514 (alignment & ThemeProperties::ALIGN_RIGHT) ? "right" : ""); 511 (alignment & ThemeProperties::ALIGN_RIGHT) ? "right" : "");
515 512
516 // Disable the promo if this is the first run, otherwise set the promo string 513 // Disable the promo if this is the first run, otherwise set the promo string
517 // for display if there is a valid outstanding promo. 514 // for display if there is a valid outstanding promo.
518 if (first_run::IsChromeFirstRun()) { 515 if (first_run::IsChromeFirstRun()) {
519 NotificationPromo::HandleClosed(NotificationPromo::NTP_NOTIFICATION_PROMO); 516 NotificationPromo::HandleClosed(NotificationPromo::NTP_NOTIFICATION_PROMO);
520 } else { 517 } else {
521 NotificationPromo notification_promo; 518 NotificationPromo notification_promo;
522 notification_promo.InitFromPrefs(NotificationPromo::NTP_NOTIFICATION_PROMO); 519 notification_promo.InitFromPrefs(NotificationPromo::NTP_NOTIFICATION_PROMO);
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
704 // Get our template. 701 // Get our template.
705 static const base::StringPiece new_tab_theme_css( 702 static const base::StringPiece new_tab_theme_css(
706 ResourceBundle::GetSharedInstance().GetRawDataResource( 703 ResourceBundle::GetSharedInstance().GetRawDataResource(
707 IDR_NEW_TAB_4_THEME_CSS)); 704 IDR_NEW_TAB_4_THEME_CSS));
708 705
709 // Create the string from our template and the replacements. 706 // Create the string from our template and the replacements.
710 std::string css_string; 707 std::string css_string;
711 css_string = ReplaceStringPlaceholders(new_tab_theme_css, subst, NULL); 708 css_string = ReplaceStringPlaceholders(new_tab_theme_css, subst, NULL);
712 new_tab_css_ = base::RefCountedString::TakeString(&css_string); 709 new_tab_css_ = base::RefCountedString::TakeString(&css_string);
713 } 710 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/frame/browser_desktop_root_window_host_win.cc ('k') | ui/base/default_theme_provider.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698