| 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/file_util.h" | 7 #include "base/file_util.h" |
| 8 #include "base/path_service.h" | 8 #include "base/path_service.h" |
| 9 #include "chrome/browser/chrome_notification_types.h" | 9 #include "chrome/browser/chrome_notification_types.h" |
| 10 #include "chrome/browser/extensions/extension_service.h" | 10 #include "chrome/browser/extensions/extension_service.h" |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 base::FilePath dst_manifest_path = temp_dir.AppendASCII("manifest.json"); | 41 base::FilePath dst_manifest_path = temp_dir.AppendASCII("manifest.json"); |
| 42 base::FilePath test_data_dir; | 42 base::FilePath test_data_dir; |
| 43 EXPECT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir)); | 43 EXPECT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir)); |
| 44 base::FilePath src_manifest_path = | 44 base::FilePath src_manifest_path = |
| 45 test_data_dir.AppendASCII("extensions/theme_minimal/manifest.json"); | 45 test_data_dir.AppendASCII("extensions/theme_minimal/manifest.json"); |
| 46 EXPECT_TRUE(base::CopyFile(src_manifest_path, dst_manifest_path)); | 46 EXPECT_TRUE(base::CopyFile(src_manifest_path, dst_manifest_path)); |
| 47 | 47 |
| 48 scoped_refptr<extensions::UnpackedInstaller> installer( | 48 scoped_refptr<extensions::UnpackedInstaller> installer( |
| 49 extensions::UnpackedInstaller::Create(service_)); | 49 extensions::UnpackedInstaller::Create(service_)); |
| 50 content::WindowedNotificationObserver observer( | 50 content::WindowedNotificationObserver observer( |
| 51 chrome::NOTIFICATION_EXTENSION_LOADED_DEPRECATED, | 51 extensions::NOTIFICATION_EXTENSION_LOADED_DEPRECATED, |
| 52 content::Source<Profile>(profile_.get())); | 52 content::Source<Profile>(profile_.get())); |
| 53 installer->Load(temp_dir); | 53 installer->Load(temp_dir); |
| 54 observer.Wait(); | 54 observer.Wait(); |
| 55 | 55 |
| 56 std::string extension_id = | 56 std::string extension_id = |
| 57 content::Details<extensions::Extension>(observer.details())->id(); | 57 content::Details<extensions::Extension>(observer.details())->id(); |
| 58 | 58 |
| 59 // Let the ThemeService finish creating the theme pack. | 59 // Let the ThemeService finish creating the theme pack. |
| 60 base::MessageLoop::current()->RunUntilIdle(); | 60 base::MessageLoop::current()->RunUntilIdle(); |
| 61 | 61 |
| 62 return extension_id; | 62 return extension_id; |
| 63 } | 63 } |
| 64 | 64 |
| 65 // Update the theme with |extension_id|. | 65 // Update the theme with |extension_id|. |
| 66 void UpdateUnpackedTheme(const std::string& extension_id) { | 66 void UpdateUnpackedTheme(const std::string& extension_id) { |
| 67 int updated_notification = | 67 int updated_notification = |
| 68 service_->IsExtensionEnabled(extension_id) | 68 service_->IsExtensionEnabled(extension_id) |
| 69 ? chrome::NOTIFICATION_EXTENSION_LOADED_DEPRECATED | 69 ? extensions::NOTIFICATION_EXTENSION_LOADED_DEPRECATED |
| 70 : chrome::NOTIFICATION_EXTENSION_UPDATE_DISABLED; | 70 : extensions::NOTIFICATION_EXTENSION_UPDATE_DISABLED; |
| 71 | 71 |
| 72 const base::FilePath& path = | 72 const base::FilePath& path = |
| 73 service_->GetInstalledExtension(extension_id)->path(); | 73 service_->GetInstalledExtension(extension_id)->path(); |
| 74 | 74 |
| 75 scoped_refptr<extensions::UnpackedInstaller> installer( | 75 scoped_refptr<extensions::UnpackedInstaller> installer( |
| 76 extensions::UnpackedInstaller::Create(service_)); | 76 extensions::UnpackedInstaller::Create(service_)); |
| 77 content::WindowedNotificationObserver observer(updated_notification, | 77 content::WindowedNotificationObserver observer(updated_notification, |
| 78 content::Source<Profile>(profile_.get())); | 78 content::Source<Profile>(profile_.get())); |
| 79 installer->Load(path); | 79 installer->Load(path); |
| 80 observer.Wait(); | 80 observer.Wait(); |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 266 ThemeServiceFactory::GetForProfile(profile_.get()); | 266 ThemeServiceFactory::GetForProfile(profile_.get()); |
| 267 theme_service->UseDefaultTheme(); | 267 theme_service->UseDefaultTheme(); |
| 268 EXPECT_TRUE(theme_service->UsingDefaultTheme()); | 268 EXPECT_TRUE(theme_service->UsingDefaultTheme()); |
| 269 EXPECT_TRUE(get_theme_supplier(theme_service)); | 269 EXPECT_TRUE(get_theme_supplier(theme_service)); |
| 270 EXPECT_EQ(get_theme_supplier(theme_service)->get_theme_type(), | 270 EXPECT_EQ(get_theme_supplier(theme_service)->get_theme_type(), |
| 271 CustomThemeSupplier::SUPERVISED_USER_THEME); | 271 CustomThemeSupplier::SUPERVISED_USER_THEME); |
| 272 } | 272 } |
| 273 #endif | 273 #endif |
| 274 | 274 |
| 275 }; // namespace theme_service_internal | 275 }; // namespace theme_service_internal |
| OLD | NEW |