| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 | 10 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 #include "components/prefs/pref_service.h" | 32 #include "components/prefs/pref_service.h" |
| 33 #include "content/public/browser/notification_service.h" | 33 #include "content/public/browser/notification_service.h" |
| 34 #include "content/public/browser/user_metrics.h" | 34 #include "content/public/browser/user_metrics.h" |
| 35 #include "extensions/browser/extension_prefs.h" | 35 #include "extensions/browser/extension_prefs.h" |
| 36 #include "extensions/browser/extension_registry.h" | 36 #include "extensions/browser/extension_registry.h" |
| 37 #include "extensions/browser/extension_system.h" | 37 #include "extensions/browser/extension_system.h" |
| 38 #include "extensions/browser/uninstall_reason.h" | 38 #include "extensions/browser/uninstall_reason.h" |
| 39 #include "extensions/common/extension.h" | 39 #include "extensions/common/extension.h" |
| 40 #include "extensions/common/extension_set.h" | 40 #include "extensions/common/extension_set.h" |
| 41 #include "ui/base/layout.h" | 41 #include "ui/base/layout.h" |
| 42 #include "ui/base/material_design/material_design_controller.h" | |
| 43 #include "ui/base/resource/resource_bundle.h" | 42 #include "ui/base/resource/resource_bundle.h" |
| 44 #include "ui/gfx/color_palette.h" | 43 #include "ui/gfx/color_palette.h" |
| 45 #include "ui/gfx/image/image_skia.h" | 44 #include "ui/gfx/image/image_skia.h" |
| 46 #include "ui/native_theme/common_theme.h" | 45 #include "ui/native_theme/common_theme.h" |
| 47 #include "ui/native_theme/native_theme.h" | 46 #include "ui/native_theme/native_theme.h" |
| 48 | 47 |
| 49 #if defined(ENABLE_EXTENSIONS) | 48 #if defined(ENABLE_EXTENSIONS) |
| 50 #include "extensions/browser/extension_registry_observer.h" | 49 #include "extensions/browser/extension_registry_observer.h" |
| 51 #endif | 50 #endif |
| 52 | 51 |
| (...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 566 if (ShouldInitWithSystemTheme()) | 565 if (ShouldInitWithSystemTheme()) |
| 567 UseSystemTheme(); | 566 UseSystemTheme(); |
| 568 else | 567 else |
| 569 UseDefaultTheme(); | 568 UseDefaultTheme(); |
| 570 set_ready(); | 569 set_ready(); |
| 571 return; | 570 return; |
| 572 } | 571 } |
| 573 | 572 |
| 574 bool loaded_pack = false; | 573 bool loaded_pack = false; |
| 575 | 574 |
| 576 // If we don't have a file pack, we're updating from an old version, or the | 575 // If we don't have a file pack, we're updating from an old version. |
| 577 // pack was created for an alternative MaterialDesignController::Mode. | |
| 578 base::FilePath path = prefs->GetFilePath(prefs::kCurrentThemePackFilename); | 576 base::FilePath path = prefs->GetFilePath(prefs::kCurrentThemePackFilename); |
| 579 if (path != base::FilePath()) { | 577 if (path != base::FilePath()) { |
| 580 path = path.Append(ui::MaterialDesignController::IsModeMaterial() | 578 path = path.Append(chrome::kThemePackFilename); |
| 581 ? chrome::kThemePackMaterialDesignFilename | |
| 582 : chrome::kThemePackFilename); | |
| 583 SwapThemeSupplier(BrowserThemePack::BuildFromDataPack(path, current_id)); | 579 SwapThemeSupplier(BrowserThemePack::BuildFromDataPack(path, current_id)); |
| 584 if (theme_supplier_) | 580 if (theme_supplier_) |
| 585 loaded_pack = true; | 581 loaded_pack = true; |
| 586 } | 582 } |
| 587 | 583 |
| 588 if (loaded_pack) { | 584 if (loaded_pack) { |
| 589 content::RecordAction(UserMetricsAction("Themes.Loaded")); | 585 content::RecordAction(UserMetricsAction("Themes.Loaded")); |
| 590 set_ready(); | 586 set_ready(); |
| 591 } | 587 } |
| 592 // Else: wait for the extension service to be ready so that the theme pack | 588 // Else: wait for the extension service to be ready so that the theme pack |
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 851 return; | 847 return; |
| 852 } | 848 } |
| 853 | 849 |
| 854 ExtensionService* service = | 850 ExtensionService* service = |
| 855 extensions::ExtensionSystem::Get(profile_)->extension_service(); | 851 extensions::ExtensionSystem::Get(profile_)->extension_service(); |
| 856 if (!service) | 852 if (!service) |
| 857 return; | 853 return; |
| 858 | 854 |
| 859 // Write the packed file to disk. | 855 // Write the packed file to disk. |
| 860 base::FilePath pack_path = | 856 base::FilePath pack_path = |
| 861 extension->path().Append(ui::MaterialDesignController::IsModeMaterial() | 857 extension->path().Append(chrome::kThemePackFilename); |
| 862 ? chrome::kThemePackMaterialDesignFilename | |
| 863 : chrome::kThemePackFilename); | |
| 864 service->GetFileTaskRunner()->PostTask( | 858 service->GetFileTaskRunner()->PostTask( |
| 865 FROM_HERE, | 859 FROM_HERE, |
| 866 base::Bind(&WritePackToDiskCallback, base::RetainedRef(pack), pack_path)); | 860 base::Bind(&WritePackToDiskCallback, base::RetainedRef(pack), pack_path)); |
| 867 | 861 |
| 868 // Save only the extension path. The packed file which matches the | 862 // Save only the extension path. The packed file will be loaded via |
| 869 // MaterialDesignController::Mode will be loaded via LoadThemePrefs(). | 863 // LoadThemePrefs(). |
| 870 SavePackName(extension->path()); | 864 SavePackName(extension->path()); |
| 871 SwapThemeSupplier(pack); | 865 SwapThemeSupplier(pack); |
| 872 } | 866 } |
| 873 | 867 |
| 874 #if defined(ENABLE_SUPERVISED_USERS) | 868 #if defined(ENABLE_SUPERVISED_USERS) |
| 875 bool ThemeService::IsSupervisedUser() const { | 869 bool ThemeService::IsSupervisedUser() const { |
| 876 return profile_->IsSupervised(); | 870 return profile_->IsSupervised(); |
| 877 } | 871 } |
| 878 | 872 |
| 879 void ThemeService::SetSupervisedUserTheme() { | 873 void ThemeService::SetSupervisedUserTheme() { |
| 880 SetCustomDefaultTheme(new SupervisedUserTheme); | 874 SetCustomDefaultTheme(new SupervisedUserTheme); |
| 881 } | 875 } |
| 882 #endif | 876 #endif |
| OLD | NEW |