OLD | NEW |
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 "base/gfx/gtk_util.h" | 10 #include "base/gfx/gtk_util.h" |
(...skipping 240 matching lines...) Loading... |
251 | 251 |
252 // Notify all GtkChromeButtons of their new rendering mode: | 252 // Notify all GtkChromeButtons of their new rendering mode: |
253 for (std::vector<GtkWidget*>::iterator it = chrome_buttons_.begin(); | 253 for (std::vector<GtkWidget*>::iterator it = chrome_buttons_.begin(); |
254 it != chrome_buttons_.end(); ++it) { | 254 it != chrome_buttons_.end(); ++it) { |
255 gtk_chrome_button_set_use_gtk_rendering( | 255 gtk_chrome_button_set_use_gtk_rendering( |
256 GTK_CHROME_BUTTON(*it), use_gtk_); | 256 GTK_CHROME_BUTTON(*it), use_gtk_); |
257 } | 257 } |
258 } | 258 } |
259 | 259 |
260 SkBitmap* GtkThemeProvider::LoadThemeBitmap(int id) { | 260 SkBitmap* GtkThemeProvider::LoadThemeBitmap(int id) { |
261 if (id == IDR_THEME_TOOLBAR && use_gtk_) { | 261 if (use_gtk_) { |
262 GtkStyle* style = gtk_rc_get_style(fake_window_); | 262 if (id == IDR_THEME_TOOLBAR) { |
263 GdkColor* color = &style->bg[GTK_STATE_NORMAL]; | 263 GtkStyle* style = gtk_rc_get_style(fake_window_); |
264 SkBitmap* bitmap = new SkBitmap; | 264 GdkColor* color = &style->bg[GTK_STATE_NORMAL]; |
265 bitmap->setConfig(SkBitmap::kARGB_8888_Config, | 265 SkBitmap* bitmap = new SkBitmap; |
266 kToolbarImageWidth, kToolbarImageHeight); | 266 bitmap->setConfig(SkBitmap::kARGB_8888_Config, |
267 bitmap->allocPixels(); | 267 kToolbarImageWidth, kToolbarImageHeight); |
268 bitmap->eraseRGB(color->red >> 8, color->green >> 8, color->blue >> 8); | 268 bitmap->allocPixels(); |
269 return bitmap; | 269 bitmap->eraseRGB(color->red >> 8, color->green >> 8, color->blue >> 8); |
270 } else { | 270 return bitmap; |
271 return BrowserThemeProvider::LoadThemeBitmap(id); | 271 } else if ((id == IDR_THEME_TAB_BACKGROUND || |
| 272 id == IDR_THEME_TAB_BACKGROUND_INCOGNITO)) { |
| 273 return GenerateTabBackgroundBitmapImpl(id); |
| 274 } |
272 } | 275 } |
| 276 |
| 277 return BrowserThemeProvider::LoadThemeBitmap(id); |
273 } | 278 } |
274 | 279 |
275 void GtkThemeProvider::SaveThemeBitmap(const std::string resource_name, | 280 void GtkThemeProvider::SaveThemeBitmap(const std::string resource_name, |
276 int id) { | 281 int id) { |
277 if (!use_gtk_) { | 282 if (!use_gtk_) { |
278 // Prevent us from writing out our mostly unused resources in gtk theme | 283 // Prevent us from writing out our mostly unused resources in gtk theme |
279 // mode. Simply preventing us from writing this data out in gtk mode isn't | 284 // mode. Simply preventing us from writing this data out in gtk mode isn't |
280 // the best design, but this would probably be a very invasive change on | 285 // the best design, but this would probably be a very invasive change on |
281 // all three platforms otherwise. | 286 // all three platforms otherwise. |
282 BrowserThemeProvider::SaveThemeBitmap(resource_name, id); | 287 BrowserThemeProvider::SaveThemeBitmap(resource_name, id); |
(...skipping 144 matching lines...) Loading... |
427 // color for all inactive windows, otherwise we end up neon pink half the | 432 // color for all inactive windows, otherwise we end up neon pink half the |
428 // time. | 433 // time. |
429 SetThemeColorFromGtk(kColorFrameInactive, &inactive_frame_color); | 434 SetThemeColorFromGtk(kColorFrameInactive, &inactive_frame_color); |
430 SetThemeTintFromGtk(kTintFrameInactive, &inactive_frame_color, | 435 SetThemeTintFromGtk(kTintFrameInactive, &inactive_frame_color, |
431 kExactColor); | 436 kExactColor); |
432 SetThemeTintFromGtk(kTintFrameIncognitoInactive, &inactive_frame_color, | 437 SetThemeTintFromGtk(kTintFrameIncognitoInactive, &inactive_frame_color, |
433 kExactColor); | 438 kExactColor); |
434 | 439 |
435 force_process_images(); | 440 force_process_images(); |
436 GenerateFrameColors(); | 441 GenerateFrameColors(); |
| 442 AutoLock lock(themed_image_cache_lock_); |
437 GenerateFrameImages(); | 443 GenerateFrameImages(); |
438 } | 444 } |
439 | 445 |
440 void GtkThemeProvider::SetThemeColorFromGtk(const char* id, GdkColor* color) { | 446 void GtkThemeProvider::SetThemeColorFromGtk(const char* id, GdkColor* color) { |
441 SetColor(id, GdkToSkColor(color)); | 447 SetColor(id, GdkToSkColor(color)); |
442 } | 448 } |
443 | 449 |
444 void GtkThemeProvider::SetThemeTintFromGtk( | 450 void GtkThemeProvider::SetThemeTintFromGtk( |
445 const char* id, | 451 const char* id, |
446 GdkColor* color, | 452 GdkColor* color, |
(...skipping 21 matching lines...) Loading... |
468 } | 474 } |
469 | 475 |
470 void GtkThemeProvider::OnDestroyChromeButton(GtkWidget* button, | 476 void GtkThemeProvider::OnDestroyChromeButton(GtkWidget* button, |
471 GtkThemeProvider* provider) { | 477 GtkThemeProvider* provider) { |
472 std::vector<GtkWidget*>::iterator it = | 478 std::vector<GtkWidget*>::iterator it = |
473 find(provider->chrome_buttons_.begin(), provider->chrome_buttons_.end(), | 479 find(provider->chrome_buttons_.begin(), provider->chrome_buttons_.end(), |
474 button); | 480 button); |
475 if (it != provider->chrome_buttons_.end()) | 481 if (it != provider->chrome_buttons_.end()) |
476 provider->chrome_buttons_.erase(it); | 482 provider->chrome_buttons_.erase(it); |
477 } | 483 } |
OLD | NEW |