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

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

Issue 12546016: Remove the Extensions URLRequestContext (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Change Cookie Override API to not expose the CookieStoreMap. Created 7 years, 4 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
11 #include "base/at_exit.h" 11 #include "base/at_exit.h"
12 #include "base/basictypes.h" 12 #include "base/basictypes.h"
13 #include "base/bind.h" 13 #include "base/bind.h"
14 #include "base/command_line.h" 14 #include "base/command_line.h"
15 #include "base/file_util.h" 15 #include "base/file_util.h"
16 #include "base/files/file_enumerator.h" 16 #include "base/files/file_enumerator.h"
17 #include "base/files/scoped_temp_dir.h" 17 #include "base/files/scoped_temp_dir.h"
18 #include "base/json/json_file_value_serializer.h" 18 #include "base/json/json_file_value_serializer.h"
19 #include "base/json/json_reader.h" 19 #include "base/json/json_reader.h"
20 #include "base/json/json_string_value_serializer.h" 20 #include "base/json/json_string_value_serializer.h"
21 #include "base/memory/scoped_ptr.h" 21 #include "base/memory/scoped_ptr.h"
22 #include "base/memory/weak_ptr.h" 22 #include "base/memory/weak_ptr.h"
23 #include "base/message_loop/message_loop.h" 23 #include "base/message_loop/message_loop.h"
24 #include "base/path_service.h" 24 #include "base/path_service.h"
25 #include "base/run_loop.h"
25 #include "base/stl_util.h" 26 #include "base/stl_util.h"
26 #include "base/strings/string16.h" 27 #include "base/strings/string16.h"
27 #include "base/strings/string_number_conversions.h" 28 #include "base/strings/string_number_conversions.h"
28 #include "base/strings/string_util.h" 29 #include "base/strings/string_util.h"
29 #include "base/strings/utf_string_conversions.h" 30 #include "base/strings/utf_string_conversions.h"
30 #include "base/version.h" 31 #include "base/version.h"
31 #include "chrome/browser/browser_process.h" 32 #include "chrome/browser/browser_process.h"
32 #include "chrome/browser/chrome_notification_types.h" 33 #include "chrome/browser/chrome_notification_types.h"
33 #include "chrome/browser/extensions/app_sync_data.h" 34 #include "chrome/browser/extensions/app_sync_data.h"
34 #include "chrome/browser/extensions/component_loader.h" 35 #include "chrome/browser/extensions/component_loader.h"
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 #include "chrome/common/extensions/extension_manifest_constants.h" 76 #include "chrome/common/extensions/extension_manifest_constants.h"
76 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h" 77 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h"
77 #include "chrome/common/extensions/manifest_handlers/content_scripts_handler.h" 78 #include "chrome/common/extensions/manifest_handlers/content_scripts_handler.h"
78 #include "chrome/common/extensions/manifest_url_handler.h" 79 #include "chrome/common/extensions/manifest_url_handler.h"
79 #include "chrome/common/extensions/permissions/permission_set.h" 80 #include "chrome/common/extensions/permissions/permission_set.h"
80 #include "chrome/common/extensions/value_builder.h" 81 #include "chrome/common/extensions/value_builder.h"
81 #include "chrome/common/pref_names.h" 82 #include "chrome/common/pref_names.h"
82 #include "chrome/common/url_constants.h" 83 #include "chrome/common/url_constants.h"
83 #include "chrome/test/base/testing_profile.h" 84 #include "chrome/test/base/testing_profile.h"
84 #include "components/user_prefs/pref_registry_syncable.h" 85 #include "components/user_prefs/pref_registry_syncable.h"
86 #include "content/public/browser/cookie_store_map.h"
85 #include "content/public/browser/dom_storage_context.h" 87 #include "content/public/browser/dom_storage_context.h"
86 #include "content/public/browser/gpu_data_manager.h" 88 #include "content/public/browser/gpu_data_manager.h"
87 #include "content/public/browser/indexed_db_context.h" 89 #include "content/public/browser/indexed_db_context.h"
88 #include "content/public/browser/notification_registrar.h" 90 #include "content/public/browser/notification_registrar.h"
89 #include "content/public/browser/notification_service.h" 91 #include "content/public/browser/notification_service.h"
90 #include "content/public/browser/plugin_service.h" 92 #include "content/public/browser/plugin_service.h"
91 #include "content/public/browser/render_process_host.h" 93 #include "content/public/browser/render_process_host.h"
92 #include "content/public/browser/storage_partition.h" 94 #include "content/public/browser/storage_partition.h"
93 #include "content/public/common/content_constants.h" 95 #include "content/public/common/content_constants.h"
94 #include "content/public/test/test_browser_thread.h"
95 #include "content/public/test/test_utils.h" 96 #include "content/public/test/test_utils.h"
96 #include "extensions/common/constants.h" 97 #include "extensions/common/constants.h"
97 #include "extensions/common/extension_resource.h" 98 #include "extensions/common/extension_resource.h"
98 #include "extensions/common/url_pattern.h" 99 #include "extensions/common/url_pattern.h"
99 #include "gpu/config/gpu_info.h" 100 #include "gpu/config/gpu_info.h"
100 #include "grit/browser_resources.h" 101 #include "grit/browser_resources.h"
101 #include "net/cookies/canonical_cookie.h" 102 #include "net/cookies/canonical_cookie.h"
102 #include "net/cookies/cookie_monster.h" 103 #include "net/cookies/cookie_monster.h"
103 #include "net/cookies/cookie_options.h" 104 #include "net/cookies/cookie_options.h"
104 #include "net/url_request/url_request_context.h" 105 #include "net/url_request/url_request_context.h"
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after
433 DISALLOW_COPY_AND_ASSIGN(MockProviderVisitor); 434 DISALLOW_COPY_AND_ASSIGN(MockProviderVisitor);
434 }; 435 };
435 436
436 ExtensionServiceTestBase::ExtensionServiceInitParams:: 437 ExtensionServiceTestBase::ExtensionServiceInitParams::
437 ExtensionServiceInitParams() 438 ExtensionServiceInitParams()
438 : autoupdate_enabled(false), is_first_run(true) { 439 : autoupdate_enabled(false), is_first_run(true) {
439 } 440 }
440 441
441 // Our message loop may be used in tests which require it to be an IO loop. 442 // Our message loop may be used in tests which require it to be an IO loop.
442 ExtensionServiceTestBase::ExtensionServiceTestBase() 443 ExtensionServiceTestBase::ExtensionServiceTestBase()
443 : loop_(base::MessageLoop::TYPE_IO), 444 : thread_bundle_(content::TestBrowserThreadBundle::IO_MAINLOOP),
444 service_(NULL), 445 service_(NULL),
445 management_policy_(NULL), 446 management_policy_(NULL),
446 expected_extensions_count_(0), 447 expected_extensions_count_(0) {
447 ui_thread_(BrowserThread::UI, &loop_),
448 db_thread_(BrowserThread::DB, &loop_),
449 file_thread_(BrowserThread::FILE, &loop_),
450 file_user_blocking_thread_(BrowserThread::FILE_USER_BLOCKING, &loop_),
451 io_thread_(BrowserThread::IO, &loop_) {
452 base::FilePath test_data_dir; 448 base::FilePath test_data_dir;
453 if (!PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir)) { 449 if (!PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir)) {
454 ADD_FAILURE(); 450 ADD_FAILURE();
455 return; 451 return;
456 } 452 }
457 data_dir_ = test_data_dir.AppendASCII("extensions"); 453 data_dir_ = test_data_dir.AppendASCII("extensions");
458 } 454 }
459 455
460 ExtensionServiceTestBase::~ExtensionServiceTestBase() { 456 ExtensionServiceTestBase::~ExtensionServiceTestBase() {
461 // Drop our reference to ExtensionService and TestingProfile, so that they 457 // Drop our reference to ExtensionService and TestingProfile, so that they
462 // can be destroyed while BrowserThreads and MessageLoop are still around 458 // can be destroyed while BrowserThreads and MessageLoop are still around
463 // (they are used in the destruction process). 459 // (they are used in the destruction process).
464 service_ = NULL; 460 service_ = NULL;
465 base::MessageLoop::current()->RunUntilIdle(); 461 base::MessageLoop::current()->RunUntilIdle();
466 profile_.reset(NULL); 462 profile_.reset(NULL);
467 base::MessageLoop::current()->RunUntilIdle(); 463 base::MessageLoop::current()->RunUntilIdle();
468 } 464 }
469 465
470 void ExtensionServiceTestBase::InitializeExtensionService( 466 void ExtensionServiceTestBase::InitializeExtensionService(
471 const ExtensionServiceTestBase::ExtensionServiceInitParams& params) { 467 const ExtensionServiceTestBase::ExtensionServiceInitParams& params) {
472 TestingProfile::Builder profile_builder; 468 TestingProfile::Builder profile_builder;
473 // Create a PrefService that only contains user defined preference values. 469 // Create a PrefService that only contains user defined preference values.
474 PrefServiceMockBuilder builder; 470 PrefServiceMockBuilder builder;
475 // If pref_file is empty, TestingProfile automatically creates 471 // If pref_file is empty, TestingProfile automatically creates
476 // TestingPrefServiceSyncable instance. 472 // TestingPrefServiceSyncable instance.
477 if (!params.pref_file.empty()) { 473 if (!params.pref_file.empty()) {
478 builder.WithUserFilePrefs(params.pref_file, 474 builder.WithUserFilePrefs(
479 loop_.message_loop_proxy().get()); 475 params.pref_file,
476 base::MessageLoop::current()->message_loop_proxy().get());
480 scoped_refptr<user_prefs::PrefRegistrySyncable> registry( 477 scoped_refptr<user_prefs::PrefRegistrySyncable> registry(
481 new user_prefs::PrefRegistrySyncable); 478 new user_prefs::PrefRegistrySyncable);
482 scoped_ptr<PrefServiceSyncable> prefs( 479 scoped_ptr<PrefServiceSyncable> prefs(
483 builder.CreateSyncable(registry.get())); 480 builder.CreateSyncable(registry.get()));
484 chrome::RegisterUserProfilePrefs(registry.get()); 481 chrome::RegisterUserProfilePrefs(registry.get());
485 profile_builder.SetPrefService(prefs.Pass()); 482 profile_builder.SetPrefService(prefs.Pass());
486 } 483 }
487 profile_builder.SetPath(params.profile_path); 484 profile_builder.SetPath(params.profile_path);
488 profile_ = profile_builder.Build(); 485 profile_ = profile_builder.Build();
489 486
490 TestExtensionSystem* system = static_cast<TestExtensionSystem*>( 487 TestExtensionSystem* system = static_cast<TestExtensionSystem*>(
491 ExtensionSystem::Get(profile_.get())); 488 ExtensionSystem::Get(profile_.get()));
492 if (!params.is_first_run) { 489 if (!params.is_first_run) {
493 ExtensionPrefs* prefs = system->CreateExtensionPrefs( 490 ExtensionPrefs* prefs = system->CreateExtensionPrefs(
494 CommandLine::ForCurrentProcess(), 491 CommandLine::ForCurrentProcess(),
495 params.extensions_install_dir); 492 params.extensions_install_dir);
496 prefs->SetAlertSystemFirstRun(); 493 prefs->SetAlertSystemFirstRun();
497 } 494 }
498 495
499 service_ = system->CreateExtensionService( 496 service_ = system->CreateExtensionService(
500 CommandLine::ForCurrentProcess(), 497 CommandLine::ForCurrentProcess(),
501 params.extensions_install_dir, 498 params.extensions_install_dir,
502 params.autoupdate_enabled); 499 params.autoupdate_enabled);
503 service_->SetFileTaskRunnerForTesting(loop_.message_loop_proxy().get()); 500 service_->SetFileTaskRunnerForTesting(
501 base::MessageLoop::current()->message_loop_proxy().get());
504 service_->set_extensions_enabled(true); 502 service_->set_extensions_enabled(true);
505 service_->set_show_extensions_prompts(false); 503 service_->set_show_extensions_prompts(false);
506 service_->set_install_updates_when_idle_for_test(false); 504 service_->set_install_updates_when_idle_for_test(false);
507 505
508 management_policy_ = 506 management_policy_ =
509 ExtensionSystem::Get(profile_.get())->management_policy(); 507 ExtensionSystem::Get(profile_.get())->management_policy();
510 508
511 // When we start up, we want to make sure there is no external provider, 509 // When we start up, we want to make sure there is no external provider,
512 // since the ExtensionService on Windows will use the Registry as a default 510 // since the ExtensionService on Windows will use the Registry as a default
513 // provider and if there is something already registered there then it will 511 // provider and if there is something already registered there then it will
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
687 ASSERT_TRUE(creator->Run(dir_path, 685 ASSERT_TRUE(creator->Run(dir_path,
688 crx_path, 686 crx_path,
689 pem_path, 687 pem_path,
690 pem_output_path, 688 pem_output_path,
691 ExtensionCreator::kOverwriteCRX)); 689 ExtensionCreator::kOverwriteCRX));
692 690
693 ASSERT_TRUE(base::PathExists(crx_path)); 691 ASSERT_TRUE(base::PathExists(crx_path));
694 } 692 }
695 693
696 // Create a CrxInstaller and start installation. To allow the install 694 // Create a CrxInstaller and start installation. To allow the install
697 // to happen, use loop_.RunUntilIdle();. Most tests will not use this 695 // to happen, use base::RunLoop().RunUntilIdle();. Most tests will not use
698 // method directly. Instead, use InstallCrx(), which waits for 696 // this method directly. Instead, use InstallCrx(), which waits for
699 // the crx to be installed and does extra error checking. 697 // the crx to be installed and does extra error checking.
700 void StartCRXInstall(const base::FilePath& crx_path) { 698 void StartCRXInstall(const base::FilePath& crx_path) {
701 StartCRXInstall(crx_path, Extension::NO_FLAGS); 699 StartCRXInstall(crx_path, Extension::NO_FLAGS);
702 } 700 }
703 701
704 void StartCRXInstall(const base::FilePath& crx_path, int creation_flags) { 702 void StartCRXInstall(const base::FilePath& crx_path, int creation_flags) {
705 ASSERT_TRUE(base::PathExists(crx_path)) 703 ASSERT_TRUE(base::PathExists(crx_path))
706 << "Path does not exist: "<< crx_path.value().c_str(); 704 << "Path does not exist: "<< crx_path.value().c_str();
707 scoped_refptr<CrxInstaller> installer(CrxInstaller::Create(service_, NULL)); 705 scoped_refptr<CrxInstaller> installer(CrxInstaller::Create(service_, NULL));
708 installer->set_creation_flags(creation_flags); 706 installer->set_creation_flags(creation_flags);
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
904 service_->disabled_extensions()->size(); 902 service_->disabled_extensions()->size();
905 903
906 extensions::CrxInstaller* installer = NULL; 904 extensions::CrxInstaller* installer = NULL;
907 service_->UpdateExtension(id, path, GURL(), &installer); 905 service_->UpdateExtension(id, path, GURL(), &installer);
908 906
909 if (installer) { 907 if (installer) {
910 content::WindowedNotificationObserver( 908 content::WindowedNotificationObserver(
911 chrome::NOTIFICATION_CRX_INSTALLER_DONE, 909 chrome::NOTIFICATION_CRX_INSTALLER_DONE,
912 content::Source<extensions::CrxInstaller>(installer)).Wait(); 910 content::Source<extensions::CrxInstaller>(installer)).Wait();
913 } else { 911 } else {
914 loop_.RunUntilIdle(); 912 base::RunLoop().RunUntilIdle();
915 } 913 }
916 914
917 std::vector<string16> errors = GetErrors(); 915 std::vector<string16> errors = GetErrors();
918 int error_count = errors.size(); 916 int error_count = errors.size();
919 int enabled_extension_count = 917 int enabled_extension_count =
920 service_->extensions()->size(); 918 service_->extensions()->size();
921 int installed_extension_count = 919 int installed_extension_count =
922 enabled_extension_count + service_->disabled_extensions()->size(); 920 enabled_extension_count + service_->disabled_extensions()->size();
923 921
924 int expected_error_count = (expected_state == FAILED) ? 1 : 0; 922 int expected_error_count = (expected_state == FAILED) ? 1 : 0;
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
987 size_t new_pref_key_count = GetPrefKeyCount(); 985 size_t new_pref_key_count = GetPrefKeyCount();
988 if (new_pref_key_count == pref_key_count) { 986 if (new_pref_key_count == pref_key_count) {
989 ValidateIntegerPref(id, "location", 987 ValidateIntegerPref(id, "location",
990 Extension::EXTERNAL_EXTENSION_UNINSTALLED); 988 Extension::EXTERNAL_EXTENSION_UNINSTALLED);
991 } else { 989 } else {
992 EXPECT_EQ(new_pref_key_count, pref_key_count - 1); 990 EXPECT_EQ(new_pref_key_count, pref_key_count - 1);
993 } 991 }
994 992
995 // The extension should not be in the service anymore. 993 // The extension should not be in the service anymore.
996 EXPECT_FALSE(service_->GetInstalledExtension(id)); 994 EXPECT_FALSE(service_->GetInstalledExtension(id));
997 loop_.RunUntilIdle(); 995 base::RunLoop().RunUntilIdle();
998 996
999 // The directory should be gone. 997 // The directory should be gone.
1000 EXPECT_FALSE(base::PathExists(extension_path)); 998 EXPECT_FALSE(base::PathExists(extension_path));
1001 } 999 }
1002 1000
1003 void ValidatePrefKeyCount(size_t count) { 1001 void ValidatePrefKeyCount(size_t count) {
1004 EXPECT_EQ(count, GetPrefKeyCount()); 1002 EXPECT_EQ(count, GetPrefKeyCount());
1005 } 1003 }
1006 1004
1007 void ValidateBooleanPref(const std::string& extension_id, 1005 void ValidateBooleanPref(const std::string& extension_id,
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after
1392 ASSERT_TRUE(dict != NULL); 1390 ASSERT_TRUE(dict != NULL);
1393 dict->Remove("behllobkkfkfnphdnhnkndlbkcpglgmj", NULL); 1391 dict->Remove("behllobkkfkfnphdnhnkndlbkcpglgmj", NULL);
1394 } 1392 }
1395 1393
1396 service_->Init(); 1394 service_->Init();
1397 // A delayed task to call GarbageCollectExtensions is posted by 1395 // A delayed task to call GarbageCollectExtensions is posted by
1398 // ExtensionService::Init. As the test won't wait for the delayed task to 1396 // ExtensionService::Init. As the test won't wait for the delayed task to
1399 // be called, call it manually instead. 1397 // be called, call it manually instead.
1400 service_->GarbageCollectExtensions(); 1398 service_->GarbageCollectExtensions();
1401 // Wait for GarbageCollectExtensions task to complete. 1399 // Wait for GarbageCollectExtensions task to complete.
1402 loop_.RunUntilIdle(); 1400 base::RunLoop().RunUntilIdle();
1403 1401
1404 base::FileEnumerator dirs(extensions_install_dir_, false, 1402 base::FileEnumerator dirs(extensions_install_dir_, false,
1405 base::FileEnumerator::DIRECTORIES); 1403 base::FileEnumerator::DIRECTORIES);
1406 size_t count = 0; 1404 size_t count = 0;
1407 while (!dirs.Next().empty()) 1405 while (!dirs.Next().empty())
1408 count++; 1406 count++;
1409 1407
1410 // We should have only gotten two extensions now. 1408 // We should have only gotten two extensions now.
1411 EXPECT_EQ(2u, count); 1409 EXPECT_EQ(2u, count);
1412 1410
(...skipping 17 matching lines...) Expand all
1430 1428
1431 InitializeInstalledExtensionService(pref_path, source_install_dir); 1429 InitializeInstalledExtensionService(pref_path, source_install_dir);
1432 1430
1433 // This is the directory that is going to be deleted, so make sure it actually 1431 // This is the directory that is going to be deleted, so make sure it actually
1434 // is there before the garbage collection. 1432 // is there before the garbage collection.
1435 ASSERT_TRUE(base::PathExists(extensions_install_dir_.AppendASCII( 1433 ASSERT_TRUE(base::PathExists(extensions_install_dir_.AppendASCII(
1436 "hpiknbiabeeppbpihjehijgoemciehgk/3"))); 1434 "hpiknbiabeeppbpihjehijgoemciehgk/3")));
1437 1435
1438 service_->GarbageCollectExtensions(); 1436 service_->GarbageCollectExtensions();
1439 // Wait for GarbageCollectExtensions task to complete. 1437 // Wait for GarbageCollectExtensions task to complete.
1440 loop_.RunUntilIdle(); 1438 base::RunLoop().RunUntilIdle();
1441 1439
1442 // Verify that the pending update for the first extension didn't get 1440 // Verify that the pending update for the first extension didn't get
1443 // deleted. 1441 // deleted.
1444 EXPECT_TRUE(base::PathExists(extensions_install_dir_.AppendASCII( 1442 EXPECT_TRUE(base::PathExists(extensions_install_dir_.AppendASCII(
1445 "bjafgdebaacbbbecmhlhpofkepfkgcpa/1.0"))); 1443 "bjafgdebaacbbbecmhlhpofkepfkgcpa/1.0")));
1446 EXPECT_TRUE(base::PathExists(extensions_install_dir_.AppendASCII( 1444 EXPECT_TRUE(base::PathExists(extensions_install_dir_.AppendASCII(
1447 "bjafgdebaacbbbecmhlhpofkepfkgcpa/2.0"))); 1445 "bjafgdebaacbbbecmhlhpofkepfkgcpa/2.0")));
1448 EXPECT_TRUE(base::PathExists(extensions_install_dir_.AppendASCII( 1446 EXPECT_TRUE(base::PathExists(extensions_install_dir_.AppendASCII(
1449 "hpiknbiabeeppbpihjehijgoemciehgk/2"))); 1447 "hpiknbiabeeppbpihjehijgoemciehgk/2")));
1450 EXPECT_FALSE(base::PathExists(extensions_install_dir_.AppendASCII( 1448 EXPECT_FALSE(base::PathExists(extensions_install_dir_.AppendASCII(
(...skipping 17 matching lines...) Expand all
1468 // is there before the garbage collection. 1466 // is there before the garbage collection.
1469 ASSERT_TRUE(base::PathExists(extensions_install_dir_.AppendASCII( 1467 ASSERT_TRUE(base::PathExists(extensions_install_dir_.AppendASCII(
1470 "hpiknbiabeeppbpihjehijgoemciehgk/3"))); 1468 "hpiknbiabeeppbpihjehijgoemciehgk/3")));
1471 1469
1472 service_->Init(); 1470 service_->Init();
1473 // A delayed task to call GarbageCollectExtensions is posted by 1471 // A delayed task to call GarbageCollectExtensions is posted by
1474 // ExtensionService::Init. As the test won't wait for the delayed task to 1472 // ExtensionService::Init. As the test won't wait for the delayed task to
1475 // be called, call it manually instead. 1473 // be called, call it manually instead.
1476 service_->GarbageCollectExtensions(); 1474 service_->GarbageCollectExtensions();
1477 // Wait for GarbageCollectExtensions task to complete. 1475 // Wait for GarbageCollectExtensions task to complete.
1478 loop_.RunUntilIdle(); 1476 base::RunLoop().RunUntilIdle();
1479 1477
1480 // Verify that the pending update for the first extension got installed. 1478 // Verify that the pending update for the first extension got installed.
1481 EXPECT_FALSE(base::PathExists(extensions_install_dir_.AppendASCII( 1479 EXPECT_FALSE(base::PathExists(extensions_install_dir_.AppendASCII(
1482 "bjafgdebaacbbbecmhlhpofkepfkgcpa/1.0"))); 1480 "bjafgdebaacbbbecmhlhpofkepfkgcpa/1.0")));
1483 EXPECT_TRUE(base::PathExists(extensions_install_dir_.AppendASCII( 1481 EXPECT_TRUE(base::PathExists(extensions_install_dir_.AppendASCII(
1484 "bjafgdebaacbbbecmhlhpofkepfkgcpa/2.0"))); 1482 "bjafgdebaacbbbecmhlhpofkepfkgcpa/2.0")));
1485 EXPECT_TRUE(base::PathExists(extensions_install_dir_.AppendASCII( 1483 EXPECT_TRUE(base::PathExists(extensions_install_dir_.AppendASCII(
1486 "hpiknbiabeeppbpihjehijgoemciehgk/2"))); 1484 "hpiknbiabeeppbpihjehijgoemciehgk/2")));
1487 EXPECT_FALSE(base::PathExists(extensions_install_dir_.AppendASCII( 1485 EXPECT_FALSE(base::PathExists(extensions_install_dir_.AppendASCII(
1488 "hpiknbiabeeppbpihjehijgoemciehgk/3"))); 1486 "hpiknbiabeeppbpihjehijgoemciehgk/3")));
(...skipping 15 matching lines...) Expand all
1504 .DirName() 1502 .DirName()
1505 .AppendASCII("Preferences"); 1503 .AppendASCII("Preferences");
1506 1504
1507 InitializeInstalledExtensionService(pref_path, source_install_dir); 1505 InitializeInstalledExtensionService(pref_path, source_install_dir);
1508 1506
1509 // Verify there are no pending extensions initially. 1507 // Verify there are no pending extensions initially.
1510 EXPECT_FALSE(service_->pending_extension_manager()->HasPendingExtensions()); 1508 EXPECT_FALSE(service_->pending_extension_manager()->HasPendingExtensions());
1511 1509
1512 service_->Init(); 1510 service_->Init();
1513 // Wait for GarbageCollectExtensions task to complete. 1511 // Wait for GarbageCollectExtensions task to complete.
1514 loop_.RunUntilIdle(); 1512 base::RunLoop().RunUntilIdle();
1515 1513
1516 // These extensions are used by the extensions we test below, they must be 1514 // These extensions are used by the extensions we test below, they must be
1517 // installed. 1515 // installed.
1518 EXPECT_TRUE(base::PathExists(extensions_install_dir_.AppendASCII( 1516 EXPECT_TRUE(base::PathExists(extensions_install_dir_.AppendASCII(
1519 "bjafgdebaacbbbecmhlhpofkepfkgcpa/1.0"))); 1517 "bjafgdebaacbbbecmhlhpofkepfkgcpa/1.0")));
1520 EXPECT_TRUE(base::PathExists(extensions_install_dir_.AppendASCII( 1518 EXPECT_TRUE(base::PathExists(extensions_install_dir_.AppendASCII(
1521 "hpiknbiabeeppbpihjehijgoemciehgk/2"))); 1519 "hpiknbiabeeppbpihjehijgoemciehgk/2")));
1522 1520
1523 // Each of these extensions should have been rejected because of dependencies 1521 // Each of these extensions should have been rejected because of dependencies
1524 // that cannot be satisfied. 1522 // that cannot be satisfied.
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
1744 1742
1745 // Uninstall it and check that its killbit gets set. 1743 // Uninstall it and check that its killbit gets set.
1746 UninstallExtension(good_crx, false); 1744 UninstallExtension(good_crx, false);
1747 ValidateIntegerPref(good_crx, "location", 1745 ValidateIntegerPref(good_crx, "location",
1748 Extension::EXTERNAL_EXTENSION_UNINSTALLED); 1746 Extension::EXTERNAL_EXTENSION_UNINSTALLED);
1749 1747
1750 // Try to re-install it externally. This should fail because of the killbit. 1748 // Try to re-install it externally. This should fail because of the killbit.
1751 service_->OnExternalExtensionFileFound(good_crx, &version, 1749 service_->OnExternalExtensionFileFound(good_crx, &version,
1752 path, Manifest::EXTERNAL_PREF, 1750 path, Manifest::EXTERNAL_PREF,
1753 Extension::NO_FLAGS, false); 1751 Extension::NO_FLAGS, false);
1754 loop_.RunUntilIdle(); 1752 base::RunLoop().RunUntilIdle();
1755 ASSERT_TRUE(NULL == service_->GetExtensionById(good_crx, false)); 1753 ASSERT_TRUE(NULL == service_->GetExtensionById(good_crx, false));
1756 ValidateIntegerPref(good_crx, "location", 1754 ValidateIntegerPref(good_crx, "location",
1757 Extension::EXTERNAL_EXTENSION_UNINSTALLED); 1755 Extension::EXTERNAL_EXTENSION_UNINSTALLED);
1758 1756
1759 version = Version("1.0.0.1"); 1757 version = Version("1.0.0.1");
1760 // Repeat the same thing with a newer version of the extension. 1758 // Repeat the same thing with a newer version of the extension.
1761 path = data_dir_.AppendASCII("good2.crx"); 1759 path = data_dir_.AppendASCII("good2.crx");
1762 service_->OnExternalExtensionFileFound(good_crx, &version, 1760 service_->OnExternalExtensionFileFound(good_crx, &version,
1763 path, Manifest::EXTERNAL_PREF, 1761 path, Manifest::EXTERNAL_PREF,
1764 Extension::NO_FLAGS, false); 1762 Extension::NO_FLAGS, false);
1765 loop_.RunUntilIdle(); 1763 base::RunLoop().RunUntilIdle();
1766 ASSERT_TRUE(NULL == service_->GetExtensionById(good_crx, false)); 1764 ASSERT_TRUE(NULL == service_->GetExtensionById(good_crx, false));
1767 ValidateIntegerPref(good_crx, "location", 1765 ValidateIntegerPref(good_crx, "location",
1768 Extension::EXTERNAL_EXTENSION_UNINSTALLED); 1766 Extension::EXTERNAL_EXTENSION_UNINSTALLED);
1769 1767
1770 // Try adding the same extension from an external update URL. 1768 // Try adding the same extension from an external update URL.
1771 ASSERT_FALSE(service_->pending_extension_manager()->AddFromExternalUpdateUrl( 1769 ASSERT_FALSE(service_->pending_extension_manager()->AddFromExternalUpdateUrl(
1772 good_crx, 1770 good_crx,
1773 GURL("http:://fake.update/url"), 1771 GURL("http:://fake.update/url"),
1774 Manifest::EXTERNAL_PREF_DOWNLOAD)); 1772 Manifest::EXTERNAL_PREF_DOWNLOAD));
1775 1773
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
1878 base::FilePath path = data_dir_ 1876 base::FilePath path = data_dir_
1879 .AppendASCII("user_script_basic.user.js"); 1877 .AppendASCII("user_script_basic.user.js");
1880 1878
1881 ASSERT_TRUE(base::PathExists(path)); 1879 ASSERT_TRUE(base::PathExists(path));
1882 scoped_refptr<CrxInstaller> installer(CrxInstaller::Create(service_, NULL)); 1880 scoped_refptr<CrxInstaller> installer(CrxInstaller::Create(service_, NULL));
1883 installer->set_allow_silent_install(true); 1881 installer->set_allow_silent_install(true);
1884 installer->InstallUserScript( 1882 installer->InstallUserScript(
1885 path, 1883 path,
1886 GURL("http://www.aaronboodman.com/scripts/user_script_basic.user.js")); 1884 GURL("http://www.aaronboodman.com/scripts/user_script_basic.user.js"));
1887 1885
1888 loop_.RunUntilIdle(); 1886 base::RunLoop().RunUntilIdle();
1889 std::vector<string16> errors = GetErrors(); 1887 std::vector<string16> errors = GetErrors();
1890 EXPECT_TRUE(installed_) << "Nothing was installed."; 1888 EXPECT_TRUE(installed_) << "Nothing was installed.";
1891 EXPECT_FALSE(was_update_) << path.value(); 1889 EXPECT_FALSE(was_update_) << path.value();
1892 ASSERT_EQ(1u, loaded_.size()) << "Nothing was loaded."; 1890 ASSERT_EQ(1u, loaded_.size()) << "Nothing was loaded.";
1893 EXPECT_EQ(0u, errors.size()) << "There were errors: " 1891 EXPECT_EQ(0u, errors.size()) << "There were errors: "
1894 << JoinString(errors, ','); 1892 << JoinString(errors, ',');
1895 EXPECT_TRUE(service_->GetExtensionById(loaded_[0]->id(), false)) << 1893 EXPECT_TRUE(service_->GetExtensionById(loaded_[0]->id(), false)) <<
1896 path.value(); 1894 path.value();
1897 1895
1898 installed_ = NULL; 1896 installed_ = NULL;
1899 was_update_ = false; 1897 was_update_ = false;
1900 loaded_.clear(); 1898 loaded_.clear();
1901 ExtensionErrorReporter::GetInstance()->ClearErrors(); 1899 ExtensionErrorReporter::GetInstance()->ClearErrors();
1902 } 1900 }
1903 1901
1904 // Extensions don't install during shutdown. 1902 // Extensions don't install during shutdown.
1905 TEST_F(ExtensionServiceTest, InstallExtensionDuringShutdown) { 1903 TEST_F(ExtensionServiceTest, InstallExtensionDuringShutdown) {
1906 InitializeEmptyExtensionService(); 1904 InitializeEmptyExtensionService();
1907 1905
1908 // Simulate shutdown. 1906 // Simulate shutdown.
1909 service_->set_browser_terminating_for_test(true); 1907 service_->set_browser_terminating_for_test(true);
1910 1908
1911 base::FilePath path = data_dir_.AppendASCII("good.crx"); 1909 base::FilePath path = data_dir_.AppendASCII("good.crx");
1912 scoped_refptr<CrxInstaller> installer(CrxInstaller::Create(service_, NULL)); 1910 scoped_refptr<CrxInstaller> installer(CrxInstaller::Create(service_, NULL));
1913 installer->set_allow_silent_install(true); 1911 installer->set_allow_silent_install(true);
1914 installer->InstallCrx(path); 1912 installer->InstallCrx(path);
1915 loop_.RunUntilIdle(); 1913 base::RunLoop().RunUntilIdle();
1916 1914
1917 EXPECT_FALSE(installed_) << "Extension installed during shutdown."; 1915 EXPECT_FALSE(installed_) << "Extension installed during shutdown.";
1918 ASSERT_EQ(0u, loaded_.size()) << "Extension loaded during shutdown."; 1916 ASSERT_EQ(0u, loaded_.size()) << "Extension loaded during shutdown.";
1919 } 1917 }
1920 1918
1921 // This tests that the granted permissions preferences are correctly set when 1919 // This tests that the granted permissions preferences are correctly set when
1922 // installing an extension. 1920 // installing an extension.
1923 TEST_F(ExtensionServiceTest, GrantedPermissions) { 1921 TEST_F(ExtensionServiceTest, GrantedPermissions) {
1924 InitializeEmptyExtensionService(); 1922 InitializeEmptyExtensionService();
1925 base::FilePath path = data_dir_ 1923 base::FilePath path = data_dir_
(...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after
2395 ValidatePrefKeyCount(pref_count); 2393 ValidatePrefKeyCount(pref_count);
2396 } 2394 }
2397 2395
2398 TEST_F(ExtensionServiceTest, LoadLocalizedTheme) { 2396 TEST_F(ExtensionServiceTest, LoadLocalizedTheme) {
2399 // Load. 2397 // Load.
2400 InitializeEmptyExtensionService(); 2398 InitializeEmptyExtensionService();
2401 base::FilePath extension_path = data_dir_ 2399 base::FilePath extension_path = data_dir_
2402 .AppendASCII("theme_i18n"); 2400 .AppendASCII("theme_i18n");
2403 2401
2404 extensions::UnpackedInstaller::Create(service_)->Load(extension_path); 2402 extensions::UnpackedInstaller::Create(service_)->Load(extension_path);
2405 loop_.RunUntilIdle(); 2403 base::RunLoop().RunUntilIdle();
2406 EXPECT_EQ(0u, GetErrors().size()); 2404 EXPECT_EQ(0u, GetErrors().size());
2407 ASSERT_EQ(1u, loaded_.size()); 2405 ASSERT_EQ(1u, loaded_.size());
2408 EXPECT_EQ(1u, service_->extensions()->size()); 2406 EXPECT_EQ(1u, service_->extensions()->size());
2409 const Extension* theme = service_->extensions()->begin()->get(); 2407 const Extension* theme = service_->extensions()->begin()->get();
2410 EXPECT_EQ("name", theme->name()); 2408 EXPECT_EQ("name", theme->name());
2411 EXPECT_EQ("description", theme->description()); 2409 EXPECT_EQ("description", theme->description());
2412 2410
2413 // Cleanup the "Cached Theme.pak" file. Ideally, this would be installed in a 2411 // Cleanup the "Cached Theme.pak" file. Ideally, this would be installed in a
2414 // temporary directory, but it automatically installs to the extension's 2412 // temporary directory, but it automatically installs to the extension's
2415 // directory, and we don't want to copy the whole extension for a unittest. 2413 // directory, and we don't want to copy the whole extension for a unittest.
(...skipping 21 matching lines...) Expand all
2437 AppendASCII("unpacked"). 2435 AppendASCII("unpacked").
2438 AppendASCII("manifest_with_key.json"); 2436 AppendASCII("manifest_with_key.json");
2439 2437
2440 ASSERT_TRUE(base::PathExists(manifest_no_key)); 2438 ASSERT_TRUE(base::PathExists(manifest_no_key));
2441 ASSERT_TRUE(base::PathExists(manifest_with_key)); 2439 ASSERT_TRUE(base::PathExists(manifest_with_key));
2442 2440
2443 // Load the unpacked extension with no key. 2441 // Load the unpacked extension with no key.
2444 base::CopyFile(manifest_no_key, manifest_path); 2442 base::CopyFile(manifest_no_key, manifest_path);
2445 extensions::UnpackedInstaller::Create(service_)->Load(extension_path); 2443 extensions::UnpackedInstaller::Create(service_)->Load(extension_path);
2446 2444
2447 loop_.RunUntilIdle(); 2445 base::RunLoop().RunUntilIdle();
2448 EXPECT_EQ(0u, GetErrors().size()); 2446 EXPECT_EQ(0u, GetErrors().size());
2449 ASSERT_EQ(1u, loaded_.size()); 2447 ASSERT_EQ(1u, loaded_.size());
2450 EXPECT_EQ(1u, service_->extensions()->size()); 2448 EXPECT_EQ(1u, service_->extensions()->size());
2451 2449
2452 // Add the key to the manifest. 2450 // Add the key to the manifest.
2453 base::CopyFile(manifest_with_key, manifest_path); 2451 base::CopyFile(manifest_with_key, manifest_path);
2454 loaded_.clear(); 2452 loaded_.clear();
2455 2453
2456 // Reload the extensions. 2454 // Reload the extensions.
2457 service_->ReloadExtensions(); 2455 service_->ReloadExtensions();
(...skipping 23 matching lines...) Expand all
2481 base::FilePath extension_path = temp.path(); 2479 base::FilePath extension_path = temp.path();
2482 base::FilePath manifest = extension_path.Append( 2480 base::FilePath manifest = extension_path.Append(
2483 extensions::kManifestFilename); 2481 extensions::kManifestFilename);
2484 base::FilePath icon_symlink = extension_path.AppendASCII("icon.png"); 2482 base::FilePath icon_symlink = extension_path.AppendASCII("icon.png");
2485 base::CopyFile(source_manifest, manifest); 2483 base::CopyFile(source_manifest, manifest);
2486 file_util::CreateSymbolicLink(source_icon, icon_symlink); 2484 file_util::CreateSymbolicLink(source_icon, icon_symlink);
2487 2485
2488 // Load extension. 2486 // Load extension.
2489 InitializeEmptyExtensionService(); 2487 InitializeEmptyExtensionService();
2490 extensions::UnpackedInstaller::Create(service_)->Load(extension_path); 2488 extensions::UnpackedInstaller::Create(service_)->Load(extension_path);
2491 loop_.RunUntilIdle(); 2489 base::RunLoop().RunUntilIdle();
2492 2490
2493 EXPECT_TRUE(GetErrors().empty()); 2491 EXPECT_TRUE(GetErrors().empty());
2494 ASSERT_EQ(1u, loaded_.size()); 2492 ASSERT_EQ(1u, loaded_.size());
2495 EXPECT_EQ(1u, service_->extensions()->size()); 2493 EXPECT_EQ(1u, service_->extensions()->size());
2496 } 2494 }
2497 #endif 2495 #endif
2498 2496
2499 TEST_F(ExtensionServiceTest, InstallLocalizedTheme) { 2497 TEST_F(ExtensionServiceTest, InstallLocalizedTheme) {
2500 InitializeEmptyExtensionService(); 2498 InitializeEmptyExtensionService();
2501 base::FilePath theme_path = data_dir_ 2499 base::FilePath theme_path = data_dir_
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
2824 service_->GetExtensionById(good_crx, false)-> 2822 service_->GetExtensionById(good_crx, false)->
2825 version()->GetString()); 2823 version()->GetString());
2826 } 2824 }
2827 2825
2828 // Test updating a not-already-installed extension - this should fail 2826 // Test updating a not-already-installed extension - this should fail
2829 TEST_F(ExtensionServiceTest, UpdateNotInstalledExtension) { 2827 TEST_F(ExtensionServiceTest, UpdateNotInstalledExtension) {
2830 InitializeEmptyExtensionService(); 2828 InitializeEmptyExtensionService();
2831 2829
2832 base::FilePath path = data_dir_.AppendASCII("good.crx"); 2830 base::FilePath path = data_dir_.AppendASCII("good.crx");
2833 UpdateExtension(good_crx, path, UPDATED); 2831 UpdateExtension(good_crx, path, UPDATED);
2834 loop_.RunUntilIdle(); 2832 base::RunLoop().RunUntilIdle();
2835 2833
2836 ASSERT_EQ(0u, service_->extensions()->size()); 2834 ASSERT_EQ(0u, service_->extensions()->size());
2837 ASSERT_FALSE(installed_); 2835 ASSERT_FALSE(installed_);
2838 ASSERT_EQ(0u, loaded_.size()); 2836 ASSERT_EQ(0u, loaded_.size());
2839 } 2837 }
2840 2838
2841 // Makes sure you can't downgrade an extension via UpdateExtension 2839 // Makes sure you can't downgrade an extension via UpdateExtension
2842 TEST_F(ExtensionServiceTest, UpdateWillNotDowngrade) { 2840 TEST_F(ExtensionServiceTest, UpdateWillNotDowngrade) {
2843 InitializeEmptyExtensionService(); 2841 InitializeEmptyExtensionService();
2844 2842
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
2929 // Start with version 2.0. 2927 // Start with version 2.0.
2930 DictionaryValue manifest; 2928 DictionaryValue manifest;
2931 manifest.SetString("version", "2.0"); 2929 manifest.SetString("version", "2.0");
2932 manifest.SetString("name", "LOAD Downgrade Test"); 2930 manifest.SetString("name", "LOAD Downgrade Test");
2933 manifest.SetInteger("manifest_version", 2); 2931 manifest.SetInteger("manifest_version", 2);
2934 2932
2935 JSONFileValueSerializer serializer(manifest_path); 2933 JSONFileValueSerializer serializer(manifest_path);
2936 ASSERT_TRUE(serializer.Serialize(manifest)); 2934 ASSERT_TRUE(serializer.Serialize(manifest));
2937 2935
2938 extensions::UnpackedInstaller::Create(service_)->Load(extension_path); 2936 extensions::UnpackedInstaller::Create(service_)->Load(extension_path);
2939 loop_.RunUntilIdle(); 2937 base::RunLoop().RunUntilIdle();
2940 2938
2941 EXPECT_EQ(0u, GetErrors().size()); 2939 EXPECT_EQ(0u, GetErrors().size());
2942 ASSERT_EQ(1u, loaded_.size()); 2940 ASSERT_EQ(1u, loaded_.size());
2943 EXPECT_EQ(Manifest::UNPACKED, loaded_[0]->location()); 2941 EXPECT_EQ(Manifest::UNPACKED, loaded_[0]->location());
2944 EXPECT_EQ(1u, service_->extensions()->size()); 2942 EXPECT_EQ(1u, service_->extensions()->size());
2945 EXPECT_EQ("2.0", loaded_[0]->VersionString()); 2943 EXPECT_EQ("2.0", loaded_[0]->VersionString());
2946 2944
2947 // Now set the version number to 1.0, reload the extensions and verify that 2945 // Now set the version number to 1.0, reload the extensions and verify that
2948 // the downgrade was accepted. 2946 // the downgrade was accepted.
2949 manifest.SetString("version", "1.0"); 2947 manifest.SetString("version", "1.0");
2950 ASSERT_TRUE(serializer.Serialize(manifest)); 2948 ASSERT_TRUE(serializer.Serialize(manifest));
2951 2949
2952 extensions::UnpackedInstaller::Create(service_)->Load(extension_path); 2950 extensions::UnpackedInstaller::Create(service_)->Load(extension_path);
2953 loop_.RunUntilIdle(); 2951 base::RunLoop().RunUntilIdle();
2954 2952
2955 EXPECT_EQ(0u, GetErrors().size()); 2953 EXPECT_EQ(0u, GetErrors().size());
2956 ASSERT_EQ(1u, loaded_.size()); 2954 ASSERT_EQ(1u, loaded_.size());
2957 EXPECT_EQ(Manifest::UNPACKED, loaded_[0]->location()); 2955 EXPECT_EQ(Manifest::UNPACKED, loaded_[0]->location());
2958 EXPECT_EQ(1u, service_->extensions()->size()); 2956 EXPECT_EQ(1u, service_->extensions()->size());
2959 EXPECT_EQ("1.0", loaded_[0]->VersionString()); 2957 EXPECT_EQ("1.0", loaded_[0]->VersionString());
2960 } 2958 }
2961 2959
2962 #if !defined(OS_CHROMEOS) 2960 #if !defined(OS_CHROMEOS)
2963 // LOAD extensions with plugins require approval. 2961 // LOAD extensions with plugins require approval.
(...skipping 15 matching lines...) Expand all
2979 service_->set_show_extensions_prompts(true); 2977 service_->set_show_extensions_prompts(true);
2980 2978
2981 // Start by canceling any install prompts. 2979 // Start by canceling any install prompts.
2982 CommandLine::ForCurrentProcess()->AppendSwitchASCII( 2980 CommandLine::ForCurrentProcess()->AppendSwitchASCII(
2983 switches::kAppsGalleryInstallAutoConfirmForTests, 2981 switches::kAppsGalleryInstallAutoConfirmForTests,
2984 "cancel"); 2982 "cancel");
2985 2983
2986 // The extension that has a plugin should not install. 2984 // The extension that has a plugin should not install.
2987 extensions::UnpackedInstaller::Create(service_)->Load( 2985 extensions::UnpackedInstaller::Create(service_)->Load(
2988 extension_with_plugin_path); 2986 extension_with_plugin_path);
2989 loop_.RunUntilIdle(); 2987 base::RunLoop().RunUntilIdle();
2990 EXPECT_EQ(0u, GetErrors().size()); 2988 EXPECT_EQ(0u, GetErrors().size());
2991 EXPECT_EQ(0u, loaded_.size()); 2989 EXPECT_EQ(0u, loaded_.size());
2992 EXPECT_EQ(0u, service_->extensions()->size()); 2990 EXPECT_EQ(0u, service_->extensions()->size());
2993 EXPECT_EQ(0u, service_->disabled_extensions()->size()); 2991 EXPECT_EQ(0u, service_->disabled_extensions()->size());
2994 2992
2995 // But the extension with no plugin should since there's no prompt. 2993 // But the extension with no plugin should since there's no prompt.
2996 ExtensionErrorReporter::GetInstance()->ClearErrors(); 2994 ExtensionErrorReporter::GetInstance()->ClearErrors();
2997 extensions::UnpackedInstaller::Create(service_)->Load( 2995 extensions::UnpackedInstaller::Create(service_)->Load(
2998 extension_no_plugin_path); 2996 extension_no_plugin_path);
2999 loop_.RunUntilIdle(); 2997 base::RunLoop().RunUntilIdle();
3000 EXPECT_EQ(0u, GetErrors().size()); 2998 EXPECT_EQ(0u, GetErrors().size());
3001 EXPECT_EQ(1u, loaded_.size()); 2999 EXPECT_EQ(1u, loaded_.size());
3002 EXPECT_EQ(1u, service_->extensions()->size()); 3000 EXPECT_EQ(1u, service_->extensions()->size());
3003 EXPECT_EQ(0u, service_->disabled_extensions()->size()); 3001 EXPECT_EQ(0u, service_->disabled_extensions()->size());
3004 EXPECT_TRUE(service_->extensions()->Contains(good2)); 3002 EXPECT_TRUE(service_->extensions()->Contains(good2));
3005 3003
3006 // The plugin extension should install if we accept the dialog. 3004 // The plugin extension should install if we accept the dialog.
3007 CommandLine::ForCurrentProcess()->AppendSwitchASCII( 3005 CommandLine::ForCurrentProcess()->AppendSwitchASCII(
3008 switches::kAppsGalleryInstallAutoConfirmForTests, 3006 switches::kAppsGalleryInstallAutoConfirmForTests,
3009 "accept"); 3007 "accept");
3010 3008
3011 ExtensionErrorReporter::GetInstance()->ClearErrors(); 3009 ExtensionErrorReporter::GetInstance()->ClearErrors();
3012 extensions::UnpackedInstaller::Create(service_)->Load( 3010 extensions::UnpackedInstaller::Create(service_)->Load(
3013 extension_with_plugin_path); 3011 extension_with_plugin_path);
3014 loop_.RunUntilIdle(); 3012 base::RunLoop().RunUntilIdle();
3015 EXPECT_EQ(0u, GetErrors().size()); 3013 EXPECT_EQ(0u, GetErrors().size());
3016 EXPECT_EQ(2u, loaded_.size()); 3014 EXPECT_EQ(2u, loaded_.size());
3017 EXPECT_EQ(2u, service_->extensions()->size()); 3015 EXPECT_EQ(2u, service_->extensions()->size());
3018 EXPECT_EQ(0u, service_->disabled_extensions()->size()); 3016 EXPECT_EQ(0u, service_->disabled_extensions()->size());
3019 EXPECT_TRUE(service_->extensions()->Contains(good1)); 3017 EXPECT_TRUE(service_->extensions()->Contains(good1));
3020 EXPECT_TRUE(service_->extensions()->Contains(good2)); 3018 EXPECT_TRUE(service_->extensions()->Contains(good2));
3021 3019
3022 // Make sure the granted permissions have been setup. 3020 // Make sure the granted permissions have been setup.
3023 scoped_refptr<PermissionSet> permissions( 3021 scoped_refptr<PermissionSet> permissions(
3024 service_->extension_prefs()->GetGrantedPermissions(good1)); 3022 service_->extension_prefs()->GetGrantedPermissions(good1));
3025 EXPECT_FALSE(permissions->IsEmpty()); 3023 EXPECT_FALSE(permissions->IsEmpty());
3026 EXPECT_TRUE(permissions->HasEffectiveFullAccess()); 3024 EXPECT_TRUE(permissions->HasEffectiveFullAccess());
3027 EXPECT_FALSE(permissions->apis().empty()); 3025 EXPECT_FALSE(permissions->apis().empty());
3028 EXPECT_TRUE(permissions->HasAPIPermission(APIPermission::kPlugin)); 3026 EXPECT_TRUE(permissions->HasAPIPermission(APIPermission::kPlugin));
3029 3027
3030 // We should be able to reload the extension without getting another prompt. 3028 // We should be able to reload the extension without getting another prompt.
3031 loaded_.clear(); 3029 loaded_.clear();
3032 CommandLine::ForCurrentProcess()->AppendSwitchASCII( 3030 CommandLine::ForCurrentProcess()->AppendSwitchASCII(
3033 switches::kAppsGalleryInstallAutoConfirmForTests, 3031 switches::kAppsGalleryInstallAutoConfirmForTests,
3034 "cancel"); 3032 "cancel");
3035 3033
3036 service_->ReloadExtension(good1); 3034 service_->ReloadExtension(good1);
3037 loop_.RunUntilIdle(); 3035 base::RunLoop().RunUntilIdle();
3038 EXPECT_EQ(1u, loaded_.size()); 3036 EXPECT_EQ(1u, loaded_.size());
3039 EXPECT_EQ(2u, service_->extensions()->size()); 3037 EXPECT_EQ(2u, service_->extensions()->size());
3040 EXPECT_EQ(0u, service_->disabled_extensions()->size()); 3038 EXPECT_EQ(0u, service_->disabled_extensions()->size());
3041 } 3039 }
3042 #endif 3040 #endif
3043 3041
3044 namespace { 3042 namespace {
3045 3043
3046 bool IsExtension(const Extension* extension) { 3044 bool IsExtension(const Extension* extension) {
3047 return extension->GetType() == Manifest::TYPE_EXTENSION; 3045 return extension->GetType() == Manifest::TYPE_EXTENSION;
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
3270 TEST_F(ExtensionServiceTest, SetUnsetBlacklistInPrefs) { 3268 TEST_F(ExtensionServiceTest, SetUnsetBlacklistInPrefs) {
3271 InitializeEmptyExtensionService(); 3269 InitializeEmptyExtensionService();
3272 std::vector<std::string> blacklist; 3270 std::vector<std::string> blacklist;
3273 blacklist.push_back(good0); 3271 blacklist.push_back(good0);
3274 blacklist.push_back("invalid_id"); // an invalid id 3272 blacklist.push_back("invalid_id"); // an invalid id
3275 blacklist.push_back(good1); 3273 blacklist.push_back(good1);
3276 ExtensionSystem::Get(profile_.get())->blacklist()->SetFromUpdater(blacklist, 3274 ExtensionSystem::Get(profile_.get())->blacklist()->SetFromUpdater(blacklist,
3277 "v1"); 3275 "v1");
3278 3276
3279 // Make sure pref is updated 3277 // Make sure pref is updated
3280 loop_.RunUntilIdle(); 3278 base::RunLoop().RunUntilIdle();
3281 3279
3282 // blacklist is set for good0,1,2 3280 // blacklist is set for good0,1,2
3283 ValidateBooleanPref(good0, "blacklist", true); 3281 ValidateBooleanPref(good0, "blacklist", true);
3284 ValidateBooleanPref(good1, "blacklist", true); 3282 ValidateBooleanPref(good1, "blacklist", true);
3285 // invalid_id should not be inserted to pref. 3283 // invalid_id should not be inserted to pref.
3286 EXPECT_FALSE(IsPrefExist("invalid_id", "blacklist")); 3284 EXPECT_FALSE(IsPrefExist("invalid_id", "blacklist"));
3287 3285
3288 // remove good1, add good2 3286 // remove good1, add good2
3289 blacklist.pop_back(); 3287 blacklist.pop_back();
3290 blacklist.push_back(good2); 3288 blacklist.push_back(good2);
(...skipping 16 matching lines...) Expand all
3307 const Extension* good = InstallCRX(path, INSTALL_NEW); 3305 const Extension* good = InstallCRX(path, INSTALL_NEW);
3308 EXPECT_EQ(good_crx, good->id()); 3306 EXPECT_EQ(good_crx, good->id());
3309 UpdateExtension(good_crx, path, FAILED_SILENTLY); 3307 UpdateExtension(good_crx, path, FAILED_SILENTLY);
3310 3308
3311 std::vector<std::string> blacklist; 3309 std::vector<std::string> blacklist;
3312 blacklist.push_back(good_crx); 3310 blacklist.push_back(good_crx);
3313 ExtensionSystem::Get(profile_.get())->blacklist()->SetFromUpdater(blacklist, 3311 ExtensionSystem::Get(profile_.get())->blacklist()->SetFromUpdater(blacklist,
3314 "v1"); 3312 "v1");
3315 3313
3316 // Make sure pref is updated 3314 // Make sure pref is updated
3317 loop_.RunUntilIdle(); 3315 base::RunLoop().RunUntilIdle();
3318 3316
3319 // Now, the good_crx is blacklisted. 3317 // Now, the good_crx is blacklisted.
3320 ValidateBooleanPref(good_crx, "blacklist", true); 3318 ValidateBooleanPref(good_crx, "blacklist", true);
3321 EXPECT_EQ(0u, service_->extensions()->size()); 3319 EXPECT_EQ(0u, service_->extensions()->size());
3322 3320
3323 // Remove good_crx from blacklist 3321 // Remove good_crx from blacklist
3324 blacklist.pop_back(); 3322 blacklist.pop_back();
3325 ExtensionSystem::Get(profile_.get())->blacklist()->SetFromUpdater(blacklist, 3323 ExtensionSystem::Get(profile_.get())->blacklist()->SetFromUpdater(blacklist,
3326 "v2"); 3324 "v2");
3327 3325
3328 // Make sure pref is updated 3326 // Make sure pref is updated
3329 loop_.RunUntilIdle(); 3327 base::RunLoop().RunUntilIdle();
3330 // blacklist value should not be set for good_crx 3328 // blacklist value should not be set for good_crx
3331 EXPECT_FALSE(IsPrefExist(good_crx, "blacklist")); 3329 EXPECT_FALSE(IsPrefExist(good_crx, "blacklist"));
3332 } 3330 }
3333 3331
3334 // Unload installed extension from blacklist. 3332 // Unload installed extension from blacklist.
3335 TEST_F(ExtensionServiceTest, BlacklistedExtensionWillNotInstall) { 3333 TEST_F(ExtensionServiceTest, BlacklistedExtensionWillNotInstall) {
3336 InitializeEmptyExtensionService(); 3334 InitializeEmptyExtensionService();
3337 3335
3338 // Fake the blacklisting of good_crx by pretending that we get an update 3336 // Fake the blacklisting of good_crx by pretending that we get an update
3339 // which includes it. 3337 // which includes it.
(...skipping 28 matching lines...) Expand all
3368 PrefService* prefs = service_->extension_prefs()->pref_service(); 3366 PrefService* prefs = service_->extension_prefs()->pref_service();
3369 whitelist.Append(base::Value::CreateStringValue(good_crx)); 3367 whitelist.Append(base::Value::CreateStringValue(good_crx));
3370 prefs->Set(prefs::kExtensionInstallAllowList, whitelist); 3368 prefs->Set(prefs::kExtensionInstallAllowList, whitelist);
3371 3369
3372 std::vector<std::string> blacklist; 3370 std::vector<std::string> blacklist;
3373 blacklist.push_back(good_crx); 3371 blacklist.push_back(good_crx);
3374 ExtensionSystem::Get(profile_.get())->blacklist()->SetFromUpdater(blacklist, 3372 ExtensionSystem::Get(profile_.get())->blacklist()->SetFromUpdater(blacklist,
3375 "v1"); 3373 "v1");
3376 3374
3377 // Make sure pref is updated 3375 // Make sure pref is updated
3378 loop_.RunUntilIdle(); 3376 base::RunLoop().RunUntilIdle();
3379 3377
3380 // The good_crx is blacklisted and the whitelist doesn't negate it. 3378 // The good_crx is blacklisted and the whitelist doesn't negate it.
3381 ValidateBooleanPref(good_crx, "blacklist", true); 3379 ValidateBooleanPref(good_crx, "blacklist", true);
3382 EXPECT_EQ(0u, service_->extensions()->size()); 3380 EXPECT_EQ(0u, service_->extensions()->size());
3383 } 3381 }
3384 3382
3385 // Test loading extensions from the profile directory, except 3383 // Test loading extensions from the profile directory, except
3386 // blacklisted ones. 3384 // blacklisted ones.
3387 TEST_F(ExtensionServiceTest, WillNotLoadBlacklistedExtensionsFromDirectory) { 3385 TEST_F(ExtensionServiceTest, WillNotLoadBlacklistedExtensionsFromDirectory) {
3388 // Initialize the test dir with a good Preferences/extensions. 3386 // Initialize the test dir with a good Preferences/extensions.
3389 base::FilePath source_install_dir = data_dir_ 3387 base::FilePath source_install_dir = data_dir_
3390 .AppendASCII("good") 3388 .AppendASCII("good")
3391 .AppendASCII("Extensions"); 3389 .AppendASCII("Extensions");
3392 base::FilePath pref_path = source_install_dir 3390 base::FilePath pref_path = source_install_dir
3393 .DirName() 3391 .DirName()
3394 .AppendASCII("Preferences"); 3392 .AppendASCII("Preferences");
3395 InitializeInstalledExtensionService(pref_path, source_install_dir); 3393 InitializeInstalledExtensionService(pref_path, source_install_dir);
3396 3394
3397 // Blacklist good1. 3395 // Blacklist good1.
3398 std::vector<std::string> blacklist; 3396 std::vector<std::string> blacklist;
3399 blacklist.push_back(good1); 3397 blacklist.push_back(good1);
3400 ExtensionSystem::Get(profile_.get())->blacklist()->SetFromUpdater(blacklist, 3398 ExtensionSystem::Get(profile_.get())->blacklist()->SetFromUpdater(blacklist,
3401 "v1"); 3399 "v1");
3402 3400
3403 // Make sure pref is updated 3401 // Make sure pref is updated
3404 loop_.RunUntilIdle(); 3402 base::RunLoop().RunUntilIdle();
3405 3403
3406 ValidateBooleanPref(good1, "blacklist", true); 3404 ValidateBooleanPref(good1, "blacklist", true);
3407 3405
3408 // Load extensions. 3406 // Load extensions.
3409 service_->Init(); 3407 service_->Init();
3410 3408
3411 std::vector<string16> errors = GetErrors(); 3409 std::vector<string16> errors = GetErrors();
3412 for (std::vector<string16>::iterator err = errors.begin(); 3410 for (std::vector<string16>::iterator err = errors.begin();
3413 err != errors.end(); ++err) { 3411 err != errors.end(); ++err) {
3414 LOG(ERROR) << *err; 3412 LOG(ERROR) << *err;
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
3464 PrefService* prefs = profile_->GetPrefs(); 3462 PrefService* prefs = profile_->GetPrefs();
3465 ListPrefUpdate update(prefs, prefs::kExtensionInstallDenyList); 3463 ListPrefUpdate update(prefs, prefs::kExtensionInstallDenyList);
3466 ListValue* blacklist = update.Get(); 3464 ListValue* blacklist = update.Get();
3467 ASSERT_TRUE(blacklist != NULL); 3465 ASSERT_TRUE(blacklist != NULL);
3468 3466
3469 // Blacklist this extension. 3467 // Blacklist this extension.
3470 blacklist->Append(Value::CreateStringValue(good_crx)); 3468 blacklist->Append(Value::CreateStringValue(good_crx));
3471 } 3469 }
3472 3470
3473 // Extension should not be running now. 3471 // Extension should not be running now.
3474 loop_.RunUntilIdle(); 3472 base::RunLoop().RunUntilIdle();
3475 EXPECT_EQ(0u, service_->extensions()->size()); 3473 EXPECT_EQ(0u, service_->extensions()->size());
3476 } 3474 }
3477 3475
3478 // Tests that component extensions are not blacklisted by policy. 3476 // Tests that component extensions are not blacklisted by policy.
3479 TEST_F(ExtensionServiceTest, ComponentExtensionWhitelisted) { 3477 TEST_F(ExtensionServiceTest, ComponentExtensionWhitelisted) {
3480 InitializeEmptyExtensionService(); 3478 InitializeEmptyExtensionService();
3481 3479
3482 // Blacklist everything. 3480 // Blacklist everything.
3483 { 3481 {
3484 ListPrefUpdate update(profile_->GetPrefs(), 3482 ListPrefUpdate update(profile_->GetPrefs(),
(...skipping 23 matching lines...) Expand all
3508 ASSERT_EQ(1u, service_->extensions()->size()); 3506 ASSERT_EQ(1u, service_->extensions()->size());
3509 EXPECT_TRUE(service_->GetExtensionById(good0, false)); 3507 EXPECT_TRUE(service_->GetExtensionById(good0, false));
3510 3508
3511 // Extension should not be uninstalled on blacklist changes. 3509 // Extension should not be uninstalled on blacklist changes.
3512 { 3510 {
3513 ListPrefUpdate update(profile_->GetPrefs(), 3511 ListPrefUpdate update(profile_->GetPrefs(),
3514 prefs::kExtensionInstallDenyList); 3512 prefs::kExtensionInstallDenyList);
3515 ListValue* blacklist = update.Get(); 3513 ListValue* blacklist = update.Get();
3516 blacklist->Append(Value::CreateStringValue(good0)); 3514 blacklist->Append(Value::CreateStringValue(good0));
3517 } 3515 }
3518 loop_.RunUntilIdle(); 3516 base::RunLoop().RunUntilIdle();
3519 ASSERT_EQ(1u, service_->extensions()->size()); 3517 ASSERT_EQ(1u, service_->extensions()->size());
3520 EXPECT_TRUE(service_->GetExtensionById(good0, false)); 3518 EXPECT_TRUE(service_->GetExtensionById(good0, false));
3521 } 3519 }
3522 3520
3523 // Tests that policy-installed extensions are not blacklisted by policy. 3521 // Tests that policy-installed extensions are not blacklisted by policy.
3524 TEST_F(ExtensionServiceTest, PolicyInstalledExtensionsWhitelisted) { 3522 TEST_F(ExtensionServiceTest, PolicyInstalledExtensionsWhitelisted) {
3525 InitializeEmptyExtensionService(); 3523 InitializeEmptyExtensionService();
3526 3524
3527 { 3525 {
3528 // Blacklist everything. 3526 // Blacklist everything.
(...skipping 28 matching lines...) Expand all
3557 ASSERT_EQ(1u, service_->extensions()->size()); 3555 ASSERT_EQ(1u, service_->extensions()->size());
3558 EXPECT_TRUE(service_->GetExtensionById(good_crx, false)); 3556 EXPECT_TRUE(service_->GetExtensionById(good_crx, false));
3559 3557
3560 // Blacklist update should not uninstall the extension. 3558 // Blacklist update should not uninstall the extension.
3561 { 3559 {
3562 ListPrefUpdate update(profile_->GetPrefs(), 3560 ListPrefUpdate update(profile_->GetPrefs(),
3563 prefs::kExtensionInstallDenyList); 3561 prefs::kExtensionInstallDenyList);
3564 ListValue* blacklist = update.Get(); 3562 ListValue* blacklist = update.Get();
3565 blacklist->Append(Value::CreateStringValue(good0)); 3563 blacklist->Append(Value::CreateStringValue(good0));
3566 } 3564 }
3567 loop_.RunUntilIdle(); 3565 base::RunLoop().RunUntilIdle();
3568 ASSERT_EQ(1u, service_->extensions()->size()); 3566 ASSERT_EQ(1u, service_->extensions()->size());
3569 EXPECT_TRUE(service_->GetExtensionById(good_crx, false)); 3567 EXPECT_TRUE(service_->GetExtensionById(good_crx, false));
3570 } 3568 }
3571 3569
3572 // Tests that extensions cannot be installed if the policy provider prohibits 3570 // Tests that extensions cannot be installed if the policy provider prohibits
3573 // it. This functionality is implemented in CrxInstaller::ConfirmInstall(). 3571 // it. This functionality is implemented in CrxInstaller::ConfirmInstall().
3574 TEST_F(ExtensionServiceTest, ManagementPolicyProhibitsInstall) { 3572 TEST_F(ExtensionServiceTest, ManagementPolicyProhibitsInstall) {
3575 InitializeEmptyExtensionService(); 3573 InitializeEmptyExtensionService();
3576 3574
3577 management_policy_->UnregisterAllProviders(); 3575 management_policy_->UnregisterAllProviders();
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
3900 InitializeExtensionProcessManager(); 3898 InitializeExtensionProcessManager();
3901 3899
3902 // Simple extension that should install without error. 3900 // Simple extension that should install without error.
3903 const char* extension_id = "behllobkkfkfnphdnhnkndlbkcpglgmj"; 3901 const char* extension_id = "behllobkkfkfnphdnhnkndlbkcpglgmj";
3904 base::FilePath ext = data_dir_ 3902 base::FilePath ext = data_dir_
3905 .AppendASCII("good") 3903 .AppendASCII("good")
3906 .AppendASCII("Extensions") 3904 .AppendASCII("Extensions")
3907 .AppendASCII(extension_id) 3905 .AppendASCII(extension_id)
3908 .AppendASCII("1.0.0.0"); 3906 .AppendASCII("1.0.0.0");
3909 extensions::UnpackedInstaller::Create(service_)->Load(ext); 3907 extensions::UnpackedInstaller::Create(service_)->Load(ext);
3910 loop_.RunUntilIdle(); 3908 base::RunLoop().RunUntilIdle();
3911 3909
3912 EXPECT_EQ(1u, service_->extensions()->size()); 3910 EXPECT_EQ(1u, service_->extensions()->size());
3913 EXPECT_EQ(0u, service_->disabled_extensions()->size()); 3911 EXPECT_EQ(0u, service_->disabled_extensions()->size());
3914 3912
3915 service_->ReloadExtension(extension_id); 3913 service_->ReloadExtension(extension_id);
3916 3914
3917 // Extension should be disabled now, waiting to be reloaded. 3915 // Extension should be disabled now, waiting to be reloaded.
3918 EXPECT_EQ(0u, service_->extensions()->size()); 3916 EXPECT_EQ(0u, service_->extensions()->size());
3919 EXPECT_EQ(1u, service_->disabled_extensions()->size()); 3917 EXPECT_EQ(1u, service_->disabled_extensions()->size());
3920 EXPECT_EQ(Extension::DISABLE_RELOAD, 3918 EXPECT_EQ(Extension::DISABLE_RELOAD,
3921 service_->extension_prefs()->GetDisableReasons(extension_id)); 3919 service_->extension_prefs()->GetDisableReasons(extension_id));
3922 3920
3923 // Reloading again should not crash. 3921 // Reloading again should not crash.
3924 service_->ReloadExtension(extension_id); 3922 service_->ReloadExtension(extension_id);
3925 3923
3926 // Finish reloading 3924 // Finish reloading
3927 loop_.RunUntilIdle(); 3925 base::RunLoop().RunUntilIdle();
3928 3926
3929 // Extension should be enabled again. 3927 // Extension should be enabled again.
3930 EXPECT_EQ(1u, service_->extensions()->size()); 3928 EXPECT_EQ(1u, service_->extensions()->size());
3931 EXPECT_EQ(0u, service_->disabled_extensions()->size()); 3929 EXPECT_EQ(0u, service_->disabled_extensions()->size());
3932 } 3930 }
3933 3931
3934 TEST_F(ExtensionServiceTest, UninstallExtension) { 3932 TEST_F(ExtensionServiceTest, UninstallExtension) {
3935 InitializeEmptyExtensionService(); 3933 InitializeEmptyExtensionService();
3936 InstallCRX(data_dir_.AppendASCII("good.crx"), INSTALL_NEW); 3934 InstallCRX(data_dir_.AppendASCII("good.crx"), INSTALL_NEW);
3937 EXPECT_EQ(1u, service_->extensions()->size()); 3935 EXPECT_EQ(1u, service_->extensions()->size());
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
4055 4053
4056 // Unpacked extensions are not allowed to be installed if they have unsupported 4054 // Unpacked extensions are not allowed to be installed if they have unsupported
4057 // requirements. 4055 // requirements.
4058 TEST_F(ExtensionServiceTest, UnpackedRequirements) { 4056 TEST_F(ExtensionServiceTest, UnpackedRequirements) {
4059 InitializeEmptyExtensionService(); 4057 InitializeEmptyExtensionService();
4060 BlackListWebGL(); 4058 BlackListWebGL();
4061 4059
4062 base::FilePath path = data_dir_.AppendASCII("requirements") 4060 base::FilePath path = data_dir_.AppendASCII("requirements")
4063 .AppendASCII("v2_bad_requirements"); 4061 .AppendASCII("v2_bad_requirements");
4064 extensions::UnpackedInstaller::Create(service_)->Load(path); 4062 extensions::UnpackedInstaller::Create(service_)->Load(path);
4065 loop_.RunUntilIdle(); 4063 base::RunLoop().RunUntilIdle();
4066 EXPECT_EQ(1u, GetErrors().size()); 4064 EXPECT_EQ(1u, GetErrors().size());
4067 EXPECT_EQ(0u, service_->extensions()->size()); 4065 EXPECT_EQ(0u, service_->extensions()->size());
4068 } 4066 }
4069 4067
4070 class ExtensionCookieCallback { 4068 class ExtensionCookieCallback {
4071 public: 4069 public:
4072 ExtensionCookieCallback() 4070 ExtensionCookieCallback()
4073 : result_(false), 4071 : result_(false),
4074 weak_factory_(base::MessageLoop::current()) {} 4072 weak_factory_(base::MessageLoop::current()) {}
4075 4073
(...skipping 20 matching lines...) Expand all
4096 4094
4097 // Load a test extension. 4095 // Load a test extension.
4098 base::FilePath path = data_dir_; 4096 base::FilePath path = data_dir_;
4099 path = path.AppendASCII("good.crx"); 4097 path = path.AppendASCII("good.crx");
4100 const Extension* extension = InstallCRX(path, INSTALL_NEW); 4098 const Extension* extension = InstallCRX(path, INSTALL_NEW);
4101 ASSERT_TRUE(extension); 4099 ASSERT_TRUE(extension);
4102 GURL ext_url(extension->url()); 4100 GURL ext_url(extension->url());
4103 std::string origin_id = webkit_database::GetIdentifierFromOrigin(ext_url); 4101 std::string origin_id = webkit_database::GetIdentifierFromOrigin(ext_url);
4104 4102
4105 // Set a cookie for the extension. 4103 // Set a cookie for the extension.
4106 net::CookieMonster* cookie_monster = 4104 net::CookieStore* cookie_store =
4107 profile_->GetRequestContextForExtensions()->GetURLRequestContext()-> 4105 BrowserContext::GetDefaultStoragePartition(profile_.get())->
4108 cookie_store()->GetCookieMonster(); 4106 GetCookieStoreMap().GetForScheme(ext_url.scheme());
4107 ASSERT_TRUE(cookie_store);
4108 net::CookieMonster* cookie_monster = cookie_store->GetCookieMonster();
4109 ASSERT_TRUE(cookie_monster); 4109 ASSERT_TRUE(cookie_monster);
4110 net::CookieOptions options; 4110 net::CookieOptions options;
4111 cookie_monster->SetCookieWithOptionsAsync( 4111 cookie_monster->SetCookieWithOptionsAsync(
4112 ext_url, "dummy=value", options, 4112 ext_url, "dummy=value", options,
4113 base::Bind(&ExtensionCookieCallback::SetCookieCallback, 4113 base::Bind(&ExtensionCookieCallback::SetCookieCallback,
4114 base::Unretained(&callback))); 4114 base::Unretained(&callback)));
4115 loop_.RunUntilIdle(); 4115 base::RunLoop().RunUntilIdle();
4116 EXPECT_TRUE(callback.result_); 4116 EXPECT_TRUE(callback.result_);
4117 4117
4118 cookie_monster->GetAllCookiesForURLAsync( 4118 cookie_monster->GetAllCookiesForURLAsync(
4119 ext_url, 4119 ext_url,
4120 base::Bind(&ExtensionCookieCallback::GetAllCookiesCallback, 4120 base::Bind(&ExtensionCookieCallback::GetAllCookiesCallback,
4121 base::Unretained(&callback))); 4121 base::Unretained(&callback)));
4122 loop_.RunUntilIdle(); 4122 base::RunLoop().RunUntilIdle();
4123 EXPECT_EQ(1U, callback.list_.size()); 4123 EXPECT_EQ(1U, callback.list_.size());
4124 4124
4125 // Open a database. 4125 // Open a database.
4126 webkit_database::DatabaseTracker* db_tracker = 4126 webkit_database::DatabaseTracker* db_tracker =
4127 BrowserContext::GetDefaultStoragePartition(profile_.get())-> 4127 BrowserContext::GetDefaultStoragePartition(profile_.get())->
4128 GetDatabaseTracker(); 4128 GetDatabaseTracker();
4129 string16 db_name = UTF8ToUTF16("db"); 4129 string16 db_name = UTF8ToUTF16("db");
4130 string16 description = UTF8ToUTF16("db_description"); 4130 string16 description = UTF8ToUTF16("db_description");
4131 int64 size; 4131 int64 size;
4132 db_tracker->DatabaseOpened(origin_id, db_name, description, 1, &size); 4132 db_tracker->DatabaseOpened(origin_id, db_name, description, 1, &size);
(...skipping 20 matching lines...) Expand all
4153 BrowserContext::GetDefaultStoragePartition(profile_.get())-> 4153 BrowserContext::GetDefaultStoragePartition(profile_.get())->
4154 GetIndexedDBContext(); 4154 GetIndexedDBContext();
4155 idb_context->SetTaskRunnerForTesting( 4155 idb_context->SetTaskRunnerForTesting(
4156 base::MessageLoop::current()->message_loop_proxy().get()); 4156 base::MessageLoop::current()->message_loop_proxy().get());
4157 base::FilePath idb_path = idb_context->GetFilePathForTesting(origin_id); 4157 base::FilePath idb_path = idb_context->GetFilePathForTesting(origin_id);
4158 EXPECT_TRUE(file_util::CreateDirectory(idb_path)); 4158 EXPECT_TRUE(file_util::CreateDirectory(idb_path));
4159 EXPECT_TRUE(base::DirectoryExists(idb_path)); 4159 EXPECT_TRUE(base::DirectoryExists(idb_path));
4160 4160
4161 // Uninstall the extension. 4161 // Uninstall the extension.
4162 service_->UninstallExtension(good_crx, false, NULL); 4162 service_->UninstallExtension(good_crx, false, NULL);
4163 loop_.RunUntilIdle(); 4163 base::RunLoop().RunUntilIdle();
4164 4164
4165 // Check that the cookie is gone. 4165 // Check that the cookie is gone.
4166 cookie_monster->GetAllCookiesForURLAsync( 4166 cookie_monster->GetAllCookiesForURLAsync(
4167 ext_url, 4167 ext_url,
4168 base::Bind(&ExtensionCookieCallback::GetAllCookiesCallback, 4168 base::Bind(&ExtensionCookieCallback::GetAllCookiesCallback,
4169 base::Unretained(&callback))); 4169 base::Unretained(&callback)));
4170 loop_.RunUntilIdle(); 4170 base::RunLoop().RunUntilIdle();
4171 EXPECT_EQ(0U, callback.list_.size()); 4171 EXPECT_EQ(0U, callback.list_.size());
4172 4172
4173 // The database should have vanished as well. 4173 // The database should have vanished as well.
4174 origins.clear(); 4174 origins.clear();
4175 db_tracker->GetAllOriginsInfo(&origins); 4175 db_tracker->GetAllOriginsInfo(&origins);
4176 EXPECT_EQ(0U, origins.size()); 4176 EXPECT_EQ(0U, origins.size());
4177 4177
4178 // Check that the LSO file has been removed. 4178 // Check that the LSO file has been removed.
4179 EXPECT_FALSE(base::PathExists(lso_file_path)); 4179 EXPECT_FALSE(base::PathExists(lso_file_path));
4180 4180
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
4212 APIPermission::kUnlimitedStorage)); 4212 APIPermission::kUnlimitedStorage));
4213 EXPECT_TRUE(extension->web_extent().MatchesURL( 4213 EXPECT_TRUE(extension->web_extent().MatchesURL(
4214 extensions::AppLaunchInfo::GetFullLaunchURL(extension))); 4214 extensions::AppLaunchInfo::GetFullLaunchURL(extension)));
4215 const GURL origin2( 4215 const GURL origin2(
4216 extensions::AppLaunchInfo::GetFullLaunchURL(extension).GetOrigin()); 4216 extensions::AppLaunchInfo::GetFullLaunchURL(extension).GetOrigin());
4217 EXPECT_EQ(origin1, origin2); 4217 EXPECT_EQ(origin1, origin2);
4218 EXPECT_TRUE(profile_->GetExtensionSpecialStoragePolicy()-> 4218 EXPECT_TRUE(profile_->GetExtensionSpecialStoragePolicy()->
4219 IsStorageUnlimited(origin2)); 4219 IsStorageUnlimited(origin2));
4220 4220
4221 // Set a cookie for the extension. 4221 // Set a cookie for the extension.
4222 content::StoragePartition* partition =
4223 content::BrowserContext::GetDefaultStoragePartition(profile_.get());
4222 net::CookieMonster* cookie_monster = 4224 net::CookieMonster* cookie_monster =
4223 profile_->GetRequestContext()->GetURLRequestContext()-> 4225 partition->GetCookieStoreMap().GetForScheme(origin1.scheme())->
4224 cookie_store()->GetCookieMonster(); 4226 GetCookieMonster();
4225 ASSERT_TRUE(cookie_monster); 4227 ASSERT_TRUE(cookie_monster);
4226 net::CookieOptions options; 4228 net::CookieOptions options;
4227 cookie_monster->SetCookieWithOptionsAsync( 4229 cookie_monster->SetCookieWithOptionsAsync(
4228 origin1, "dummy=value", options, 4230 origin1, "dummy=value", options,
4229 base::Bind(&ExtensionCookieCallback::SetCookieCallback, 4231 base::Bind(&ExtensionCookieCallback::SetCookieCallback,
4230 base::Unretained(&callback))); 4232 base::Unretained(&callback)));
4231 loop_.RunUntilIdle(); 4233 base::RunLoop().RunUntilIdle();
4232 EXPECT_TRUE(callback.result_); 4234 EXPECT_TRUE(callback.result_);
4233 4235
4234 cookie_monster->GetAllCookiesForURLAsync( 4236 cookie_monster->GetAllCookiesForURLAsync(
4235 origin1, 4237 origin1,
4236 base::Bind(&ExtensionCookieCallback::GetAllCookiesCallback, 4238 base::Bind(&ExtensionCookieCallback::GetAllCookiesCallback,
4237 base::Unretained(&callback))); 4239 base::Unretained(&callback)));
4238 loop_.RunUntilIdle(); 4240 base::RunLoop().RunUntilIdle();
4239 EXPECT_EQ(1U, callback.list_.size()); 4241 EXPECT_EQ(1U, callback.list_.size());
4240 4242
4241 // Open a database. 4243 // Open a database.
4242 webkit_database::DatabaseTracker* db_tracker = 4244 webkit_database::DatabaseTracker* db_tracker =
4243 BrowserContext::GetDefaultStoragePartition(profile_.get())-> 4245 BrowserContext::GetDefaultStoragePartition(profile_.get())->
4244 GetDatabaseTracker(); 4246 GetDatabaseTracker();
4245 string16 db_name = UTF8ToUTF16("db"); 4247 string16 db_name = UTF8ToUTF16("db");
4246 string16 description = UTF8ToUTF16("db_description"); 4248 string16 description = UTF8ToUTF16("db_description");
4247 int64 size; 4249 int64 size;
4248 db_tracker->DatabaseOpened(origin_id, db_name, description, 1, &size); 4250 db_tracker->DatabaseOpened(origin_id, db_name, description, 1, &size);
(...skipping 30 matching lines...) Expand all
4279 UninstallExtension(id1, false); 4281 UninstallExtension(id1, false);
4280 EXPECT_EQ(1u, service_->extensions()->size()); 4282 EXPECT_EQ(1u, service_->extensions()->size());
4281 EXPECT_TRUE(profile_->GetExtensionSpecialStoragePolicy()-> 4283 EXPECT_TRUE(profile_->GetExtensionSpecialStoragePolicy()->
4282 IsStorageUnlimited(origin1)); 4284 IsStorageUnlimited(origin1));
4283 4285
4284 // Check that the cookie is still there. 4286 // Check that the cookie is still there.
4285 cookie_monster->GetAllCookiesForURLAsync( 4287 cookie_monster->GetAllCookiesForURLAsync(
4286 origin1, 4288 origin1,
4287 base::Bind(&ExtensionCookieCallback::GetAllCookiesCallback, 4289 base::Bind(&ExtensionCookieCallback::GetAllCookiesCallback,
4288 base::Unretained(&callback))); 4290 base::Unretained(&callback)));
4289 loop_.RunUntilIdle(); 4291 base::RunLoop().RunUntilIdle();
4290 EXPECT_EQ(1U, callback.list_.size()); 4292 EXPECT_EQ(1U, callback.list_.size());
4291 4293
4292 // Now uninstall the other. Storage should be cleared for the apps. 4294 // Now uninstall the other. Storage should be cleared for the apps.
4293 UninstallExtension(id2, false); 4295 UninstallExtension(id2, false);
4294 EXPECT_EQ(0u, service_->extensions()->size()); 4296 EXPECT_EQ(0u, service_->extensions()->size());
4295 EXPECT_FALSE(profile_->GetExtensionSpecialStoragePolicy()-> 4297 EXPECT_FALSE(profile_->GetExtensionSpecialStoragePolicy()->
4296 IsStorageUnlimited(origin1)); 4298 IsStorageUnlimited(origin1));
4297 4299
4298 // Check that the cookie is gone. 4300 // Check that the cookie is gone.
4299 cookie_monster->GetAllCookiesForURLAsync( 4301 cookie_monster->GetAllCookiesForURLAsync(
4300 origin1, 4302 origin1,
4301 base::Bind(&ExtensionCookieCallback::GetAllCookiesCallback, 4303 base::Bind(&ExtensionCookieCallback::GetAllCookiesCallback,
4302 base::Unretained(&callback))); 4304 base::Unretained(&callback)));
4303 loop_.RunUntilIdle(); 4305 base::RunLoop().RunUntilIdle();
4304 EXPECT_EQ(0U, callback.list_.size()); 4306 EXPECT_EQ(0U, callback.list_.size());
4305 4307
4306 // The database should have vanished as well. 4308 // The database should have vanished as well.
4307 origins.clear(); 4309 origins.clear();
4308 db_tracker->GetAllOriginsInfo(&origins); 4310 db_tracker->GetAllOriginsInfo(&origins);
4309 EXPECT_EQ(0U, origins.size()); 4311 EXPECT_EQ(0U, origins.size());
4310 4312
4311 // Check that the LSO file has been removed. 4313 // Check that the LSO file has been removed.
4312 EXPECT_FALSE(base::PathExists(lso_file_path)); 4314 EXPECT_FALSE(base::PathExists(lso_file_path));
4313 4315
4314 // Check if the indexed db has disappeared too. 4316 // Check if the indexed db has disappeared too.
4315 EXPECT_FALSE(base::DirectoryExists(idb_path)); 4317 EXPECT_FALSE(base::DirectoryExists(idb_path));
4316 } 4318 }
4317 4319
4318 // Tests loading single extensions (like --load-extension) 4320 // Tests loading single extensions (like --load-extension)
4319 // Flaky crashes. http://crbug.com/231806 4321 // Flaky crashes. http://crbug.com/231806
4320 TEST_F(ExtensionServiceTest, DISABLED_LoadExtension) { 4322 TEST_F(ExtensionServiceTest, DISABLED_LoadExtension) {
4321 InitializeEmptyExtensionService(); 4323 InitializeEmptyExtensionService();
4322 4324
4323 base::FilePath ext1 = data_dir_ 4325 base::FilePath ext1 = data_dir_
4324 .AppendASCII("good") 4326 .AppendASCII("good")
4325 .AppendASCII("Extensions") 4327 .AppendASCII("Extensions")
4326 .AppendASCII("behllobkkfkfnphdnhnkndlbkcpglgmj") 4328 .AppendASCII("behllobkkfkfnphdnhnkndlbkcpglgmj")
4327 .AppendASCII("1.0.0.0"); 4329 .AppendASCII("1.0.0.0");
4328 extensions::UnpackedInstaller::Create(service_)->Load(ext1); 4330 extensions::UnpackedInstaller::Create(service_)->Load(ext1);
4329 loop_.RunUntilIdle(); 4331 base::RunLoop().RunUntilIdle();
4330 EXPECT_EQ(0u, GetErrors().size()); 4332 EXPECT_EQ(0u, GetErrors().size());
4331 ASSERT_EQ(1u, loaded_.size()); 4333 ASSERT_EQ(1u, loaded_.size());
4332 EXPECT_EQ(Manifest::UNPACKED, loaded_[0]->location()); 4334 EXPECT_EQ(Manifest::UNPACKED, loaded_[0]->location());
4333 EXPECT_EQ(1u, service_->extensions()->size()); 4335 EXPECT_EQ(1u, service_->extensions()->size());
4334 4336
4335 ValidatePrefKeyCount(1); 4337 ValidatePrefKeyCount(1);
4336 4338
4337 base::FilePath no_manifest = data_dir_ 4339 base::FilePath no_manifest = data_dir_
4338 .AppendASCII("bad") 4340 .AppendASCII("bad")
4339 // .AppendASCII("Extensions") 4341 // .AppendASCII("Extensions")
4340 .AppendASCII("cccccccccccccccccccccccccccccccc") 4342 .AppendASCII("cccccccccccccccccccccccccccccccc")
4341 .AppendASCII("1"); 4343 .AppendASCII("1");
4342 extensions::UnpackedInstaller::Create(service_)->Load(no_manifest); 4344 extensions::UnpackedInstaller::Create(service_)->Load(no_manifest);
4343 loop_.RunUntilIdle(); 4345 base::RunLoop().RunUntilIdle();
4344 EXPECT_EQ(1u, GetErrors().size()); 4346 EXPECT_EQ(1u, GetErrors().size());
4345 ASSERT_EQ(1u, loaded_.size()); 4347 ASSERT_EQ(1u, loaded_.size());
4346 EXPECT_EQ(1u, service_->extensions()->size()); 4348 EXPECT_EQ(1u, service_->extensions()->size());
4347 4349
4348 // Test uninstall. 4350 // Test uninstall.
4349 std::string id = loaded_[0]->id(); 4351 std::string id = loaded_[0]->id();
4350 EXPECT_FALSE(unloaded_id_.length()); 4352 EXPECT_FALSE(unloaded_id_.length());
4351 service_->UninstallExtension(id, false, NULL); 4353 service_->UninstallExtension(id, false, NULL);
4352 loop_.RunUntilIdle(); 4354 base::RunLoop().RunUntilIdle();
4353 EXPECT_EQ(id, unloaded_id_); 4355 EXPECT_EQ(id, unloaded_id_);
4354 ASSERT_EQ(0u, loaded_.size()); 4356 ASSERT_EQ(0u, loaded_.size());
4355 EXPECT_EQ(0u, service_->extensions()->size()); 4357 EXPECT_EQ(0u, service_->extensions()->size());
4356 } 4358 }
4357 4359
4358 // Tests that we generate IDs when they are not specified in the manifest for 4360 // Tests that we generate IDs when they are not specified in the manifest for
4359 // --load-extension. 4361 // --load-extension.
4360 TEST_F(ExtensionServiceTest, GenerateID) { 4362 TEST_F(ExtensionServiceTest, GenerateID) {
4361 InitializeEmptyExtensionService(); 4363 InitializeEmptyExtensionService();
4362 4364
4363 base::FilePath no_id_ext = data_dir_.AppendASCII("no_id"); 4365 base::FilePath no_id_ext = data_dir_.AppendASCII("no_id");
4364 extensions::UnpackedInstaller::Create(service_)->Load(no_id_ext); 4366 extensions::UnpackedInstaller::Create(service_)->Load(no_id_ext);
4365 loop_.RunUntilIdle(); 4367 base::RunLoop().RunUntilIdle();
4366 EXPECT_EQ(0u, GetErrors().size()); 4368 EXPECT_EQ(0u, GetErrors().size());
4367 ASSERT_EQ(1u, loaded_.size()); 4369 ASSERT_EQ(1u, loaded_.size());
4368 ASSERT_TRUE(Extension::IdIsValid(loaded_[0]->id())); 4370 ASSERT_TRUE(Extension::IdIsValid(loaded_[0]->id()));
4369 EXPECT_EQ(loaded_[0]->location(), Manifest::UNPACKED); 4371 EXPECT_EQ(loaded_[0]->location(), Manifest::UNPACKED);
4370 4372
4371 ValidatePrefKeyCount(1); 4373 ValidatePrefKeyCount(1);
4372 4374
4373 std::string previous_id = loaded_[0]->id(); 4375 std::string previous_id = loaded_[0]->id();
4374 4376
4375 // If we reload the same path, we should get the same extension ID. 4377 // If we reload the same path, we should get the same extension ID.
4376 extensions::UnpackedInstaller::Create(service_)->Load(no_id_ext); 4378 extensions::UnpackedInstaller::Create(service_)->Load(no_id_ext);
4377 loop_.RunUntilIdle(); 4379 base::RunLoop().RunUntilIdle();
4378 ASSERT_EQ(1u, loaded_.size()); 4380 ASSERT_EQ(1u, loaded_.size());
4379 ASSERT_EQ(previous_id, loaded_[0]->id()); 4381 ASSERT_EQ(previous_id, loaded_[0]->id());
4380 } 4382 }
4381 4383
4382 void ExtensionServiceTest::TestExternalProvider( 4384 void ExtensionServiceTest::TestExternalProvider(
4383 MockExtensionProvider* provider, Manifest::Location location) { 4385 MockExtensionProvider* provider, Manifest::Location location) {
4384 // Verify that starting with no providers loads no extensions. 4386 // Verify that starting with no providers loads no extensions.
4385 service_->Init(); 4387 service_->Init();
4386 ASSERT_EQ(0u, loaded_.size()); 4388 ASSERT_EQ(0u, loaded_.size());
4387 4389
(...skipping 17 matching lines...) Expand all
4405 ASSERT_EQ(location, loaded_[0]->location()); 4407 ASSERT_EQ(location, loaded_[0]->location());
4406 ASSERT_EQ("1.0.0.0", loaded_[0]->version()->GetString()); 4408 ASSERT_EQ("1.0.0.0", loaded_[0]->version()->GetString());
4407 ValidatePrefKeyCount(1); 4409 ValidatePrefKeyCount(1);
4408 ValidateIntegerPref(good_crx, "state", Extension::ENABLED); 4410 ValidateIntegerPref(good_crx, "state", Extension::ENABLED);
4409 ValidateIntegerPref(good_crx, "location", location); 4411 ValidateIntegerPref(good_crx, "location", location);
4410 4412
4411 // Reload extensions without changing anything. The extension should be 4413 // Reload extensions without changing anything. The extension should be
4412 // loaded again. 4414 // loaded again.
4413 loaded_.clear(); 4415 loaded_.clear();
4414 service_->ReloadExtensions(); 4416 service_->ReloadExtensions();
4415 loop_.RunUntilIdle(); 4417 base::RunLoop().RunUntilIdle();
4416 ASSERT_EQ(0u, GetErrors().size()); 4418 ASSERT_EQ(0u, GetErrors().size());
4417 ASSERT_EQ(1u, loaded_.size()); 4419 ASSERT_EQ(1u, loaded_.size());
4418 ValidatePrefKeyCount(1); 4420 ValidatePrefKeyCount(1);
4419 ValidateIntegerPref(good_crx, "state", Extension::ENABLED); 4421 ValidateIntegerPref(good_crx, "state", Extension::ENABLED);
4420 ValidateIntegerPref(good_crx, "location", location); 4422 ValidateIntegerPref(good_crx, "location", location);
4421 4423
4422 // Now update the extension with a new version. We should get upgraded. 4424 // Now update the extension with a new version. We should get upgraded.
4423 source_path = source_path.DirName().AppendASCII("good2.crx"); 4425 source_path = source_path.DirName().AppendASCII("good2.crx");
4424 provider->UpdateOrAddExtension(good_crx, "1.0.0.1", source_path); 4426 provider->UpdateOrAddExtension(good_crx, "1.0.0.1", source_path);
4425 4427
4426 loaded_.clear(); 4428 loaded_.clear();
4427 service_->CheckForExternalUpdates(); 4429 service_->CheckForExternalUpdates();
4428 content::WindowedNotificationObserver( 4430 content::WindowedNotificationObserver(
4429 chrome::NOTIFICATION_CRX_INSTALLER_DONE, 4431 chrome::NOTIFICATION_CRX_INSTALLER_DONE,
4430 content::NotificationService::AllSources()).Wait(); 4432 content::NotificationService::AllSources()).Wait();
4431 ASSERT_EQ(0u, GetErrors().size()); 4433 ASSERT_EQ(0u, GetErrors().size());
4432 ASSERT_EQ(1u, loaded_.size()); 4434 ASSERT_EQ(1u, loaded_.size());
4433 ASSERT_EQ("1.0.0.1", loaded_[0]->version()->GetString()); 4435 ASSERT_EQ("1.0.0.1", loaded_[0]->version()->GetString());
4434 ValidatePrefKeyCount(1); 4436 ValidatePrefKeyCount(1);
4435 ValidateIntegerPref(good_crx, "state", Extension::ENABLED); 4437 ValidateIntegerPref(good_crx, "state", Extension::ENABLED);
4436 ValidateIntegerPref(good_crx, "location", location); 4438 ValidateIntegerPref(good_crx, "location", location);
4437 4439
4438 // Uninstall the extension and reload. Nothing should happen because the 4440 // Uninstall the extension and reload. Nothing should happen because the
4439 // preference should prevent us from reinstalling. 4441 // preference should prevent us from reinstalling.
4440 std::string id = loaded_[0]->id(); 4442 std::string id = loaded_[0]->id();
4441 bool no_uninstall = 4443 bool no_uninstall =
4442 management_policy_->MustRemainEnabled(loaded_[0].get(), NULL); 4444 management_policy_->MustRemainEnabled(loaded_[0].get(), NULL);
4443 service_->UninstallExtension(id, false, NULL); 4445 service_->UninstallExtension(id, false, NULL);
4444 loop_.RunUntilIdle(); 4446 base::RunLoop().RunUntilIdle();
4445 4447
4446 base::FilePath install_path = extensions_install_dir_.AppendASCII(id); 4448 base::FilePath install_path = extensions_install_dir_.AppendASCII(id);
4447 if (no_uninstall) { 4449 if (no_uninstall) {
4448 // Policy controlled extensions should not have been touched by uninstall. 4450 // Policy controlled extensions should not have been touched by uninstall.
4449 ASSERT_TRUE(base::PathExists(install_path)); 4451 ASSERT_TRUE(base::PathExists(install_path));
4450 } else { 4452 } else {
4451 // The extension should also be gone from the install directory. 4453 // The extension should also be gone from the install directory.
4452 ASSERT_FALSE(base::PathExists(install_path)); 4454 ASSERT_FALSE(base::PathExists(install_path));
4453 loaded_.clear(); 4455 loaded_.clear();
4454 service_->CheckForExternalUpdates(); 4456 service_->CheckForExternalUpdates();
4455 loop_.RunUntilIdle(); 4457 base::RunLoop().RunUntilIdle();
4456 ASSERT_EQ(0u, loaded_.size()); 4458 ASSERT_EQ(0u, loaded_.size());
4457 ValidatePrefKeyCount(1); 4459 ValidatePrefKeyCount(1);
4458 ValidateIntegerPref(good_crx, "state", 4460 ValidateIntegerPref(good_crx, "state",
4459 Extension::EXTERNAL_EXTENSION_UNINSTALLED); 4461 Extension::EXTERNAL_EXTENSION_UNINSTALLED);
4460 ValidateIntegerPref(good_crx, "location", location); 4462 ValidateIntegerPref(good_crx, "location", location);
4461 4463
4462 // Now clear the preference and reinstall. 4464 // Now clear the preference and reinstall.
4463 SetPrefInteg(good_crx, "state", Extension::ENABLED); 4465 SetPrefInteg(good_crx, "state", Extension::ENABLED);
4464 4466
4465 loaded_.clear(); 4467 loaded_.clear();
4466 service_->CheckForExternalUpdates(); 4468 service_->CheckForExternalUpdates();
4467 content::WindowedNotificationObserver( 4469 content::WindowedNotificationObserver(
4468 chrome::NOTIFICATION_CRX_INSTALLER_DONE, 4470 chrome::NOTIFICATION_CRX_INSTALLER_DONE,
4469 content::NotificationService::AllSources()).Wait(); 4471 content::NotificationService::AllSources()).Wait();
4470 ASSERT_EQ(1u, loaded_.size()); 4472 ASSERT_EQ(1u, loaded_.size());
4471 } 4473 }
4472 ValidatePrefKeyCount(1); 4474 ValidatePrefKeyCount(1);
4473 ValidateIntegerPref(good_crx, "state", Extension::ENABLED); 4475 ValidateIntegerPref(good_crx, "state", Extension::ENABLED);
4474 ValidateIntegerPref(good_crx, "location", location); 4476 ValidateIntegerPref(good_crx, "location", location);
4475 4477
4476 if (management_policy_->MustRemainEnabled(loaded_[0].get(), NULL)) { 4478 if (management_policy_->MustRemainEnabled(loaded_[0].get(), NULL)) {
4477 EXPECT_EQ(2, provider->visit_count()); 4479 EXPECT_EQ(2, provider->visit_count());
4478 } else { 4480 } else {
4479 // Now test an externally triggered uninstall (deleting the registry key or 4481 // Now test an externally triggered uninstall (deleting the registry key or
4480 // the pref entry). 4482 // the pref entry).
4481 provider->RemoveExtension(good_crx); 4483 provider->RemoveExtension(good_crx);
4482 4484
4483 loaded_.clear(); 4485 loaded_.clear();
4484 service_->OnExternalProviderReady(provider); 4486 service_->OnExternalProviderReady(provider);
4485 loop_.RunUntilIdle(); 4487 base::RunLoop().RunUntilIdle();
4486 ASSERT_EQ(0u, loaded_.size()); 4488 ASSERT_EQ(0u, loaded_.size());
4487 ValidatePrefKeyCount(0); 4489 ValidatePrefKeyCount(0);
4488 4490
4489 // The extension should also be gone from the install directory. 4491 // The extension should also be gone from the install directory.
4490 ASSERT_FALSE(base::PathExists(install_path)); 4492 ASSERT_FALSE(base::PathExists(install_path));
4491 4493
4492 // Now test the case where user uninstalls and then the extension is removed 4494 // Now test the case where user uninstalls and then the extension is removed
4493 // from the external provider. 4495 // from the external provider.
4494 provider->UpdateOrAddExtension(good_crx, "1.0.0.1", source_path); 4496 provider->UpdateOrAddExtension(good_crx, "1.0.0.1", source_path);
4495 service_->CheckForExternalUpdates(); 4497 service_->CheckForExternalUpdates();
4496 content::WindowedNotificationObserver( 4498 content::WindowedNotificationObserver(
4497 chrome::NOTIFICATION_CRX_INSTALLER_DONE, 4499 chrome::NOTIFICATION_CRX_INSTALLER_DONE,
4498 content::NotificationService::AllSources()).Wait(); 4500 content::NotificationService::AllSources()).Wait();
4499 4501
4500 ASSERT_EQ(1u, loaded_.size()); 4502 ASSERT_EQ(1u, loaded_.size());
4501 ASSERT_EQ(0u, GetErrors().size()); 4503 ASSERT_EQ(0u, GetErrors().size());
4502 4504
4503 // User uninstalls. 4505 // User uninstalls.
4504 loaded_.clear(); 4506 loaded_.clear();
4505 service_->UninstallExtension(id, false, NULL); 4507 service_->UninstallExtension(id, false, NULL);
4506 loop_.RunUntilIdle(); 4508 base::RunLoop().RunUntilIdle();
4507 ASSERT_EQ(0u, loaded_.size()); 4509 ASSERT_EQ(0u, loaded_.size());
4508 4510
4509 // Then remove the extension from the extension provider. 4511 // Then remove the extension from the extension provider.
4510 provider->RemoveExtension(good_crx); 4512 provider->RemoveExtension(good_crx);
4511 4513
4512 // Should still be at 0. 4514 // Should still be at 0.
4513 loaded_.clear(); 4515 loaded_.clear();
4514 extensions::InstalledLoader(service_).LoadAllExtensions(); 4516 extensions::InstalledLoader(service_).LoadAllExtensions();
4515 loop_.RunUntilIdle(); 4517 base::RunLoop().RunUntilIdle();
4516 ASSERT_EQ(0u, loaded_.size()); 4518 ASSERT_EQ(0u, loaded_.size());
4517 ValidatePrefKeyCount(1); 4519 ValidatePrefKeyCount(1);
4518 4520
4519 EXPECT_EQ(5, provider->visit_count()); 4521 EXPECT_EQ(5, provider->visit_count());
4520 } 4522 }
4521 } 4523 }
4522 4524
4523 // Tests the external installation feature 4525 // Tests the external installation feature
4524 #if defined(OS_WIN) 4526 #if defined(OS_WIN)
4525 TEST_F(ExtensionServiceTest, ExternalInstallRegistry) { 4527 TEST_F(ExtensionServiceTest, ExternalInstallRegistry) {
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
4600 set_extensions_enabled(false); 4602 set_extensions_enabled(false);
4601 4603
4602 service_->Init(); 4604 service_->Init();
4603 4605
4604 ASSERT_EQ(0u, GetErrors().size()); 4606 ASSERT_EQ(0u, GetErrors().size());
4605 ASSERT_EQ(0u, loaded_.size()); 4607 ASSERT_EQ(0u, loaded_.size());
4606 4608
4607 // Verify that it's not the disabled extensions flag causing it not to load. 4609 // Verify that it's not the disabled extensions flag causing it not to load.
4608 set_extensions_enabled(true); 4610 set_extensions_enabled(true);
4609 service_->ReloadExtensions(); 4611 service_->ReloadExtensions();
4610 loop_.RunUntilIdle(); 4612 base::RunLoop().RunUntilIdle();
4611 4613
4612 ASSERT_EQ(0u, GetErrors().size()); 4614 ASSERT_EQ(0u, GetErrors().size());
4613 ASSERT_EQ(0u, loaded_.size()); 4615 ASSERT_EQ(0u, loaded_.size());
4614 } 4616 }
4615 4617
4616 // Test that running multiple update checks simultaneously does not 4618 // Test that running multiple update checks simultaneously does not
4617 // keep the update from succeeding. 4619 // keep the update from succeeding.
4618 TEST_F(ExtensionServiceTest, MultipleExternalUpdateCheck) { 4620 TEST_F(ExtensionServiceTest, MultipleExternalUpdateCheck) {
4619 InitializeEmptyExtensionService(); 4621 InitializeEmptyExtensionService();
4620 4622
4621 MockExtensionProvider* provider = 4623 MockExtensionProvider* provider =
4622 new MockExtensionProvider(service_, Manifest::EXTERNAL_PREF); 4624 new MockExtensionProvider(service_, Manifest::EXTERNAL_PREF);
4623 AddMockExternalProvider(provider); 4625 AddMockExternalProvider(provider);
4624 4626
4625 // Verify that starting with no providers loads no extensions. 4627 // Verify that starting with no providers loads no extensions.
4626 service_->Init(); 4628 service_->Init();
4627 ASSERT_EQ(0u, loaded_.size()); 4629 ASSERT_EQ(0u, loaded_.size());
4628 4630
4629 // Start two checks for updates. 4631 // Start two checks for updates.
4630 provider->set_visit_count(0); 4632 provider->set_visit_count(0);
4631 service_->CheckForExternalUpdates(); 4633 service_->CheckForExternalUpdates();
4632 service_->CheckForExternalUpdates(); 4634 service_->CheckForExternalUpdates();
4633 loop_.RunUntilIdle(); 4635 base::RunLoop().RunUntilIdle();
4634 4636
4635 // Two calls should cause two checks for external extensions. 4637 // Two calls should cause two checks for external extensions.
4636 EXPECT_EQ(2, provider->visit_count()); 4638 EXPECT_EQ(2, provider->visit_count());
4637 EXPECT_EQ(0u, GetErrors().size()); 4639 EXPECT_EQ(0u, GetErrors().size());
4638 EXPECT_EQ(0u, loaded_.size()); 4640 EXPECT_EQ(0u, loaded_.size());
4639 4641
4640 // Register a test extension externally using the mock registry provider. 4642 // Register a test extension externally using the mock registry provider.
4641 base::FilePath source_path = data_dir_.AppendASCII("good.crx"); 4643 base::FilePath source_path = data_dir_.AppendASCII("good.crx");
4642 provider->UpdateOrAddExtension(good_crx, "1.0.0.0", source_path); 4644 provider->UpdateOrAddExtension(good_crx, "1.0.0.0", source_path);
4643 4645
(...skipping 11 matching lines...) Expand all
4655 ASSERT_EQ(Manifest::EXTERNAL_PREF, loaded_[0]->location()); 4657 ASSERT_EQ(Manifest::EXTERNAL_PREF, loaded_[0]->location());
4656 ASSERT_EQ("1.0.0.0", loaded_[0]->version()->GetString()); 4658 ASSERT_EQ("1.0.0.0", loaded_[0]->version()->GetString());
4657 ValidatePrefKeyCount(1); 4659 ValidatePrefKeyCount(1);
4658 ValidateIntegerPref(good_crx, "state", Extension::ENABLED); 4660 ValidateIntegerPref(good_crx, "state", Extension::ENABLED);
4659 ValidateIntegerPref(good_crx, "location", Manifest::EXTERNAL_PREF); 4661 ValidateIntegerPref(good_crx, "location", Manifest::EXTERNAL_PREF);
4660 4662
4661 provider->RemoveExtension(good_crx); 4663 provider->RemoveExtension(good_crx);
4662 provider->set_visit_count(0); 4664 provider->set_visit_count(0);
4663 service_->CheckForExternalUpdates(); 4665 service_->CheckForExternalUpdates();
4664 service_->CheckForExternalUpdates(); 4666 service_->CheckForExternalUpdates();
4665 loop_.RunUntilIdle(); 4667 base::RunLoop().RunUntilIdle();
4666 4668
4667 // Two calls should cause two checks for external extensions. 4669 // Two calls should cause two checks for external extensions.
4668 // Because the external source no longer includes good_crx, 4670 // Because the external source no longer includes good_crx,
4669 // good_crx will be uninstalled. So, expect that no extensions 4671 // good_crx will be uninstalled. So, expect that no extensions
4670 // are loaded. 4672 // are loaded.
4671 EXPECT_EQ(2, provider->visit_count()); 4673 EXPECT_EQ(2, provider->visit_count());
4672 EXPECT_EQ(0u, GetErrors().size()); 4674 EXPECT_EQ(0u, GetErrors().size());
4673 EXPECT_EQ(0u, loaded_.size()); 4675 EXPECT_EQ(0u, loaded_.size());
4674 } 4676 }
4675 4677
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
4927 TEST(ExtensionServiceTestSimple, Enabledness) { 4929 TEST(ExtensionServiceTestSimple, Enabledness) {
4928 // Make sure the PluginService singleton is destroyed at the end of the test. 4930 // Make sure the PluginService singleton is destroyed at the end of the test.
4929 base::ShadowingAtExitManager at_exit_manager; 4931 base::ShadowingAtExitManager at_exit_manager;
4930 #if defined(ENABLE_PLUGINS) 4932 #if defined(ENABLE_PLUGINS)
4931 content::PluginService::GetInstance()->Init(); 4933 content::PluginService::GetInstance()->Init();
4932 content::PluginService::GetInstance()->DisablePluginsDiscoveryForTesting(); 4934 content::PluginService::GetInstance()->DisablePluginsDiscoveryForTesting();
4933 #endif 4935 #endif
4934 4936
4935 ExtensionErrorReporter::Init(false); // no noisy errors 4937 ExtensionErrorReporter::Init(false); // no noisy errors
4936 ExtensionsReadyRecorder recorder; 4938 ExtensionsReadyRecorder recorder;
4939 content::TestBrowserThreadBundle thread_bundle;
4937 scoped_ptr<TestingProfile> profile(new TestingProfile()); 4940 scoped_ptr<TestingProfile> profile(new TestingProfile());
4938 base::MessageLoop loop;
4939 content::TestBrowserThread ui_thread(BrowserThread::UI, &loop);
4940 content::TestBrowserThread file_thread(BrowserThread::FILE, &loop);
4941 #if defined OS_CHROMEOS 4941 #if defined OS_CHROMEOS
4942 chromeos::ScopedTestDeviceSettingsService device_settings_service; 4942 chromeos::ScopedTestDeviceSettingsService device_settings_service;
4943 chromeos::ScopedTestCrosSettings cros_settings; 4943 chromeos::ScopedTestCrosSettings cros_settings;
4944 scoped_ptr<chromeos::ScopedTestUserManager> user_manager( 4944 scoped_ptr<chromeos::ScopedTestUserManager> user_manager(
4945 new chromeos::ScopedTestUserManager); 4945 new chromeos::ScopedTestUserManager);
4946 #endif 4946 #endif
4947 scoped_ptr<CommandLine> command_line; 4947 scoped_ptr<CommandLine> command_line;
4948 base::FilePath install_dir = profile->GetPath() 4948 base::FilePath install_dir = profile->GetPath()
4949 .AppendASCII(extensions::kInstallDirectoryName); 4949 .AppendASCII(extensions::kInstallDirectoryName);
4950 4950
4951 // By default, we are enabled. 4951 // By default, we are enabled.
4952 command_line.reset(new CommandLine(CommandLine::NO_PROGRAM)); 4952 command_line.reset(new CommandLine(CommandLine::NO_PROGRAM));
4953 ExtensionService* service = static_cast<extensions::TestExtensionSystem*>( 4953 ExtensionService* service = static_cast<extensions::TestExtensionSystem*>(
4954 ExtensionSystem::Get(profile.get()))-> 4954 ExtensionSystem::Get(profile.get()))->
4955 CreateExtensionService( 4955 CreateExtensionService(
4956 command_line.get(), 4956 command_line.get(),
4957 install_dir, 4957 install_dir,
4958 false); 4958 false);
4959 EXPECT_TRUE(service->extensions_enabled()); 4959 EXPECT_TRUE(service->extensions_enabled());
4960 service->Init(); 4960 service->Init();
4961 loop.RunUntilIdle(); 4961 base::RunLoop().RunUntilIdle();
4962 EXPECT_TRUE(recorder.ready()); 4962 EXPECT_TRUE(recorder.ready());
4963 #if defined OS_CHROMEOS 4963 #if defined OS_CHROMEOS
4964 user_manager.reset(); 4964 user_manager.reset();
4965 #endif 4965 #endif
4966 4966
4967 // If either the command line or pref is set, we are disabled. 4967 // If either the command line or pref is set, we are disabled.
4968 recorder.set_ready(false); 4968 recorder.set_ready(false);
4969 profile.reset(new TestingProfile()); 4969 profile.reset(new TestingProfile());
4970 command_line->AppendSwitch(switches::kDisableExtensions); 4970 command_line->AppendSwitch(switches::kDisableExtensions);
4971 service = static_cast<extensions::TestExtensionSystem*>( 4971 service = static_cast<extensions::TestExtensionSystem*>(
4972 ExtensionSystem::Get(profile.get()))-> 4972 ExtensionSystem::Get(profile.get()))->
4973 CreateExtensionService( 4973 CreateExtensionService(
4974 command_line.get(), 4974 command_line.get(),
4975 install_dir, 4975 install_dir,
4976 false); 4976 false);
4977 EXPECT_FALSE(service->extensions_enabled()); 4977 EXPECT_FALSE(service->extensions_enabled());
4978 service->Init(); 4978 service->Init();
4979 loop.RunUntilIdle(); 4979 base::RunLoop().RunUntilIdle();
4980 EXPECT_TRUE(recorder.ready()); 4980 EXPECT_TRUE(recorder.ready());
4981 4981
4982 recorder.set_ready(false); 4982 recorder.set_ready(false);
4983 profile.reset(new TestingProfile()); 4983 profile.reset(new TestingProfile());
4984 profile->GetPrefs()->SetBoolean(prefs::kDisableExtensions, true); 4984 profile->GetPrefs()->SetBoolean(prefs::kDisableExtensions, true);
4985 service = static_cast<extensions::TestExtensionSystem*>( 4985 service = static_cast<extensions::TestExtensionSystem*>(
4986 ExtensionSystem::Get(profile.get()))-> 4986 ExtensionSystem::Get(profile.get()))->
4987 CreateExtensionService( 4987 CreateExtensionService(
4988 command_line.get(), 4988 command_line.get(),
4989 install_dir, 4989 install_dir,
4990 false); 4990 false);
4991 EXPECT_FALSE(service->extensions_enabled()); 4991 EXPECT_FALSE(service->extensions_enabled());
4992 service->Init(); 4992 service->Init();
4993 loop.RunUntilIdle(); 4993 base::RunLoop().RunUntilIdle();
4994 EXPECT_TRUE(recorder.ready()); 4994 EXPECT_TRUE(recorder.ready());
4995 4995
4996 recorder.set_ready(false); 4996 recorder.set_ready(false);
4997 profile.reset(new TestingProfile()); 4997 profile.reset(new TestingProfile());
4998 profile->GetPrefs()->SetBoolean(prefs::kDisableExtensions, true); 4998 profile->GetPrefs()->SetBoolean(prefs::kDisableExtensions, true);
4999 command_line.reset(new CommandLine(CommandLine::NO_PROGRAM)); 4999 command_line.reset(new CommandLine(CommandLine::NO_PROGRAM));
5000 service = static_cast<extensions::TestExtensionSystem*>( 5000 service = static_cast<extensions::TestExtensionSystem*>(
5001 ExtensionSystem::Get(profile.get()))-> 5001 ExtensionSystem::Get(profile.get()))->
5002 CreateExtensionService( 5002 CreateExtensionService(
5003 command_line.get(), 5003 command_line.get(),
5004 install_dir, 5004 install_dir,
5005 false); 5005 false);
5006 EXPECT_FALSE(service->extensions_enabled()); 5006 EXPECT_FALSE(service->extensions_enabled());
5007 service->Init(); 5007 service->Init();
5008 loop.RunUntilIdle(); 5008 base::RunLoop().RunUntilIdle();
5009 EXPECT_TRUE(recorder.ready()); 5009 EXPECT_TRUE(recorder.ready());
5010 5010
5011 // Explicitly delete all the resources used in this test. 5011 // Explicitly delete all the resources used in this test.
5012 profile.reset(); 5012 profile.reset();
5013 service = NULL; 5013 service = NULL;
5014 // Execute any pending deletion tasks. 5014 // Execute any pending deletion tasks.
5015 loop.RunUntilIdle(); 5015 base::RunLoop().RunUntilIdle();
5016 } 5016 }
5017 5017
5018 // Test loading extensions that require limited and unlimited storage quotas. 5018 // Test loading extensions that require limited and unlimited storage quotas.
5019 TEST_F(ExtensionServiceTest, StorageQuota) { 5019 TEST_F(ExtensionServiceTest, StorageQuota) {
5020 InitializeEmptyExtensionService(); 5020 InitializeEmptyExtensionService();
5021 5021
5022 base::FilePath extensions_path = data_dir_ 5022 base::FilePath extensions_path = data_dir_
5023 .AppendASCII("storage_quota"); 5023 .AppendASCII("storage_quota");
5024 5024
5025 base::FilePath limited_quota_ext = 5025 base::FilePath limited_quota_ext =
5026 extensions_path.AppendASCII("limited_quota") 5026 extensions_path.AppendASCII("limited_quota")
5027 .AppendASCII("1.0"); 5027 .AppendASCII("1.0");
5028 5028
5029 // The old permission name for unlimited quota was "unlimited_storage", but 5029 // The old permission name for unlimited quota was "unlimited_storage", but
5030 // we changed it to "unlimitedStorage". This tests both versions. 5030 // we changed it to "unlimitedStorage". This tests both versions.
5031 base::FilePath unlimited_quota_ext = 5031 base::FilePath unlimited_quota_ext =
5032 extensions_path.AppendASCII("unlimited_quota") 5032 extensions_path.AppendASCII("unlimited_quota")
5033 .AppendASCII("1.0"); 5033 .AppendASCII("1.0");
5034 base::FilePath unlimited_quota_ext2 = 5034 base::FilePath unlimited_quota_ext2 =
5035 extensions_path.AppendASCII("unlimited_quota") 5035 extensions_path.AppendASCII("unlimited_quota")
5036 .AppendASCII("2.0"); 5036 .AppendASCII("2.0");
5037 extensions::UnpackedInstaller::Create(service_)->Load(limited_quota_ext); 5037 extensions::UnpackedInstaller::Create(service_)->Load(limited_quota_ext);
5038 extensions::UnpackedInstaller::Create(service_)->Load(unlimited_quota_ext); 5038 extensions::UnpackedInstaller::Create(service_)->Load(unlimited_quota_ext);
5039 extensions::UnpackedInstaller::Create(service_)->Load(unlimited_quota_ext2); 5039 extensions::UnpackedInstaller::Create(service_)->Load(unlimited_quota_ext2);
5040 loop_.RunUntilIdle(); 5040 base::RunLoop().RunUntilIdle();
5041 5041
5042 ASSERT_EQ(3u, loaded_.size()); 5042 ASSERT_EQ(3u, loaded_.size());
5043 EXPECT_TRUE(profile_.get()); 5043 EXPECT_TRUE(profile_.get());
5044 EXPECT_FALSE(profile_->IsOffTheRecord()); 5044 EXPECT_FALSE(profile_->IsOffTheRecord());
5045 EXPECT_FALSE(profile_->GetExtensionSpecialStoragePolicy()->IsStorageUnlimited( 5045 EXPECT_FALSE(profile_->GetExtensionSpecialStoragePolicy()->IsStorageUnlimited(
5046 loaded_[0]->url())); 5046 loaded_[0]->url()));
5047 EXPECT_TRUE(profile_->GetExtensionSpecialStoragePolicy()->IsStorageUnlimited( 5047 EXPECT_TRUE(profile_->GetExtensionSpecialStoragePolicy()->IsStorageUnlimited(
5048 loaded_[1]->url())); 5048 loaded_[1]->url()));
5049 EXPECT_TRUE(profile_->GetExtensionSpecialStoragePolicy()->IsStorageUnlimited( 5049 EXPECT_TRUE(profile_->GetExtensionSpecialStoragePolicy()->IsStorageUnlimited(
5050 loaded_[2]->url())); 5050 loaded_[2]->url()));
(...skipping 1145 matching lines...) Expand 10 before | Expand all | Expand 10 after
6196 // needs to know about. 6196 // needs to know about.
6197 EXPECT_FALSE(extensions::HasExternalInstallError(service_)); 6197 EXPECT_FALSE(extensions::HasExternalInstallError(service_));
6198 6198
6199 // This is a normal extension, installed normally. 6199 // This is a normal extension, installed normally.
6200 // This should NOT trigger an alert. 6200 // This should NOT trigger an alert.
6201 set_extensions_enabled(true); 6201 set_extensions_enabled(true);
6202 base::FilePath path = data_dir_.AppendASCII("good.crx"); 6202 base::FilePath path = data_dir_.AppendASCII("good.crx");
6203 InstallCRX(path, INSTALL_NEW); 6203 InstallCRX(path, INSTALL_NEW);
6204 6204
6205 service_->CheckForExternalUpdates(); 6205 service_->CheckForExternalUpdates();
6206 loop_.RunUntilIdle(); 6206 base::RunLoop().RunUntilIdle();
6207 EXPECT_FALSE(extensions::HasExternalInstallError(service_)); 6207 EXPECT_FALSE(extensions::HasExternalInstallError(service_));
6208 6208
6209 // A hosted app, installed externally. 6209 // A hosted app, installed externally.
6210 // This should NOT trigger an alert. 6210 // This should NOT trigger an alert.
6211 provider->UpdateOrAddExtension(hosted_app, "1.0.0.0", 6211 provider->UpdateOrAddExtension(hosted_app, "1.0.0.0",
6212 data_dir_.AppendASCII("hosted_app.crx")); 6212 data_dir_.AppendASCII("hosted_app.crx"));
6213 6213
6214 service_->CheckForExternalUpdates(); 6214 service_->CheckForExternalUpdates();
6215 content::WindowedNotificationObserver( 6215 content::WindowedNotificationObserver(
6216 chrome::NOTIFICATION_CRX_INSTALLER_DONE, 6216 chrome::NOTIFICATION_CRX_INSTALLER_DONE,
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
6371 content::NotificationService::AllSources(), id_set); 6371 content::NotificationService::AllSources(), id_set);
6372 6372
6373 // Installation should be allowed but the extension should never have been 6373 // Installation should be allowed but the extension should never have been
6374 // loaded and it should be blacklisted in prefs. 6374 // loaded and it should be blacklisted in prefs.
6375 service_->OnExtensionInstalled( 6375 service_->OnExtensionInstalled(
6376 extension.get(), 6376 extension.get(),
6377 syncer::StringOrdinal(), 6377 syncer::StringOrdinal(),
6378 false /* has requirement errors */, 6378 false /* has requirement errors */,
6379 extensions::Blacklist::BLACKLISTED, 6379 extensions::Blacklist::BLACKLISTED,
6380 false /* wait for idle */); 6380 false /* wait for idle */);
6381 loop_.RunUntilIdle(); 6381 base::RunLoop().RunUntilIdle();
6382 6382
6383 // Extension was installed but not loaded. 6383 // Extension was installed but not loaded.
6384 EXPECT_TRUE(notifications.CheckNotifications( 6384 EXPECT_TRUE(notifications.CheckNotifications(
6385 chrome::NOTIFICATION_EXTENSION_INSTALLED)); 6385 chrome::NOTIFICATION_EXTENSION_INSTALLED));
6386 6386
6387 EXPECT_TRUE(service_->GetInstalledExtension(id)); 6387 EXPECT_TRUE(service_->GetInstalledExtension(id));
6388 EXPECT_FALSE(service_->extensions()->Contains(id)); 6388 EXPECT_FALSE(service_->extensions()->Contains(id));
6389 EXPECT_TRUE(service_->blacklisted_extensions()->Contains(id)); 6389 EXPECT_TRUE(service_->blacklisted_extensions()->Contains(id));
6390 EXPECT_TRUE(service_->extension_prefs()->IsExtensionBlacklisted(id)); 6390 EXPECT_TRUE(service_->extension_prefs()->IsExtensionBlacklisted(id));
6391 EXPECT_TRUE( 6391 EXPECT_TRUE(
6392 service_->extension_prefs()->IsBlacklistedExtensionAcknowledged(id)); 6392 service_->extension_prefs()->IsBlacklistedExtensionAcknowledged(id));
6393 } 6393 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698