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

Side by Side Diff: chrome/browser/gtk/gtk_theme_provider.cc

Issue 272033: Misc. cleanup for theme provider code, including:... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 2 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) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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/gtk/gtk_theme_provider.h" 5 #include "chrome/browser/gtk/gtk_theme_provider.h"
6 6
7 #include <gtk/gtk.h> 7 #include <gtk/gtk.h>
8 8
9 #include "app/gfx/color_utils.h" 9 #include "app/gfx/color_utils.h"
10 #include "app/gfx/gtk_util.h" 10 #include "app/gfx/gtk_util.h"
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 void GtkThemeProvider::SetNativeTheme() { 120 void GtkThemeProvider::SetNativeTheme() {
121 profile()->GetPrefs()->SetBoolean(prefs::kUsesSystemTheme, true); 121 profile()->GetPrefs()->SetBoolean(prefs::kUsesSystemTheme, true);
122 ClearAllThemeData(); 122 ClearAllThemeData();
123 LoadGtkValues(); 123 LoadGtkValues();
124 NotifyThemeChanged(); 124 NotifyThemeChanged();
125 } 125 }
126 126
127 void GtkThemeProvider::Observe(NotificationType type, 127 void GtkThemeProvider::Observe(NotificationType type,
128 const NotificationSource& source, 128 const NotificationSource& source,
129 const NotificationDetails& details) { 129 const NotificationDetails& details) {
130 if (type == NotificationType::PREF_CHANGED) { 130 if ((type == NotificationType::PREF_CHANGED) &&
131 std::wstring key = *Details<std::wstring>(details).ptr(); 131 (*Details<std::wstring>(details).ptr() == prefs::kUsesSystemTheme))
132 if (key == prefs::kUsesSystemTheme) { 132 use_gtk_ = profile()->GetPrefs()->GetBoolean(prefs::kUsesSystemTheme);
133 use_gtk_ = profile()->GetPrefs()->GetBoolean(prefs::kUsesSystemTheme);
134 }
135 }
136 } 133 }
137 134
138 GtkWidget* GtkThemeProvider::BuildChromeButton() { 135 GtkWidget* GtkThemeProvider::BuildChromeButton() {
139 GtkWidget* button = gtk_chrome_button_new(); 136 GtkWidget* button = gtk_chrome_button_new();
140 gtk_chrome_button_set_use_gtk_rendering(GTK_CHROME_BUTTON(button), use_gtk_); 137 gtk_chrome_button_set_use_gtk_rendering(GTK_CHROME_BUTTON(button), use_gtk_);
141 chrome_buttons_.push_back(button); 138 chrome_buttons_.push_back(button);
142 139
143 g_signal_connect(button, "destroy", G_CALLBACK(OnDestroyChromeButton), 140 g_signal_connect(button, "destroy", G_CALLBACK(OnDestroyChromeButton),
144 this); 141 this);
145 return button; 142 return button;
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 if (use_gtk_) { 258 if (use_gtk_) {
262 if (id == IDR_THEME_TOOLBAR) { 259 if (id == IDR_THEME_TOOLBAR) {
263 GtkStyle* style = gtk_rc_get_style(fake_window_); 260 GtkStyle* style = gtk_rc_get_style(fake_window_);
264 GdkColor* color = &style->bg[GTK_STATE_NORMAL]; 261 GdkColor* color = &style->bg[GTK_STATE_NORMAL];
265 SkBitmap* bitmap = new SkBitmap; 262 SkBitmap* bitmap = new SkBitmap;
266 bitmap->setConfig(SkBitmap::kARGB_8888_Config, 263 bitmap->setConfig(SkBitmap::kARGB_8888_Config,
267 kToolbarImageWidth, kToolbarImageHeight); 264 kToolbarImageWidth, kToolbarImageHeight);
268 bitmap->allocPixels(); 265 bitmap->allocPixels();
269 bitmap->eraseRGB(color->red >> 8, color->green >> 8, color->blue >> 8); 266 bitmap->eraseRGB(color->red >> 8, color->green >> 8, color->blue >> 8);
270 return bitmap; 267 return bitmap;
271 } else if ((id == IDR_THEME_TAB_BACKGROUND || 268 }
272 id == IDR_THEME_TAB_BACKGROUND_INCOGNITO)) { 269 if ((id == IDR_THEME_TAB_BACKGROUND) ||
270 (id == IDR_THEME_TAB_BACKGROUND_INCOGNITO))
273 return GenerateTabBackgroundBitmapImpl(id); 271 return GenerateTabBackgroundBitmapImpl(id);
274 }
275 } 272 }
276 273
277 return BrowserThemeProvider::LoadThemeBitmap(id); 274 return BrowserThemeProvider::LoadThemeBitmap(id);
278 } 275 }
279 276
280 void GtkThemeProvider::SaveThemeBitmap(const std::string resource_name, 277 void GtkThemeProvider::SaveThemeBitmap(const std::string resource_name,
281 int id) { 278 int id) {
282 if (!use_gtk_) { 279 if (!use_gtk_) {
283 // Prevent us from writing out our mostly unused resources in gtk theme 280 // Prevent us from writing out our mostly unused resources in gtk theme
284 // mode. Simply preventing us from writing this data out in gtk mode isn't 281 // mode. Simply preventing us from writing this data out in gtk mode isn't
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
474 } 471 }
475 472
476 void GtkThemeProvider::OnDestroyChromeButton(GtkWidget* button, 473 void GtkThemeProvider::OnDestroyChromeButton(GtkWidget* button,
477 GtkThemeProvider* provider) { 474 GtkThemeProvider* provider) {
478 std::vector<GtkWidget*>::iterator it = 475 std::vector<GtkWidget*>::iterator it =
479 find(provider->chrome_buttons_.begin(), provider->chrome_buttons_.end(), 476 find(provider->chrome_buttons_.begin(), provider->chrome_buttons_.end(),
480 button); 477 button);
481 if (it != provider->chrome_buttons_.end()) 478 if (it != provider->chrome_buttons_.end())
482 provider->chrome_buttons_.erase(it); 479 provider->chrome_buttons_.erase(it);
483 } 480 }
OLDNEW
« no previous file with comments | « chrome/browser/gtk/gtk_theme_provider.h ('k') | chrome/browser/gtk/gtk_theme_provider_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698