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_syncable_service.h" | 5 #include "chrome/browser/themes/theme_syncable_service.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 | 89 |
90 virtual bool UsingDefaultTheme() const OVERRIDE { | 90 virtual bool UsingDefaultTheme() const OVERRIDE { |
91 return using_default_theme_; | 91 return using_default_theme_; |
92 } | 92 } |
93 | 93 |
94 virtual bool UsingNativeTheme() const OVERRIDE { | 94 virtual bool UsingNativeTheme() const OVERRIDE { |
95 return using_native_theme_; | 95 return using_native_theme_; |
96 } | 96 } |
97 | 97 |
98 virtual string GetThemeID() const OVERRIDE { | 98 virtual string GetThemeID() const OVERRIDE { |
99 if (theme_extension_) | 99 if (theme_extension_.get()) |
100 return theme_extension_->id(); | 100 return theme_extension_->id(); |
101 else | 101 else |
102 return ""; | 102 return ""; |
103 } | 103 } |
104 | 104 |
105 const extensions::Extension* theme_extension() const { | 105 const extensions::Extension* theme_extension() const { |
106 return theme_extension_.get(); | 106 return theme_extension_.get(); |
107 } | 107 } |
108 | 108 |
109 bool is_dirty() const { | 109 bool is_dirty() const { |
(...skipping 22 matching lines...) Expand all Loading... |
132 DictionaryValue source; | 132 DictionaryValue source; |
133 source.SetString(extension_manifest_keys::kName, name); | 133 source.SetString(extension_manifest_keys::kName, name); |
134 source.Set(extension_manifest_keys::kTheme, new DictionaryValue()); | 134 source.Set(extension_manifest_keys::kTheme, new DictionaryValue()); |
135 source.SetString(extension_manifest_keys::kUpdateURL, update_url); | 135 source.SetString(extension_manifest_keys::kUpdateURL, update_url); |
136 source.SetString(extension_manifest_keys::kVersion, "0.0.0.0"); | 136 source.SetString(extension_manifest_keys::kVersion, "0.0.0.0"); |
137 string error; | 137 string error; |
138 scoped_refptr<extensions::Extension> extension = | 138 scoped_refptr<extensions::Extension> extension = |
139 extensions::Extension::Create( | 139 extensions::Extension::Create( |
140 extension_path, extensions::Extension::EXTERNAL_PREF_DOWNLOAD, source, | 140 extension_path, extensions::Extension::EXTERNAL_PREF_DOWNLOAD, source, |
141 extensions::Extension::NO_FLAGS, &error); | 141 extensions::Extension::NO_FLAGS, &error); |
142 EXPECT_TRUE(extension); | 142 EXPECT_TRUE(extension.get()); |
143 EXPECT_EQ("", error); | 143 EXPECT_EQ("", error); |
144 return extension; | 144 return extension; |
145 } | 145 } |
146 | 146 |
147 } // namespace | 147 } // namespace |
148 | 148 |
149 class ThemeSyncableServiceTest : public testing::Test { | 149 class ThemeSyncableServiceTest : public testing::Test { |
150 protected: | 150 protected: |
151 ThemeSyncableServiceTest() | 151 ThemeSyncableServiceTest() |
152 : loop_(MessageLoop::TYPE_DEFAULT), | 152 : loop_(MessageLoop::TYPE_DEFAULT), |
(...skipping 27 matching lines...) Expand all Loading... |
180 FilePath(kExtensionFilePath), | 180 FilePath(kExtensionFilePath), |
181 false); | 181 false); |
182 EXPECT_TRUE(service->extensions_enabled()); | 182 EXPECT_TRUE(service->extensions_enabled()); |
183 service->Init(); | 183 service->Init(); |
184 loop_.RunAllPending(); | 184 loop_.RunAllPending(); |
185 | 185 |
186 // Create and add custom theme extension so the ThemeSyncableService can | 186 // Create and add custom theme extension so the ThemeSyncableService can |
187 // find it. | 187 // find it. |
188 theme_extension_ = MakeThemeExtension(FilePath(kExtensionFilePath), | 188 theme_extension_ = MakeThemeExtension(FilePath(kExtensionFilePath), |
189 kCustomThemeName, kCustomThemeUrl); | 189 kCustomThemeName, kCustomThemeUrl); |
190 service->AddExtension(theme_extension_); | 190 service->AddExtension(theme_extension_.get()); |
191 ASSERT_EQ(1u, service->extensions()->size()); | 191 ASSERT_EQ(1u, service->extensions()->size()); |
192 } | 192 } |
193 | 193 |
194 FakeThemeService* BuildForProfile(Profile* profile) { | 194 FakeThemeService* BuildForProfile(Profile* profile) { |
195 return static_cast<FakeThemeService*>( | 195 return static_cast<FakeThemeService*>( |
196 ThemeServiceFactory::GetInstance()->SetTestingFactoryAndUse( | 196 ThemeServiceFactory::GetInstance()->SetTestingFactoryAndUse( |
197 profile, &BuildMockThemeService)); | 197 profile, &BuildMockThemeService)); |
198 } | 198 } |
199 | 199 |
200 syncer::SyncDataList MakeThemeDataList( | 200 syncer::SyncDataList MakeThemeDataList( |
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
551 // use_system_theme_by_default bit should be preserved. | 551 // use_system_theme_by_default bit should be preserved. |
552 fake_theme_service_->UseDefaultTheme(); | 552 fake_theme_service_->UseDefaultTheme(); |
553 theme_sync_service_->OnThemeChange(); | 553 theme_sync_service_->OnThemeChange(); |
554 EXPECT_EQ(1u, change_list.size()); | 554 EXPECT_EQ(1u, change_list.size()); |
555 const sync_pb::ThemeSpecifics& change_specifics = | 555 const sync_pb::ThemeSpecifics& change_specifics = |
556 change_list[0].sync_data().GetSpecifics().theme(); | 556 change_list[0].sync_data().GetSpecifics().theme(); |
557 EXPECT_FALSE(change_specifics.use_custom_theme()); | 557 EXPECT_FALSE(change_specifics.use_custom_theme()); |
558 EXPECT_TRUE(change_specifics.use_system_theme_by_default()); | 558 EXPECT_TRUE(change_specifics.use_system_theme_by_default()); |
559 } | 559 } |
560 #endif | 560 #endif |
OLD | NEW |