Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(302)

Side by Side Diff: chrome/browser/extensions/extension_service_unittest.cc

Issue 12093036: Move Extension Location and Type enums to Manifest, and move InstallWarning to its own file. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/extensions/extension_service_unittest.h" 5 #include "chrome/browser/extensions/extension_service_unittest.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <set> 8 #include <set>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 using content::IndexedDBContext; 114 using content::IndexedDBContext;
115 using content::PluginService; 115 using content::PluginService;
116 using extensions::APIPermission; 116 using extensions::APIPermission;
117 using extensions::APIPermissionSet; 117 using extensions::APIPermissionSet;
118 using extensions::CrxInstaller; 118 using extensions::CrxInstaller;
119 using extensions::Extension; 119 using extensions::Extension;
120 using extensions::ExtensionCreator; 120 using extensions::ExtensionCreator;
121 using extensions::ExtensionPrefs; 121 using extensions::ExtensionPrefs;
122 using extensions::ExtensionSystem; 122 using extensions::ExtensionSystem;
123 using extensions::FeatureSwitch; 123 using extensions::FeatureSwitch;
124 using extensions::Manifest;
124 using extensions::PermissionSet; 125 using extensions::PermissionSet;
125 using extensions::URLPatternSet; 126 using extensions::URLPatternSet;
126 127
127 namespace keys = extension_manifest_keys; 128 namespace keys = extension_manifest_keys;
128 129
129 namespace { 130 namespace {
130 131
131 // Extension ids used during testing. 132 // Extension ids used during testing.
132 const char* const all_zero = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"; 133 const char* const all_zero = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
133 const char* const zero_n_one = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab"; 134 const char* const zero_n_one = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab";
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 CHECK(file_util::CreateTemporaryFile(&temp_file)); 179 CHECK(file_util::CreateTemporaryFile(&temp_file));
179 return temp_file; 180 return temp_file;
180 } 181 }
181 182
182 } // namespace 183 } // namespace
183 184
184 class MockExtensionProvider : public extensions::ExternalProviderInterface { 185 class MockExtensionProvider : public extensions::ExternalProviderInterface {
185 public: 186 public:
186 MockExtensionProvider( 187 MockExtensionProvider(
187 VisitorInterface* visitor, 188 VisitorInterface* visitor,
188 Extension::Location location) 189 Manifest::Location location)
189 : location_(location), visitor_(visitor), visit_count_(0) { 190 : location_(location), visitor_(visitor), visit_count_(0) {
190 } 191 }
191 192
192 virtual ~MockExtensionProvider() {} 193 virtual ~MockExtensionProvider() {}
193 194
194 void UpdateOrAddExtension(const std::string& id, 195 void UpdateOrAddExtension(const std::string& id,
195 const std::string& version, 196 const std::string& version,
196 const FilePath& path) { 197 const FilePath& path) {
197 extension_map_[id] = std::make_pair(version, path); 198 extension_map_[id] = std::make_pair(version, path);
198 } 199 }
(...skipping 15 matching lines...) Expand all
214 } 215 }
215 visitor_->OnExternalProviderReady(this); 216 visitor_->OnExternalProviderReady(this);
216 } 217 }
217 218
218 virtual bool HasExtension(const std::string& id) const OVERRIDE { 219 virtual bool HasExtension(const std::string& id) const OVERRIDE {
219 return extension_map_.find(id) != extension_map_.end(); 220 return extension_map_.find(id) != extension_map_.end();
220 } 221 }
221 222
222 virtual bool GetExtensionDetails( 223 virtual bool GetExtensionDetails(
223 const std::string& id, 224 const std::string& id,
224 Extension::Location* location, 225 Manifest::Location* location,
225 scoped_ptr<Version>* version) const OVERRIDE { 226 scoped_ptr<Version>* version) const OVERRIDE {
226 DataMap::const_iterator it = extension_map_.find(id); 227 DataMap::const_iterator it = extension_map_.find(id);
227 if (it == extension_map_.end()) 228 if (it == extension_map_.end())
228 return false; 229 return false;
229 230
230 if (version) 231 if (version)
231 version->reset(new Version(it->second.first)); 232 version->reset(new Version(it->second.first));
232 233
233 if (location) 234 if (location)
234 *location = location_; 235 *location = location_;
235 236
236 return true; 237 return true;
237 } 238 }
238 239
239 virtual bool IsReady() const OVERRIDE { 240 virtual bool IsReady() const OVERRIDE {
240 return true; 241 return true;
241 } 242 }
242 243
243 virtual void ServiceShutdown() OVERRIDE { 244 virtual void ServiceShutdown() OVERRIDE {
244 } 245 }
245 246
246 int visit_count() const { return visit_count_; } 247 int visit_count() const { return visit_count_; }
247 void set_visit_count(int visit_count) { 248 void set_visit_count(int visit_count) {
248 visit_count_ = visit_count; 249 visit_count_ = visit_count;
249 } 250 }
250 251
251 private: 252 private:
252 typedef std::map< std::string, std::pair<std::string, FilePath> > DataMap; 253 typedef std::map< std::string, std::pair<std::string, FilePath> > DataMap;
253 DataMap extension_map_; 254 DataMap extension_map_;
254 Extension::Location location_; 255 Manifest::Location location_;
255 VisitorInterface* visitor_; 256 VisitorInterface* visitor_;
256 257
257 // visit_count_ tracks the number of calls to VisitRegisteredExtension(). 258 // visit_count_ tracks the number of calls to VisitRegisteredExtension().
258 // Mutable because it must be incremented on each call to 259 // Mutable because it must be incremented on each call to
259 // VisitRegisteredExtension(), which must be a const method to inherit 260 // VisitRegisteredExtension(), which must be a const method to inherit
260 // from the class being mocked. 261 // from the class being mocked.
261 mutable int visit_count_; 262 mutable int visit_count_;
262 263
263 DISALLOW_COPY_AND_ASSIGN(MockExtensionProvider); 264 DISALLOW_COPY_AND_ASSIGN(MockExtensionProvider);
264 }; 265 };
(...skipping 14 matching lines...) Expand all
279 : ids_found_(0), 280 : ids_found_(0),
280 fake_base_path_(fake_base_path), 281 fake_base_path_(fake_base_path),
281 expected_creation_flags_(expected_creation_flags) { 282 expected_creation_flags_(expected_creation_flags) {
282 } 283 }
283 284
284 int Visit(const std::string& json_data) { 285 int Visit(const std::string& json_data) {
285 // Give the test json file to the provider for parsing. 286 // Give the test json file to the provider for parsing.
286 provider_.reset(new extensions::ExternalProviderImpl( 287 provider_.reset(new extensions::ExternalProviderImpl(
287 this, 288 this,
288 new extensions::ExternalTestingLoader(json_data, fake_base_path_), 289 new extensions::ExternalTestingLoader(json_data, fake_base_path_),
289 Extension::EXTERNAL_PREF, 290 Manifest::EXTERNAL_PREF,
290 Extension::EXTERNAL_PREF_DOWNLOAD, 291 Manifest::EXTERNAL_PREF_DOWNLOAD,
291 Extension::NO_FLAGS)); 292 Extension::NO_FLAGS));
292 293
293 // We also parse the file into a dictionary to compare what we get back 294 // We also parse the file into a dictionary to compare what we get back
294 // from the provider. 295 // from the provider.
295 JSONStringValueSerializer serializer(json_data); 296 JSONStringValueSerializer serializer(json_data);
296 Value* json_value = serializer.Deserialize(NULL, NULL); 297 Value* json_value = serializer.Deserialize(NULL, NULL);
297 298
298 if (!json_value || !json_value->IsType(Value::TYPE_DICTIONARY)) { 299 if (!json_value || !json_value->IsType(Value::TYPE_DICTIONARY)) {
299 NOTREACHED() << "Unable to deserialize json data"; 300 NOTREACHED() << "Unable to deserialize json data";
300 return -1; 301 return -1;
301 } else { 302 } else {
302 DictionaryValue* external_extensions = 303 DictionaryValue* external_extensions =
303 static_cast<DictionaryValue*>(json_value); 304 static_cast<DictionaryValue*>(json_value);
304 prefs_.reset(external_extensions); 305 prefs_.reset(external_extensions);
305 } 306 }
306 307
307 // Reset our counter. 308 // Reset our counter.
308 ids_found_ = 0; 309 ids_found_ = 0;
309 // Ask the provider to look up all extensions and return them. 310 // Ask the provider to look up all extensions and return them.
310 provider_->VisitRegisteredExtension(); 311 provider_->VisitRegisteredExtension();
311 312
312 return ids_found_; 313 return ids_found_;
313 } 314 }
314 315
315 virtual bool OnExternalExtensionFileFound(const std::string& id, 316 virtual bool OnExternalExtensionFileFound(const std::string& id,
316 const Version* version, 317 const Version* version,
317 const FilePath& path, 318 const FilePath& path,
318 Extension::Location unused, 319 Manifest::Location unused,
319 int creation_flags, 320 int creation_flags,
320 bool mark_acknowledged) { 321 bool mark_acknowledged) {
321 EXPECT_EQ(expected_creation_flags_, creation_flags); 322 EXPECT_EQ(expected_creation_flags_, creation_flags);
322 323
323 ++ids_found_; 324 ++ids_found_;
324 DictionaryValue* pref; 325 DictionaryValue* pref;
325 // This tests is to make sure that the provider only notifies us of the 326 // This tests is to make sure that the provider only notifies us of the
326 // values we gave it. So if the id we doesn't exist in our internal 327 // values we gave it. So if the id we doesn't exist in our internal
327 // dictionary then something is wrong. 328 // dictionary then something is wrong.
328 EXPECT_TRUE(prefs_->GetDictionary(id, &pref)) 329 EXPECT_TRUE(prefs_->GetDictionary(id, &pref))
329 << "Got back ID (" << id.c_str() << ") we weren't expecting"; 330 << "Got back ID (" << id.c_str() << ") we weren't expecting";
330 331
331 EXPECT_TRUE(path.IsAbsolute()); 332 EXPECT_TRUE(path.IsAbsolute());
332 if (!fake_base_path_.empty()) 333 if (!fake_base_path_.empty())
333 EXPECT_TRUE(fake_base_path_.IsParent(path)); 334 EXPECT_TRUE(fake_base_path_.IsParent(path));
334 335
335 if (pref) { 336 if (pref) {
336 EXPECT_TRUE(provider_->HasExtension(id)); 337 EXPECT_TRUE(provider_->HasExtension(id));
337 338
338 // Ask provider if the extension we got back is registered. 339 // Ask provider if the extension we got back is registered.
339 Extension::Location location = Extension::INVALID; 340 Manifest::Location location = Manifest::INVALID_LOCATION;
340 scoped_ptr<Version> v1; 341 scoped_ptr<Version> v1;
341 FilePath crx_path; 342 FilePath crx_path;
342 343
343 EXPECT_TRUE(provider_->GetExtensionDetails(id, NULL, &v1)); 344 EXPECT_TRUE(provider_->GetExtensionDetails(id, NULL, &v1));
344 EXPECT_STREQ(version->GetString().c_str(), v1->GetString().c_str()); 345 EXPECT_STREQ(version->GetString().c_str(), v1->GetString().c_str());
345 346
346 scoped_ptr<Version> v2; 347 scoped_ptr<Version> v2;
347 EXPECT_TRUE(provider_->GetExtensionDetails(id, &location, &v2)); 348 EXPECT_TRUE(provider_->GetExtensionDetails(id, &location, &v2));
348 EXPECT_STREQ(version->GetString().c_str(), v1->GetString().c_str()); 349 EXPECT_STREQ(version->GetString().c_str(), v1->GetString().c_str());
349 EXPECT_STREQ(version->GetString().c_str(), v2->GetString().c_str()); 350 EXPECT_STREQ(version->GetString().c_str(), v2->GetString().c_str());
350 EXPECT_EQ(Extension::EXTERNAL_PREF, location); 351 EXPECT_EQ(Manifest::EXTERNAL_PREF, location);
351 352
352 // Remove it so we won't count it ever again. 353 // Remove it so we won't count it ever again.
353 prefs_->Remove(id, NULL); 354 prefs_->Remove(id, NULL);
354 } 355 }
355 return true; 356 return true;
356 } 357 }
357 358
358 virtual bool OnExternalExtensionUpdateUrlFound( 359 virtual bool OnExternalExtensionUpdateUrlFound(
359 const std::string& id, const GURL& update_url, 360 const std::string& id, const GURL& update_url,
360 Extension::Location location) { 361 Manifest::Location location) {
361 ++ids_found_; 362 ++ids_found_;
362 DictionaryValue* pref; 363 DictionaryValue* pref;
363 // This tests is to make sure that the provider only notifies us of the 364 // This tests is to make sure that the provider only notifies us of the
364 // values we gave it. So if the id we doesn't exist in our internal 365 // values we gave it. So if the id we doesn't exist in our internal
365 // dictionary then something is wrong. 366 // dictionary then something is wrong.
366 EXPECT_TRUE(prefs_->GetDictionary(id, &pref)) 367 EXPECT_TRUE(prefs_->GetDictionary(id, &pref))
367 << L"Got back ID (" << id.c_str() << ") we weren't expecting"; 368 << L"Got back ID (" << id.c_str() << ") we weren't expecting";
368 EXPECT_EQ(Extension::EXTERNAL_PREF_DOWNLOAD, location); 369 EXPECT_EQ(Manifest::EXTERNAL_PREF_DOWNLOAD, location);
369 370
370 if (pref) { 371 if (pref) {
371 EXPECT_TRUE(provider_->HasExtension(id)); 372 EXPECT_TRUE(provider_->HasExtension(id));
372 373
373 // External extensions with update URLs do not have versions. 374 // External extensions with update URLs do not have versions.
374 scoped_ptr<Version> v1; 375 scoped_ptr<Version> v1;
375 Extension::Location location1 = Extension::INVALID; 376 Manifest::Location location1 = Manifest::INVALID_LOCATION;
376 EXPECT_TRUE(provider_->GetExtensionDetails(id, &location1, &v1)); 377 EXPECT_TRUE(provider_->GetExtensionDetails(id, &location1, &v1));
377 EXPECT_FALSE(v1.get()); 378 EXPECT_FALSE(v1.get());
378 EXPECT_EQ(Extension::EXTERNAL_PREF_DOWNLOAD, location1); 379 EXPECT_EQ(Manifest::EXTERNAL_PREF_DOWNLOAD, location1);
379 380
380 // Remove it so we won't count it again. 381 // Remove it so we won't count it again.
381 prefs_->Remove(id, NULL); 382 prefs_->Remove(id, NULL);
382 } 383 }
383 return true; 384 return true;
384 } 385 }
385 386
386 virtual void OnExternalProviderReady( 387 virtual void OnExternalProviderReady(
387 const extensions::ExternalProviderInterface* provider) { 388 const extensions::ExternalProviderInterface* provider) {
388 EXPECT_EQ(provider, provider_.get()); 389 EXPECT_EQ(provider, provider_.get());
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
595 } 596 }
596 } 597 }
597 598
598 void AddMockExternalProvider( 599 void AddMockExternalProvider(
599 extensions::ExternalProviderInterface* provider) { 600 extensions::ExternalProviderInterface* provider) {
600 service_->AddProviderForTesting(provider); 601 service_->AddProviderForTesting(provider);
601 } 602 }
602 603
603 protected: 604 protected:
604 void TestExternalProvider(MockExtensionProvider* provider, 605 void TestExternalProvider(MockExtensionProvider* provider,
605 Extension::Location location); 606 Manifest::Location location);
606 607
607 void PackCRX(const FilePath& dir_path, 608 void PackCRX(const FilePath& dir_path,
608 const FilePath& pem_path, 609 const FilePath& pem_path,
609 const FilePath& crx_path) { 610 const FilePath& crx_path) {
610 // Use the existing pem key, if provided. 611 // Use the existing pem key, if provided.
611 FilePath pem_output_path; 612 FilePath pem_output_path;
612 if (pem_path.value().empty()) { 613 if (pem_path.value().empty()) {
613 pem_output_path = crx_path.DirName().AppendASCII("temp.pem"); 614 pem_output_path = crx_path.DirName().AppendASCII("temp.pem");
614 } else { 615 } else {
615 ASSERT_TRUE(file_util::PathExists(pem_path)); 616 ASSERT_TRUE(file_util::PathExists(pem_path));
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
693 return InstallCRX(path, install_state, Extension::NO_FLAGS); 694 return InstallCRX(path, install_state, Extension::NO_FLAGS);
694 } 695 }
695 696
696 const Extension* InstallCRXFromWebStore(const FilePath& path, 697 const Extension* InstallCRXFromWebStore(const FilePath& path,
697 InstallState install_state) { 698 InstallState install_state) {
698 StartCRXInstall(path, Extension::FROM_WEBSTORE); 699 StartCRXInstall(path, Extension::FROM_WEBSTORE);
699 return WaitForCrxInstall(path, install_state); 700 return WaitForCrxInstall(path, install_state);
700 } 701 }
701 702
702 const Extension* InstallCRXWithLocation(const FilePath& crx_path, 703 const Extension* InstallCRXWithLocation(const FilePath& crx_path,
703 Extension::Location install_location, 704 Manifest::Location install_location,
704 InstallState install_state) { 705 InstallState install_state) {
705 EXPECT_TRUE(file_util::PathExists(crx_path)) 706 EXPECT_TRUE(file_util::PathExists(crx_path))
706 << "Path does not exist: "<< crx_path.value().c_str(); 707 << "Path does not exist: "<< crx_path.value().c_str();
707 // no client (silent install) 708 // no client (silent install)
708 scoped_refptr<CrxInstaller> installer(CrxInstaller::Create(service_, NULL)); 709 scoped_refptr<CrxInstaller> installer(CrxInstaller::Create(service_, NULL));
709 installer->set_install_source(install_location); 710 installer->set_install_source(install_location);
710 installer->InstallCrx(crx_path); 711 installer->InstallCrx(crx_path);
711 712
712 return WaitForCrxInstall(crx_path, install_state); 713 return WaitForCrxInstall(crx_path, install_state);
713 } 714 }
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after
1117 service_->Init(); 1118 service_->Init();
1118 1119
1119 uint32 expected_num_extensions = 3u; 1120 uint32 expected_num_extensions = 3u;
1120 ASSERT_EQ(expected_num_extensions, loaded_.size()); 1121 ASSERT_EQ(expected_num_extensions, loaded_.size());
1121 1122
1122 EXPECT_EQ(std::string(good0), loaded_[0]->id()); 1123 EXPECT_EQ(std::string(good0), loaded_[0]->id());
1123 EXPECT_EQ(std::string("My extension 1"), 1124 EXPECT_EQ(std::string("My extension 1"),
1124 loaded_[0]->name()); 1125 loaded_[0]->name());
1125 EXPECT_EQ(std::string("The first extension that I made."), 1126 EXPECT_EQ(std::string("The first extension that I made."),
1126 loaded_[0]->description()); 1127 loaded_[0]->description());
1127 EXPECT_EQ(Extension::INTERNAL, loaded_[0]->location()); 1128 EXPECT_EQ(Manifest::INTERNAL, loaded_[0]->location());
1128 EXPECT_TRUE(service_->GetExtensionById(loaded_[0]->id(), false)); 1129 EXPECT_TRUE(service_->GetExtensionById(loaded_[0]->id(), false));
1129 EXPECT_EQ(expected_num_extensions, service_->extensions()->size()); 1130 EXPECT_EQ(expected_num_extensions, service_->extensions()->size());
1130 1131
1131 ValidatePrefKeyCount(3); 1132 ValidatePrefKeyCount(3);
1132 ValidateIntegerPref(good0, "state", Extension::ENABLED); 1133 ValidateIntegerPref(good0, "state", Extension::ENABLED);
1133 ValidateIntegerPref(good0, "location", Extension::INTERNAL); 1134 ValidateIntegerPref(good0, "location", Manifest::INTERNAL);
1134 ValidateIntegerPref(good1, "state", Extension::ENABLED); 1135 ValidateIntegerPref(good1, "state", Extension::ENABLED);
1135 ValidateIntegerPref(good1, "location", Extension::INTERNAL); 1136 ValidateIntegerPref(good1, "location", Manifest::INTERNAL);
1136 ValidateIntegerPref(good2, "state", Extension::ENABLED); 1137 ValidateIntegerPref(good2, "state", Extension::ENABLED);
1137 ValidateIntegerPref(good2, "location", Extension::INTERNAL); 1138 ValidateIntegerPref(good2, "location", Manifest::INTERNAL);
1138 1139
1139 URLPatternSet expected_patterns; 1140 URLPatternSet expected_patterns;
1140 AddPattern(&expected_patterns, "file:///*"); 1141 AddPattern(&expected_patterns, "file:///*");
1141 AddPattern(&expected_patterns, "http://*.google.com/*"); 1142 AddPattern(&expected_patterns, "http://*.google.com/*");
1142 AddPattern(&expected_patterns, "https://*.google.com/*"); 1143 AddPattern(&expected_patterns, "https://*.google.com/*");
1143 const Extension* extension = loaded_[0]; 1144 const Extension* extension = loaded_[0];
1144 const extensions::UserScriptList& scripts = extension->content_scripts(); 1145 const extensions::UserScriptList& scripts = extension->content_scripts();
1145 ASSERT_EQ(2u, scripts.size()); 1146 ASSERT_EQ(2u, scripts.size());
1146 EXPECT_EQ(expected_patterns, scripts[0].url_patterns()); 1147 EXPECT_EQ(expected_patterns, scripts[0].url_patterns());
1147 EXPECT_EQ(2u, scripts[0].js_scripts().size()); 1148 EXPECT_EQ(2u, scripts[0].js_scripts().size());
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
1187 #else 1188 #else
1188 ASSERT_EQ(2u, loaded_[1]->plugins().size()); 1189 ASSERT_EQ(2u, loaded_[1]->plugins().size());
1189 EXPECT_EQ(loaded_[1]->path().AppendASCII("content_plugin.dll").value(), 1190 EXPECT_EQ(loaded_[1]->path().AppendASCII("content_plugin.dll").value(),
1190 loaded_[1]->plugins()[0].path.value()); 1191 loaded_[1]->plugins()[0].path.value());
1191 EXPECT_TRUE(loaded_[1]->plugins()[0].is_public); 1192 EXPECT_TRUE(loaded_[1]->plugins()[0].is_public);
1192 EXPECT_EQ(loaded_[1]->path().AppendASCII("extension_plugin.dll").value(), 1193 EXPECT_EQ(loaded_[1]->path().AppendASCII("extension_plugin.dll").value(),
1193 loaded_[1]->plugins()[1].path.value()); 1194 loaded_[1]->plugins()[1].path.value());
1194 EXPECT_FALSE(loaded_[1]->plugins()[1].is_public); 1195 EXPECT_FALSE(loaded_[1]->plugins()[1].is_public);
1195 #endif 1196 #endif
1196 1197
1197 EXPECT_EQ(Extension::INTERNAL, loaded_[1]->location()); 1198 EXPECT_EQ(Manifest::INTERNAL, loaded_[1]->location());
1198 1199
1199 int index = expected_num_extensions - 1; 1200 int index = expected_num_extensions - 1;
1200 EXPECT_EQ(std::string(good2), loaded_[index]->id()); 1201 EXPECT_EQ(std::string(good2), loaded_[index]->id());
1201 EXPECT_EQ(std::string("My extension 3"), loaded_[index]->name()); 1202 EXPECT_EQ(std::string("My extension 3"), loaded_[index]->name());
1202 EXPECT_EQ(std::string(""), loaded_[index]->description()); 1203 EXPECT_EQ(std::string(""), loaded_[index]->description());
1203 EXPECT_EQ(0u, loaded_[index]->content_scripts().size()); 1204 EXPECT_EQ(0u, loaded_[index]->content_scripts().size());
1204 EXPECT_EQ(Extension::INTERNAL, loaded_[index]->location()); 1205 EXPECT_EQ(Manifest::INTERNAL, loaded_[index]->location());
1205 }; 1206 };
1206 1207
1207 // Test loading bad extensions from the profile directory. 1208 // Test loading bad extensions from the profile directory.
1208 TEST_F(ExtensionServiceTest, LoadAllExtensionsFromDirectoryFail) { 1209 TEST_F(ExtensionServiceTest, LoadAllExtensionsFromDirectoryFail) {
1209 // Initialize the test dir with a bad Preferences/extensions. 1210 // Initialize the test dir with a bad Preferences/extensions.
1210 FilePath source_install_dir = data_dir_ 1211 FilePath source_install_dir = data_dir_
1211 .AppendASCII("bad") 1212 .AppendASCII("bad")
1212 .AppendASCII("Extensions"); 1213 .AppendASCII("Extensions");
1213 FilePath pref_path = source_install_dir 1214 FilePath pref_path = source_install_dir
1214 .DirName() 1215 .DirName()
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
1371 ValidatePrefKeyCount(0); 1372 ValidatePrefKeyCount(0);
1372 1373
1373 // A simple extension that should install without error. 1374 // A simple extension that should install without error.
1374 path = data_dir_.AppendASCII("good.crx"); 1375 path = data_dir_.AppendASCII("good.crx");
1375 InstallCRX(path, INSTALL_NEW); 1376 InstallCRX(path, INSTALL_NEW);
1376 // TODO(erikkay): verify the contents of the installed extension. 1377 // TODO(erikkay): verify the contents of the installed extension.
1377 1378
1378 int pref_count = 0; 1379 int pref_count = 0;
1379 ValidatePrefKeyCount(++pref_count); 1380 ValidatePrefKeyCount(++pref_count);
1380 ValidateIntegerPref(good_crx, "state", Extension::ENABLED); 1381 ValidateIntegerPref(good_crx, "state", Extension::ENABLED);
1381 ValidateIntegerPref(good_crx, "location", Extension::INTERNAL); 1382 ValidateIntegerPref(good_crx, "location", Manifest::INTERNAL);
1382 1383
1383 // An extension with page actions. 1384 // An extension with page actions.
1384 path = data_dir_.AppendASCII("page_action.crx"); 1385 path = data_dir_.AppendASCII("page_action.crx");
1385 InstallCRX(path, INSTALL_NEW); 1386 InstallCRX(path, INSTALL_NEW);
1386 ValidatePrefKeyCount(++pref_count); 1387 ValidatePrefKeyCount(++pref_count);
1387 ValidateIntegerPref(page_action, "state", Extension::ENABLED); 1388 ValidateIntegerPref(page_action, "state", Extension::ENABLED);
1388 ValidateIntegerPref(page_action, "location", Extension::INTERNAL); 1389 ValidateIntegerPref(page_action, "location", Manifest::INTERNAL);
1389 1390
1390 // Bad signature. 1391 // Bad signature.
1391 path = data_dir_.AppendASCII("bad_signature.crx"); 1392 path = data_dir_.AppendASCII("bad_signature.crx");
1392 InstallCRX(path, INSTALL_FAILED); 1393 InstallCRX(path, INSTALL_FAILED);
1393 ValidatePrefKeyCount(pref_count); 1394 ValidatePrefKeyCount(pref_count);
1394 1395
1395 // 0-length extension file. 1396 // 0-length extension file.
1396 path = data_dir_.AppendASCII("not_an_extension.crx"); 1397 path = data_dir_.AppendASCII("not_an_extension.crx");
1397 InstallCRX(path, INSTALL_FAILED); 1398 InstallCRX(path, INSTALL_FAILED);
1398 ValidatePrefKeyCount(pref_count); 1399 ValidatePrefKeyCount(pref_count);
(...skipping 24 matching lines...) Expand all
1423 1424
1424 FilePath path = data_dir_.AppendASCII("good.crx"); 1425 FilePath path = data_dir_.AppendASCII("good.crx");
1425 set_extensions_enabled(true); 1426 set_extensions_enabled(true);
1426 1427
1427 // Register and install an external extension. 1428 // Register and install an external extension.
1428 Version version("1.0.0.0"); 1429 Version version("1.0.0.0");
1429 service_->OnExternalExtensionFileFound( 1430 service_->OnExternalExtensionFileFound(
1430 good_crx, 1431 good_crx,
1431 &version, 1432 &version,
1432 path, 1433 path,
1433 Extension::EXTERNAL_PREF, 1434 Manifest::EXTERNAL_PREF,
1434 Extension::FROM_BOOKMARK, 1435 Extension::FROM_BOOKMARK,
1435 false /* mark_acknowledged */); 1436 false /* mark_acknowledged */);
1436 loop_.RunUntilIdle(); 1437 loop_.RunUntilIdle();
1437 1438
1438 const Extension* extension = service_->GetExtensionById(good_crx, false); 1439 const Extension* extension = service_->GetExtensionById(good_crx, false);
1439 ASSERT_TRUE(extension); 1440 ASSERT_TRUE(extension);
1440 ASSERT_TRUE(extension->from_bookmark()); 1441 ASSERT_TRUE(extension->from_bookmark());
1441 ValidateBooleanPref(good_crx, kPrefFromBookmark, true); 1442 ValidateBooleanPref(good_crx, kPrefFromBookmark, true);
1442 1443
1443 // Upgrade to version 2.0, the flag should be preserved. 1444 // Upgrade to version 2.0, the flag should be preserved.
1444 path = data_dir_.AppendASCII("good2.crx"); 1445 path = data_dir_.AppendASCII("good2.crx");
1445 UpdateExtension(good_crx, path, ENABLED); 1446 UpdateExtension(good_crx, path, ENABLED);
1446 ValidateBooleanPref(good_crx, kPrefFromBookmark, true); 1447 ValidateBooleanPref(good_crx, kPrefFromBookmark, true);
1447 extension = service_->GetExtensionById(good_crx, false); 1448 extension = service_->GetExtensionById(good_crx, false);
1448 ASSERT_TRUE(extension); 1449 ASSERT_TRUE(extension);
1449 ASSERT_TRUE(extension->from_bookmark()); 1450 ASSERT_TRUE(extension->from_bookmark());
1450 } 1451 }
1451 1452
1452 // Test the handling of Extension::EXTERNAL_EXTENSION_UNINSTALLED 1453 // Test the handling of Extension::EXTERNAL_EXTENSION_UNINSTALLED
1453 TEST_F(ExtensionServiceTest, UninstallingExternalExtensions) { 1454 TEST_F(ExtensionServiceTest, UninstallingExternalExtensions) {
1454 InitializeEmptyExtensionService(); 1455 InitializeEmptyExtensionService();
1455 1456
1456 FilePath path = data_dir_.AppendASCII("good.crx"); 1457 FilePath path = data_dir_.AppendASCII("good.crx");
1457 set_extensions_enabled(true); 1458 set_extensions_enabled(true);
1458 1459
1459 Version version("1.0.0.0"); 1460 Version version("1.0.0.0");
1460 // Install an external extension. 1461 // Install an external extension.
1461 service_->OnExternalExtensionFileFound(good_crx, &version, 1462 service_->OnExternalExtensionFileFound(good_crx, &version,
1462 path, Extension::EXTERNAL_PREF, 1463 path, Manifest::EXTERNAL_PREF,
1463 Extension::NO_FLAGS, false); 1464 Extension::NO_FLAGS, false);
1464 loop_.RunUntilIdle(); 1465 loop_.RunUntilIdle();
1465 ASSERT_TRUE(service_->GetExtensionById(good_crx, false)); 1466 ASSERT_TRUE(service_->GetExtensionById(good_crx, false));
1466 1467
1467 // Uninstall it and check that its killbit gets set. 1468 // Uninstall it and check that its killbit gets set.
1468 UninstallExtension(good_crx, false); 1469 UninstallExtension(good_crx, false);
1469 ValidateIntegerPref(good_crx, "location", 1470 ValidateIntegerPref(good_crx, "location",
1470 Extension::EXTERNAL_EXTENSION_UNINSTALLED); 1471 Extension::EXTERNAL_EXTENSION_UNINSTALLED);
1471 1472
1472 // Try to re-install it externally. This should fail because of the killbit. 1473 // Try to re-install it externally. This should fail because of the killbit.
1473 service_->OnExternalExtensionFileFound(good_crx, &version, 1474 service_->OnExternalExtensionFileFound(good_crx, &version,
1474 path, Extension::EXTERNAL_PREF, 1475 path, Manifest::EXTERNAL_PREF,
1475 Extension::NO_FLAGS, false); 1476 Extension::NO_FLAGS, false);
1476 loop_.RunUntilIdle(); 1477 loop_.RunUntilIdle();
1477 ASSERT_TRUE(NULL == service_->GetExtensionById(good_crx, false)); 1478 ASSERT_TRUE(NULL == service_->GetExtensionById(good_crx, false));
1478 ValidateIntegerPref(good_crx, "location", 1479 ValidateIntegerPref(good_crx, "location",
1479 Extension::EXTERNAL_EXTENSION_UNINSTALLED); 1480 Extension::EXTERNAL_EXTENSION_UNINSTALLED);
1480 1481
1481 version = Version("1.0.0.1"); 1482 version = Version("1.0.0.1");
1482 // Repeat the same thing with a newer version of the extension. 1483 // Repeat the same thing with a newer version of the extension.
1483 path = data_dir_.AppendASCII("good2.crx"); 1484 path = data_dir_.AppendASCII("good2.crx");
1484 service_->OnExternalExtensionFileFound(good_crx, &version, 1485 service_->OnExternalExtensionFileFound(good_crx, &version,
1485 path, Extension::EXTERNAL_PREF, 1486 path, Manifest::EXTERNAL_PREF,
1486 Extension::NO_FLAGS, false); 1487 Extension::NO_FLAGS, false);
1487 loop_.RunUntilIdle(); 1488 loop_.RunUntilIdle();
1488 ASSERT_TRUE(NULL == service_->GetExtensionById(good_crx, false)); 1489 ASSERT_TRUE(NULL == service_->GetExtensionById(good_crx, false));
1489 ValidateIntegerPref(good_crx, "location", 1490 ValidateIntegerPref(good_crx, "location",
1490 Extension::EXTERNAL_EXTENSION_UNINSTALLED); 1491 Extension::EXTERNAL_EXTENSION_UNINSTALLED);
1491 1492
1492 // Try adding the same extension from an external update URL. 1493 // Try adding the same extension from an external update URL.
1493 ASSERT_FALSE(service_->pending_extension_manager()->AddFromExternalUpdateUrl( 1494 ASSERT_FALSE(service_->pending_extension_manager()->AddFromExternalUpdateUrl(
1494 good_crx, 1495 good_crx,
1495 GURL("http:://fake.update/url"), 1496 GURL("http:://fake.update/url"),
1496 Extension::EXTERNAL_PREF_DOWNLOAD)); 1497 Manifest::EXTERNAL_PREF_DOWNLOAD));
1497 1498
1498 ASSERT_FALSE(service_->pending_extension_manager()->IsIdPending(good_crx)); 1499 ASSERT_FALSE(service_->pending_extension_manager()->IsIdPending(good_crx));
1499 } 1500 }
1500 1501
1501 // Test that uninstalling an external extension does not crash when 1502 // Test that uninstalling an external extension does not crash when
1502 // the extension could not be loaded. 1503 // the extension could not be loaded.
1503 // This extension shown in preferences file requires an experimental permission. 1504 // This extension shown in preferences file requires an experimental permission.
1504 // It could not be loaded without such permission. 1505 // It could not be loaded without such permission.
1505 TEST_F(ExtensionServiceTest, UninstallingNotLoadedExtension) { 1506 TEST_F(ExtensionServiceTest, UninstallingNotLoadedExtension) {
1506 FilePath source_install_dir = data_dir_ 1507 FilePath source_install_dir = data_dir_
1507 .AppendASCII("good") 1508 .AppendASCII("good")
1508 .AppendASCII("Extensions"); 1509 .AppendASCII("Extensions");
1509 // The preference contains an external extension 1510 // The preference contains an external extension
1510 // that requires 'experimental' permission. 1511 // that requires 'experimental' permission.
1511 FilePath pref_path = source_install_dir 1512 FilePath pref_path = source_install_dir
1512 .DirName() 1513 .DirName()
1513 .AppendASCII("PreferencesExperimental"); 1514 .AppendASCII("PreferencesExperimental");
1514 1515
1515 // Aforementioned extension will not be loaded if 1516 // Aforementioned extension will not be loaded if
1516 // there is no '--enable-experimental-extension-apis' command line flag. 1517 // there is no '--enable-experimental-extension-apis' command line flag.
1517 InitializeInstalledExtensionService(pref_path, source_install_dir); 1518 InitializeInstalledExtensionService(pref_path, source_install_dir);
1518 1519
1519 service_->Init(); 1520 service_->Init();
1520 1521
1521 // Check and try to uninstall it. 1522 // Check and try to uninstall it.
1522 // If we don't check whether the extension is loaded before we uninstall it 1523 // If we don't check whether the extension is loaded before we uninstall it
1523 // in CheckExternalUninstall, a crash will happen here because we will get or 1524 // in CheckExternalUninstall, a crash will happen here because we will get or
1524 // dereference a NULL pointer (extension) inside UninstallExtension. 1525 // dereference a NULL pointer (extension) inside UninstallExtension.
1525 MockExtensionProvider provider(NULL, Extension::EXTERNAL_REGISTRY); 1526 MockExtensionProvider provider(NULL, Manifest::EXTERNAL_REGISTRY);
1526 service_->OnExternalProviderReady(&provider); 1527 service_->OnExternalProviderReady(&provider);
1527 } 1528 }
1528 1529
1529 // Test that external extensions with incorrect IDs are not installed. 1530 // Test that external extensions with incorrect IDs are not installed.
1530 TEST_F(ExtensionServiceTest, FailOnWrongId) { 1531 TEST_F(ExtensionServiceTest, FailOnWrongId) {
1531 InitializeEmptyExtensionService(); 1532 InitializeEmptyExtensionService();
1532 FilePath path = data_dir_.AppendASCII("good.crx"); 1533 FilePath path = data_dir_.AppendASCII("good.crx");
1533 set_extensions_enabled(true); 1534 set_extensions_enabled(true);
1534 1535
1535 Version version("1.0.0.0"); 1536 Version version("1.0.0.0");
1536 1537
1537 const std::string wrong_id = all_zero; 1538 const std::string wrong_id = all_zero;
1538 const std::string correct_id = good_crx; 1539 const std::string correct_id = good_crx;
1539 ASSERT_NE(correct_id, wrong_id); 1540 ASSERT_NE(correct_id, wrong_id);
1540 1541
1541 // Install an external extension with an ID from the external 1542 // Install an external extension with an ID from the external
1542 // source that is not equal to the ID in the extension manifest. 1543 // source that is not equal to the ID in the extension manifest.
1543 service_->OnExternalExtensionFileFound( 1544 service_->OnExternalExtensionFileFound(
1544 wrong_id, &version, path, Extension::EXTERNAL_PREF, 1545 wrong_id, &version, path, Manifest::EXTERNAL_PREF,
1545 Extension::NO_FLAGS, false); 1546 Extension::NO_FLAGS, false);
1546 1547
1547 loop_.RunUntilIdle(); 1548 loop_.RunUntilIdle();
1548 ASSERT_FALSE(service_->GetExtensionById(good_crx, false)); 1549 ASSERT_FALSE(service_->GetExtensionById(good_crx, false));
1549 1550
1550 // Try again with the right ID. Expect success. 1551 // Try again with the right ID. Expect success.
1551 service_->OnExternalExtensionFileFound( 1552 service_->OnExternalExtensionFileFound(
1552 correct_id, &version, path, Extension::EXTERNAL_PREF, 1553 correct_id, &version, path, Manifest::EXTERNAL_PREF,
1553 Extension::NO_FLAGS, false); 1554 Extension::NO_FLAGS, false);
1554 loop_.RunUntilIdle(); 1555 loop_.RunUntilIdle();
1555 ASSERT_TRUE(service_->GetExtensionById(good_crx, false)); 1556 ASSERT_TRUE(service_->GetExtensionById(good_crx, false));
1556 } 1557 }
1557 1558
1558 // Test that external extensions with incorrect versions are not installed. 1559 // Test that external extensions with incorrect versions are not installed.
1559 TEST_F(ExtensionServiceTest, FailOnWrongVersion) { 1560 TEST_F(ExtensionServiceTest, FailOnWrongVersion) {
1560 InitializeEmptyExtensionService(); 1561 InitializeEmptyExtensionService();
1561 FilePath path = data_dir_.AppendASCII("good.crx"); 1562 FilePath path = data_dir_.AppendASCII("good.crx");
1562 set_extensions_enabled(true); 1563 set_extensions_enabled(true);
1563 1564
1564 // Install an external extension with a version from the external 1565 // Install an external extension with a version from the external
1565 // source that is not equal to the version in the extension manifest. 1566 // source that is not equal to the version in the extension manifest.
1566 Version wrong_version("1.2.3.4"); 1567 Version wrong_version("1.2.3.4");
1567 service_->OnExternalExtensionFileFound( 1568 service_->OnExternalExtensionFileFound(
1568 good_crx, &wrong_version, path, Extension::EXTERNAL_PREF, 1569 good_crx, &wrong_version, path, Manifest::EXTERNAL_PREF,
1569 Extension::NO_FLAGS, false); 1570 Extension::NO_FLAGS, false);
1570 1571
1571 loop_.RunUntilIdle(); 1572 loop_.RunUntilIdle();
1572 ASSERT_FALSE(service_->GetExtensionById(good_crx, false)); 1573 ASSERT_FALSE(service_->GetExtensionById(good_crx, false));
1573 1574
1574 // Try again with the right version. Expect success. 1575 // Try again with the right version. Expect success.
1575 service_->pending_extension_manager()->Remove(good_crx); 1576 service_->pending_extension_manager()->Remove(good_crx);
1576 Version correct_version("1.0.0.0"); 1577 Version correct_version("1.0.0.0");
1577 service_->OnExternalExtensionFileFound( 1578 service_->OnExternalExtensionFileFound(
1578 good_crx, &correct_version, path, Extension::EXTERNAL_PREF, 1579 good_crx, &correct_version, path, Manifest::EXTERNAL_PREF,
1579 Extension::NO_FLAGS, false); 1580 Extension::NO_FLAGS, false);
1580 loop_.RunUntilIdle(); 1581 loop_.RunUntilIdle();
1581 ASSERT_TRUE(service_->GetExtensionById(good_crx, false)); 1582 ASSERT_TRUE(service_->GetExtensionById(good_crx, false));
1582 } 1583 }
1583 1584
1584 // Install a user script (they get converted automatically to an extension) 1585 // Install a user script (they get converted automatically to an extension)
1585 TEST_F(ExtensionServiceTest, InstallUserScript) { 1586 TEST_F(ExtensionServiceTest, InstallUserScript) {
1586 // The details of script conversion are tested elsewhere, this just tests 1587 // The details of script conversion are tested elsewhere, this just tests
1587 // integration with ExtensionService. 1588 // integration with ExtensionService.
1588 InitializeEmptyExtensionService(); 1589 InitializeEmptyExtensionService();
(...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after
2055 2056
2056 TEST_F(ExtensionServiceTest, InstallTheme) { 2057 TEST_F(ExtensionServiceTest, InstallTheme) {
2057 InitializeEmptyExtensionService(); 2058 InitializeEmptyExtensionService();
2058 2059
2059 // A theme. 2060 // A theme.
2060 FilePath path = data_dir_.AppendASCII("theme.crx"); 2061 FilePath path = data_dir_.AppendASCII("theme.crx");
2061 InstallCRX(path, INSTALL_NEW); 2062 InstallCRX(path, INSTALL_NEW);
2062 int pref_count = 0; 2063 int pref_count = 0;
2063 ValidatePrefKeyCount(++pref_count); 2064 ValidatePrefKeyCount(++pref_count);
2064 ValidateIntegerPref(theme_crx, "state", Extension::ENABLED); 2065 ValidateIntegerPref(theme_crx, "state", Extension::ENABLED);
2065 ValidateIntegerPref(theme_crx, "location", Extension::INTERNAL); 2066 ValidateIntegerPref(theme_crx, "location", Manifest::INTERNAL);
2066 2067
2067 // A theme when extensions are disabled. Themes can be installed, even when 2068 // A theme when extensions are disabled. Themes can be installed, even when
2068 // extensions are disabled. 2069 // extensions are disabled.
2069 set_extensions_enabled(false); 2070 set_extensions_enabled(false);
2070 path = data_dir_.AppendASCII("theme2.crx"); 2071 path = data_dir_.AppendASCII("theme2.crx");
2071 InstallCRX(path, INSTALL_NEW); 2072 InstallCRX(path, INSTALL_NEW);
2072 ValidatePrefKeyCount(++pref_count); 2073 ValidatePrefKeyCount(++pref_count);
2073 ValidateIntegerPref(theme2_crx, "state", Extension::ENABLED); 2074 ValidateIntegerPref(theme2_crx, "state", Extension::ENABLED);
2074 ValidateIntegerPref(theme2_crx, "location", Extension::INTERNAL); 2075 ValidateIntegerPref(theme2_crx, "location", Manifest::INTERNAL);
2075 2076
2076 // A theme with extension elements. Themes cannot have extension elements, 2077 // A theme with extension elements. Themes cannot have extension elements,
2077 // so any such elements (like content scripts) should be ignored. 2078 // so any such elements (like content scripts) should be ignored.
2078 set_extensions_enabled(true); 2079 set_extensions_enabled(true);
2079 { 2080 {
2080 path = data_dir_.AppendASCII("theme_with_extension.crx"); 2081 path = data_dir_.AppendASCII("theme_with_extension.crx");
2081 const Extension* extension = InstallCRX(path, INSTALL_NEW); 2082 const Extension* extension = InstallCRX(path, INSTALL_NEW);
2082 ValidatePrefKeyCount(++pref_count); 2083 ValidatePrefKeyCount(++pref_count);
2083 ASSERT_TRUE(extension); 2084 ASSERT_TRUE(extension);
2084 EXPECT_TRUE(extension->is_theme()); 2085 EXPECT_TRUE(extension->is_theme());
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
2206 TEST_F(ExtensionServiceTest, InstallApps) { 2207 TEST_F(ExtensionServiceTest, InstallApps) {
2207 InitializeEmptyExtensionService(); 2208 InitializeEmptyExtensionService();
2208 2209
2209 // An empty app. 2210 // An empty app.
2210 const Extension* app = PackAndInstallCRX(data_dir_.AppendASCII("app1"), 2211 const Extension* app = PackAndInstallCRX(data_dir_.AppendASCII("app1"),
2211 INSTALL_NEW); 2212 INSTALL_NEW);
2212 int pref_count = 0; 2213 int pref_count = 0;
2213 ValidatePrefKeyCount(++pref_count); 2214 ValidatePrefKeyCount(++pref_count);
2214 ASSERT_EQ(1u, service_->extensions()->size()); 2215 ASSERT_EQ(1u, service_->extensions()->size());
2215 ValidateIntegerPref(app->id(), "state", Extension::ENABLED); 2216 ValidateIntegerPref(app->id(), "state", Extension::ENABLED);
2216 ValidateIntegerPref(app->id(), "location", Extension::INTERNAL); 2217 ValidateIntegerPref(app->id(), "location", Manifest::INTERNAL);
2217 2218
2218 // Another app with non-overlapping extent. Should succeed. 2219 // Another app with non-overlapping extent. Should succeed.
2219 PackAndInstallCRX(data_dir_.AppendASCII("app2"), INSTALL_NEW); 2220 PackAndInstallCRX(data_dir_.AppendASCII("app2"), INSTALL_NEW);
2220 ValidatePrefKeyCount(++pref_count); 2221 ValidatePrefKeyCount(++pref_count);
2221 2222
2222 // A third app whose extent overlaps the first. Should fail. 2223 // A third app whose extent overlaps the first. Should fail.
2223 PackAndInstallCRX(data_dir_.AppendASCII("app3"), INSTALL_FAILED); 2224 PackAndInstallCRX(data_dir_.AppendASCII("app3"), INSTALL_FAILED);
2224 ValidatePrefKeyCount(pref_count); 2225 ValidatePrefKeyCount(pref_count);
2225 } 2226 }
2226 2227
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
2402 // Test that when an extension version is reinstalled, nothing happens. 2403 // Test that when an extension version is reinstalled, nothing happens.
2403 TEST_F(ExtensionServiceTest, Reinstall) { 2404 TEST_F(ExtensionServiceTest, Reinstall) {
2404 InitializeEmptyExtensionService(); 2405 InitializeEmptyExtensionService();
2405 2406
2406 // A simple extension that should install without error. 2407 // A simple extension that should install without error.
2407 FilePath path = data_dir_.AppendASCII("good.crx"); 2408 FilePath path = data_dir_.AppendASCII("good.crx");
2408 InstallCRX(path, INSTALL_NEW); 2409 InstallCRX(path, INSTALL_NEW);
2409 2410
2410 ValidatePrefKeyCount(1); 2411 ValidatePrefKeyCount(1);
2411 ValidateIntegerPref(good_crx, "state", Extension::ENABLED); 2412 ValidateIntegerPref(good_crx, "state", Extension::ENABLED);
2412 ValidateIntegerPref(good_crx, "location", Extension::INTERNAL); 2413 ValidateIntegerPref(good_crx, "location", Manifest::INTERNAL);
2413 2414
2414 // Reinstall the same version, it should overwrite the previous one. 2415 // Reinstall the same version, it should overwrite the previous one.
2415 InstallCRX(path, INSTALL_UPDATED); 2416 InstallCRX(path, INSTALL_UPDATED);
2416 2417
2417 ValidatePrefKeyCount(1); 2418 ValidatePrefKeyCount(1);
2418 ValidateIntegerPref(good_crx, "state", Extension::ENABLED); 2419 ValidateIntegerPref(good_crx, "state", Extension::ENABLED);
2419 ValidateIntegerPref(good_crx, "location", Extension::INTERNAL); 2420 ValidateIntegerPref(good_crx, "location", Manifest::INTERNAL);
2420 } 2421 }
2421 2422
2422 // Test that we can determine if extensions came from the 2423 // Test that we can determine if extensions came from the
2423 // Chrome web store. 2424 // Chrome web store.
2424 TEST_F(ExtensionServiceTest, FromWebStore) { 2425 TEST_F(ExtensionServiceTest, FromWebStore) {
2425 InitializeEmptyExtensionService(); 2426 InitializeEmptyExtensionService();
2426 2427
2427 // A simple extension that should install without error. 2428 // A simple extension that should install without error.
2428 FilePath path = data_dir_.AppendASCII("good.crx"); 2429 FilePath path = data_dir_.AppendASCII("good.crx");
2429 // Not from web store. 2430 // Not from web store.
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
2591 good2->id())); 2592 good2->id()));
2592 } 2593 }
2593 2594
2594 // Tests that updating preserves extension location. 2595 // Tests that updating preserves extension location.
2595 TEST_F(ExtensionServiceTest, UpdateExtensionPreservesLocation) { 2596 TEST_F(ExtensionServiceTest, UpdateExtensionPreservesLocation) {
2596 InitializeEmptyExtensionService(); 2597 InitializeEmptyExtensionService();
2597 2598
2598 FilePath path = data_dir_.AppendASCII("good.crx"); 2599 FilePath path = data_dir_.AppendASCII("good.crx");
2599 2600
2600 const Extension* good = 2601 const Extension* good =
2601 InstallCRXWithLocation(path, Extension::EXTERNAL_PREF, INSTALL_NEW); 2602 InstallCRXWithLocation(path, Manifest::EXTERNAL_PREF, INSTALL_NEW);
2602 2603
2603 ASSERT_EQ("1.0.0.0", good->VersionString()); 2604 ASSERT_EQ("1.0.0.0", good->VersionString());
2604 ASSERT_EQ(good_crx, good->id()); 2605 ASSERT_EQ(good_crx, good->id());
2605 2606
2606 path = data_dir_.AppendASCII("good2.crx"); 2607 path = data_dir_.AppendASCII("good2.crx");
2607 UpdateExtension(good_crx, path, ENABLED); 2608 UpdateExtension(good_crx, path, ENABLED);
2608 const Extension* good2 = service_->GetExtensionById(good_crx, false); 2609 const Extension* good2 = service_->GetExtensionById(good_crx, false);
2609 ASSERT_EQ("1.0.0.1", good2->version()->GetString()); 2610 ASSERT_EQ("1.0.0.1", good2->version()->GetString());
2610 EXPECT_EQ(good2->location(), Extension::EXTERNAL_PREF); 2611 EXPECT_EQ(good2->location(), Manifest::EXTERNAL_PREF);
2611 } 2612 }
2612 2613
2613 // Makes sure that LOAD extension types can downgrade. 2614 // Makes sure that LOAD extension types can downgrade.
2614 TEST_F(ExtensionServiceTest, LoadExtensionsCanDowngrade) { 2615 TEST_F(ExtensionServiceTest, LoadExtensionsCanDowngrade) {
2615 InitializeEmptyExtensionService(); 2616 InitializeEmptyExtensionService();
2616 2617
2617 base::ScopedTempDir temp; 2618 base::ScopedTempDir temp;
2618 ASSERT_TRUE(temp.CreateUniqueTempDir()); 2619 ASSERT_TRUE(temp.CreateUniqueTempDir());
2619 2620
2620 // We'll write the extension manifest dynamically to a temporary path 2621 // We'll write the extension manifest dynamically to a temporary path
2621 // to make it easier to change the version number. 2622 // to make it easier to change the version number.
2622 FilePath extension_path = temp.path(); 2623 FilePath extension_path = temp.path();
2623 FilePath manifest_path = extension_path.Append(Extension::kManifestFilename); 2624 FilePath manifest_path = extension_path.Append(Extension::kManifestFilename);
2624 ASSERT_FALSE(file_util::PathExists(manifest_path)); 2625 ASSERT_FALSE(file_util::PathExists(manifest_path));
2625 2626
2626 // Start with version 2.0. 2627 // Start with version 2.0.
2627 DictionaryValue manifest; 2628 DictionaryValue manifest;
2628 manifest.SetString("version", "2.0"); 2629 manifest.SetString("version", "2.0");
2629 manifest.SetString("name", "LOAD Downgrade Test"); 2630 manifest.SetString("name", "LOAD Downgrade Test");
2630 manifest.SetInteger("manifest_version", 2); 2631 manifest.SetInteger("manifest_version", 2);
2631 2632
2632 JSONFileValueSerializer serializer(manifest_path); 2633 JSONFileValueSerializer serializer(manifest_path);
2633 ASSERT_TRUE(serializer.Serialize(manifest)); 2634 ASSERT_TRUE(serializer.Serialize(manifest));
2634 2635
2635 extensions::UnpackedInstaller::Create(service_)->Load(extension_path); 2636 extensions::UnpackedInstaller::Create(service_)->Load(extension_path);
2636 loop_.RunUntilIdle(); 2637 loop_.RunUntilIdle();
2637 2638
2638 EXPECT_EQ(0u, GetErrors().size()); 2639 EXPECT_EQ(0u, GetErrors().size());
2639 ASSERT_EQ(1u, loaded_.size()); 2640 ASSERT_EQ(1u, loaded_.size());
2640 EXPECT_EQ(Extension::LOAD, loaded_[0]->location()); 2641 EXPECT_EQ(Manifest::LOAD, loaded_[0]->location());
2641 EXPECT_EQ(1u, service_->extensions()->size()); 2642 EXPECT_EQ(1u, service_->extensions()->size());
2642 EXPECT_EQ("2.0", loaded_[0]->VersionString()); 2643 EXPECT_EQ("2.0", loaded_[0]->VersionString());
2643 2644
2644 // Now set the version number to 1.0, reload the extensions and verify that 2645 // Now set the version number to 1.0, reload the extensions and verify that
2645 // the downgrade was accepted. 2646 // the downgrade was accepted.
2646 manifest.SetString("version", "1.0"); 2647 manifest.SetString("version", "1.0");
2647 ASSERT_TRUE(serializer.Serialize(manifest)); 2648 ASSERT_TRUE(serializer.Serialize(manifest));
2648 2649
2649 extensions::UnpackedInstaller::Create(service_)->Load(extension_path); 2650 extensions::UnpackedInstaller::Create(service_)->Load(extension_path);
2650 loop_.RunUntilIdle(); 2651 loop_.RunUntilIdle();
2651 2652
2652 EXPECT_EQ(0u, GetErrors().size()); 2653 EXPECT_EQ(0u, GetErrors().size());
2653 ASSERT_EQ(1u, loaded_.size()); 2654 ASSERT_EQ(1u, loaded_.size());
2654 EXPECT_EQ(Extension::LOAD, loaded_[0]->location()); 2655 EXPECT_EQ(Manifest::LOAD, loaded_[0]->location());
2655 EXPECT_EQ(1u, service_->extensions()->size()); 2656 EXPECT_EQ(1u, service_->extensions()->size());
2656 EXPECT_EQ("1.0", loaded_[0]->VersionString()); 2657 EXPECT_EQ("1.0", loaded_[0]->VersionString());
2657 } 2658 }
2658 2659
2659 #if !defined(OS_CHROMEOS) 2660 #if !defined(OS_CHROMEOS)
2660 // LOAD extensions with plugins require approval. 2661 // LOAD extensions with plugins require approval.
2661 TEST_F(ExtensionServiceTest, LoadExtensionsWithPlugins) { 2662 TEST_F(ExtensionServiceTest, LoadExtensionsWithPlugins) {
2662 FilePath extension_with_plugin_path = data_dir_ 2663 FilePath extension_with_plugin_path = data_dir_
2663 .AppendASCII("good") 2664 .AppendASCII("good")
2664 .AppendASCII("Extensions") 2665 .AppendASCII("Extensions")
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
2732 loop_.RunUntilIdle(); 2733 loop_.RunUntilIdle();
2733 EXPECT_EQ(1u, loaded_.size()); 2734 EXPECT_EQ(1u, loaded_.size());
2734 EXPECT_EQ(2u, service_->extensions()->size()); 2735 EXPECT_EQ(2u, service_->extensions()->size());
2735 EXPECT_EQ(0u, service_->disabled_extensions()->size()); 2736 EXPECT_EQ(0u, service_->disabled_extensions()->size());
2736 } 2737 }
2737 #endif 2738 #endif
2738 2739
2739 namespace { 2740 namespace {
2740 2741
2741 bool IsExtension(const Extension& extension) { 2742 bool IsExtension(const Extension& extension) {
2742 return extension.GetType() == Extension::TYPE_EXTENSION; 2743 return extension.GetType() == Manifest::TYPE_EXTENSION;
2743 } 2744 }
2744 2745
2745 } // namespace 2746 } // namespace
2746 2747
2747 // Test adding a pending extension. 2748 // Test adding a pending extension.
2748 TEST_F(ExtensionServiceTest, AddPendingExtensionFromSync) { 2749 TEST_F(ExtensionServiceTest, AddPendingExtensionFromSync) {
2749 InitializeEmptyExtensionService(); 2750 InitializeEmptyExtensionService();
2750 2751
2751 const std::string kFakeId(all_zero); 2752 const std::string kFakeId(all_zero);
2752 const GURL kFakeUpdateURL("http:://fake.update/url"); 2753 const GURL kFakeUpdateURL("http:://fake.update/url");
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
2822 #define MAYBE_UpdatePendingExternalCrx DISABLED_UpdatePendingExternalCrx 2823 #define MAYBE_UpdatePendingExternalCrx DISABLED_UpdatePendingExternalCrx
2823 #else 2824 #else
2824 #define MAYBE_UpdatePendingExternalCrx UpdatePendingExternalCrx 2825 #define MAYBE_UpdatePendingExternalCrx UpdatePendingExternalCrx
2825 #endif 2826 #endif
2826 // Test updating a pending CRX as if the source is an external extension 2827 // Test updating a pending CRX as if the source is an external extension
2827 // with an update URL. In this case we don't know if the CRX is a theme 2828 // with an update URL. In this case we don't know if the CRX is a theme
2828 // or not. 2829 // or not.
2829 TEST_F(ExtensionServiceTest, MAYBE_UpdatePendingExternalCrx) { 2830 TEST_F(ExtensionServiceTest, MAYBE_UpdatePendingExternalCrx) {
2830 InitializeEmptyExtensionService(); 2831 InitializeEmptyExtensionService();
2831 EXPECT_TRUE(service_->pending_extension_manager()->AddFromExternalUpdateUrl( 2832 EXPECT_TRUE(service_->pending_extension_manager()->AddFromExternalUpdateUrl(
2832 theme_crx, GURL(), Extension::EXTERNAL_PREF_DOWNLOAD)); 2833 theme_crx, GURL(), Manifest::EXTERNAL_PREF_DOWNLOAD));
2833 2834
2834 EXPECT_TRUE(service_->pending_extension_manager()->IsIdPending(theme_crx)); 2835 EXPECT_TRUE(service_->pending_extension_manager()->IsIdPending(theme_crx));
2835 2836
2836 FilePath path = data_dir_.AppendASCII("theme.crx"); 2837 FilePath path = data_dir_.AppendASCII("theme.crx");
2837 UpdateExtension(theme_crx, path, ENABLED); 2838 UpdateExtension(theme_crx, path, ENABLED);
2838 2839
2839 EXPECT_FALSE(service_->pending_extension_manager()->IsIdPending(theme_crx)); 2840 EXPECT_FALSE(service_->pending_extension_manager()->IsIdPending(theme_crx));
2840 2841
2841 const Extension* extension = service_->GetExtensionById(theme_crx, true); 2842 const Extension* extension = service_->GetExtensionById(theme_crx, true);
2842 ASSERT_TRUE(extension); 2843 ASSERT_TRUE(extension);
(...skipping 16 matching lines...) Expand all
2859 kGoodInstallSilently)); 2860 kGoodInstallSilently));
2860 2861
2861 // Check that there is a pending crx, with is_from_sync set to true. 2862 // Check that there is a pending crx, with is_from_sync set to true.
2862 const extensions::PendingExtensionInfo* pending_extension_info; 2863 const extensions::PendingExtensionInfo* pending_extension_info;
2863 ASSERT_TRUE((pending_extension_info = service_->pending_extension_manager()-> 2864 ASSERT_TRUE((pending_extension_info = service_->pending_extension_manager()->
2864 GetById(kGoodId))); 2865 GetById(kGoodId)));
2865 EXPECT_TRUE(pending_extension_info->is_from_sync()); 2866 EXPECT_TRUE(pending_extension_info->is_from_sync());
2866 2867
2867 // Add a crx to be updated, with the same ID, from a non-sync source. 2868 // Add a crx to be updated, with the same ID, from a non-sync source.
2868 EXPECT_TRUE(service_->pending_extension_manager()->AddFromExternalUpdateUrl( 2869 EXPECT_TRUE(service_->pending_extension_manager()->AddFromExternalUpdateUrl(
2869 kGoodId, GURL(kGoodUpdateURL), Extension::EXTERNAL_PREF_DOWNLOAD)); 2870 kGoodId, GURL(kGoodUpdateURL), Manifest::EXTERNAL_PREF_DOWNLOAD));
2870 2871
2871 // Check that there is a pending crx, with is_from_sync set to false. 2872 // Check that there is a pending crx, with is_from_sync set to false.
2872 ASSERT_TRUE((pending_extension_info = service_->pending_extension_manager()-> 2873 ASSERT_TRUE((pending_extension_info = service_->pending_extension_manager()->
2873 GetById(kGoodId))); 2874 GetById(kGoodId)));
2874 EXPECT_FALSE(pending_extension_info->is_from_sync()); 2875 EXPECT_FALSE(pending_extension_info->is_from_sync());
2875 EXPECT_EQ(Extension::EXTERNAL_PREF_DOWNLOAD, 2876 EXPECT_EQ(Manifest::EXTERNAL_PREF_DOWNLOAD,
2876 pending_extension_info->install_source()); 2877 pending_extension_info->install_source());
2877 2878
2878 // Add a crx to be installed from the update mechanism. 2879 // Add a crx to be installed from the update mechanism.
2879 EXPECT_FALSE(service_->pending_extension_manager()->AddFromSync( 2880 EXPECT_FALSE(service_->pending_extension_manager()->AddFromSync(
2880 kGoodId, GURL(kGoodUpdateURL), &IsExtension, 2881 kGoodId, GURL(kGoodUpdateURL), &IsExtension,
2881 kGoodInstallSilently)); 2882 kGoodInstallSilently));
2882 2883
2883 // Check that the external, non-sync update was not overridden. 2884 // Check that the external, non-sync update was not overridden.
2884 ASSERT_TRUE((pending_extension_info = service_->pending_extension_manager()-> 2885 ASSERT_TRUE((pending_extension_info = service_->pending_extension_manager()->
2885 GetById(kGoodId))); 2886 GetById(kGoodId)));
2886 EXPECT_FALSE(pending_extension_info->is_from_sync()); 2887 EXPECT_FALSE(pending_extension_info->is_from_sync());
2887 EXPECT_EQ(Extension::EXTERNAL_PREF_DOWNLOAD, 2888 EXPECT_EQ(Manifest::EXTERNAL_PREF_DOWNLOAD,
2888 pending_extension_info->install_source()); 2889 pending_extension_info->install_source());
2889 } 2890 }
2890 2891
2891 // Updating a theme should fail if the updater is explicitly told that 2892 // Updating a theme should fail if the updater is explicitly told that
2892 // the CRX is not a theme. 2893 // the CRX is not a theme.
2893 TEST_F(ExtensionServiceTest, UpdatePendingCrxThemeMismatch) { 2894 TEST_F(ExtensionServiceTest, UpdatePendingCrxThemeMismatch) {
2894 InitializeEmptyExtensionService(); 2895 InitializeEmptyExtensionService();
2895 EXPECT_TRUE(service_->pending_extension_manager()->AddFromSync( 2896 EXPECT_TRUE(service_->pending_extension_manager()->AddFromSync(
2896 theme_crx, GURL(), &IsExtension, true)); 2897 theme_crx, GURL(), &IsExtension, true));
2897 2898
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
2948 FilePath path = data_dir_.AppendASCII("good.crx"); 2949 FilePath path = data_dir_.AppendASCII("good.crx");
2949 const Extension* good = InstallCRX(path, INSTALL_NEW); 2950 const Extension* good = InstallCRX(path, INSTALL_NEW);
2950 ASSERT_EQ(1u, service_->extensions()->size()); 2951 ASSERT_EQ(1u, service_->extensions()->size());
2951 2952
2952 EXPECT_FALSE(good->is_theme()); 2953 EXPECT_FALSE(good->is_theme());
2953 2954
2954 // Use AddExtensionImpl() as AddFrom*() would balk. 2955 // Use AddExtensionImpl() as AddFrom*() would balk.
2955 service_->pending_extension_manager()->AddExtensionImpl( 2956 service_->pending_extension_manager()->AddExtensionImpl(
2956 good->id(), extensions::ManifestURL::GetUpdateURL(good), 2957 good->id(), extensions::ManifestURL::GetUpdateURL(good),
2957 Version(), &IsExtension, kGoodIsFromSync, 2958 Version(), &IsExtension, kGoodIsFromSync,
2958 kGoodInstallSilently, Extension::INTERNAL); 2959 kGoodInstallSilently, Manifest::INTERNAL);
2959 UpdateExtension(good->id(), path, ENABLED); 2960 UpdateExtension(good->id(), path, ENABLED);
2960 2961
2961 EXPECT_FALSE(service_->pending_extension_manager()->IsIdPending(kGoodId)); 2962 EXPECT_FALSE(service_->pending_extension_manager()->IsIdPending(kGoodId));
2962 } 2963 }
2963 2964
2964 // Test pref settings for blacklist and unblacklist extensions. 2965 // Test pref settings for blacklist and unblacklist extensions.
2965 TEST_F(ExtensionServiceTest, SetUnsetBlacklistInPrefs) { 2966 TEST_F(ExtensionServiceTest, SetUnsetBlacklistInPrefs) {
2966 InitializeEmptyExtensionService(); 2967 InitializeEmptyExtensionService();
2967 std::vector<std::string> blacklist; 2968 std::vector<std::string> blacklist;
2968 blacklist.push_back(good0); 2969 blacklist.push_back(good0);
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
3227 // Mark good.crx for force-installation. 3228 // Mark good.crx for force-installation.
3228 DictionaryPrefUpdate forcelist_update(profile_->GetPrefs(), 3229 DictionaryPrefUpdate forcelist_update(profile_->GetPrefs(),
3229 prefs::kExtensionInstallForceList); 3230 prefs::kExtensionInstallForceList);
3230 extensions::ExternalPolicyLoader::AddExtension( 3231 extensions::ExternalPolicyLoader::AddExtension(
3231 forcelist_update.Get(), good_crx, "http://example.com/update_url"); 3232 forcelist_update.Get(), good_crx, "http://example.com/update_url");
3232 } 3233 }
3233 3234
3234 // Have policy force-install an extension. 3235 // Have policy force-install an extension.
3235 MockExtensionProvider* provider = 3236 MockExtensionProvider* provider =
3236 new MockExtensionProvider(service_, 3237 new MockExtensionProvider(service_,
3237 Extension::EXTERNAL_POLICY_DOWNLOAD); 3238 Manifest::EXTERNAL_POLICY_DOWNLOAD);
3238 AddMockExternalProvider(provider); 3239 AddMockExternalProvider(provider);
3239 provider->UpdateOrAddExtension(good_crx, "1.0.0.0", 3240 provider->UpdateOrAddExtension(good_crx, "1.0.0.0",
3240 data_dir_.AppendASCII("good.crx")); 3241 data_dir_.AppendASCII("good.crx"));
3241 3242
3242 // Reloading extensions should find our externally registered extension 3243 // Reloading extensions should find our externally registered extension
3243 // and install it. 3244 // and install it.
3244 service_->CheckForExternalUpdates(); 3245 service_->CheckForExternalUpdates();
3245 loop_.RunUntilIdle(); 3246 loop_.RunUntilIdle();
3246 3247
3247 // Extension should be installed despite blacklist. 3248 // Extension should be installed despite blacklist.
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
3282 // Create a fake extension to be loaded as though it were read from prefs. 3283 // Create a fake extension to be loaded as though it were read from prefs.
3283 FilePath path = data_dir_.AppendASCII("management") 3284 FilePath path = data_dir_.AppendASCII("management")
3284 .AppendASCII("simple_extension"); 3285 .AppendASCII("simple_extension");
3285 DictionaryValue manifest; 3286 DictionaryValue manifest;
3286 manifest.SetString(keys::kName, "simple_extension"); 3287 manifest.SetString(keys::kName, "simple_extension");
3287 manifest.SetString(keys::kVersion, "1"); 3288 manifest.SetString(keys::kVersion, "1");
3288 // LOAD is for extensions loaded from the command line. We use it here, even 3289 // LOAD is for extensions loaded from the command line. We use it here, even
3289 // though we're testing loading from prefs, so that we don't need to provide 3290 // though we're testing loading from prefs, so that we don't need to provide
3290 // an extension key. 3291 // an extension key.
3291 extensions::ExtensionInfo extension_info(&manifest, "", path, 3292 extensions::ExtensionInfo extension_info(&manifest, "", path,
3292 Extension::LOAD); 3293 Manifest::LOAD);
3293 3294
3294 // Ensure we can load it with no management policy in place. 3295 // Ensure we can load it with no management policy in place.
3295 management_policy_->UnregisterAllProviders(); 3296 management_policy_->UnregisterAllProviders();
3296 EXPECT_EQ(0u, service_->extensions()->size()); 3297 EXPECT_EQ(0u, service_->extensions()->size());
3297 extensions::InstalledLoader(service_).Load(extension_info, false); 3298 extensions::InstalledLoader(service_).Load(extension_info, false);
3298 EXPECT_EQ(1u, service_->extensions()->size()); 3299 EXPECT_EQ(1u, service_->extensions()->size());
3299 3300
3300 const Extension* extension = *(service_->extensions()->begin()); 3301 const Extension* extension = *(service_->extensions()->begin());
3301 EXPECT_TRUE(service_->UninstallExtension(extension->id(), false, NULL)); 3302 EXPECT_TRUE(service_->UninstallExtension(extension->id(), false, NULL));
3302 EXPECT_EQ(0u, service_->extensions()->size()); 3303 EXPECT_EQ(0u, service_->extensions()->size());
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
3396 EXPECT_EQ(0u, service_->disabled_extensions()->size()); 3397 EXPECT_EQ(0u, service_->disabled_extensions()->size());
3397 } 3398 }
3398 3399
3399 TEST_F(ExtensionServiceTest, ExternalExtensionAutoAcknowledgement) { 3400 TEST_F(ExtensionServiceTest, ExternalExtensionAutoAcknowledgement) {
3400 InitializeEmptyExtensionService(); 3401 InitializeEmptyExtensionService();
3401 set_extensions_enabled(true); 3402 set_extensions_enabled(true);
3402 3403
3403 { 3404 {
3404 // Register and install an external extension. 3405 // Register and install an external extension.
3405 MockExtensionProvider* provider = 3406 MockExtensionProvider* provider =
3406 new MockExtensionProvider(service_, Extension::EXTERNAL_PREF); 3407 new MockExtensionProvider(service_, Manifest::EXTERNAL_PREF);
3407 AddMockExternalProvider(provider); 3408 AddMockExternalProvider(provider);
3408 provider->UpdateOrAddExtension(good_crx, "1.0.0.0", 3409 provider->UpdateOrAddExtension(good_crx, "1.0.0.0",
3409 data_dir_.AppendASCII("good.crx")); 3410 data_dir_.AppendASCII("good.crx"));
3410 } 3411 }
3411 { 3412 {
3412 // Have policy force-install an extension. 3413 // Have policy force-install an extension.
3413 MockExtensionProvider* provider = 3414 MockExtensionProvider* provider =
3414 new MockExtensionProvider(service_, 3415 new MockExtensionProvider(service_,
3415 Extension::EXTERNAL_POLICY_DOWNLOAD); 3416 Manifest::EXTERNAL_POLICY_DOWNLOAD);
3416 AddMockExternalProvider(provider); 3417 AddMockExternalProvider(provider);
3417 provider->UpdateOrAddExtension(page_action, "1.0.0.0", 3418 provider->UpdateOrAddExtension(page_action, "1.0.0.0",
3418 data_dir_.AppendASCII("page_action.crx")); 3419 data_dir_.AppendASCII("page_action.crx"));
3419 } 3420 }
3420 3421
3421 // Providers are set up. Let them run. 3422 // Providers are set up. Let them run.
3422 service_->CheckForExternalUpdates(); 3423 service_->CheckForExternalUpdates();
3423 loop_.RunUntilIdle(); 3424 loop_.RunUntilIdle();
3424 3425
3425 ASSERT_EQ(2u, service_->extensions()->size()); 3426 ASSERT_EQ(2u, service_->extensions()->size());
(...skipping 18 matching lines...) Expand all
3444 " \"external_crx\": \"good.crx\"," 3445 " \"external_crx\": \"good.crx\","
3445 " \"external_version\": \"1.0.0.0\"," 3446 " \"external_version\": \"1.0.0.0\","
3446 " \"is_bookmark_app\": false" 3447 " \"is_bookmark_app\": false"
3447 " }" 3448 " }"
3448 "}"; 3449 "}";
3449 default_apps::Provider* provider = 3450 default_apps::Provider* provider =
3450 new default_apps::Provider( 3451 new default_apps::Provider(
3451 profile_.get(), 3452 profile_.get(),
3452 service_, 3453 service_,
3453 new extensions::ExternalTestingLoader(json_data, data_dir_), 3454 new extensions::ExternalTestingLoader(json_data, data_dir_),
3454 Extension::INTERNAL, 3455 Manifest::INTERNAL,
3455 Extension::INVALID, 3456 Manifest::INVALID_LOCATION,
3456 Extension::FROM_WEBSTORE | Extension::WAS_INSTALLED_BY_DEFAULT); 3457 Extension::FROM_WEBSTORE | Extension::WAS_INSTALLED_BY_DEFAULT);
3457 3458
3458 AddMockExternalProvider(provider); 3459 AddMockExternalProvider(provider);
3459 } 3460 }
3460 3461
3461 ASSERT_EQ(0u, service_->extensions()->size()); 3462 ASSERT_EQ(0u, service_->extensions()->size());
3462 service_->CheckForExternalUpdates(); 3463 service_->CheckForExternalUpdates();
3463 loop_.RunUntilIdle(); 3464 loop_.RunUntilIdle();
3464 3465
3465 ASSERT_EQ(1u, service_->extensions()->size()); 3466 ASSERT_EQ(1u, service_->extensions()->size());
(...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after
3967 3968
3968 FilePath ext1 = data_dir_ 3969 FilePath ext1 = data_dir_
3969 .AppendASCII("good") 3970 .AppendASCII("good")
3970 .AppendASCII("Extensions") 3971 .AppendASCII("Extensions")
3971 .AppendASCII("behllobkkfkfnphdnhnkndlbkcpglgmj") 3972 .AppendASCII("behllobkkfkfnphdnhnkndlbkcpglgmj")
3972 .AppendASCII("1.0.0.0"); 3973 .AppendASCII("1.0.0.0");
3973 extensions::UnpackedInstaller::Create(service_)->Load(ext1); 3974 extensions::UnpackedInstaller::Create(service_)->Load(ext1);
3974 loop_.RunUntilIdle(); 3975 loop_.RunUntilIdle();
3975 EXPECT_EQ(0u, GetErrors().size()); 3976 EXPECT_EQ(0u, GetErrors().size());
3976 ASSERT_EQ(1u, loaded_.size()); 3977 ASSERT_EQ(1u, loaded_.size());
3977 EXPECT_EQ(Extension::LOAD, loaded_[0]->location()); 3978 EXPECT_EQ(Manifest::LOAD, loaded_[0]->location());
3978 EXPECT_EQ(1u, service_->extensions()->size()); 3979 EXPECT_EQ(1u, service_->extensions()->size());
3979 3980
3980 ValidatePrefKeyCount(1); 3981 ValidatePrefKeyCount(1);
3981 3982
3982 FilePath no_manifest = data_dir_ 3983 FilePath no_manifest = data_dir_
3983 .AppendASCII("bad") 3984 .AppendASCII("bad")
3984 // .AppendASCII("Extensions") 3985 // .AppendASCII("Extensions")
3985 .AppendASCII("cccccccccccccccccccccccccccccccc") 3986 .AppendASCII("cccccccccccccccccccccccccccccccc")
3986 .AppendASCII("1"); 3987 .AppendASCII("1");
3987 extensions::UnpackedInstaller::Create(service_)->Load(no_manifest); 3988 extensions::UnpackedInstaller::Create(service_)->Load(no_manifest);
(...skipping 16 matching lines...) Expand all
4004 // --load-extension. 4005 // --load-extension.
4005 TEST_F(ExtensionServiceTest, GenerateID) { 4006 TEST_F(ExtensionServiceTest, GenerateID) {
4006 InitializeEmptyExtensionService(); 4007 InitializeEmptyExtensionService();
4007 4008
4008 FilePath no_id_ext = data_dir_.AppendASCII("no_id"); 4009 FilePath no_id_ext = data_dir_.AppendASCII("no_id");
4009 extensions::UnpackedInstaller::Create(service_)->Load(no_id_ext); 4010 extensions::UnpackedInstaller::Create(service_)->Load(no_id_ext);
4010 loop_.RunUntilIdle(); 4011 loop_.RunUntilIdle();
4011 EXPECT_EQ(0u, GetErrors().size()); 4012 EXPECT_EQ(0u, GetErrors().size());
4012 ASSERT_EQ(1u, loaded_.size()); 4013 ASSERT_EQ(1u, loaded_.size());
4013 ASSERT_TRUE(Extension::IdIsValid(loaded_[0]->id())); 4014 ASSERT_TRUE(Extension::IdIsValid(loaded_[0]->id()));
4014 EXPECT_EQ(loaded_[0]->location(), Extension::LOAD); 4015 EXPECT_EQ(loaded_[0]->location(), Manifest::LOAD);
4015 4016
4016 ValidatePrefKeyCount(1); 4017 ValidatePrefKeyCount(1);
4017 4018
4018 std::string previous_id = loaded_[0]->id(); 4019 std::string previous_id = loaded_[0]->id();
4019 4020
4020 // If we reload the same path, we should get the same extension ID. 4021 // If we reload the same path, we should get the same extension ID.
4021 extensions::UnpackedInstaller::Create(service_)->Load(no_id_ext); 4022 extensions::UnpackedInstaller::Create(service_)->Load(no_id_ext);
4022 loop_.RunUntilIdle(); 4023 loop_.RunUntilIdle();
4023 ASSERT_EQ(1u, loaded_.size()); 4024 ASSERT_EQ(1u, loaded_.size());
4024 ASSERT_EQ(previous_id, loaded_[0]->id()); 4025 ASSERT_EQ(previous_id, loaded_[0]->id());
4025 } 4026 }
4026 4027
4027 void ExtensionServiceTest::TestExternalProvider( 4028 void ExtensionServiceTest::TestExternalProvider(
4028 MockExtensionProvider* provider, Extension::Location location) { 4029 MockExtensionProvider* provider, Manifest::Location location) {
4029 // Verify that starting with no providers loads no extensions. 4030 // Verify that starting with no providers loads no extensions.
4030 service_->Init(); 4031 service_->Init();
4031 ASSERT_EQ(0u, loaded_.size()); 4032 ASSERT_EQ(0u, loaded_.size());
4032 4033
4033 provider->set_visit_count(0); 4034 provider->set_visit_count(0);
4034 4035
4035 // Register a test extension externally using the mock registry provider. 4036 // Register a test extension externally using the mock registry provider.
4036 FilePath source_path = data_dir_.AppendASCII("good.crx"); 4037 FilePath source_path = data_dir_.AppendASCII("good.crx");
4037 4038
4038 // Add the extension. 4039 // Add the extension.
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
4158 4159
4159 // Tests the external installation feature 4160 // Tests the external installation feature
4160 #if defined(OS_WIN) 4161 #if defined(OS_WIN)
4161 TEST_F(ExtensionServiceTest, ExternalInstallRegistry) { 4162 TEST_F(ExtensionServiceTest, ExternalInstallRegistry) {
4162 // This should all work, even when normal extension installation is disabled. 4163 // This should all work, even when normal extension installation is disabled.
4163 InitializeEmptyExtensionService(); 4164 InitializeEmptyExtensionService();
4164 set_extensions_enabled(false); 4165 set_extensions_enabled(false);
4165 4166
4166 // Now add providers. Extension system takes ownership of the objects. 4167 // Now add providers. Extension system takes ownership of the objects.
4167 MockExtensionProvider* reg_provider = 4168 MockExtensionProvider* reg_provider =
4168 new MockExtensionProvider(service_, Extension::EXTERNAL_REGISTRY); 4169 new MockExtensionProvider(service_, Manifest::EXTERNAL_REGISTRY);
4169 AddMockExternalProvider(reg_provider); 4170 AddMockExternalProvider(reg_provider);
4170 TestExternalProvider(reg_provider, Extension::EXTERNAL_REGISTRY); 4171 TestExternalProvider(reg_provider, Manifest::EXTERNAL_REGISTRY);
4171 } 4172 }
4172 #endif 4173 #endif
4173 4174
4174 TEST_F(ExtensionServiceTest, ExternalInstallPref) { 4175 TEST_F(ExtensionServiceTest, ExternalInstallPref) {
4175 InitializeEmptyExtensionService(); 4176 InitializeEmptyExtensionService();
4176 4177
4177 // Now add providers. Extension system takes ownership of the objects. 4178 // Now add providers. Extension system takes ownership of the objects.
4178 MockExtensionProvider* pref_provider = 4179 MockExtensionProvider* pref_provider =
4179 new MockExtensionProvider(service_, Extension::EXTERNAL_PREF); 4180 new MockExtensionProvider(service_, Manifest::EXTERNAL_PREF);
4180 4181
4181 AddMockExternalProvider(pref_provider); 4182 AddMockExternalProvider(pref_provider);
4182 TestExternalProvider(pref_provider, Extension::EXTERNAL_PREF); 4183 TestExternalProvider(pref_provider, Manifest::EXTERNAL_PREF);
4183 } 4184 }
4184 4185
4185 TEST_F(ExtensionServiceTest, ExternalInstallPrefUpdateUrl) { 4186 TEST_F(ExtensionServiceTest, ExternalInstallPrefUpdateUrl) {
4186 // This should all work, even when normal extension installation is disabled. 4187 // This should all work, even when normal extension installation is disabled.
4187 InitializeEmptyExtensionService(); 4188 InitializeEmptyExtensionService();
4188 set_extensions_enabled(false); 4189 set_extensions_enabled(false);
4189 4190
4190 // TODO(skerner): The mock provider is not a good model of a provider 4191 // TODO(skerner): The mock provider is not a good model of a provider
4191 // that works with update URLs, because it adds file and version info. 4192 // that works with update URLs, because it adds file and version info.
4192 // Extend the mock to work with update URLs. This test checks the 4193 // Extend the mock to work with update URLs. This test checks the
4193 // behavior that is common to all external extension visitors. The 4194 // behavior that is common to all external extension visitors. The
4194 // browser test ExtensionManagementTest.ExternalUrlUpdate tests that 4195 // browser test ExtensionManagementTest.ExternalUrlUpdate tests that
4195 // what the visitor does results in an extension being downloaded and 4196 // what the visitor does results in an extension being downloaded and
4196 // installed. 4197 // installed.
4197 MockExtensionProvider* pref_provider = 4198 MockExtensionProvider* pref_provider =
4198 new MockExtensionProvider(service_, 4199 new MockExtensionProvider(service_,
4199 Extension::EXTERNAL_PREF_DOWNLOAD); 4200 Manifest::EXTERNAL_PREF_DOWNLOAD);
4200 AddMockExternalProvider(pref_provider); 4201 AddMockExternalProvider(pref_provider);
4201 TestExternalProvider(pref_provider, Extension::EXTERNAL_PREF_DOWNLOAD); 4202 TestExternalProvider(pref_provider, Manifest::EXTERNAL_PREF_DOWNLOAD);
4202 } 4203 }
4203 4204
4204 TEST_F(ExtensionServiceTest, ExternalInstallPolicyUpdateUrl) { 4205 TEST_F(ExtensionServiceTest, ExternalInstallPolicyUpdateUrl) {
4205 // This should all work, even when normal extension installation is disabled. 4206 // This should all work, even when normal extension installation is disabled.
4206 InitializeEmptyExtensionService(); 4207 InitializeEmptyExtensionService();
4207 set_extensions_enabled(false); 4208 set_extensions_enabled(false);
4208 4209
4209 // TODO(skerner): The mock provider is not a good model of a provider 4210 // TODO(skerner): The mock provider is not a good model of a provider
4210 // that works with update URLs, because it adds file and version info. 4211 // that works with update URLs, because it adds file and version info.
4211 // Extend the mock to work with update URLs. This test checks the 4212 // Extend the mock to work with update URLs. This test checks the
4212 // behavior that is common to all external extension visitors. The 4213 // behavior that is common to all external extension visitors. The
4213 // browser test ExtensionManagementTest.ExternalUrlUpdate tests that 4214 // browser test ExtensionManagementTest.ExternalUrlUpdate tests that
4214 // what the visitor does results in an extension being downloaded and 4215 // what the visitor does results in an extension being downloaded and
4215 // installed. 4216 // installed.
4216 MockExtensionProvider* pref_provider = 4217 MockExtensionProvider* pref_provider =
4217 new MockExtensionProvider(service_, 4218 new MockExtensionProvider(service_,
4218 Extension::EXTERNAL_POLICY_DOWNLOAD); 4219 Manifest::EXTERNAL_POLICY_DOWNLOAD);
4219 AddMockExternalProvider(pref_provider); 4220 AddMockExternalProvider(pref_provider);
4220 TestExternalProvider(pref_provider, Extension::EXTERNAL_POLICY_DOWNLOAD); 4221 TestExternalProvider(pref_provider, Manifest::EXTERNAL_POLICY_DOWNLOAD);
4221 } 4222 }
4222 4223
4223 // Tests that external extensions get uninstalled when the external extension 4224 // Tests that external extensions get uninstalled when the external extension
4224 // providers can't account for them. 4225 // providers can't account for them.
4225 TEST_F(ExtensionServiceTest, ExternalUninstall) { 4226 TEST_F(ExtensionServiceTest, ExternalUninstall) {
4226 // Start the extensions service with one external extension already installed. 4227 // Start the extensions service with one external extension already installed.
4227 FilePath source_install_dir = data_dir_ 4228 FilePath source_install_dir = data_dir_
4228 .AppendASCII("good") 4229 .AppendASCII("good")
4229 .AppendASCII("Extensions"); 4230 .AppendASCII("Extensions");
4230 FilePath pref_path = source_install_dir 4231 FilePath pref_path = source_install_dir
(...skipping 17 matching lines...) Expand all
4248 ASSERT_EQ(0u, GetErrors().size()); 4249 ASSERT_EQ(0u, GetErrors().size());
4249 ASSERT_EQ(0u, loaded_.size()); 4250 ASSERT_EQ(0u, loaded_.size());
4250 } 4251 }
4251 4252
4252 // Test that running multiple update checks simultaneously does not 4253 // Test that running multiple update checks simultaneously does not
4253 // keep the update from succeeding. 4254 // keep the update from succeeding.
4254 TEST_F(ExtensionServiceTest, MultipleExternalUpdateCheck) { 4255 TEST_F(ExtensionServiceTest, MultipleExternalUpdateCheck) {
4255 InitializeEmptyExtensionService(); 4256 InitializeEmptyExtensionService();
4256 4257
4257 MockExtensionProvider* provider = 4258 MockExtensionProvider* provider =
4258 new MockExtensionProvider(service_, Extension::EXTERNAL_PREF); 4259 new MockExtensionProvider(service_, Manifest::EXTERNAL_PREF);
4259 AddMockExternalProvider(provider); 4260 AddMockExternalProvider(provider);
4260 4261
4261 // Verify that starting with no providers loads no extensions. 4262 // Verify that starting with no providers loads no extensions.
4262 service_->Init(); 4263 service_->Init();
4263 ASSERT_EQ(0u, loaded_.size()); 4264 ASSERT_EQ(0u, loaded_.size());
4264 4265
4265 // Start two checks for updates. 4266 // Start two checks for updates.
4266 provider->set_visit_count(0); 4267 provider->set_visit_count(0);
4267 service_->CheckForExternalUpdates(); 4268 service_->CheckForExternalUpdates();
4268 service_->CheckForExternalUpdates(); 4269 service_->CheckForExternalUpdates();
(...skipping 10 matching lines...) Expand all
4279 4280
4280 // Two checks for external updates should find the extension, and install it 4281 // Two checks for external updates should find the extension, and install it
4281 // once. 4282 // once.
4282 provider->set_visit_count(0); 4283 provider->set_visit_count(0);
4283 service_->CheckForExternalUpdates(); 4284 service_->CheckForExternalUpdates();
4284 service_->CheckForExternalUpdates(); 4285 service_->CheckForExternalUpdates();
4285 loop_.RunUntilIdle(); 4286 loop_.RunUntilIdle();
4286 EXPECT_EQ(2, provider->visit_count()); 4287 EXPECT_EQ(2, provider->visit_count());
4287 ASSERT_EQ(0u, GetErrors().size()); 4288 ASSERT_EQ(0u, GetErrors().size());
4288 ASSERT_EQ(1u, loaded_.size()); 4289 ASSERT_EQ(1u, loaded_.size());
4289 ASSERT_EQ(Extension::EXTERNAL_PREF, loaded_[0]->location()); 4290 ASSERT_EQ(Manifest::EXTERNAL_PREF, loaded_[0]->location());
4290 ASSERT_EQ("1.0.0.0", loaded_[0]->version()->GetString()); 4291 ASSERT_EQ("1.0.0.0", loaded_[0]->version()->GetString());
4291 ValidatePrefKeyCount(1); 4292 ValidatePrefKeyCount(1);
4292 ValidateIntegerPref(good_crx, "state", Extension::ENABLED); 4293 ValidateIntegerPref(good_crx, "state", Extension::ENABLED);
4293 ValidateIntegerPref(good_crx, "location", Extension::EXTERNAL_PREF); 4294 ValidateIntegerPref(good_crx, "location", Manifest::EXTERNAL_PREF);
4294 4295
4295 provider->RemoveExtension(good_crx); 4296 provider->RemoveExtension(good_crx);
4296 provider->set_visit_count(0); 4297 provider->set_visit_count(0);
4297 service_->CheckForExternalUpdates(); 4298 service_->CheckForExternalUpdates();
4298 service_->CheckForExternalUpdates(); 4299 service_->CheckForExternalUpdates();
4299 loop_.RunUntilIdle(); 4300 loop_.RunUntilIdle();
4300 4301
4301 // Two calls should cause two checks for external extensions. 4302 // Two calls should cause two checks for external extensions.
4302 // Because the external source no longer includes good_crx, 4303 // Because the external source no longer includes good_crx,
4303 // good_crx will be uninstalled. So, expect that no extensions 4304 // good_crx will be uninstalled. So, expect that no extensions
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after
4688 path.Append(Extension::kManifestFilename), &manifest)); 4689 path.Append(Extension::kManifestFilename), &manifest));
4689 4690
4690 service_->component_loader()->Add(manifest, path); 4691 service_->component_loader()->Add(manifest, path);
4691 service_->Init(); 4692 service_->Init();
4692 4693
4693 // Note that we do not pump messages -- the extension should be loaded 4694 // Note that we do not pump messages -- the extension should be loaded
4694 // immediately. 4695 // immediately.
4695 4696
4696 EXPECT_EQ(0u, GetErrors().size()); 4697 EXPECT_EQ(0u, GetErrors().size());
4697 ASSERT_EQ(1u, loaded_.size()); 4698 ASSERT_EQ(1u, loaded_.size());
4698 EXPECT_EQ(Extension::COMPONENT, loaded_[0]->location()); 4699 EXPECT_EQ(Manifest::COMPONENT, loaded_[0]->location());
4699 EXPECT_EQ(1u, service_->extensions()->size()); 4700 EXPECT_EQ(1u, service_->extensions()->size());
4700 4701
4701 // Component extensions get a prefs entry on first install. 4702 // Component extensions get a prefs entry on first install.
4702 ValidatePrefKeyCount(1); 4703 ValidatePrefKeyCount(1);
4703 4704
4704 // Reload all extensions, and make sure it comes back. 4705 // Reload all extensions, and make sure it comes back.
4705 std::string extension_id = (*service_->extensions()->begin())->id(); 4706 std::string extension_id = (*service_->extensions()->begin())->id();
4706 loaded_.clear(); 4707 loaded_.clear();
4707 service_->ReloadExtensions(); 4708 service_->ReloadExtensions();
4708 ASSERT_EQ(1u, service_->extensions()->size()); 4709 ASSERT_EQ(1u, service_->extensions()->size());
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
4828 ASSERT_EQ(list.size(), 1U); 4829 ASSERT_EQ(list.size(), 1U);
4829 extensions::ExtensionSyncData data(list[0]); 4830 extensions::ExtensionSyncData data(list[0]);
4830 EXPECT_TRUE(data.enabled()); 4831 EXPECT_TRUE(data.enabled());
4831 EXPECT_TRUE(data.incognito_enabled()); 4832 EXPECT_TRUE(data.incognito_enabled());
4832 } 4833 }
4833 } 4834 }
4834 4835
4835 TEST_F(ExtensionServiceTest, SyncForUninstalledExternalExtension) { 4836 TEST_F(ExtensionServiceTest, SyncForUninstalledExternalExtension) {
4836 InitializeEmptyExtensionService(); 4837 InitializeEmptyExtensionService();
4837 InstallCRXWithLocation(data_dir_.AppendASCII("good.crx"), 4838 InstallCRXWithLocation(data_dir_.AppendASCII("good.crx"),
4838 Extension::EXTERNAL_PREF, INSTALL_NEW); 4839 Manifest::EXTERNAL_PREF, INSTALL_NEW);
4839 const Extension* extension = service_->GetInstalledExtension(good_crx); 4840 const Extension* extension = service_->GetInstalledExtension(good_crx);
4840 ASSERT_TRUE(extension); 4841 ASSERT_TRUE(extension);
4841 4842
4842 TestSyncProcessorStub processor; 4843 TestSyncProcessorStub processor;
4843 service_->MergeDataAndStartSyncing( 4844 service_->MergeDataAndStartSyncing(
4844 syncer::EXTENSIONS, syncer::SyncDataList(), 4845 syncer::EXTENSIONS, syncer::SyncDataList(),
4845 scoped_ptr<syncer::SyncChangeProcessor>(new TestSyncProcessorStub), 4846 scoped_ptr<syncer::SyncChangeProcessor>(new TestSyncProcessorStub),
4846 scoped_ptr<syncer::SyncErrorFactory>(new syncer::SyncErrorFactoryMock())); 4847 scoped_ptr<syncer::SyncErrorFactory>(new syncer::SyncErrorFactoryMock()));
4847 4848
4848 UninstallExtension(good_crx, false); 4849 UninstallExtension(good_crx, false);
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after
5264 EXPECT_TRUE(service_->updater()->WillCheckSoon()); 5265 EXPECT_TRUE(service_->updater()->WillCheckSoon());
5265 EXPECT_FALSE(service_->IsExtensionEnabled(good_crx)); 5266 EXPECT_FALSE(service_->IsExtensionEnabled(good_crx));
5266 EXPECT_TRUE(service_->IsIncognitoEnabled(good_crx)); 5267 EXPECT_TRUE(service_->IsIncognitoEnabled(good_crx));
5267 5268
5268 const extensions::PendingExtensionInfo* info; 5269 const extensions::PendingExtensionInfo* info;
5269 EXPECT_TRUE((info = service_->pending_extension_manager()-> 5270 EXPECT_TRUE((info = service_->pending_extension_manager()->
5270 GetById(good_crx))); 5271 GetById(good_crx)));
5271 EXPECT_EQ(ext_specifics->update_url(), info->update_url().spec()); 5272 EXPECT_EQ(ext_specifics->update_url(), info->update_url().spec());
5272 EXPECT_TRUE(info->is_from_sync()); 5273 EXPECT_TRUE(info->is_from_sync());
5273 EXPECT_TRUE(info->install_silently()); 5274 EXPECT_TRUE(info->install_silently());
5274 EXPECT_EQ(Extension::INTERNAL, info->install_source()); 5275 EXPECT_EQ(Manifest::INTERNAL, info->install_source());
5275 // TODO(akalin): Figure out a way to test |info.ShouldAllowInstall()|. 5276 // TODO(akalin): Figure out a way to test |info.ShouldAllowInstall()|.
5276 } 5277 }
5277 5278
5278 TEST_F(ExtensionServiceTest, InstallPriorityExternalUpdateUrl) { 5279 TEST_F(ExtensionServiceTest, InstallPriorityExternalUpdateUrl) {
5279 InitializeEmptyExtensionService(); 5280 InitializeEmptyExtensionService();
5280 5281
5281 FilePath path = data_dir_.AppendASCII("good.crx"); 5282 FilePath path = data_dir_.AppendASCII("good.crx");
5282 InstallCRX(path, INSTALL_NEW); 5283 InstallCRX(path, INSTALL_NEW);
5283 ValidatePrefKeyCount(1u); 5284 ValidatePrefKeyCount(1u);
5284 ValidateIntegerPref(good_crx, "state", Extension::ENABLED); 5285 ValidateIntegerPref(good_crx, "state", Extension::ENABLED);
5285 ValidateIntegerPref(good_crx, "location", Extension::INTERNAL); 5286 ValidateIntegerPref(good_crx, "location", Manifest::INTERNAL);
5286 5287
5287 extensions::PendingExtensionManager* pending = 5288 extensions::PendingExtensionManager* pending =
5288 service_->pending_extension_manager(); 5289 service_->pending_extension_manager();
5289 EXPECT_FALSE(pending->IsIdPending(kGoodId)); 5290 EXPECT_FALSE(pending->IsIdPending(kGoodId));
5290 5291
5291 // Skip install when the location is the same. 5292 // Skip install when the location is the same.
5292 EXPECT_FALSE( 5293 EXPECT_FALSE(
5293 service_->OnExternalExtensionUpdateUrlFound( 5294 service_->OnExternalExtensionUpdateUrlFound(
5294 kGoodId, GURL(kGoodUpdateURL), Extension::INTERNAL)); 5295 kGoodId, GURL(kGoodUpdateURL), Manifest::INTERNAL));
5295 EXPECT_FALSE(pending->IsIdPending(kGoodId)); 5296 EXPECT_FALSE(pending->IsIdPending(kGoodId));
5296 5297
5297 // Install when the location has higher priority. 5298 // Install when the location has higher priority.
5298 EXPECT_TRUE( 5299 EXPECT_TRUE(
5299 service_->OnExternalExtensionUpdateUrlFound( 5300 service_->OnExternalExtensionUpdateUrlFound(
5300 kGoodId, GURL(kGoodUpdateURL), Extension::EXTERNAL_POLICY_DOWNLOAD)); 5301 kGoodId, GURL(kGoodUpdateURL), Manifest::EXTERNAL_POLICY_DOWNLOAD));
5301 EXPECT_TRUE(pending->IsIdPending(kGoodId)); 5302 EXPECT_TRUE(pending->IsIdPending(kGoodId));
5302 5303
5303 // Try the low priority again. Should be rejected. 5304 // Try the low priority again. Should be rejected.
5304 EXPECT_FALSE( 5305 EXPECT_FALSE(
5305 service_->OnExternalExtensionUpdateUrlFound( 5306 service_->OnExternalExtensionUpdateUrlFound(
5306 kGoodId, GURL(kGoodUpdateURL), Extension::EXTERNAL_PREF_DOWNLOAD)); 5307 kGoodId, GURL(kGoodUpdateURL), Manifest::EXTERNAL_PREF_DOWNLOAD));
5307 // The existing record should still be present in the pending extension 5308 // The existing record should still be present in the pending extension
5308 // manager. 5309 // manager.
5309 EXPECT_TRUE(pending->IsIdPending(kGoodId)); 5310 EXPECT_TRUE(pending->IsIdPending(kGoodId));
5310 5311
5311 pending->Remove(kGoodId); 5312 pending->Remove(kGoodId);
5312 5313
5313 // Skip install when the location has the same priority as the installed 5314 // Skip install when the location has the same priority as the installed
5314 // location. 5315 // location.
5315 EXPECT_FALSE(service_->OnExternalExtensionUpdateUrlFound( 5316 EXPECT_FALSE(service_->OnExternalExtensionUpdateUrlFound(
5316 kGoodId, GURL(kGoodUpdateURL), Extension::INTERNAL)); 5317 kGoodId, GURL(kGoodUpdateURL), Manifest::INTERNAL));
5317 5318
5318 EXPECT_FALSE(pending->IsIdPending(kGoodId)); 5319 EXPECT_FALSE(pending->IsIdPending(kGoodId));
5319 } 5320 }
5320 5321
5321 TEST_F(ExtensionServiceTest, InstallPriorityExternalLocalFile) { 5322 TEST_F(ExtensionServiceTest, InstallPriorityExternalLocalFile) {
5322 Version older_version("0.1.0.0"); 5323 Version older_version("0.1.0.0");
5323 Version newer_version("2.0.0.0"); 5324 Version newer_version("2.0.0.0");
5324 5325
5325 // We don't want the extension to be installed. A path that doesn't 5326 // We don't want the extension to be installed. A path that doesn't
5326 // point to a valid CRX ensures this. 5327 // point to a valid CRX ensures this.
5327 const FilePath kInvalidPathToCrx = FilePath(); 5328 const FilePath kInvalidPathToCrx = FilePath();
5328 5329
5329 const int kCreationFlags = 0; 5330 const int kCreationFlags = 0;
5330 const bool kDontMarkAcknowledged = false; 5331 const bool kDontMarkAcknowledged = false;
5331 5332
5332 InitializeEmptyExtensionService(); 5333 InitializeEmptyExtensionService();
5333 5334
5334 // The test below uses install source constants to test that 5335 // The test below uses install source constants to test that
5335 // priority is enforced. It assumes a specific ranking of install 5336 // priority is enforced. It assumes a specific ranking of install
5336 // sources: Registry (EXTERNAL_REGISTRY) overrides external pref 5337 // sources: Registry (EXTERNAL_REGISTRY) overrides external pref
5337 // (EXTERNAL_PREF), and external pref overrides user install (INTERNAL). 5338 // (EXTERNAL_PREF), and external pref overrides user install (INTERNAL).
5338 // The following assertions verify these assumptions: 5339 // The following assertions verify these assumptions:
5339 ASSERT_EQ(Extension::EXTERNAL_REGISTRY, 5340 ASSERT_EQ(Manifest::EXTERNAL_REGISTRY,
5340 Extension::GetHigherPriorityLocation(Extension::EXTERNAL_REGISTRY, 5341 Manifest::GetHigherPriorityLocation(Manifest::EXTERNAL_REGISTRY,
5341 Extension::EXTERNAL_PREF)); 5342 Manifest::EXTERNAL_PREF));
5342 ASSERT_EQ(Extension::EXTERNAL_REGISTRY, 5343 ASSERT_EQ(Manifest::EXTERNAL_REGISTRY,
5343 Extension::GetHigherPriorityLocation(Extension::EXTERNAL_REGISTRY, 5344 Manifest::GetHigherPriorityLocation(Manifest::EXTERNAL_REGISTRY,
5344 Extension::INTERNAL)); 5345 Manifest::INTERNAL));
5345 ASSERT_EQ(Extension::EXTERNAL_PREF, 5346 ASSERT_EQ(Manifest::EXTERNAL_PREF,
5346 Extension::GetHigherPriorityLocation(Extension::EXTERNAL_PREF, 5347 Manifest::GetHigherPriorityLocation(Manifest::EXTERNAL_PREF,
5347 Extension::INTERNAL)); 5348 Manifest::INTERNAL));
5348 5349
5349 extensions::PendingExtensionManager* pending = 5350 extensions::PendingExtensionManager* pending =
5350 service_->pending_extension_manager(); 5351 service_->pending_extension_manager();
5351 EXPECT_FALSE(pending->IsIdPending(kGoodId)); 5352 EXPECT_FALSE(pending->IsIdPending(kGoodId));
5352 5353
5353 // Simulate an external source adding the extension as INTERNAL. 5354 // Simulate an external source adding the extension as INTERNAL.
5354 EXPECT_TRUE( 5355 EXPECT_TRUE(
5355 service_->OnExternalExtensionFileFound( 5356 service_->OnExternalExtensionFileFound(
5356 kGoodId, &older_version, kInvalidPathToCrx, 5357 kGoodId, &older_version, kInvalidPathToCrx,
5357 Extension::INTERNAL, kCreationFlags, kDontMarkAcknowledged)); 5358 Manifest::INTERNAL, kCreationFlags, kDontMarkAcknowledged));
5358 EXPECT_TRUE(pending->IsIdPending(kGoodId)); 5359 EXPECT_TRUE(pending->IsIdPending(kGoodId));
5359 WaitForCrxInstall(kInvalidPathToCrx, INSTALL_FAILED); 5360 WaitForCrxInstall(kInvalidPathToCrx, INSTALL_FAILED);
5360 5361
5361 // Simulate an external source adding the extension as EXTERNAL_PREF. 5362 // Simulate an external source adding the extension as EXTERNAL_PREF.
5362 EXPECT_TRUE( 5363 EXPECT_TRUE(
5363 service_->OnExternalExtensionFileFound( 5364 service_->OnExternalExtensionFileFound(
5364 kGoodId, &older_version, kInvalidPathToCrx, 5365 kGoodId, &older_version, kInvalidPathToCrx,
5365 Extension::EXTERNAL_PREF, kCreationFlags, kDontMarkAcknowledged)); 5366 Manifest::EXTERNAL_PREF, kCreationFlags, kDontMarkAcknowledged));
5366 EXPECT_TRUE(pending->IsIdPending(kGoodId)); 5367 EXPECT_TRUE(pending->IsIdPending(kGoodId));
5367 WaitForCrxInstall(kInvalidPathToCrx, INSTALL_FAILED); 5368 WaitForCrxInstall(kInvalidPathToCrx, INSTALL_FAILED);
5368 5369
5369 // Simulate an external source adding as EXTERNAL_PREF again. 5370 // Simulate an external source adding as EXTERNAL_PREF again.
5370 // This is rejected because the version and the location are the same as 5371 // This is rejected because the version and the location are the same as
5371 // the previous installation, which is still pending. 5372 // the previous installation, which is still pending.
5372 EXPECT_FALSE( 5373 EXPECT_FALSE(
5373 service_->OnExternalExtensionFileFound( 5374 service_->OnExternalExtensionFileFound(
5374 kGoodId, &older_version, kInvalidPathToCrx, 5375 kGoodId, &older_version, kInvalidPathToCrx,
5375 Extension::EXTERNAL_PREF, kCreationFlags, kDontMarkAcknowledged)); 5376 Manifest::EXTERNAL_PREF, kCreationFlags, kDontMarkAcknowledged));
5376 EXPECT_TRUE(pending->IsIdPending(kGoodId)); 5377 EXPECT_TRUE(pending->IsIdPending(kGoodId));
5377 5378
5378 // Try INTERNAL again. Should fail. 5379 // Try INTERNAL again. Should fail.
5379 EXPECT_FALSE( 5380 EXPECT_FALSE(
5380 service_->OnExternalExtensionFileFound( 5381 service_->OnExternalExtensionFileFound(
5381 kGoodId, &older_version, kInvalidPathToCrx, 5382 kGoodId, &older_version, kInvalidPathToCrx,
5382 Extension::INTERNAL, kCreationFlags, kDontMarkAcknowledged)); 5383 Manifest::INTERNAL, kCreationFlags, kDontMarkAcknowledged));
5383 EXPECT_TRUE(pending->IsIdPending(kGoodId)); 5384 EXPECT_TRUE(pending->IsIdPending(kGoodId));
5384 5385
5385 // Now the registry adds the extension. 5386 // Now the registry adds the extension.
5386 EXPECT_TRUE( 5387 EXPECT_TRUE(
5387 service_->OnExternalExtensionFileFound( 5388 service_->OnExternalExtensionFileFound(
5388 kGoodId, &older_version, kInvalidPathToCrx, 5389 kGoodId, &older_version, kInvalidPathToCrx,
5389 Extension::EXTERNAL_REGISTRY, kCreationFlags, kDontMarkAcknowledged)); 5390 Manifest::EXTERNAL_REGISTRY, kCreationFlags, kDontMarkAcknowledged));
5390 EXPECT_TRUE(pending->IsIdPending(kGoodId)); 5391 EXPECT_TRUE(pending->IsIdPending(kGoodId));
5391 WaitForCrxInstall(kInvalidPathToCrx, INSTALL_FAILED); 5392 WaitForCrxInstall(kInvalidPathToCrx, INSTALL_FAILED);
5392 5393
5393 // Registry outranks both external pref and internal, so both fail. 5394 // Registry outranks both external pref and internal, so both fail.
5394 EXPECT_FALSE( 5395 EXPECT_FALSE(
5395 service_->OnExternalExtensionFileFound( 5396 service_->OnExternalExtensionFileFound(
5396 kGoodId, &older_version, kInvalidPathToCrx, 5397 kGoodId, &older_version, kInvalidPathToCrx,
5397 Extension::EXTERNAL_PREF, kCreationFlags, kDontMarkAcknowledged)); 5398 Manifest::EXTERNAL_PREF, kCreationFlags, kDontMarkAcknowledged));
5398 EXPECT_TRUE(pending->IsIdPending(kGoodId)); 5399 EXPECT_TRUE(pending->IsIdPending(kGoodId));
5399 5400
5400 EXPECT_FALSE( 5401 EXPECT_FALSE(
5401 service_->OnExternalExtensionFileFound( 5402 service_->OnExternalExtensionFileFound(
5402 kGoodId, &older_version, kInvalidPathToCrx, 5403 kGoodId, &older_version, kInvalidPathToCrx,
5403 Extension::INTERNAL, kCreationFlags, kDontMarkAcknowledged)); 5404 Manifest::INTERNAL, kCreationFlags, kDontMarkAcknowledged));
5404 EXPECT_TRUE(pending->IsIdPending(kGoodId)); 5405 EXPECT_TRUE(pending->IsIdPending(kGoodId));
5405 5406
5406 pending->Remove(kGoodId); 5407 pending->Remove(kGoodId);
5407 5408
5408 // Install the extension. 5409 // Install the extension.
5409 FilePath path = data_dir_.AppendASCII("good.crx"); 5410 FilePath path = data_dir_.AppendASCII("good.crx");
5410 const Extension* ext = InstallCRX(path, INSTALL_NEW); 5411 const Extension* ext = InstallCRX(path, INSTALL_NEW);
5411 ValidatePrefKeyCount(1u); 5412 ValidatePrefKeyCount(1u);
5412 ValidateIntegerPref(good_crx, "state", Extension::ENABLED); 5413 ValidateIntegerPref(good_crx, "state", Extension::ENABLED);
5413 ValidateIntegerPref(good_crx, "location", Extension::INTERNAL); 5414 ValidateIntegerPref(good_crx, "location", Manifest::INTERNAL);
5414 5415
5415 // Now test the logic of OnExternalExtensionFileFound() when the extension 5416 // Now test the logic of OnExternalExtensionFileFound() when the extension
5416 // being added is already installed. 5417 // being added is already installed.
5417 5418
5418 // Tests assume |older_version| is less than the installed version, and 5419 // Tests assume |older_version| is less than the installed version, and
5419 // |newer_version| is greater. Verify this: 5420 // |newer_version| is greater. Verify this:
5420 ASSERT_TRUE(older_version.IsOlderThan(ext->VersionString())); 5421 ASSERT_TRUE(older_version.IsOlderThan(ext->VersionString()));
5421 ASSERT_TRUE(ext->version()->IsOlderThan(newer_version.GetString())); 5422 ASSERT_TRUE(ext->version()->IsOlderThan(newer_version.GetString()));
5422 5423
5423 // An external install for the same location should fail if the version is 5424 // An external install for the same location should fail if the version is
5424 // older, or the same, and succeed if the version is newer. 5425 // older, or the same, and succeed if the version is newer.
5425 5426
5426 // Older than the installed version... 5427 // Older than the installed version...
5427 EXPECT_FALSE( 5428 EXPECT_FALSE(
5428 service_->OnExternalExtensionFileFound( 5429 service_->OnExternalExtensionFileFound(
5429 kGoodId, &older_version, kInvalidPathToCrx, 5430 kGoodId, &older_version, kInvalidPathToCrx,
5430 Extension::INTERNAL, kCreationFlags, kDontMarkAcknowledged)); 5431 Manifest::INTERNAL, kCreationFlags, kDontMarkAcknowledged));
5431 EXPECT_FALSE(pending->IsIdPending(kGoodId)); 5432 EXPECT_FALSE(pending->IsIdPending(kGoodId));
5432 5433
5433 // Same version as the installed version... 5434 // Same version as the installed version...
5434 EXPECT_FALSE( 5435 EXPECT_FALSE(
5435 service_->OnExternalExtensionFileFound( 5436 service_->OnExternalExtensionFileFound(
5436 kGoodId, ext->version(), kInvalidPathToCrx, 5437 kGoodId, ext->version(), kInvalidPathToCrx,
5437 Extension::INTERNAL, kCreationFlags, kDontMarkAcknowledged)); 5438 Manifest::INTERNAL, kCreationFlags, kDontMarkAcknowledged));
5438 EXPECT_FALSE(pending->IsIdPending(kGoodId)); 5439 EXPECT_FALSE(pending->IsIdPending(kGoodId));
5439 5440
5440 // Newer than the installed version... 5441 // Newer than the installed version...
5441 EXPECT_TRUE( 5442 EXPECT_TRUE(
5442 service_->OnExternalExtensionFileFound( 5443 service_->OnExternalExtensionFileFound(
5443 kGoodId, &newer_version, kInvalidPathToCrx, 5444 kGoodId, &newer_version, kInvalidPathToCrx,
5444 Extension::INTERNAL, kCreationFlags, kDontMarkAcknowledged)); 5445 Manifest::INTERNAL, kCreationFlags, kDontMarkAcknowledged));
5445 EXPECT_TRUE(pending->IsIdPending(kGoodId)); 5446 EXPECT_TRUE(pending->IsIdPending(kGoodId));
5446 5447
5447 // An external install for a higher priority install source should succeed 5448 // An external install for a higher priority install source should succeed
5448 // if the version is greater. |older_version| is not... 5449 // if the version is greater. |older_version| is not...
5449 EXPECT_FALSE( 5450 EXPECT_FALSE(
5450 service_->OnExternalExtensionFileFound( 5451 service_->OnExternalExtensionFileFound(
5451 kGoodId, &older_version, kInvalidPathToCrx, 5452 kGoodId, &older_version, kInvalidPathToCrx,
5452 Extension::EXTERNAL_PREF, kCreationFlags, kDontMarkAcknowledged)); 5453 Manifest::EXTERNAL_PREF, kCreationFlags, kDontMarkAcknowledged));
5453 EXPECT_TRUE(pending->IsIdPending(kGoodId)); 5454 EXPECT_TRUE(pending->IsIdPending(kGoodId));
5454 5455
5455 // |newer_version| is newer. 5456 // |newer_version| is newer.
5456 EXPECT_TRUE( 5457 EXPECT_TRUE(
5457 service_->OnExternalExtensionFileFound( 5458 service_->OnExternalExtensionFileFound(
5458 kGoodId, &newer_version, kInvalidPathToCrx, 5459 kGoodId, &newer_version, kInvalidPathToCrx,
5459 Extension::EXTERNAL_PREF, kCreationFlags, kDontMarkAcknowledged)); 5460 Manifest::EXTERNAL_PREF, kCreationFlags, kDontMarkAcknowledged));
5460 EXPECT_TRUE(pending->IsIdPending(kGoodId)); 5461 EXPECT_TRUE(pending->IsIdPending(kGoodId));
5461 5462
5462 // An external install for an even higher priority install source should 5463 // An external install for an even higher priority install source should
5463 // succeed if the version is greater. 5464 // succeed if the version is greater.
5464 EXPECT_TRUE( 5465 EXPECT_TRUE(
5465 service_->OnExternalExtensionFileFound( 5466 service_->OnExternalExtensionFileFound(
5466 kGoodId, &newer_version, kInvalidPathToCrx, 5467 kGoodId, &newer_version, kInvalidPathToCrx,
5467 Extension::EXTERNAL_REGISTRY, kCreationFlags, kDontMarkAcknowledged)); 5468 Manifest::EXTERNAL_REGISTRY, kCreationFlags, kDontMarkAcknowledged));
5468 EXPECT_TRUE(pending->IsIdPending(kGoodId)); 5469 EXPECT_TRUE(pending->IsIdPending(kGoodId));
5469 5470
5470 // Because EXTERNAL_PREF is a lower priority source than EXTERNAL_REGISTRY, 5471 // Because EXTERNAL_PREF is a lower priority source than EXTERNAL_REGISTRY,
5471 // adding from external pref will now fail. 5472 // adding from external pref will now fail.
5472 EXPECT_FALSE( 5473 EXPECT_FALSE(
5473 service_->OnExternalExtensionFileFound( 5474 service_->OnExternalExtensionFileFound(
5474 kGoodId, &newer_version, kInvalidPathToCrx, 5475 kGoodId, &newer_version, kInvalidPathToCrx,
5475 Extension::EXTERNAL_PREF, kCreationFlags, kDontMarkAcknowledged)); 5476 Manifest::EXTERNAL_PREF, kCreationFlags, kDontMarkAcknowledged));
5476 EXPECT_TRUE(pending->IsIdPending(kGoodId)); 5477 EXPECT_TRUE(pending->IsIdPending(kGoodId));
5477 } 5478 }
5478 5479
5479 TEST_F(ExtensionServiceTest, ConcurrentExternalLocalFile) { 5480 TEST_F(ExtensionServiceTest, ConcurrentExternalLocalFile) {
5480 Version kVersion123("1.2.3"); 5481 Version kVersion123("1.2.3");
5481 Version kVersion124("1.2.4"); 5482 Version kVersion124("1.2.4");
5482 Version kVersion125("1.2.5"); 5483 Version kVersion125("1.2.5");
5483 const FilePath kInvalidPathToCrx = FilePath(); 5484 const FilePath kInvalidPathToCrx = FilePath();
5484 const int kCreationFlags = 0; 5485 const int kCreationFlags = 0;
5485 const bool kDontMarkAcknowledged = false; 5486 const bool kDontMarkAcknowledged = false;
5486 5487
5487 InitializeEmptyExtensionService(); 5488 InitializeEmptyExtensionService();
5488 5489
5489 extensions::PendingExtensionManager* pending = 5490 extensions::PendingExtensionManager* pending =
5490 service_->pending_extension_manager(); 5491 service_->pending_extension_manager();
5491 EXPECT_FALSE(pending->IsIdPending(kGoodId)); 5492 EXPECT_FALSE(pending->IsIdPending(kGoodId));
5492 5493
5493 // An external provider starts installing from a local crx. 5494 // An external provider starts installing from a local crx.
5494 EXPECT_TRUE( 5495 EXPECT_TRUE(
5495 service_->OnExternalExtensionFileFound( 5496 service_->OnExternalExtensionFileFound(
5496 kGoodId, &kVersion123, kInvalidPathToCrx, 5497 kGoodId, &kVersion123, kInvalidPathToCrx,
5497 Extension::EXTERNAL_PREF, kCreationFlags, kDontMarkAcknowledged)); 5498 Manifest::EXTERNAL_PREF, kCreationFlags, kDontMarkAcknowledged));
5498 const extensions::PendingExtensionInfo* info; 5499 const extensions::PendingExtensionInfo* info;
5499 EXPECT_TRUE((info = pending->GetById(kGoodId))); 5500 EXPECT_TRUE((info = pending->GetById(kGoodId)));
5500 EXPECT_TRUE(info->version().IsValid()); 5501 EXPECT_TRUE(info->version().IsValid());
5501 EXPECT_TRUE(info->version().Equals(kVersion123)); 5502 EXPECT_TRUE(info->version().Equals(kVersion123));
5502 5503
5503 // Adding a newer version overrides the currently pending version. 5504 // Adding a newer version overrides the currently pending version.
5504 EXPECT_TRUE( 5505 EXPECT_TRUE(
5505 service_->OnExternalExtensionFileFound( 5506 service_->OnExternalExtensionFileFound(
5506 kGoodId, &kVersion124, kInvalidPathToCrx, 5507 kGoodId, &kVersion124, kInvalidPathToCrx,
5507 Extension::EXTERNAL_PREF, kCreationFlags, kDontMarkAcknowledged)); 5508 Manifest::EXTERNAL_PREF, kCreationFlags, kDontMarkAcknowledged));
5508 EXPECT_TRUE((info = pending->GetById(kGoodId))); 5509 EXPECT_TRUE((info = pending->GetById(kGoodId)));
5509 EXPECT_TRUE(info->version().IsValid()); 5510 EXPECT_TRUE(info->version().IsValid());
5510 EXPECT_TRUE(info->version().Equals(kVersion124)); 5511 EXPECT_TRUE(info->version().Equals(kVersion124));
5511 5512
5512 // Adding an older version fails. 5513 // Adding an older version fails.
5513 EXPECT_FALSE( 5514 EXPECT_FALSE(
5514 service_->OnExternalExtensionFileFound( 5515 service_->OnExternalExtensionFileFound(
5515 kGoodId, &kVersion123, kInvalidPathToCrx, 5516 kGoodId, &kVersion123, kInvalidPathToCrx,
5516 Extension::EXTERNAL_PREF, kCreationFlags, kDontMarkAcknowledged)); 5517 Manifest::EXTERNAL_PREF, kCreationFlags, kDontMarkAcknowledged));
5517 EXPECT_TRUE((info = pending->GetById(kGoodId))); 5518 EXPECT_TRUE((info = pending->GetById(kGoodId)));
5518 EXPECT_TRUE(info->version().IsValid()); 5519 EXPECT_TRUE(info->version().IsValid());
5519 EXPECT_TRUE(info->version().Equals(kVersion124)); 5520 EXPECT_TRUE(info->version().Equals(kVersion124));
5520 5521
5521 // Adding an older version fails even when coming from a higher-priority 5522 // Adding an older version fails even when coming from a higher-priority
5522 // location. 5523 // location.
5523 EXPECT_FALSE( 5524 EXPECT_FALSE(
5524 service_->OnExternalExtensionFileFound( 5525 service_->OnExternalExtensionFileFound(
5525 kGoodId, &kVersion123, kInvalidPathToCrx, 5526 kGoodId, &kVersion123, kInvalidPathToCrx,
5526 Extension::EXTERNAL_REGISTRY, kCreationFlags, kDontMarkAcknowledged)); 5527 Manifest::EXTERNAL_REGISTRY, kCreationFlags, kDontMarkAcknowledged));
5527 EXPECT_TRUE((info = pending->GetById(kGoodId))); 5528 EXPECT_TRUE((info = pending->GetById(kGoodId)));
5528 EXPECT_TRUE(info->version().IsValid()); 5529 EXPECT_TRUE(info->version().IsValid());
5529 EXPECT_TRUE(info->version().Equals(kVersion124)); 5530 EXPECT_TRUE(info->version().Equals(kVersion124));
5530 5531
5531 // Adding the latest version from the webstore overrides a specific version. 5532 // Adding the latest version from the webstore overrides a specific version.
5532 GURL kUpdateUrl("http://example.com/update"); 5533 GURL kUpdateUrl("http://example.com/update");
5533 EXPECT_TRUE( 5534 EXPECT_TRUE(
5534 service_->OnExternalExtensionUpdateUrlFound( 5535 service_->OnExternalExtensionUpdateUrlFound(
5535 kGoodId, kUpdateUrl, Extension::EXTERNAL_POLICY_DOWNLOAD)); 5536 kGoodId, kUpdateUrl, Manifest::EXTERNAL_POLICY_DOWNLOAD));
5536 EXPECT_TRUE((info = pending->GetById(kGoodId))); 5537 EXPECT_TRUE((info = pending->GetById(kGoodId)));
5537 EXPECT_FALSE(info->version().IsValid()); 5538 EXPECT_FALSE(info->version().IsValid());
5538 } 5539 }
5539 5540
5540 // This makes sure we can package and install CRX files that use whitelisted 5541 // This makes sure we can package and install CRX files that use whitelisted
5541 // permissions. 5542 // permissions.
5542 TEST_F(ExtensionServiceTest, InstallWhitelistedExtension) { 5543 TEST_F(ExtensionServiceTest, InstallWhitelistedExtension) {
5543 std::string test_id = "hdkklepkcpckhnpgjnmbdfhehckloojk"; 5544 std::string test_id = "hdkklepkcpckhnpgjnmbdfhehckloojk";
5544 CommandLine::ForCurrentProcess()->AppendSwitchASCII( 5545 CommandLine::ForCurrentProcess()->AppendSwitchASCII(
5545 switches::kWhitelistedExtensionID, test_id); 5546 switches::kWhitelistedExtensionID, test_id);
(...skipping 23 matching lines...) Expand all
5569 5570
5570 // All tests use a single extension. Put the id and path in member vars 5571 // All tests use a single extension. Put the id and path in member vars
5571 // that all methods can read. 5572 // that all methods can read.
5572 crx_id_ = kGoodId; 5573 crx_id_ = kGoodId;
5573 crx_path_ = data_dir_.AppendASCII("good.crx"); 5574 crx_path_ = data_dir_.AppendASCII("good.crx");
5574 } 5575 }
5575 5576
5576 // Fake an external source adding a URL to fetch an extension from. 5577 // Fake an external source adding a URL to fetch an extension from.
5577 bool AddPendingExternalPrefUrl() { 5578 bool AddPendingExternalPrefUrl() {
5578 return service_->pending_extension_manager()->AddFromExternalUpdateUrl( 5579 return service_->pending_extension_manager()->AddFromExternalUpdateUrl(
5579 crx_id_, GURL(), Extension::EXTERNAL_PREF_DOWNLOAD); 5580 crx_id_, GURL(), Manifest::EXTERNAL_PREF_DOWNLOAD);
5580 } 5581 }
5581 5582
5582 // Fake an external file from external_extensions.json. 5583 // Fake an external file from external_extensions.json.
5583 bool AddPendingExternalPrefFileInstall() { 5584 bool AddPendingExternalPrefFileInstall() {
5584 Version version("1.0.0.0"); 5585 Version version("1.0.0.0");
5585 5586
5586 return service_->OnExternalExtensionFileFound( 5587 return service_->OnExternalExtensionFileFound(
5587 crx_id_, &version, crx_path_, Extension::EXTERNAL_PREF, 5588 crx_id_, &version, crx_path_, Manifest::EXTERNAL_PREF,
5588 Extension::NO_FLAGS, false); 5589 Extension::NO_FLAGS, false);
5589 } 5590 }
5590 5591
5591 // Fake a request from sync to install an extension. 5592 // Fake a request from sync to install an extension.
5592 bool AddPendingSyncInstall() { 5593 bool AddPendingSyncInstall() {
5593 return service_->pending_extension_manager()->AddFromSync( 5594 return service_->pending_extension_manager()->AddFromSync(
5594 crx_id_, GURL(kGoodUpdateURL), &IsExtension, kGoodInstallSilently); 5595 crx_id_, GURL(kGoodUpdateURL), &IsExtension, kGoodInstallSilently);
5595 } 5596 }
5596 5597
5597 // Fake a policy install. 5598 // Fake a policy install.
5598 bool AddPendingPolicyInstall() { 5599 bool AddPendingPolicyInstall() {
5599 // Get path to the CRX with id |kGoodId|. 5600 // Get path to the CRX with id |kGoodId|.
5600 return service_->OnExternalExtensionUpdateUrlFound( 5601 return service_->OnExternalExtensionUpdateUrlFound(
5601 crx_id_, GURL(), Extension::EXTERNAL_POLICY_DOWNLOAD); 5602 crx_id_, GURL(), Manifest::EXTERNAL_POLICY_DOWNLOAD);
5602 } 5603 }
5603 5604
5604 // Get the install source of a pending extension. 5605 // Get the install source of a pending extension.
5605 Extension::Location GetPendingLocation() { 5606 Manifest::Location GetPendingLocation() {
5606 const extensions::PendingExtensionInfo* info; 5607 const extensions::PendingExtensionInfo* info;
5607 EXPECT_TRUE((info = service_->pending_extension_manager()-> 5608 EXPECT_TRUE((info = service_->pending_extension_manager()->
5608 GetById(crx_id_))); 5609 GetById(crx_id_)));
5609 return info->install_source(); 5610 return info->install_source();
5610 } 5611 }
5611 5612
5612 // Is an extension pending from a sync request? 5613 // Is an extension pending from a sync request?
5613 bool GetPendingIsFromSync() { 5614 bool GetPendingIsFromSync() {
5614 const extensions::PendingExtensionInfo* info; 5615 const extensions::PendingExtensionInfo* info;
5615 EXPECT_TRUE((info = service_->pending_extension_manager()-> 5616 EXPECT_TRUE((info = service_->pending_extension_manager()->
(...skipping 21 matching lines...) Expand all
5637 // Test that a pending request for installation of an external CRX from 5638 // Test that a pending request for installation of an external CRX from
5638 // an update URL overrides a pending request to install the same extension 5639 // an update URL overrides a pending request to install the same extension
5639 // from sync. 5640 // from sync.
5640 TEST_F(ExtensionSourcePriorityTest, PendingExternalFileOverSync) { 5641 TEST_F(ExtensionSourcePriorityTest, PendingExternalFileOverSync) {
5641 InitializeEmptyExtensionService(); 5642 InitializeEmptyExtensionService();
5642 5643
5643 ASSERT_FALSE(IsCrxInstalled()); 5644 ASSERT_FALSE(IsCrxInstalled());
5644 5645
5645 // Install pending extension from sync. 5646 // Install pending extension from sync.
5646 EXPECT_TRUE(AddPendingSyncInstall()); 5647 EXPECT_TRUE(AddPendingSyncInstall());
5647 ASSERT_EQ(Extension::INTERNAL, GetPendingLocation()); 5648 ASSERT_EQ(Manifest::INTERNAL, GetPendingLocation());
5648 EXPECT_TRUE(GetPendingIsFromSync()); 5649 EXPECT_TRUE(GetPendingIsFromSync());
5649 ASSERT_FALSE(IsCrxInstalled()); 5650 ASSERT_FALSE(IsCrxInstalled());
5650 5651
5651 // Install pending as external prefs json would. 5652 // Install pending as external prefs json would.
5652 AddPendingExternalPrefFileInstall(); 5653 AddPendingExternalPrefFileInstall();
5653 ASSERT_EQ(Extension::EXTERNAL_PREF, GetPendingLocation()); 5654 ASSERT_EQ(Manifest::EXTERNAL_PREF, GetPendingLocation());
5654 ASSERT_FALSE(IsCrxInstalled()); 5655 ASSERT_FALSE(IsCrxInstalled());
5655 5656
5656 // Another request from sync should be ignorred. 5657 // Another request from sync should be ignorred.
5657 EXPECT_FALSE(AddPendingSyncInstall()); 5658 EXPECT_FALSE(AddPendingSyncInstall());
5658 ASSERT_EQ(Extension::EXTERNAL_PREF, GetPendingLocation()); 5659 ASSERT_EQ(Manifest::EXTERNAL_PREF, GetPendingLocation());
5659 ASSERT_FALSE(IsCrxInstalled()); 5660 ASSERT_FALSE(IsCrxInstalled());
5660 5661
5661 WaitForCrxInstall(crx_path_, INSTALL_NEW); 5662 WaitForCrxInstall(crx_path_, INSTALL_NEW);
5662 ASSERT_TRUE(IsCrxInstalled()); 5663 ASSERT_TRUE(IsCrxInstalled());
5663 } 5664 }
5664 5665
5665 // Test that an install of an external CRX from an update overrides 5666 // Test that an install of an external CRX from an update overrides
5666 // an install of the same extension from sync. 5667 // an install of the same extension from sync.
5667 TEST_F(ExtensionSourcePriorityTest, PendingExternalUrlOverSync) { 5668 TEST_F(ExtensionSourcePriorityTest, PendingExternalUrlOverSync) {
5668 InitializeEmptyExtensionService(); 5669 InitializeEmptyExtensionService();
5669 ASSERT_FALSE(IsCrxInstalled()); 5670 ASSERT_FALSE(IsCrxInstalled());
5670 5671
5671 EXPECT_TRUE(AddPendingSyncInstall()); 5672 EXPECT_TRUE(AddPendingSyncInstall());
5672 ASSERT_EQ(Extension::INTERNAL, GetPendingLocation()); 5673 ASSERT_EQ(Manifest::INTERNAL, GetPendingLocation());
5673 EXPECT_TRUE(GetPendingIsFromSync()); 5674 EXPECT_TRUE(GetPendingIsFromSync());
5674 ASSERT_FALSE(IsCrxInstalled()); 5675 ASSERT_FALSE(IsCrxInstalled());
5675 5676
5676 ASSERT_TRUE(AddPendingExternalPrefUrl()); 5677 ASSERT_TRUE(AddPendingExternalPrefUrl());
5677 ASSERT_EQ(Extension::EXTERNAL_PREF_DOWNLOAD, GetPendingLocation()); 5678 ASSERT_EQ(Manifest::EXTERNAL_PREF_DOWNLOAD, GetPendingLocation());
5678 EXPECT_FALSE(GetPendingIsFromSync()); 5679 EXPECT_FALSE(GetPendingIsFromSync());
5679 ASSERT_FALSE(IsCrxInstalled()); 5680 ASSERT_FALSE(IsCrxInstalled());
5680 5681
5681 EXPECT_FALSE(AddPendingSyncInstall()); 5682 EXPECT_FALSE(AddPendingSyncInstall());
5682 ASSERT_EQ(Extension::EXTERNAL_PREF_DOWNLOAD, GetPendingLocation()); 5683 ASSERT_EQ(Manifest::EXTERNAL_PREF_DOWNLOAD, GetPendingLocation());
5683 EXPECT_FALSE(GetPendingIsFromSync()); 5684 EXPECT_FALSE(GetPendingIsFromSync());
5684 ASSERT_FALSE(IsCrxInstalled()); 5685 ASSERT_FALSE(IsCrxInstalled());
5685 } 5686 }
5686 5687
5687 // Test that an external install request stops sync from installing 5688 // Test that an external install request stops sync from installing
5688 // the same extension. 5689 // the same extension.
5689 TEST_F(ExtensionSourcePriorityTest, InstallExternalBlocksSyncRequest) { 5690 TEST_F(ExtensionSourcePriorityTest, InstallExternalBlocksSyncRequest) {
5690 InitializeEmptyExtensionService(); 5691 InitializeEmptyExtensionService();
5691 ASSERT_FALSE(IsCrxInstalled()); 5692 ASSERT_FALSE(IsCrxInstalled());
5692 5693
(...skipping 16 matching lines...) Expand all
5709 ASSERT_FALSE(AddPendingSyncInstall()); 5710 ASSERT_FALSE(AddPendingSyncInstall());
5710 } 5711 }
5711 5712
5712 // Test that installing an external extension displays a GlobalError. 5713 // Test that installing an external extension displays a GlobalError.
5713 TEST_F(ExtensionServiceTest, ExternalInstallGlobalError) { 5714 TEST_F(ExtensionServiceTest, ExternalInstallGlobalError) {
5714 FeatureSwitch::ScopedOverride prompt( 5715 FeatureSwitch::ScopedOverride prompt(
5715 FeatureSwitch::prompt_for_external_extensions(), true); 5716 FeatureSwitch::prompt_for_external_extensions(), true);
5716 5717
5717 InitializeEmptyExtensionService(); 5718 InitializeEmptyExtensionService();
5718 MockExtensionProvider* provider = 5719 MockExtensionProvider* provider =
5719 new MockExtensionProvider(service_, Extension::EXTERNAL_PREF); 5720 new MockExtensionProvider(service_, Manifest::EXTERNAL_PREF);
5720 AddMockExternalProvider(provider); 5721 AddMockExternalProvider(provider);
5721 5722
5722 service_->UpdateExternalExtensionAlert(); 5723 service_->UpdateExternalExtensionAlert();
5723 // Should return false, meaning there aren't any extensions that the user 5724 // Should return false, meaning there aren't any extensions that the user
5724 // needs to know about. 5725 // needs to know about.
5725 EXPECT_FALSE(extensions::HasExternalInstallError(service_)); 5726 EXPECT_FALSE(extensions::HasExternalInstallError(service_));
5726 5727
5727 // This is a normal extension, installed normally. 5728 // This is a normal extension, installed normally.
5728 // This should NOT trigger an alert. 5729 // This should NOT trigger an alert.
5729 set_extensions_enabled(true); 5730 set_extensions_enabled(true);
(...skipping 24 matching lines...) Expand all
5754 } 5755 }
5755 5756
5756 // Test that external extensions are initially disabled, and that enabling 5757 // Test that external extensions are initially disabled, and that enabling
5757 // them clears the prompt. 5758 // them clears the prompt.
5758 TEST_F(ExtensionServiceTest, ExternalInstallInitiallyDisabled) { 5759 TEST_F(ExtensionServiceTest, ExternalInstallInitiallyDisabled) {
5759 FeatureSwitch::ScopedOverride prompt( 5760 FeatureSwitch::ScopedOverride prompt(
5760 FeatureSwitch::prompt_for_external_extensions(), true); 5761 FeatureSwitch::prompt_for_external_extensions(), true);
5761 5762
5762 InitializeEmptyExtensionService(); 5763 InitializeEmptyExtensionService();
5763 MockExtensionProvider* provider = 5764 MockExtensionProvider* provider =
5764 new MockExtensionProvider(service_, Extension::EXTERNAL_PREF); 5765 new MockExtensionProvider(service_, Manifest::EXTERNAL_PREF);
5765 AddMockExternalProvider(provider); 5766 AddMockExternalProvider(provider);
5766 5767
5767 provider->UpdateOrAddExtension(page_action, "1.0.0.0", 5768 provider->UpdateOrAddExtension(page_action, "1.0.0.0",
5768 data_dir_.AppendASCII("page_action.crx")); 5769 data_dir_.AppendASCII("page_action.crx"));
5769 5770
5770 service_->CheckForExternalUpdates(); 5771 service_->CheckForExternalUpdates();
5771 loop_.RunUntilIdle(); 5772 loop_.RunUntilIdle();
5772 EXPECT_TRUE(extensions::HasExternalInstallError(service_)); 5773 EXPECT_TRUE(extensions::HasExternalInstallError(service_));
5773 EXPECT_FALSE(service_->IsExtensionEnabled(page_action)); 5774 EXPECT_FALSE(service_->IsExtensionEnabled(page_action));
5774 5775
5775 const Extension* extension = 5776 const Extension* extension =
5776 service_->disabled_extensions()->GetByID(page_action); 5777 service_->disabled_extensions()->GetByID(page_action);
5777 EXPECT_TRUE(extension); 5778 EXPECT_TRUE(extension);
5778 EXPECT_EQ(page_action, extension->id()); 5779 EXPECT_EQ(page_action, extension->id());
5779 5780
5780 service_->EnableExtension(page_action); 5781 service_->EnableExtension(page_action);
5781 EXPECT_FALSE(extensions::HasExternalInstallError(service_)); 5782 EXPECT_FALSE(extensions::HasExternalInstallError(service_));
5782 EXPECT_TRUE(service_->IsExtensionEnabled(page_action)); 5783 EXPECT_TRUE(service_->IsExtensionEnabled(page_action));
5783 } 5784 }
5784 5785
5785 // Test that installing multiple external extensions works. 5786 // Test that installing multiple external extensions works.
5786 TEST_F(ExtensionServiceTest, ExternalInstallMultiple) { 5787 TEST_F(ExtensionServiceTest, ExternalInstallMultiple) {
5787 FeatureSwitch::ScopedOverride prompt( 5788 FeatureSwitch::ScopedOverride prompt(
5788 FeatureSwitch::prompt_for_external_extensions(), true); 5789 FeatureSwitch::prompt_for_external_extensions(), true);
5789 5790
5790 InitializeEmptyExtensionService(); 5791 InitializeEmptyExtensionService();
5791 MockExtensionProvider* provider = 5792 MockExtensionProvider* provider =
5792 new MockExtensionProvider(service_, Extension::EXTERNAL_PREF); 5793 new MockExtensionProvider(service_, Manifest::EXTERNAL_PREF);
5793 AddMockExternalProvider(provider); 5794 AddMockExternalProvider(provider);
5794 5795
5795 provider->UpdateOrAddExtension(page_action, "1.0.0.0", 5796 provider->UpdateOrAddExtension(page_action, "1.0.0.0",
5796 data_dir_.AppendASCII("page_action.crx")); 5797 data_dir_.AppendASCII("page_action.crx"));
5797 provider->UpdateOrAddExtension(good_crx, "1.0.0.0", 5798 provider->UpdateOrAddExtension(good_crx, "1.0.0.0",
5798 data_dir_.AppendASCII("good.crx")); 5799 data_dir_.AppendASCII("good.crx"));
5799 provider->UpdateOrAddExtension(theme_crx, "2.0", 5800 provider->UpdateOrAddExtension(theme_crx, "2.0",
5800 data_dir_.AppendASCII("theme.crx")); 5801 data_dir_.AppendASCII("theme.crx"));
5801 5802
5802 service_->CheckForExternalUpdates(); 5803 service_->CheckForExternalUpdates();
(...skipping 11 matching lines...) Expand all
5814 EXPECT_FALSE(extensions::HasExternalInstallError(service_)); 5815 EXPECT_FALSE(extensions::HasExternalInstallError(service_));
5815 } 5816 }
5816 5817
5817 // Test that a sideloaded extension gets wiped out. 5818 // Test that a sideloaded extension gets wiped out.
5818 TEST_F(ExtensionServiceTest, WipeOutExtension) { 5819 TEST_F(ExtensionServiceTest, WipeOutExtension) {
5819 FeatureSwitch::ScopedOverride prompt( 5820 FeatureSwitch::ScopedOverride prompt(
5820 FeatureSwitch::sideload_wipeout(), true); 5821 FeatureSwitch::sideload_wipeout(), true);
5821 5822
5822 InitializeEmptyExtensionService(); 5823 InitializeEmptyExtensionService();
5823 MockExtensionProvider* provider_registry = 5824 MockExtensionProvider* provider_registry =
5824 new MockExtensionProvider(service_, Extension::EXTERNAL_REGISTRY); 5825 new MockExtensionProvider(service_, Manifest::EXTERNAL_REGISTRY);
5825 AddMockExternalProvider(provider_registry); 5826 AddMockExternalProvider(provider_registry);
5826 MockExtensionProvider* provider_pref = 5827 MockExtensionProvider* provider_pref =
5827 new MockExtensionProvider(service_, Extension::EXTERNAL_PREF); 5828 new MockExtensionProvider(service_, Manifest::EXTERNAL_PREF);
5828 AddMockExternalProvider(provider_pref); 5829 AddMockExternalProvider(provider_pref);
5829 5830
5830 provider_registry->UpdateOrAddExtension(good_crx, "1.0.0.0", 5831 provider_registry->UpdateOrAddExtension(good_crx, "1.0.0.0",
5831 data_dir_.AppendASCII("good.crx")); 5832 data_dir_.AppendASCII("good.crx"));
5832 provider_pref->UpdateOrAddExtension(good_crx, "1.0.0.0", 5833 provider_pref->UpdateOrAddExtension(good_crx, "1.0.0.0",
5833 data_dir_.AppendASCII("good.crx")); 5834 data_dir_.AppendASCII("good.crx"));
5834 5835
5835 service_->CheckForExternalUpdates(); 5836 service_->CheckForExternalUpdates();
5836 loop_.RunUntilIdle(); 5837 loop_.RunUntilIdle();
5837 EXPECT_FALSE(extensions::HasExternalInstallError(service_)); 5838 EXPECT_FALSE(extensions::HasExternalInstallError(service_));
5838 EXPECT_FALSE(service_->IsExtensionEnabled(good_crx)); 5839 EXPECT_FALSE(service_->IsExtensionEnabled(good_crx));
5839 EXPECT_TRUE(service_->IsExtensionEnabled(page_action)); 5840 EXPECT_TRUE(service_->IsExtensionEnabled(page_action));
5840 5841
5841 ExtensionPrefs* prefs = service_->extension_prefs(); 5842 ExtensionPrefs* prefs = service_->extension_prefs();
5842 EXPECT_NE(0, prefs->GetDisableReasons(good_crx) & 5843 EXPECT_NE(0, prefs->GetDisableReasons(good_crx) &
5843 Extension::DISABLE_SIDELOAD_WIPEOUT); 5844 Extension::DISABLE_SIDELOAD_WIPEOUT);
5844 EXPECT_EQ(0, prefs->GetDisableReasons(page_action) & 5845 EXPECT_EQ(0, prefs->GetDisableReasons(page_action) &
5845 Extension::DISABLE_SIDELOAD_WIPEOUT); 5846 Extension::DISABLE_SIDELOAD_WIPEOUT);
5846 } 5847 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_service.cc ('k') | chrome/browser/extensions/extension_sorting_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698