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

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

Issue 196663003: Introduce an extension parameter which is used to customize the extension. It's available for exter… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Modified test parameters Created 6 years, 9 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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 389 matching lines...) Expand 10 before | Expand all | Expand 10 after
400 EXPECT_STREQ(version->GetString().c_str(), v2->GetString().c_str()); 400 EXPECT_STREQ(version->GetString().c_str(), v2->GetString().c_str());
401 EXPECT_EQ(Manifest::EXTERNAL_PREF, location); 401 EXPECT_EQ(Manifest::EXTERNAL_PREF, location);
402 402
403 // Remove it so we won't count it ever again. 403 // Remove it so we won't count it ever again.
404 prefs_->Remove(id, NULL); 404 prefs_->Remove(id, NULL);
405 } 405 }
406 return true; 406 return true;
407 } 407 }
408 408
409 virtual bool OnExternalExtensionUpdateUrlFound( 409 virtual bool OnExternalExtensionUpdateUrlFound(
410 const std::string& id, const GURL& update_url, 410 const std::string& id,
411 const std::string& install_parameter,
412 const GURL& update_url,
411 Manifest::Location location, 413 Manifest::Location location,
412 int creation_flags, 414 int creation_flags,
413 bool mark_acknowledged) OVERRIDE { 415 bool mark_acknowledged) OVERRIDE {
414 ++ids_found_; 416 ++ids_found_;
415 base::DictionaryValue* pref; 417 base::DictionaryValue* pref;
416 // This tests is to make sure that the provider only notifies us of the 418 // This tests is to make sure that the provider only notifies us of the
417 // values we gave it. So if the id we doesn't exist in our internal 419 // values we gave it. So if the id we doesn't exist in our internal
418 // dictionary then something is wrong. 420 // dictionary then something is wrong.
419 EXPECT_TRUE(prefs_->GetDictionary(id, &pref)) 421 EXPECT_TRUE(prefs_->GetDictionary(id, &pref))
420 << L"Got back ID (" << id.c_str() << ") we weren't expecting"; 422 << L"Got back ID (" << id.c_str() << ") we weren't expecting";
421 EXPECT_EQ(Manifest::EXTERNAL_PREF_DOWNLOAD, location); 423 EXPECT_EQ(Manifest::EXTERNAL_PREF_DOWNLOAD, location);
422 424
423 if (pref) { 425 if (pref) {
424 EXPECT_TRUE(provider_->HasExtension(id)); 426 EXPECT_TRUE(provider_->HasExtension(id));
425 427
426 // External extensions with update URLs do not have versions. 428 // External extensions with update URLs do not have versions.
427 scoped_ptr<Version> v1; 429 scoped_ptr<Version> v1;
428 Manifest::Location location1 = Manifest::INVALID_LOCATION; 430 Manifest::Location location1 = Manifest::INVALID_LOCATION;
429 EXPECT_TRUE(provider_->GetExtensionDetails(id, &location1, &v1)); 431 EXPECT_TRUE(provider_->GetExtensionDetails(id, &location1, &v1));
430 EXPECT_FALSE(v1.get()); 432 EXPECT_FALSE(v1.get());
431 EXPECT_EQ(Manifest::EXTERNAL_PREF_DOWNLOAD, location1); 433 EXPECT_EQ(Manifest::EXTERNAL_PREF_DOWNLOAD, location1);
432 434
435 std::string parsed_install_parameter;
436 pref->GetString("install_parameter", &parsed_install_parameter);
437 EXPECT_EQ(parsed_install_parameter, install_parameter);
438
433 // Remove it so we won't count it again. 439 // Remove it so we won't count it again.
434 prefs_->Remove(id, NULL); 440 prefs_->Remove(id, NULL);
435 } 441 }
436 return true; 442 return true;
437 } 443 }
438 444
439 virtual void OnExternalProviderReady( 445 virtual void OnExternalProviderReady(
440 const extensions::ExternalProviderInterface* provider) OVERRIDE { 446 const extensions::ExternalProviderInterface* provider) OVERRIDE {
441 EXPECT_EQ(provider, provider_.get()); 447 EXPECT_EQ(provider, provider_.get());
442 EXPECT_TRUE(provider->IsReady()); 448 EXPECT_TRUE(provider->IsReady());
(...skipping 1373 matching lines...) Expand 10 before | Expand all | Expand 10 after
1816 path, Manifest::EXTERNAL_PREF, 1822 path, Manifest::EXTERNAL_PREF,
1817 Extension::NO_FLAGS, false); 1823 Extension::NO_FLAGS, false);
1818 base::RunLoop().RunUntilIdle(); 1824 base::RunLoop().RunUntilIdle();
1819 ASSERT_TRUE(NULL == service_->GetExtensionById(good_crx, false)); 1825 ASSERT_TRUE(NULL == service_->GetExtensionById(good_crx, false));
1820 ValidateIntegerPref(good_crx, "location", 1826 ValidateIntegerPref(good_crx, "location",
1821 Extension::EXTERNAL_EXTENSION_UNINSTALLED); 1827 Extension::EXTERNAL_EXTENSION_UNINSTALLED);
1822 1828
1823 // Try adding the same extension from an external update URL. 1829 // Try adding the same extension from an external update URL.
1824 ASSERT_FALSE(service_->pending_extension_manager()->AddFromExternalUpdateUrl( 1830 ASSERT_FALSE(service_->pending_extension_manager()->AddFromExternalUpdateUrl(
1825 good_crx, 1831 good_crx,
1832 std::string(),
1826 GURL("http:://fake.update/url"), 1833 GURL("http:://fake.update/url"),
1827 Manifest::EXTERNAL_PREF_DOWNLOAD, 1834 Manifest::EXTERNAL_PREF_DOWNLOAD,
1828 Extension::NO_FLAGS, 1835 Extension::NO_FLAGS,
1829 false)); 1836 false));
1830 1837
1831 ASSERT_FALSE(service_->pending_extension_manager()->IsIdPending(good_crx)); 1838 ASSERT_FALSE(service_->pending_extension_manager()->IsIdPending(good_crx));
1832 } 1839 }
1833 1840
1834 // Test that uninstalling an external extension does not crash when 1841 // Test that uninstalling an external extension does not crash when
1835 // the extension could not be loaded. 1842 // the extension could not be loaded.
(...skipping 1354 matching lines...) Expand 10 before | Expand all | Expand 10 after
3190 #define MAYBE_UpdatePendingExternalCrx DISABLED_UpdatePendingExternalCrx 3197 #define MAYBE_UpdatePendingExternalCrx DISABLED_UpdatePendingExternalCrx
3191 #else 3198 #else
3192 #define MAYBE_UpdatePendingExternalCrx UpdatePendingExternalCrx 3199 #define MAYBE_UpdatePendingExternalCrx UpdatePendingExternalCrx
3193 #endif 3200 #endif
3194 // Test updating a pending CRX as if the source is an external extension 3201 // Test updating a pending CRX as if the source is an external extension
3195 // with an update URL. In this case we don't know if the CRX is a theme 3202 // with an update URL. In this case we don't know if the CRX is a theme
3196 // or not. 3203 // or not.
3197 TEST_F(ExtensionServiceTest, MAYBE_UpdatePendingExternalCrx) { 3204 TEST_F(ExtensionServiceTest, MAYBE_UpdatePendingExternalCrx) {
3198 InitializeEmptyExtensionService(); 3205 InitializeEmptyExtensionService();
3199 EXPECT_TRUE(service_->pending_extension_manager()->AddFromExternalUpdateUrl( 3206 EXPECT_TRUE(service_->pending_extension_manager()->AddFromExternalUpdateUrl(
3200 theme_crx, GURL(), Manifest::EXTERNAL_PREF_DOWNLOAD, Extension::NO_FLAGS, 3207 theme_crx,
3208 std::string(),
3209 GURL(),
3210 Manifest::EXTERNAL_PREF_DOWNLOAD,
3211 Extension::NO_FLAGS,
3201 false)); 3212 false));
3202 3213
3203 EXPECT_TRUE(service_->pending_extension_manager()->IsIdPending(theme_crx)); 3214 EXPECT_TRUE(service_->pending_extension_manager()->IsIdPending(theme_crx));
3204 3215
3205 base::FilePath path = data_dir_.AppendASCII("theme.crx"); 3216 base::FilePath path = data_dir_.AppendASCII("theme.crx");
3206 UpdateExtension(theme_crx, path, ENABLED); 3217 UpdateExtension(theme_crx, path, ENABLED);
3207 3218
3208 EXPECT_FALSE(service_->pending_extension_manager()->IsIdPending(theme_crx)); 3219 EXPECT_FALSE(service_->pending_extension_manager()->IsIdPending(theme_crx));
3209 3220
3210 const Extension* extension = service_->GetExtensionById(theme_crx, true); 3221 const Extension* extension = service_->GetExtensionById(theme_crx, true);
(...skipping 18 matching lines...) Expand all
3229 kGoodInstallSilently)); 3240 kGoodInstallSilently));
3230 3241
3231 // Check that there is a pending crx, with is_from_sync set to true. 3242 // Check that there is a pending crx, with is_from_sync set to true.
3232 const extensions::PendingExtensionInfo* pending_extension_info; 3243 const extensions::PendingExtensionInfo* pending_extension_info;
3233 ASSERT_TRUE((pending_extension_info = service_->pending_extension_manager()-> 3244 ASSERT_TRUE((pending_extension_info = service_->pending_extension_manager()->
3234 GetById(kGoodId))); 3245 GetById(kGoodId)));
3235 EXPECT_TRUE(pending_extension_info->is_from_sync()); 3246 EXPECT_TRUE(pending_extension_info->is_from_sync());
3236 3247
3237 // Add a crx to be updated, with the same ID, from a non-sync source. 3248 // Add a crx to be updated, with the same ID, from a non-sync source.
3238 EXPECT_TRUE(service_->pending_extension_manager()->AddFromExternalUpdateUrl( 3249 EXPECT_TRUE(service_->pending_extension_manager()->AddFromExternalUpdateUrl(
3239 kGoodId, GURL(kGoodUpdateURL), Manifest::EXTERNAL_PREF_DOWNLOAD, 3250 kGoodId,
3240 Extension::NO_FLAGS, false)); 3251 std::string(),
3252 GURL(kGoodUpdateURL),
3253 Manifest::EXTERNAL_PREF_DOWNLOAD,
3254 Extension::NO_FLAGS,
3255 false));
3241 3256
3242 // Check that there is a pending crx, with is_from_sync set to false. 3257 // Check that there is a pending crx, with is_from_sync set to false.
3243 ASSERT_TRUE((pending_extension_info = service_->pending_extension_manager()-> 3258 ASSERT_TRUE((pending_extension_info = service_->pending_extension_manager()->
3244 GetById(kGoodId))); 3259 GetById(kGoodId)));
3245 EXPECT_FALSE(pending_extension_info->is_from_sync()); 3260 EXPECT_FALSE(pending_extension_info->is_from_sync());
3246 EXPECT_EQ(Manifest::EXTERNAL_PREF_DOWNLOAD, 3261 EXPECT_EQ(Manifest::EXTERNAL_PREF_DOWNLOAD,
3247 pending_extension_info->install_source()); 3262 pending_extension_info->install_source());
3248 3263
3249 // Add a crx to be installed from the update mechanism. 3264 // Add a crx to be installed from the update mechanism.
3250 EXPECT_FALSE(service_->pending_extension_manager()->AddFromSync( 3265 EXPECT_FALSE(service_->pending_extension_manager()->AddFromSync(
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
3317 InitializeEmptyExtensionService(); 3332 InitializeEmptyExtensionService();
3318 3333
3319 base::FilePath path = data_dir_.AppendASCII("good.crx"); 3334 base::FilePath path = data_dir_.AppendASCII("good.crx");
3320 const Extension* good = InstallCRX(path, INSTALL_NEW); 3335 const Extension* good = InstallCRX(path, INSTALL_NEW);
3321 ASSERT_EQ(1u, registry_->enabled_extensions().size()); 3336 ASSERT_EQ(1u, registry_->enabled_extensions().size());
3322 3337
3323 EXPECT_FALSE(good->is_theme()); 3338 EXPECT_FALSE(good->is_theme());
3324 3339
3325 // Use AddExtensionImpl() as AddFrom*() would balk. 3340 // Use AddExtensionImpl() as AddFrom*() would balk.
3326 service_->pending_extension_manager()->AddExtensionImpl( 3341 service_->pending_extension_manager()->AddExtensionImpl(
3327 good->id(), extensions::ManifestURL::GetUpdateURL(good), 3342 good->id(),
3328 Version(), &IsExtension, kGoodIsFromSync, 3343 std::string(),
3329 kGoodInstallSilently, Manifest::INTERNAL, 3344 extensions::ManifestURL::GetUpdateURL(good),
3330 Extension::NO_FLAGS, false); 3345 Version(),
3346 &IsExtension,
3347 kGoodIsFromSync,
3348 kGoodInstallSilently,
3349 Manifest::INTERNAL,
3350 Extension::NO_FLAGS,
3351 false);
3331 UpdateExtension(good->id(), path, ENABLED); 3352 UpdateExtension(good->id(), path, ENABLED);
3332 3353
3333 EXPECT_FALSE(service_->pending_extension_manager()->IsIdPending(kGoodId)); 3354 EXPECT_FALSE(service_->pending_extension_manager()->IsIdPending(kGoodId));
3334 } 3355 }
3335 3356
3336 #if defined(ENABLE_BLACKLIST_TESTS) 3357 #if defined(ENABLE_BLACKLIST_TESTS)
3337 // Tests blacklisting then unblacklisting extensions after the service has been 3358 // Tests blacklisting then unblacklisting extensions after the service has been
3338 // initialized. 3359 // initialized.
3339 TEST_F(ExtensionServiceTest, SetUnsetBlacklistInPrefs) { 3360 TEST_F(ExtensionServiceTest, SetUnsetBlacklistInPrefs) {
3340 extensions::TestBlacklist test_blacklist; 3361 extensions::TestBlacklist test_blacklist;
(...skipping 1680 matching lines...) Expand 10 before | Expand all | Expand 10 after
5021 "{" 5042 "{"
5022 " \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\": {" 5043 " \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\": {"
5023 " \"external_crx\": \"RandomExtension.crx\"," 5044 " \"external_crx\": \"RandomExtension.crx\","
5024 " \"external_version\": \"1.0\"" 5045 " \"external_version\": \"1.0\""
5025 " }," 5046 " },"
5026 " \"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\": {" 5047 " \"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\": {"
5027 " \"external_crx\": \"RandomExtension2.crx\"," 5048 " \"external_crx\": \"RandomExtension2.crx\","
5028 " \"external_version\": \"2.0\"" 5049 " \"external_version\": \"2.0\""
5029 " }," 5050 " },"
5030 " \"cccccccccccccccccccccccccccccccc\": {" 5051 " \"cccccccccccccccccccccccccccccccc\": {"
5031 " \"external_update_url\": \"http:\\\\foo.com/update\"" 5052 " \"external_update_url\": \"http:\\\\foo.com/update\","
5053 " \"install_parameter\": \"id\""
5032 " }" 5054 " }"
5033 "}"; 5055 "}";
5034 EXPECT_EQ(3, visitor.Visit(json_data)); 5056 EXPECT_EQ(3, visitor.Visit(json_data));
5035 5057
5036 // Simulate an external_extensions.json file that contains seven invalid 5058 // Simulate an external_extensions.json file that contains seven invalid
5037 // records: 5059 // records:
5038 // - One that is missing the 'external_crx' key. 5060 // - One that is missing the 'external_crx' key.
5039 // - One that is missing the 'external_version' key. 5061 // - One that is missing the 'external_version' key.
5040 // - One that is specifying .. in the path. 5062 // - One that is specifying .. in the path.
5041 // - One that specifies both a file and update URL. 5063 // - One that specifies both a file and update URL.
(...skipping 1168 matching lines...) Expand 10 before | Expand all | Expand 10 after
6210 InstallCRX(path, INSTALL_NEW); 6232 InstallCRX(path, INSTALL_NEW);
6211 ValidatePrefKeyCount(1u); 6233 ValidatePrefKeyCount(1u);
6212 ValidateIntegerPref(good_crx, "state", Extension::ENABLED); 6234 ValidateIntegerPref(good_crx, "state", Extension::ENABLED);
6213 ValidateIntegerPref(good_crx, "location", Manifest::INTERNAL); 6235 ValidateIntegerPref(good_crx, "location", Manifest::INTERNAL);
6214 6236
6215 extensions::PendingExtensionManager* pending = 6237 extensions::PendingExtensionManager* pending =
6216 service_->pending_extension_manager(); 6238 service_->pending_extension_manager();
6217 EXPECT_FALSE(pending->IsIdPending(kGoodId)); 6239 EXPECT_FALSE(pending->IsIdPending(kGoodId));
6218 6240
6219 // Skip install when the location is the same. 6241 // Skip install when the location is the same.
6220 EXPECT_FALSE( 6242 EXPECT_FALSE(service_->OnExternalExtensionUpdateUrlFound(kGoodId,
6221 service_->OnExternalExtensionUpdateUrlFound( 6243 std::string(),
6222 kGoodId, GURL(kGoodUpdateURL), Manifest::INTERNAL, 6244 GURL(kGoodUpdateURL),
6223 Extension::NO_FLAGS, false)); 6245 Manifest::INTERNAL,
6246 Extension::NO_FLAGS,
6247 false));
6224 EXPECT_FALSE(pending->IsIdPending(kGoodId)); 6248 EXPECT_FALSE(pending->IsIdPending(kGoodId));
6225 6249
6226 // Install when the location has higher priority. 6250 // Install when the location has higher priority.
6227 EXPECT_TRUE( 6251 EXPECT_TRUE(service_->OnExternalExtensionUpdateUrlFound(
6228 service_->OnExternalExtensionUpdateUrlFound( 6252 kGoodId,
6229 kGoodId, GURL(kGoodUpdateURL), Manifest::EXTERNAL_POLICY_DOWNLOAD, 6253 std::string(),
6230 Extension::NO_FLAGS, false)); 6254 GURL(kGoodUpdateURL),
6255 Manifest::EXTERNAL_POLICY_DOWNLOAD,
6256 Extension::NO_FLAGS,
6257 false));
6231 EXPECT_TRUE(pending->IsIdPending(kGoodId)); 6258 EXPECT_TRUE(pending->IsIdPending(kGoodId));
6232 6259
6233 // Try the low priority again. Should be rejected. 6260 // Try the low priority again. Should be rejected.
6234 EXPECT_FALSE( 6261 EXPECT_FALSE(service_->OnExternalExtensionUpdateUrlFound(
6235 service_->OnExternalExtensionUpdateUrlFound( 6262 kGoodId,
6236 kGoodId, GURL(kGoodUpdateURL), Manifest::EXTERNAL_PREF_DOWNLOAD, 6263 std::string(),
6237 Extension::NO_FLAGS, false)); 6264 GURL(kGoodUpdateURL),
6265 Manifest::EXTERNAL_PREF_DOWNLOAD,
6266 Extension::NO_FLAGS,
6267 false));
6238 // The existing record should still be present in the pending extension 6268 // The existing record should still be present in the pending extension
6239 // manager. 6269 // manager.
6240 EXPECT_TRUE(pending->IsIdPending(kGoodId)); 6270 EXPECT_TRUE(pending->IsIdPending(kGoodId));
6241 6271
6242 pending->Remove(kGoodId); 6272 pending->Remove(kGoodId);
6243 6273
6244 // Skip install when the location has the same priority as the installed 6274 // Skip install when the location has the same priority as the installed
6245 // location. 6275 // location.
6246 EXPECT_FALSE(service_->OnExternalExtensionUpdateUrlFound( 6276 EXPECT_FALSE(service_->OnExternalExtensionUpdateUrlFound(kGoodId,
6247 kGoodId, GURL(kGoodUpdateURL), Manifest::INTERNAL, 6277 std::string(),
6248 Extension::NO_FLAGS, false)); 6278 GURL(kGoodUpdateURL),
6279 Manifest::INTERNAL,
6280 Extension::NO_FLAGS,
6281 false));
6249 6282
6250 EXPECT_FALSE(pending->IsIdPending(kGoodId)); 6283 EXPECT_FALSE(pending->IsIdPending(kGoodId));
6251 } 6284 }
6252 6285
6253 TEST_F(ExtensionServiceTest, InstallPriorityExternalLocalFile) { 6286 TEST_F(ExtensionServiceTest, InstallPriorityExternalLocalFile) {
6254 Version older_version("0.1.0.0"); 6287 Version older_version("0.1.0.0");
6255 Version newer_version("2.0.0.0"); 6288 Version newer_version("2.0.0.0");
6256 6289
6257 // We don't want the extension to be installed. A path that doesn't 6290 // We don't want the extension to be installed. A path that doesn't
6258 // point to a valid CRX ensures this. 6291 // point to a valid CRX ensures this.
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
6476 EXPECT_FALSE( 6509 EXPECT_FALSE(
6477 service_->OnExternalExtensionFileFound( 6510 service_->OnExternalExtensionFileFound(
6478 kGoodId, &kVersion123, kInvalidPathToCrx, 6511 kGoodId, &kVersion123, kInvalidPathToCrx,
6479 Manifest::EXTERNAL_REGISTRY, kCreationFlags, kDontMarkAcknowledged)); 6512 Manifest::EXTERNAL_REGISTRY, kCreationFlags, kDontMarkAcknowledged));
6480 EXPECT_TRUE((info = pending->GetById(kGoodId))); 6513 EXPECT_TRUE((info = pending->GetById(kGoodId)));
6481 EXPECT_TRUE(info->version().IsValid()); 6514 EXPECT_TRUE(info->version().IsValid());
6482 EXPECT_TRUE(info->version().Equals(kVersion124)); 6515 EXPECT_TRUE(info->version().Equals(kVersion124));
6483 6516
6484 // Adding the latest version from the webstore overrides a specific version. 6517 // Adding the latest version from the webstore overrides a specific version.
6485 GURL kUpdateUrl("http://example.com/update"); 6518 GURL kUpdateUrl("http://example.com/update");
6486 EXPECT_TRUE( 6519 EXPECT_TRUE(service_->OnExternalExtensionUpdateUrlFound(
6487 service_->OnExternalExtensionUpdateUrlFound( 6520 kGoodId,
6488 kGoodId, kUpdateUrl, Manifest::EXTERNAL_POLICY_DOWNLOAD, 6521 std::string(),
6489 Extension::NO_FLAGS, false)); 6522 kUpdateUrl,
6523 Manifest::EXTERNAL_POLICY_DOWNLOAD,
6524 Extension::NO_FLAGS,
6525 false));
6490 EXPECT_TRUE((info = pending->GetById(kGoodId))); 6526 EXPECT_TRUE((info = pending->GetById(kGoodId)));
6491 EXPECT_FALSE(info->version().IsValid()); 6527 EXPECT_FALSE(info->version().IsValid());
6492 } 6528 }
6493 6529
6494 // This makes sure we can package and install CRX files that use whitelisted 6530 // This makes sure we can package and install CRX files that use whitelisted
6495 // permissions. 6531 // permissions.
6496 TEST_F(ExtensionServiceTest, InstallWhitelistedExtension) { 6532 TEST_F(ExtensionServiceTest, InstallWhitelistedExtension) {
6497 std::string test_id = "hdkklepkcpckhnpgjnmbdfhehckloojk"; 6533 std::string test_id = "hdkklepkcpckhnpgjnmbdfhehckloojk";
6498 CommandLine::ForCurrentProcess()->AppendSwitchASCII( 6534 CommandLine::ForCurrentProcess()->AppendSwitchASCII(
6499 switches::kWhitelistedExtensionID, test_id); 6535 switches::kWhitelistedExtensionID, test_id);
(...skipping 23 matching lines...) Expand all
6523 6559
6524 // All tests use a single extension. Put the id and path in member vars 6560 // All tests use a single extension. Put the id and path in member vars
6525 // that all methods can read. 6561 // that all methods can read.
6526 crx_id_ = kGoodId; 6562 crx_id_ = kGoodId;
6527 crx_path_ = data_dir_.AppendASCII("good.crx"); 6563 crx_path_ = data_dir_.AppendASCII("good.crx");
6528 } 6564 }
6529 6565
6530 // Fake an external source adding a URL to fetch an extension from. 6566 // Fake an external source adding a URL to fetch an extension from.
6531 bool AddPendingExternalPrefUrl() { 6567 bool AddPendingExternalPrefUrl() {
6532 return service_->pending_extension_manager()->AddFromExternalUpdateUrl( 6568 return service_->pending_extension_manager()->AddFromExternalUpdateUrl(
6533 crx_id_, GURL(), Manifest::EXTERNAL_PREF_DOWNLOAD, 6569 crx_id_,
6534 Extension::NO_FLAGS, false); 6570 std::string(),
6571 GURL(),
6572 Manifest::EXTERNAL_PREF_DOWNLOAD,
6573 Extension::NO_FLAGS,
6574 false);
6535 } 6575 }
6536 6576
6537 // Fake an external file from external_extensions.json. 6577 // Fake an external file from external_extensions.json.
6538 bool AddPendingExternalPrefFileInstall() { 6578 bool AddPendingExternalPrefFileInstall() {
6539 Version version("1.0.0.0"); 6579 Version version("1.0.0.0");
6540 6580
6541 return service_->OnExternalExtensionFileFound( 6581 return service_->OnExternalExtensionFileFound(
6542 crx_id_, &version, crx_path_, Manifest::EXTERNAL_PREF, 6582 crx_id_, &version, crx_path_, Manifest::EXTERNAL_PREF,
6543 Extension::NO_FLAGS, false); 6583 Extension::NO_FLAGS, false);
6544 } 6584 }
6545 6585
6546 // Fake a request from sync to install an extension. 6586 // Fake a request from sync to install an extension.
6547 bool AddPendingSyncInstall() { 6587 bool AddPendingSyncInstall() {
6548 return service_->pending_extension_manager()->AddFromSync( 6588 return service_->pending_extension_manager()->AddFromSync(
6549 crx_id_, GURL(kGoodUpdateURL), &IsExtension, kGoodInstallSilently); 6589 crx_id_, GURL(kGoodUpdateURL), &IsExtension, kGoodInstallSilently);
6550 } 6590 }
6551 6591
6552 // Fake a policy install. 6592 // Fake a policy install.
6553 bool AddPendingPolicyInstall() { 6593 bool AddPendingPolicyInstall() {
6554 // Get path to the CRX with id |kGoodId|. 6594 // Get path to the CRX with id |kGoodId|.
6555 return service_->OnExternalExtensionUpdateUrlFound( 6595 return service_->OnExternalExtensionUpdateUrlFound(
6556 crx_id_, GURL(), Manifest::EXTERNAL_POLICY_DOWNLOAD, 6596 crx_id_,
6557 Extension::NO_FLAGS, false); 6597 std::string(),
6598 GURL(),
6599 Manifest::EXTERNAL_POLICY_DOWNLOAD,
6600 Extension::NO_FLAGS,
6601 false);
6558 } 6602 }
6559 6603
6560 // Get the install source of a pending extension. 6604 // Get the install source of a pending extension.
6561 Manifest::Location GetPendingLocation() { 6605 Manifest::Location GetPendingLocation() {
6562 const extensions::PendingExtensionInfo* info; 6606 const extensions::PendingExtensionInfo* info;
6563 EXPECT_TRUE((info = service_->pending_extension_manager()-> 6607 EXPECT_TRUE((info = service_->pending_extension_manager()->
6564 GetById(crx_id_))); 6608 GetById(crx_id_)));
6565 return info->install_source(); 6609 return info->install_source();
6566 } 6610 }
6567 6611
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after
6954 // ReconcileKnownDisabled(). 6998 // ReconcileKnownDisabled().
6955 service_->EnableExtension(good2); 6999 service_->EnableExtension(good2);
6956 service_->ReconcileKnownDisabled(); 7000 service_->ReconcileKnownDisabled();
6957 expected_extensions.insert(good2); 7001 expected_extensions.insert(good2);
6958 expected_disabled_extensions.erase(good2); 7002 expected_disabled_extensions.erase(good2);
6959 7003
6960 EXPECT_EQ(expected_extensions, registry_->enabled_extensions().GetIDs()); 7004 EXPECT_EQ(expected_extensions, registry_->enabled_extensions().GetIDs());
6961 EXPECT_EQ(expected_disabled_extensions, 7005 EXPECT_EQ(expected_disabled_extensions,
6962 registry_->disabled_extensions().GetIDs()); 7006 registry_->disabled_extensions().GetIDs());
6963 } 7007 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_service.cc ('k') | chrome/browser/extensions/external_policy_loader_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698