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/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" |
11 #include "base/strings/string_util.h" | 11 #include "base/strings/string_util.h" |
12 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
13 #include "chrome/browser/chrome_notification_types.h" | 13 #include "chrome/browser/chrome_notification_types.h" |
14 #include "chrome/browser/extensions/extension_service.h" | 14 #include "chrome/browser/extensions/extension_service.h" |
15 #include "chrome/browser/extensions/extension_system.h" | 15 #include "chrome/browser/extensions/extension_system.h" |
16 #include "chrome/browser/profiles/profile.h" | 16 #include "chrome/browser/profiles/profile.h" |
17 #include "chrome/browser/themes/browser_theme_pack.h" | 17 #include "chrome/browser/themes/browser_theme_pack.h" |
18 #include "chrome/browser/themes/custom_theme_provider.h" | |
18 #include "chrome/browser/themes/theme_properties.h" | 19 #include "chrome/browser/themes/theme_properties.h" |
19 #include "chrome/browser/themes/theme_syncable_service.h" | 20 #include "chrome/browser/themes/theme_syncable_service.h" |
20 #include "chrome/common/chrome_constants.h" | 21 #include "chrome/common/chrome_constants.h" |
21 #include "chrome/common/extensions/extension_manifest_constants.h" | 22 #include "chrome/common/extensions/extension_manifest_constants.h" |
22 #include "chrome/common/pref_names.h" | 23 #include "chrome/common/pref_names.h" |
23 #include "content/public/browser/notification_service.h" | 24 #include "content/public/browser/notification_service.h" |
24 #include "content/public/browser/user_metrics.h" | 25 #include "content/public/browser/user_metrics.h" |
25 #include "grit/theme_resources.h" | 26 #include "grit/theme_resources.h" |
26 #include "grit/ui_resources.h" | 27 #include "grit/ui_resources.h" |
27 #include "ui/base/layout.h" | 28 #include "ui/base/layout.h" |
28 #include "ui/base/resource/resource_bundle.h" | 29 #include "ui/base/resource/resource_bundle.h" |
29 #include "ui/gfx/image/image_skia.h" | 30 #include "ui/gfx/image/image_skia.h" |
30 | 31 |
31 #if defined(OS_WIN) | 32 #if defined(OS_WIN) |
32 #include "ui/base/win/shell.h" | 33 #include "ui/base/win/shell.h" |
33 #endif | 34 #endif |
34 | 35 |
35 #if defined(ENABLE_MANAGED_USERS) | 36 #if defined(ENABLE_MANAGED_USERS) |
36 #include "chrome/browser/managed_mode/managed_user_service.h" | 37 #include "chrome/browser/managed_mode/managed_user_service.h" |
38 #include "chrome/browser/managed_mode/managed_user_theme.h" | |
37 #endif | 39 #endif |
38 | 40 |
39 using content::BrowserThread; | 41 using content::BrowserThread; |
40 using content::UserMetricsAction; | 42 using content::UserMetricsAction; |
41 using extensions::Extension; | 43 using extensions::Extension; |
42 using ui::ResourceBundle; | 44 using ui::ResourceBundle; |
43 | 45 |
44 typedef ThemeProperties Properties; | 46 typedef ThemeProperties Properties; |
45 | 47 |
46 // The default theme if we haven't installed a theme yet or if we've clicked | 48 // The default theme if we haven't installed a theme yet or if we've clicked |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
97 chrome::NOTIFICATION_EXTENSIONS_READY, | 99 chrome::NOTIFICATION_EXTENSIONS_READY, |
98 content::Source<Profile>(profile_)); | 100 content::Source<Profile>(profile_)); |
99 } | 101 } |
100 | 102 |
101 theme_syncable_service_.reset(new ThemeSyncableService(profile_, this)); | 103 theme_syncable_service_.reset(new ThemeSyncableService(profile_, this)); |
102 } | 104 } |
103 | 105 |
104 gfx::Image ThemeService::GetImageNamed(int id) const { | 106 gfx::Image ThemeService::GetImageNamed(int id) const { |
105 DCHECK(CalledOnValidThread()); | 107 DCHECK(CalledOnValidThread()); |
106 | 108 |
107 // For a managed user, use the special frame instead of the default one. | |
108 // TODO(akuegel): Remove this once we have the default managed user theme. | |
109 if (IsManagedUser()) { | |
110 if (id == IDR_THEME_FRAME) | |
111 id = IDR_MANAGED_USER_THEME_FRAME; | |
112 else if (id == IDR_THEME_FRAME_INACTIVE) | |
113 id = IDR_MANAGED_USER_THEME_FRAME_INACTIVE; | |
114 else if (id == IDR_THEME_TAB_BACKGROUND || id == IDR_THEME_TAB_BACKGROUND_V) | |
115 id = IDR_MANAGED_USER_THEME_TAB_BACKGROUND; | |
116 } | |
117 | |
118 gfx::Image image; | 109 gfx::Image image; |
119 if (theme_pack_.get()) | 110 if (theme_provider_.get()) |
120 image = theme_pack_->GetImageNamed(id); | 111 image = theme_provider_->GetImageNamed(id); |
121 | 112 |
122 if (image.IsEmpty()) | 113 if (image.IsEmpty()) |
123 image = rb_.GetNativeImageNamed(id); | 114 image = rb_.GetNativeImageNamed(id); |
124 | 115 |
125 return image; | 116 return image; |
126 } | 117 } |
127 | 118 |
128 gfx::ImageSkia* ThemeService::GetImageSkiaNamed(int id) const { | 119 gfx::ImageSkia* ThemeService::GetImageSkiaNamed(int id) const { |
129 gfx::Image image = GetImageNamed(id); | 120 gfx::Image image = GetImageNamed(id); |
130 if (image.IsEmpty()) | 121 if (image.IsEmpty()) |
131 return NULL; | 122 return NULL; |
132 // TODO(pkotwicz): Remove this const cast. The gfx::Image interface returns | 123 // TODO(pkotwicz): Remove this const cast. The gfx::Image interface returns |
133 // its images const. GetImageSkiaNamed() also should but has many callsites. | 124 // its images const. GetImageSkiaNamed() also should but has many callsites. |
134 return const_cast<gfx::ImageSkia*>(image.ToImageSkia()); | 125 return const_cast<gfx::ImageSkia*>(image.ToImageSkia()); |
135 } | 126 } |
136 | 127 |
137 SkColor ThemeService::GetColor(int id) const { | 128 SkColor ThemeService::GetColor(int id) const { |
138 DCHECK(CalledOnValidThread()); | 129 DCHECK(CalledOnValidThread()); |
139 | |
140 // TODO(akuegel): Remove this once we have the default managed user theme. | |
141 if (IsManagedUser()) { | |
142 if (id == Properties::COLOR_FRAME) | |
143 id = Properties::COLOR_FRAME_MANAGED_USER; | |
144 else if (id == Properties::COLOR_FRAME_INACTIVE) | |
145 id = Properties::COLOR_FRAME_MANAGED_USER_INACTIVE; | |
146 } | |
147 | |
148 SkColor color; | 130 SkColor color; |
149 if (theme_pack_.get() && theme_pack_->GetColor(id, &color)) | 131 if (theme_provider_.get() && theme_provider_->GetColor(id, &color)) |
150 return color; | 132 return color; |
151 | 133 |
152 // For backward compat with older themes, some newer colors are generated from | 134 // For backward compat with older themes, some newer colors are generated from |
153 // older ones if they are missing. | 135 // older ones if they are missing. |
154 switch (id) { | 136 switch (id) { |
155 case Properties::COLOR_NTP_SECTION_HEADER_TEXT: | 137 case Properties::COLOR_NTP_SECTION_HEADER_TEXT: |
156 return IncreaseLightness(GetColor(Properties::COLOR_NTP_TEXT), 0.30); | 138 return IncreaseLightness(GetColor(Properties::COLOR_NTP_TEXT), 0.30); |
157 case Properties::COLOR_NTP_SECTION_HEADER_TEXT_HOVER: | 139 case Properties::COLOR_NTP_SECTION_HEADER_TEXT_HOVER: |
158 return GetColor(Properties::COLOR_NTP_TEXT); | 140 return GetColor(Properties::COLOR_NTP_TEXT); |
159 case Properties::COLOR_NTP_SECTION_HEADER_RULE: | 141 case Properties::COLOR_NTP_SECTION_HEADER_RULE: |
160 return IncreaseLightness(GetColor(Properties::COLOR_NTP_TEXT), 0.70); | 142 return IncreaseLightness(GetColor(Properties::COLOR_NTP_TEXT), 0.70); |
161 case Properties::COLOR_NTP_SECTION_HEADER_RULE_LIGHT: | 143 case Properties::COLOR_NTP_SECTION_HEADER_RULE_LIGHT: |
162 return IncreaseLightness(GetColor(Properties::COLOR_NTP_TEXT), 0.86); | 144 return IncreaseLightness(GetColor(Properties::COLOR_NTP_TEXT), 0.86); |
163 case Properties::COLOR_NTP_TEXT_LIGHT: | 145 case Properties::COLOR_NTP_TEXT_LIGHT: |
164 return IncreaseLightness(GetColor(Properties::COLOR_NTP_TEXT), 0.40); | 146 return IncreaseLightness(GetColor(Properties::COLOR_NTP_TEXT), 0.40); |
165 case Properties::COLOR_MANAGED_USER_LABEL: | 147 case Properties::COLOR_MANAGED_USER_LABEL: |
166 // TODO(akuegel): Use GetReadableColor() once we want to support other | 148 return color_utils::GetReadableColor( |
167 // themes as well. | 149 SK_ColorWHITE, |
168 return SkColorSetRGB(231, 245, 255); | 150 GetColor(Properties::COLOR_MANAGED_USER_LABEL_BACKGROUND)); |
169 case Properties::COLOR_MANAGED_USER_LABEL_BACKGROUND: | 151 case Properties::COLOR_MANAGED_USER_LABEL_BACKGROUND: |
170 // TODO(akuegel): Replace this constant by a color calculated from the | 152 return color_utils::BlendTowardOppositeLuminance( |
171 // frame color once the default managed user theme is finished and we | 153 GetColor(Properties::COLOR_FRAME), 0x80); |
172 // allow managed users to install other themes. | |
173 return SkColorSetRGB(108, 167, 210); | |
174 } | 154 } |
175 | 155 |
176 return Properties::GetDefaultColor(id); | 156 return Properties::GetDefaultColor(id); |
177 } | 157 } |
178 | 158 |
179 bool ThemeService::GetDisplayProperty(int id, int* result) const { | 159 bool ThemeService::GetDisplayProperty(int id, int* result) const { |
180 if (theme_pack_.get()) | 160 if (theme_provider_.get()) |
181 return theme_pack_->GetDisplayProperty(id, result); | 161 return theme_provider_->GetDisplayProperty(id, result); |
182 | 162 |
183 return Properties::GetDefaultDisplayProperty(id, result); | 163 return Properties::GetDefaultDisplayProperty(id, result); |
184 } | 164 } |
185 | 165 |
186 bool ThemeService::ShouldUseNativeFrame() const { | 166 bool ThemeService::ShouldUseNativeFrame() const { |
187 if (HasCustomImage(IDR_THEME_FRAME)) | 167 if (HasCustomImage(IDR_THEME_FRAME)) |
188 return false; | 168 return false; |
189 #if defined(OS_WIN) | 169 #if defined(OS_WIN) |
190 return ui::win::IsAeroGlassEnabled(); | 170 return ui::win::IsAeroGlassEnabled(); |
191 #else | 171 #else |
192 return false; | 172 return false; |
193 #endif | 173 #endif |
194 } | 174 } |
195 | 175 |
196 bool ThemeService::HasCustomImage(int id) const { | 176 bool ThemeService::HasCustomImage(int id) const { |
197 if (!Properties::IsThemeableImage(id)) | 177 if (!Properties::IsThemeableImage(id)) |
198 return false; | 178 return false; |
199 | 179 |
200 if (theme_pack_.get()) | 180 if (theme_provider_.get()) |
201 return theme_pack_->HasCustomImage(id); | 181 return theme_provider_->HasCustomImage(id); |
202 | |
203 if (IsManagedUser() && | |
204 (id == IDR_THEME_FRAME || id == IDR_THEME_FRAME_INACTIVE || | |
205 id == IDR_THEME_TAB_BACKGROUND || id == IDR_THEME_TAB_BACKGROUND_V)) | |
206 return true; | |
207 | 182 |
208 return false; | 183 return false; |
209 } | 184 } |
210 | 185 |
211 base::RefCountedMemory* ThemeService::GetRawData( | 186 base::RefCountedMemory* ThemeService::GetRawData( |
212 int id, | 187 int id, |
213 ui::ScaleFactor scale_factor) const { | 188 ui::ScaleFactor scale_factor) const { |
214 // Check to see whether we should substitute some images. | 189 // Check to see whether we should substitute some images. |
215 int ntp_alternate; | 190 int ntp_alternate; |
216 GetDisplayProperty(Properties::NTP_LOGO_ALTERNATE, &ntp_alternate); | 191 GetDisplayProperty(Properties::NTP_LOGO_ALTERNATE, &ntp_alternate); |
217 if (id == IDR_PRODUCT_LOGO && ntp_alternate != 0) | 192 if (id == IDR_PRODUCT_LOGO && ntp_alternate != 0) |
218 id = IDR_PRODUCT_LOGO_WHITE; | 193 id = IDR_PRODUCT_LOGO_WHITE; |
219 | 194 |
220 base::RefCountedMemory* data = NULL; | 195 base::RefCountedMemory* data = NULL; |
221 if (theme_pack_.get()) | 196 if (theme_provider_.get()) |
222 data = theme_pack_->GetRawData(id, scale_factor); | 197 data = theme_provider_->GetRawData(id, scale_factor); |
223 if (!data) | 198 if (!data) |
224 data = rb_.LoadDataResourceBytesForScale(id, ui::SCALE_FACTOR_100P); | 199 data = rb_.LoadDataResourceBytesForScale(id, ui::SCALE_FACTOR_100P); |
225 | 200 |
226 return data; | 201 return data; |
227 } | 202 } |
228 | 203 |
229 void ThemeService::Observe(int type, | 204 void ThemeService::Observe(int type, |
230 const content::NotificationSource& source, | 205 const content::NotificationSource& source, |
231 const content::NotificationDetails& details) { | 206 const content::NotificationDetails& details) { |
232 DCHECK(type == chrome::NOTIFICATION_EXTENSIONS_READY); | 207 DCHECK(type == chrome::NOTIFICATION_EXTENSIONS_READY); |
(...skipping 21 matching lines...) Expand all Loading... | |
254 DCHECK(service->GetExtensionById(extension->id(), false)); | 229 DCHECK(service->GetExtensionById(extension->id(), false)); |
255 } | 230 } |
256 | 231 |
257 BuildFromExtension(extension); | 232 BuildFromExtension(extension); |
258 SaveThemeID(extension->id()); | 233 SaveThemeID(extension->id()); |
259 | 234 |
260 NotifyThemeChanged(); | 235 NotifyThemeChanged(); |
261 content::RecordAction(UserMetricsAction("Themes_Installed")); | 236 content::RecordAction(UserMetricsAction("Themes_Installed")); |
262 } | 237 } |
263 | 238 |
239 void ThemeService::SetCustomDefaultTheme( | |
240 scoped_refptr<CustomThemeProvider> theme_provider) { | |
241 SaveThemeID(kDefaultThemeID); | |
pkotwicz
2013/07/19 05:54:13
The call to SaveThemeID(kDefaultThemeID) is done f
Adrian Kuegel
2013/07/19 13:54:39
Right. I removed those lines.
| |
242 ClearAllThemeData(); | |
243 if (theme_provider_.get()) | |
244 theme_provider_->StopUsingTheme(); | |
245 theme_provider_ = theme_provider; | |
246 if (theme_provider_.get()) | |
247 theme_provider_->StartUsingTheme(); | |
248 NotifyThemeChanged(); | |
249 } | |
250 | |
264 void ThemeService::RemoveUnusedThemes() { | 251 void ThemeService::RemoveUnusedThemes() { |
265 if (!profile_) | 252 if (!profile_) |
266 return; | 253 return; |
267 ExtensionService* service = profile_->GetExtensionService(); | 254 ExtensionService* service = profile_->GetExtensionService(); |
268 if (!service) | 255 if (!service) |
269 return; | 256 return; |
270 std::string current_theme = GetThemeID(); | 257 std::string current_theme = GetThemeID(); |
271 std::vector<std::string> remove_list; | 258 std::vector<std::string> remove_list; |
272 const ExtensionSet* extensions = service->extensions(); | 259 const ExtensionSet* extensions = service->extensions(); |
273 for (ExtensionSet::const_iterator it = extensions->begin(); | 260 for (ExtensionSet::const_iterator it = extensions->begin(); |
274 it != extensions->end(); ++it) { | 261 it != extensions->end(); ++it) { |
275 if ((*it)->is_theme() && (*it)->id() != current_theme) { | 262 if ((*it)->is_theme() && (*it)->id() != current_theme) { |
276 remove_list.push_back((*it)->id()); | 263 remove_list.push_back((*it)->id()); |
277 } | 264 } |
278 } | 265 } |
279 for (size_t i = 0; i < remove_list.size(); ++i) | 266 for (size_t i = 0; i < remove_list.size(); ++i) |
280 service->UninstallExtension(remove_list[i], false, NULL); | 267 service->UninstallExtension(remove_list[i], false, NULL); |
281 } | 268 } |
282 | 269 |
283 void ThemeService::UseDefaultTheme() { | 270 void ThemeService::UseDefaultTheme() { |
271 content::RecordAction(UserMetricsAction("Themes_Reset")); | |
272 if (IsManagedUser()) { | |
273 SetCustomDefaultTheme(new ManagedUserTheme()); | |
274 return; | |
275 } | |
284 ClearAllThemeData(); | 276 ClearAllThemeData(); |
285 NotifyThemeChanged(); | 277 NotifyThemeChanged(); |
286 content::RecordAction(UserMetricsAction("Themes_Reset")); | |
287 } | 278 } |
288 | 279 |
289 void ThemeService::SetNativeTheme() { | 280 void ThemeService::SetNativeTheme() { |
290 UseDefaultTheme(); | 281 UseDefaultTheme(); |
291 } | 282 } |
292 | 283 |
293 bool ThemeService::UsingDefaultTheme() const { | 284 bool ThemeService::UsingDefaultTheme() const { |
294 std::string id = GetThemeID(); | 285 std::string id = GetThemeID(); |
295 return id == ThemeService::kDefaultThemeID || | 286 return id == ThemeService::kDefaultThemeID || |
296 id == kDefaultThemeGalleryID; | 287 id == kDefaultThemeGalleryID; |
297 } | 288 } |
298 | 289 |
299 bool ThemeService::UsingNativeTheme() const { | 290 bool ThemeService::UsingNativeTheme() const { |
300 return UsingDefaultTheme(); | 291 return UsingDefaultTheme(); |
301 } | 292 } |
302 | 293 |
303 std::string ThemeService::GetThemeID() const { | 294 std::string ThemeService::GetThemeID() const { |
304 return profile_->GetPrefs()->GetString(prefs::kCurrentThemeID); | 295 return profile_->GetPrefs()->GetString(prefs::kCurrentThemeID); |
305 } | 296 } |
306 | 297 |
307 color_utils::HSL ThemeService::GetTint(int id) const { | 298 color_utils::HSL ThemeService::GetTint(int id) const { |
308 DCHECK(CalledOnValidThread()); | 299 DCHECK(CalledOnValidThread()); |
309 | 300 |
310 color_utils::HSL hsl; | 301 color_utils::HSL hsl; |
311 if (theme_pack_.get() && theme_pack_->GetTint(id, &hsl)) | 302 if (theme_provider_.get() && theme_provider_->GetTint(id, &hsl)) |
312 return hsl; | 303 return hsl; |
313 | 304 |
314 return ThemeProperties::GetDefaultTint(id); | 305 return ThemeProperties::GetDefaultTint(id); |
315 } | 306 } |
316 | 307 |
317 void ThemeService::ClearAllThemeData() { | 308 void ThemeService::ClearAllThemeData() { |
309 if (theme_provider_.get()) | |
310 theme_provider_->StopUsingTheme(); | |
318 // Clear our image cache. | 311 // Clear our image cache. |
319 FreePlatformCaches(); | 312 FreePlatformCaches(); |
320 theme_pack_ = NULL; | 313 theme_provider_ = NULL; |
321 | 314 |
322 profile_->GetPrefs()->ClearPref(prefs::kCurrentThemePackFilename); | 315 profile_->GetPrefs()->ClearPref(prefs::kCurrentThemePackFilename); |
323 SaveThemeID(kDefaultThemeID); | 316 SaveThemeID(kDefaultThemeID); |
324 | 317 |
325 RemoveUnusedThemes(); | 318 RemoveUnusedThemes(); |
pkotwicz
2013/07/19 05:54:13
You want to check |ready_| before calling RemoveUn
Adrian Kuegel
2013/07/19 13:54:39
But I guess I should check that then in the functi
pkotwicz
2013/07/19 18:33:20
Putting the check there's fine.
| |
326 } | 319 } |
327 | 320 |
328 void ThemeService::LoadThemePrefs() { | 321 void ThemeService::LoadThemePrefs() { |
329 PrefService* prefs = profile_->GetPrefs(); | 322 PrefService* prefs = profile_->GetPrefs(); |
330 | 323 |
331 std::string current_id = GetThemeID(); | 324 std::string current_id = GetThemeID(); |
332 if (current_id == kDefaultThemeID) { | 325 if (current_id == kDefaultThemeID) { |
333 set_ready(); | 326 set_ready(); |
pkotwicz
2013/07/19 05:54:13
I would rather call UseDefaultTheme() / SetNativeT
Adrian Kuegel
2013/07/19 13:54:39
I do it now almost like that. Since UseDefaultThem
pkotwicz
2013/07/19 18:33:20
Cool!
| |
334 return; | 327 return; |
335 } | 328 } |
336 | 329 |
337 bool loaded_pack = false; | 330 bool loaded_pack = false; |
338 | 331 |
339 // If we don't have a file pack, we're updating from an old version. | 332 // If we don't have a file pack, we're updating from an old version. |
340 base::FilePath path = prefs->GetFilePath(prefs::kCurrentThemePackFilename); | 333 base::FilePath path = prefs->GetFilePath(prefs::kCurrentThemePackFilename); |
341 if (path != base::FilePath()) { | 334 if (path != base::FilePath()) { |
342 theme_pack_ = BrowserThemePack::BuildFromDataPack(path, current_id); | 335 if (theme_provider_.get()) |
343 loaded_pack = theme_pack_.get() != NULL; | 336 theme_provider_->StopUsingTheme(); |
337 theme_provider_ = BrowserThemePack::BuildFromDataPack(path, current_id); | |
338 if (theme_provider_.get()) { | |
339 theme_provider_->StartUsingTheme(); | |
340 loaded_pack = true; | |
341 } | |
344 } | 342 } |
345 | 343 |
346 if (loaded_pack) { | 344 if (loaded_pack) { |
347 content::RecordAction(UserMetricsAction("Themes.Loaded")); | 345 content::RecordAction(UserMetricsAction("Themes.Loaded")); |
348 set_ready(); | 346 set_ready(); |
349 } else { | 347 } else { |
350 // TODO(erg): We need to pop up a dialog informing the user that their | 348 // TODO(erg): We need to pop up a dialog informing the user that their |
351 // theme is being migrated. | 349 // theme is being migrated. |
352 ExtensionService* service = | 350 ExtensionService* service = |
353 extensions::ExtensionSystem::Get(profile_)->extension_service(); | 351 extensions::ExtensionSystem::Get(profile_)->extension_service(); |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
423 return; | 421 return; |
424 | 422 |
425 // Write the packed file to disk. | 423 // Write the packed file to disk. |
426 base::FilePath pack_path = | 424 base::FilePath pack_path = |
427 extension->path().Append(chrome::kThemePackFilename); | 425 extension->path().Append(chrome::kThemePackFilename); |
428 service->GetFileTaskRunner()->PostTask( | 426 service->GetFileTaskRunner()->PostTask( |
429 FROM_HERE, | 427 FROM_HERE, |
430 base::Bind(&WritePackToDiskCallback, pack, pack_path)); | 428 base::Bind(&WritePackToDiskCallback, pack, pack_path)); |
431 | 429 |
432 SavePackName(pack_path); | 430 SavePackName(pack_path); |
433 theme_pack_ = pack; | 431 if (theme_provider_.get()) |
pkotwicz
2013/07/19 05:54:13
Optional: It may be worth putting this code in its
Adrian Kuegel
2013/07/19 13:54:39
Done.
| |
432 theme_provider_->StopUsingTheme(); | |
433 theme_provider_ = pack; | |
434 theme_provider_->StartUsingTheme(); | |
434 } | 435 } |
435 | 436 |
436 bool ThemeService::IsManagedUser() const { | 437 bool ThemeService::IsManagedUser() const { |
437 #if defined(ENABLE_MANAGED_USERS) | 438 #if defined(ENABLE_MANAGED_USERS) |
438 return ManagedUserService::ProfileIsManaged(profile_); | 439 return ManagedUserService::ProfileIsManaged(profile_); |
439 #endif | 440 #endif |
440 return false; | 441 return false; |
441 } | 442 } |
442 | 443 |
443 void ThemeService::OnInfobarDisplayed() { | 444 void ThemeService::OnInfobarDisplayed() { |
444 number_of_infobars_++; | 445 number_of_infobars_++; |
445 } | 446 } |
446 | 447 |
447 void ThemeService::OnInfobarDestroyed() { | 448 void ThemeService::OnInfobarDestroyed() { |
448 number_of_infobars_--; | 449 number_of_infobars_--; |
449 | 450 |
450 if (number_of_infobars_ == 0) | 451 if (number_of_infobars_ == 0) |
451 RemoveUnusedThemes(); | 452 RemoveUnusedThemes(); |
452 } | 453 } |
453 | 454 |
454 ThemeSyncableService* ThemeService::GetThemeSyncableService() const { | 455 ThemeSyncableService* ThemeService::GetThemeSyncableService() const { |
455 return theme_syncable_service_.get(); | 456 return theme_syncable_service_.get(); |
456 } | 457 } |
OLD | NEW |