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