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

Side by Side Diff: chrome/browser/themes/theme_service.cc

Issue 13497002: Crop images from custom themes before storing them into the theme pack (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 7 years, 8 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
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/themes/theme_service.h" 5 #include "chrome/browser/themes/theme_service.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/memory/ref_counted_memory.h" 8 #include "base/memory/ref_counted_memory.h"
9 #include "base/prefs/pref_service.h" 9 #include "base/prefs/pref_service.h"
10 #include "base/sequenced_task_runner.h" 10 #include "base/sequenced_task_runner.h"
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 chrome::NOTIFICATION_EXTENSIONS_READY, 101 chrome::NOTIFICATION_EXTENSIONS_READY,
102 content::Source<Profile>(profile_)); 102 content::Source<Profile>(profile_));
103 } 103 }
104 104
105 theme_syncable_service_.reset(new ThemeSyncableService(profile_, this)); 105 theme_syncable_service_.reset(new ThemeSyncableService(profile_, this));
106 } 106 }
107 107
108 gfx::Image ThemeService::GetImageNamed(int id) const { 108 gfx::Image ThemeService::GetImageNamed(int id) const {
109 DCHECK(CalledOnValidThread()); 109 DCHECK(CalledOnValidThread());
110 110
111 const gfx::Image* image = NULL; 111 gfx::Image image;
112
113 if (theme_pack_.get()) 112 if (theme_pack_.get())
114 image = theme_pack_->GetImageNamed(id); 113 image = theme_pack_->GetImageNamed(id);
115 114
116 #if defined(USE_AURA) && !defined(USE_ASH) && defined(OS_LINUX) 115 #if defined(USE_AURA) && !defined(USE_ASH) && defined(OS_LINUX)
117 const ui::LinuxUI* linux_ui = ui::LinuxUI::instance(); 116 const ui::LinuxUI* linux_ui = ui::LinuxUI::instance();
118 if (!image && linux_ui) 117 if (image.IsEmpty() && linux_ui)
119 image = linux_ui->GetThemeImageNamed(id); 118 image = linux_ui->GetThemeImageNamed(id);
120 #endif 119 #endif
121 120
122 if (!image) 121 if (image.IsEmpty())
123 image = &rb_.GetNativeImageNamed(id); 122 image = rb_.GetNativeImageNamed(id);
124 123
125 return image ? *image : gfx::Image(); 124 return image;
126 } 125 }
127 126
128 gfx::ImageSkia* ThemeService::GetImageSkiaNamed(int id) const { 127 gfx::ImageSkia* ThemeService::GetImageSkiaNamed(int id) const {
129 gfx::Image image = GetImageNamed(id); 128 gfx::Image image = GetImageNamed(id);
130 if (image.IsEmpty()) 129 if (image.IsEmpty())
131 return NULL; 130 return NULL;
132 // TODO(pkotwicz): Remove this const cast. The gfx::Image interface returns 131 // TODO(pkotwicz): Remove this const cast. The gfx::Image interface returns
133 // its images const. GetImageSkiaNamed() also should but has many callsites. 132 // its images const. GetImageSkiaNamed() also should but has many callsites.
134 return const_cast<gfx::ImageSkia*>(image.ToImageSkia()); 133 return const_cast<gfx::ImageSkia*>(image.ToImageSkia());
135 } 134 }
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 void ThemeService::OnInfobarDestroyed() { 421 void ThemeService::OnInfobarDestroyed() {
423 number_of_infobars_--; 422 number_of_infobars_--;
424 423
425 if (number_of_infobars_ == 0) 424 if (number_of_infobars_ == 0)
426 RemoveUnusedThemes(); 425 RemoveUnusedThemes();
427 } 426 }
428 427
429 ThemeSyncableService* ThemeService::GetThemeSyncableService() const { 428 ThemeSyncableService* ThemeService::GetThemeSyncableService() const {
430 return theme_syncable_service_.get(); 429 return theme_syncable_service_.get();
431 } 430 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698