| 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/gtk/gtk_theme_service.h" | 5 #include "chrome/browser/ui/gtk/gtk_theme_service.h" |
| 6 | 6 |
| 7 #include <gtk/gtk.h> | 7 #include <gtk/gtk.h> |
| 8 | 8 |
| 9 #include <set> | 9 #include <set> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 302 ThemeService::Init(profile); | 302 ThemeService::Init(profile); |
| 303 } | 303 } |
| 304 | 304 |
| 305 gfx::ImageSkia* GtkThemeService::GetImageSkiaNamed(int id) const { | 305 gfx::ImageSkia* GtkThemeService::GetImageSkiaNamed(int id) const { |
| 306 // TODO(pkotwicz): Remove this const cast. The gfx::Image interface returns | 306 // TODO(pkotwicz): Remove this const cast. The gfx::Image interface returns |
| 307 // its images const. GetImageSkiaNamed() also should but has many callsites. | 307 // its images const. GetImageSkiaNamed() also should but has many callsites. |
| 308 return const_cast<gfx::ImageSkia*>(GetImageNamed(id).ToImageSkia()); | 308 return const_cast<gfx::ImageSkia*>(GetImageNamed(id).ToImageSkia()); |
| 309 } | 309 } |
| 310 | 310 |
| 311 gfx::Image GtkThemeService::GetImageNamed(int id) const { | 311 gfx::Image GtkThemeService::GetImageNamed(int id) const { |
| 312 // TODO(akuegel): Remove this once we have the default managed user theme. | |
| 313 if (ManagedUserService::ProfileIsManaged(profile())) { | |
| 314 if (id == IDR_THEME_FRAME) | |
| 315 id = IDR_MANAGED_USER_THEME_FRAME; | |
| 316 else if (id == IDR_THEME_FRAME_INACTIVE) | |
| 317 id = IDR_MANAGED_USER_THEME_FRAME_INACTIVE; | |
| 318 } | |
| 319 | |
| 320 // Try to get our cached version: | 312 // Try to get our cached version: |
| 321 ImageCache::const_iterator it = gtk_images_.find(id); | 313 ImageCache::const_iterator it = gtk_images_.find(id); |
| 322 if (it != gtk_images_.end()) | 314 if (it != gtk_images_.end()) |
| 323 return *it->second; | 315 return *it->second; |
| 324 | 316 |
| 325 if (use_gtk_ && IsOverridableImage(id)) { | 317 if (use_gtk_ && IsOverridableImage(id)) { |
| 326 gfx::Image* image = new gfx::Image(gfx::ImageSkia::CreateFrom1xBitmap( | 318 gfx::Image* image = new gfx::Image(gfx::ImageSkia::CreateFrom1xBitmap( |
| 327 GenerateGtkThemeBitmap(id))); | 319 GenerateGtkThemeBitmap(id))); |
| 328 gtk_images_[id] = image; | 320 gtk_images_[id] = image; |
| 329 return *image; | 321 return *image; |
| 330 } | 322 } |
| 331 | 323 |
| 332 return ThemeService::GetImageNamed(id); | 324 return ThemeService::GetImageNamed(id); |
| 333 } | 325 } |
| 334 | 326 |
| 335 SkColor GtkThemeService::GetColor(int id) const { | 327 SkColor GtkThemeService::GetColor(int id) const { |
| 336 // TODO(akuegel): Remove this once we have the default managed user theme. | |
| 337 if (ManagedUserService::ProfileIsManaged(profile())) { | |
| 338 if (id == ThemeProperties::COLOR_FRAME) | |
| 339 id = ThemeProperties::COLOR_FRAME_MANAGED_USER; | |
| 340 else if (id == ThemeProperties::COLOR_FRAME_INACTIVE) | |
| 341 id = ThemeProperties::COLOR_FRAME_MANAGED_USER_INACTIVE; | |
| 342 } | |
| 343 | |
| 344 if (use_gtk_) { | 328 if (use_gtk_) { |
| 345 ColorMap::const_iterator it = colors_.find(id); | 329 ColorMap::const_iterator it = colors_.find(id); |
| 346 if (it != colors_.end()) | 330 if (it != colors_.end()) |
| 347 return it->second; | 331 return it->second; |
| 348 } | 332 } |
| 349 | 333 |
| 350 return ThemeService::GetColor(id); | 334 return ThemeService::GetColor(id); |
| 351 } | 335 } |
| 352 | 336 |
| 353 bool GtkThemeService::HasCustomImage(int id) const { | 337 bool GtkThemeService::HasCustomImage(int id) const { |
| (...skipping 831 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1185 cairo_stroke(cr); | 1169 cairo_stroke(cr); |
| 1186 cairo_destroy(cr); | 1170 cairo_destroy(cr); |
| 1187 cairo_pattern_destroy(pattern); | 1171 cairo_pattern_destroy(pattern); |
| 1188 | 1172 |
| 1189 return TRUE; | 1173 return TRUE; |
| 1190 } | 1174 } |
| 1191 | 1175 |
| 1192 void GtkThemeService::OnUsesSystemThemeChanged() { | 1176 void GtkThemeService::OnUsesSystemThemeChanged() { |
| 1193 use_gtk_ = profile()->GetPrefs()->GetBoolean(prefs::kUsesSystemTheme); | 1177 use_gtk_ = profile()->GetPrefs()->GetBoolean(prefs::kUsesSystemTheme); |
| 1194 } | 1178 } |
| OLD | NEW |