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" |
11 #include "base/sequenced_task_runner.h" | 11 #include "base/sequenced_task_runner.h" |
12 #include "base/strings/string_util.h" | 12 #include "base/strings/string_util.h" |
13 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
14 #include "chrome/browser/chrome_notification_types.h" | 14 #include "chrome/browser/chrome_notification_types.h" |
15 #include "chrome/browser/extensions/extension_service.h" | 15 #include "chrome/browser/extensions/extension_service.h" |
16 #include "chrome/browser/profiles/profile.h" | 16 #include "chrome/browser/profiles/profile.h" |
17 #include "chrome/browser/supervised_user/supervised_user_theme.h" | |
18 #include "chrome/browser/themes/browser_theme_pack.h" | 17 #include "chrome/browser/themes/browser_theme_pack.h" |
19 #include "chrome/browser/themes/custom_theme_supplier.h" | 18 #include "chrome/browser/themes/custom_theme_supplier.h" |
20 #include "chrome/browser/themes/theme_properties.h" | 19 #include "chrome/browser/themes/theme_properties.h" |
21 #include "chrome/browser/themes/theme_syncable_service.h" | 20 #include "chrome/browser/themes/theme_syncable_service.h" |
22 #include "chrome/common/chrome_constants.h" | 21 #include "chrome/common/chrome_constants.h" |
23 #include "chrome/common/pref_names.h" | 22 #include "chrome/common/pref_names.h" |
24 #include "content/public/browser/notification_service.h" | 23 #include "content/public/browser/notification_service.h" |
25 #include "content/public/browser/user_metrics.h" | 24 #include "content/public/browser/user_metrics.h" |
26 #include "extensions/browser/extension_prefs.h" | 25 #include "extensions/browser/extension_prefs.h" |
27 #include "extensions/browser/extension_registry.h" | 26 #include "extensions/browser/extension_registry.h" |
28 #include "extensions/browser/extension_system.h" | 27 #include "extensions/browser/extension_system.h" |
29 #include "extensions/common/extension.h" | 28 #include "extensions/common/extension.h" |
30 #include "extensions/common/extension_set.h" | 29 #include "extensions/common/extension_set.h" |
31 #include "grit/theme_resources.h" | 30 #include "grit/theme_resources.h" |
32 #include "grit/ui_resources.h" | 31 #include "grit/ui_resources.h" |
33 #include "ui/base/layout.h" | 32 #include "ui/base/layout.h" |
34 #include "ui/base/resource/resource_bundle.h" | 33 #include "ui/base/resource/resource_bundle.h" |
35 #include "ui/gfx/image/image_skia.h" | 34 #include "ui/gfx/image/image_skia.h" |
36 | 35 |
36 #if defined(ENABLE_MANAGED_USERS) | |
37 #include "chrome/browser/supervised_user/supervised_user_theme.h" | |
38 #endif | |
39 | |
37 #if defined(OS_WIN) | 40 #if defined(OS_WIN) |
38 #include "ui/base/win/shell.h" | 41 #include "ui/base/win/shell.h" |
39 #endif | 42 #endif |
40 | 43 |
41 using base::UserMetricsAction; | 44 using base::UserMetricsAction; |
42 using content::BrowserThread; | 45 using content::BrowserThread; |
43 using extensions::Extension; | 46 using extensions::Extension; |
44 using extensions::UnloadedExtensionInfo; | 47 using extensions::UnloadedExtensionInfo; |
45 using ui::ResourceBundle; | 48 using ui::ResourceBundle; |
46 | 49 |
(...skipping 531 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
578 base::Bind(&WritePackToDiskCallback, pack, pack_path)); | 581 base::Bind(&WritePackToDiskCallback, pack, pack_path)); |
579 | 582 |
580 SavePackName(pack_path); | 583 SavePackName(pack_path); |
581 SwapThemeSupplier(pack); | 584 SwapThemeSupplier(pack); |
582 } | 585 } |
583 | 586 |
584 bool ThemeService::IsSupervisedUser() const { | 587 bool ThemeService::IsSupervisedUser() const { |
585 return profile_->IsSupervised(); | 588 return profile_->IsSupervised(); |
586 } | 589 } |
587 | 590 |
588 void ThemeService::SetSupervisedUserTheme() { | 591 void ThemeService::SetSupervisedUserTheme() { |
Bernhard Bauer
2014/06/30 16:04:18
Could we move the whole method into the #ifdef?
mckev
2014/07/11 18:27:54
Done.
| |
592 #if defined(ENABLE_MANAGED_USERS) | |
589 SetCustomDefaultTheme(new SupervisedUserTheme); | 593 SetCustomDefaultTheme(new SupervisedUserTheme); |
594 #else | |
595 DCHECK(false) << "Supervised users aren't enabled."; | |
Bernhard Bauer
2014/06/30 16:04:18
This is more commonly written as NOTREACHED() (see
mckev
2014/07/11 18:27:54
Awesome, thanks for the tip!
| |
596 #endif | |
590 } | 597 } |
591 | 598 |
592 void ThemeService::OnInfobarDisplayed() { | 599 void ThemeService::OnInfobarDisplayed() { |
593 number_of_infobars_++; | 600 number_of_infobars_++; |
594 } | 601 } |
595 | 602 |
596 void ThemeService::OnInfobarDestroyed() { | 603 void ThemeService::OnInfobarDestroyed() { |
597 number_of_infobars_--; | 604 number_of_infobars_--; |
598 | 605 |
599 if (number_of_infobars_ == 0) | 606 if (number_of_infobars_ == 0) |
600 RemoveUnusedThemes(false); | 607 RemoveUnusedThemes(false); |
601 } | 608 } |
602 | 609 |
603 ThemeSyncableService* ThemeService::GetThemeSyncableService() const { | 610 ThemeSyncableService* ThemeService::GetThemeSyncableService() const { |
604 return theme_syncable_service_.get(); | 611 return theme_syncable_service_.get(); |
605 } | 612 } |
OLD | NEW |