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/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
112 gfx::Image image; | 112 gfx::Image image; |
113 if (theme_supplier_.get()) | 113 if (theme_supplier_.get()) |
114 image = theme_supplier_->GetImageNamed(id); | 114 image = theme_supplier_->GetImageNamed(id); |
115 | 115 |
116 if (image.IsEmpty()) | 116 if (image.IsEmpty()) |
117 image = rb_.GetNativeImageNamed(id); | 117 image = rb_.GetNativeImageNamed(id); |
118 | 118 |
119 return image; | 119 return image; |
120 } | 120 } |
121 | 121 |
122 bool ThemeService::UsingNativeTheme() const { | 122 bool ThemeService::UsingSystemTheme() const { |
123 return UsingDefaultTheme(); | 123 return UsingDefaultTheme(); |
124 } | 124 } |
125 | 125 |
126 gfx::ImageSkia* ThemeService::GetImageSkiaNamed(int id) const { | 126 gfx::ImageSkia* ThemeService::GetImageSkiaNamed(int id) const { |
127 gfx::Image image = GetImageNamed(id); | 127 gfx::Image image = GetImageNamed(id); |
128 if (image.IsEmpty()) | 128 if (image.IsEmpty()) |
129 return NULL; | 129 return NULL; |
130 // TODO(pkotwicz): Remove this const cast. The gfx::Image interface returns | 130 // TODO(pkotwicz): Remove this const cast. The gfx::Image interface returns |
131 // its images const. GetImageSkiaNamed() also should but has many callsites. | 131 // its images const. GetImageSkiaNamed() also should but has many callsites. |
132 return const_cast<gfx::ImageSkia*>(image.ToImageSkia()); | 132 return const_cast<gfx::ImageSkia*>(image.ToImageSkia()); |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
184 | 184 |
185 int ThemeService::GetDisplayProperty(int id) const { | 185 int ThemeService::GetDisplayProperty(int id) const { |
186 int result = 0; | 186 int result = 0; |
187 if (theme_supplier_.get() && | 187 if (theme_supplier_.get() && |
188 theme_supplier_->GetDisplayProperty(id, &result)) { | 188 theme_supplier_->GetDisplayProperty(id, &result)) { |
189 return result; | 189 return result; |
190 } | 190 } |
191 | 191 |
192 if (id == Properties::NTP_LOGO_ALTERNATE && | 192 if (id == Properties::NTP_LOGO_ALTERNATE && |
193 !UsingDefaultTheme() && | 193 !UsingDefaultTheme() && |
194 !UsingNativeTheme()) { | 194 !UsingSystemTheme()) { |
195 // Use the alternate logo for themes from the web store except for | 195 // Use the alternate logo for themes from the web store except for |
196 // |kDefaultThemeGalleryID|. | 196 // |kDefaultThemeGalleryID|. |
197 return 1; | 197 return 1; |
198 } | 198 } |
199 | 199 |
200 return Properties::GetDefaultDisplayProperty(id); | 200 return Properties::GetDefaultDisplayProperty(id); |
201 } | 201 } |
202 | 202 |
203 bool ThemeService::ShouldUseNativeFrame() const { | 203 bool ThemeService::ShouldUseNativeFrame() const { |
204 if (HasCustomImage(IDR_THEME_FRAME)) | 204 if (HasCustomImage(IDR_THEME_FRAME)) |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
375 if (ready_) | 375 if (ready_) |
376 content::RecordAction(UserMetricsAction("Themes_Reset")); | 376 content::RecordAction(UserMetricsAction("Themes_Reset")); |
377 if (IsManagedUser()) { | 377 if (IsManagedUser()) { |
378 SetManagedUserTheme(); | 378 SetManagedUserTheme(); |
379 return; | 379 return; |
380 } | 380 } |
381 ClearAllThemeData(); | 381 ClearAllThemeData(); |
382 NotifyThemeChanged(); | 382 NotifyThemeChanged(); |
383 } | 383 } |
384 | 384 |
385 void ThemeService::SetNativeTheme() { | 385 void ThemeService::UseSystemTheme() { |
386 UseDefaultTheme(); | 386 UseDefaultTheme(); |
387 } | 387 } |
388 | 388 |
389 bool ThemeService::UsingDefaultTheme() const { | 389 bool ThemeService::UsingDefaultTheme() const { |
390 std::string id = GetThemeID(); | 390 std::string id = GetThemeID(); |
391 return id == ThemeService::kDefaultThemeID || | 391 return id == ThemeService::kDefaultThemeID || |
392 id == kDefaultThemeGalleryID; | 392 id == kDefaultThemeGalleryID; |
393 } | 393 } |
394 | 394 |
395 std::string ThemeService::GetThemeID() const { | 395 std::string ThemeService::GetThemeID() const { |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
429 } | 429 } |
430 | 430 |
431 void ThemeService::LoadThemePrefs() { | 431 void ThemeService::LoadThemePrefs() { |
432 PrefService* prefs = profile_->GetPrefs(); | 432 PrefService* prefs = profile_->GetPrefs(); |
433 | 433 |
434 std::string current_id = GetThemeID(); | 434 std::string current_id = GetThemeID(); |
435 if (current_id == kDefaultThemeID) { | 435 if (current_id == kDefaultThemeID) { |
436 // Managed users have a different default theme. | 436 // Managed users have a different default theme. |
437 if (IsManagedUser()) | 437 if (IsManagedUser()) |
438 SetManagedUserTheme(); | 438 SetManagedUserTheme(); |
439 else if (ShouldInitWithNativeTheme()) | 439 else if (ShouldInitWithNativeTheme()) |
msw
2014/04/22 18:02:13
nit: shouldn't this match SetNativeTheme / UseSyst
Evan Stade
2014/04/22 18:16:06
good catch, I changed this partially but didn't ge
| |
440 SetNativeTheme(); | 440 UseSystemTheme(); |
441 else | 441 else |
442 UseDefaultTheme(); | 442 UseDefaultTheme(); |
443 set_ready(); | 443 set_ready(); |
444 return; | 444 return; |
445 } | 445 } |
446 | 446 |
447 bool loaded_pack = false; | 447 bool loaded_pack = false; |
448 | 448 |
449 // If we don't have a file pack, we're updating from an old version. | 449 // If we don't have a file pack, we're updating from an old version. |
450 base::FilePath path = prefs->GetFilePath(prefs::kCurrentThemePackFilename); | 450 base::FilePath path = prefs->GetFilePath(prefs::kCurrentThemePackFilename); |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
597 void ThemeService::OnInfobarDestroyed() { | 597 void ThemeService::OnInfobarDestroyed() { |
598 number_of_infobars_--; | 598 number_of_infobars_--; |
599 | 599 |
600 if (number_of_infobars_ == 0) | 600 if (number_of_infobars_ == 0) |
601 RemoveUnusedThemes(false); | 601 RemoveUnusedThemes(false); |
602 } | 602 } |
603 | 603 |
604 ThemeSyncableService* ThemeService::GetThemeSyncableService() const { | 604 ThemeSyncableService* ThemeService::GetThemeSyncableService() const { |
605 return theme_syncable_service_.get(); | 605 return theme_syncable_service_.get(); |
606 } | 606 } |
OLD | NEW |