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

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

Issue 9977021: Add ExtensionSytem::Get(Profile*) as a wrapper around (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/extensions/extension_service_unittest.h" 5 #include "chrome/browser/extensions/extension_service_unittest.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <set> 8 #include <set>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 19 matching lines...) Expand all
30 #include "chrome/browser/extensions/component_loader.h" 30 #include "chrome/browser/extensions/component_loader.h"
31 #include "chrome/browser/extensions/crx_installer.h" 31 #include "chrome/browser/extensions/crx_installer.h"
32 #include "chrome/browser/extensions/extension_creator.h" 32 #include "chrome/browser/extensions/extension_creator.h"
33 #include "chrome/browser/extensions/extension_error_reporter.h" 33 #include "chrome/browser/extensions/extension_error_reporter.h"
34 #include "chrome/browser/extensions/extension_global_error.h" 34 #include "chrome/browser/extensions/extension_global_error.h"
35 #include "chrome/browser/extensions/extension_service.h" 35 #include "chrome/browser/extensions/extension_service.h"
36 #include "chrome/browser/extensions/extension_sorting.h" 36 #include "chrome/browser/extensions/extension_sorting.h"
37 #include "chrome/browser/extensions/extension_special_storage_policy.h" 37 #include "chrome/browser/extensions/extension_special_storage_policy.h"
38 #include "chrome/browser/extensions/extension_sync_data.h" 38 #include "chrome/browser/extensions/extension_sync_data.h"
39 #include "chrome/browser/extensions/extension_system.h" 39 #include "chrome/browser/extensions/extension_system.h"
40 #include "chrome/browser/extensions/extension_system_factory.h"
41 #include "chrome/browser/extensions/external_extension_provider_impl.h" 40 #include "chrome/browser/extensions/external_extension_provider_impl.h"
42 #include "chrome/browser/extensions/external_extension_provider_interface.h" 41 #include "chrome/browser/extensions/external_extension_provider_interface.h"
43 #include "chrome/browser/extensions/external_pref_extension_loader.h" 42 #include "chrome/browser/extensions/external_pref_extension_loader.h"
44 #include "chrome/browser/extensions/installed_loader.h" 43 #include "chrome/browser/extensions/installed_loader.h"
45 #include "chrome/browser/extensions/pack_extension_job.cc" 44 #include "chrome/browser/extensions/pack_extension_job.cc"
46 #include "chrome/browser/extensions/pending_extension_info.h" 45 #include "chrome/browser/extensions/pending_extension_info.h"
47 #include "chrome/browser/extensions/pending_extension_manager.h" 46 #include "chrome/browser/extensions/pending_extension_manager.h"
48 #include "chrome/browser/extensions/test_extension_system.h" 47 #include "chrome/browser/extensions/test_extension_system.h"
49 #include "chrome/browser/extensions/unpacked_installer.h" 48 #include "chrome/browser/extensions/unpacked_installer.h"
50 #include "chrome/browser/extensions/updater/extension_updater.h" 49 #include "chrome/browser/extensions/updater/extension_updater.h"
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 Profile::RegisterUserPrefs(prefs); 414 Profile::RegisterUserPrefs(prefs);
416 browser::RegisterUserPrefs(prefs); 415 browser::RegisterUserPrefs(prefs);
417 profile->SetPrefService(prefs); 416 profile->SetPrefService(prefs);
418 417
419 ThemeServiceFactory::GetInstance()->ForceRegisterPrefsForTest(prefs); 418 ThemeServiceFactory::GetInstance()->ForceRegisterPrefsForTest(prefs);
420 PluginPrefsFactory::GetInstance()->ForceRegisterPrefsForTest(prefs); 419 PluginPrefsFactory::GetInstance()->ForceRegisterPrefsForTest(prefs);
421 420
422 profile_.reset(profile); 421 profile_.reset(profile);
423 422
424 service_ = static_cast<TestExtensionSystem*>( 423 service_ = static_cast<TestExtensionSystem*>(
425 ExtensionSystemFactory::GetForProfile(profile))->CreateExtensionService( 424 ExtensionSystem::Get(profile))->CreateExtensionService(
426 CommandLine::ForCurrentProcess(), 425 CommandLine::ForCurrentProcess(),
427 extensions_install_dir, 426 extensions_install_dir,
428 autoupdate_enabled); 427 autoupdate_enabled);
429 service_->set_extensions_enabled(true); 428 service_->set_extensions_enabled(true);
430 service_->set_show_extensions_prompts(false); 429 service_->set_show_extensions_prompts(false);
431 430
432 // When we start up, we want to make sure there is no external provider, 431 // When we start up, we want to make sure there is no external provider,
433 // since the ExtensionService on Windows will use the Registry as a default 432 // since the ExtensionService on Windows will use the Registry as a default
434 // provider and if there is something already registered there then it will 433 // provider and if there is something already registered there then it will
435 // interfere with the tests. Those tests that need an external provider 434 // interfere with the tests. Those tests that need an external provider
(...skipping 19 matching lines...) Expand all
455 454
456 InitializeExtensionService(temp_prefs, extensions_install_dir_, false); 455 InitializeExtensionService(temp_prefs, extensions_install_dir_, false);
457 } 456 }
458 457
459 void ExtensionServiceTestBase::InitializeEmptyExtensionService() { 458 void ExtensionServiceTestBase::InitializeEmptyExtensionService() {
460 InitializeExtensionServiceHelper(false); 459 InitializeExtensionServiceHelper(false);
461 } 460 }
462 461
463 void ExtensionServiceTestBase::InitializeExtensionProcessManager() { 462 void ExtensionServiceTestBase::InitializeExtensionProcessManager() {
464 static_cast<TestExtensionSystem*>( 463 static_cast<TestExtensionSystem*>(
465 ExtensionSystemFactory::GetForProfile(profile_.get()))-> 464 ExtensionSystem::Get(profile_.get()))->
466 CreateExtensionProcessManager(); 465 CreateExtensionProcessManager();
467 } 466 }
468 467
469 void ExtensionServiceTestBase::InitializeExtensionServiceWithUpdater() { 468 void ExtensionServiceTestBase::InitializeExtensionServiceWithUpdater() {
470 InitializeExtensionServiceHelper(true); 469 InitializeExtensionServiceHelper(true);
471 service_->updater()->Start(); 470 service_->updater()->Start();
472 } 471 }
473 472
474 void ExtensionServiceTestBase::InitializeExtensionServiceHelper( 473 void ExtensionServiceTestBase::InitializeExtensionServiceHelper(
475 bool autoupdate_enabled) { 474 bool autoupdate_enabled) {
(...skipping 3372 matching lines...) Expand 10 before | Expand all | Expand 10 after
3848 content::TestBrowserThread file_thread(BrowserThread::FILE, &loop); 3847 content::TestBrowserThread file_thread(BrowserThread::FILE, &loop);
3849 scoped_ptr<CommandLine> command_line; 3848 scoped_ptr<CommandLine> command_line;
3850 FilePath install_dir = profile->GetPath() 3849 FilePath install_dir = profile->GetPath()
3851 .AppendASCII(ExtensionService::kInstallDirectoryName); 3850 .AppendASCII(ExtensionService::kInstallDirectoryName);
3852 webkit::npapi::MockPluginList plugin_list(NULL, 0); 3851 webkit::npapi::MockPluginList plugin_list(NULL, 0);
3853 PluginService::GetInstance()->SetPluginListForTesting(&plugin_list); 3852 PluginService::GetInstance()->SetPluginListForTesting(&plugin_list);
3854 3853
3855 // By default, we are enabled. 3854 // By default, we are enabled.
3856 command_line.reset(new CommandLine(CommandLine::NO_PROGRAM)); 3855 command_line.reset(new CommandLine(CommandLine::NO_PROGRAM));
3857 ExtensionService* service = static_cast<TestExtensionSystem*>( 3856 ExtensionService* service = static_cast<TestExtensionSystem*>(
3858 ExtensionSystemFactory::GetForProfile(profile.get()))-> 3857 ExtensionSystem::Get(profile.get()))->
3859 CreateExtensionService( 3858 CreateExtensionService(
3860 command_line.get(), 3859 command_line.get(),
3861 install_dir, 3860 install_dir,
3862 false); 3861 false);
3863 EXPECT_TRUE(service->extensions_enabled()); 3862 EXPECT_TRUE(service->extensions_enabled());
3864 service->Init(); 3863 service->Init();
3865 loop.RunAllPending(); 3864 loop.RunAllPending();
3866 EXPECT_TRUE(recorder.ready()); 3865 EXPECT_TRUE(recorder.ready());
3867 3866
3868 // If either the command line or pref is set, we are disabled. 3867 // If either the command line or pref is set, we are disabled.
3869 recorder.set_ready(false); 3868 recorder.set_ready(false);
3870 profile.reset(new TestingProfile()); 3869 profile.reset(new TestingProfile());
3871 command_line->AppendSwitch(switches::kDisableExtensions); 3870 command_line->AppendSwitch(switches::kDisableExtensions);
3872 service = static_cast<TestExtensionSystem*>( 3871 service = static_cast<TestExtensionSystem*>(
3873 ExtensionSystemFactory::GetForProfile(profile.get()))-> 3872 ExtensionSystem::Get(profile.get()))->
3874 CreateExtensionService( 3873 CreateExtensionService(
3875 command_line.get(), 3874 command_line.get(),
3876 install_dir, 3875 install_dir,
3877 false); 3876 false);
3878 EXPECT_FALSE(service->extensions_enabled()); 3877 EXPECT_FALSE(service->extensions_enabled());
3879 service->Init(); 3878 service->Init();
3880 loop.RunAllPending(); 3879 loop.RunAllPending();
3881 EXPECT_TRUE(recorder.ready()); 3880 EXPECT_TRUE(recorder.ready());
3882 3881
3883 recorder.set_ready(false); 3882 recorder.set_ready(false);
3884 profile.reset(new TestingProfile()); 3883 profile.reset(new TestingProfile());
3885 profile->GetPrefs()->SetBoolean(prefs::kDisableExtensions, true); 3884 profile->GetPrefs()->SetBoolean(prefs::kDisableExtensions, true);
3886 service = static_cast<TestExtensionSystem*>( 3885 service = static_cast<TestExtensionSystem*>(
3887 ExtensionSystemFactory::GetForProfile(profile.get()))-> 3886 ExtensionSystem::Get(profile.get()))->
3888 CreateExtensionService( 3887 CreateExtensionService(
3889 command_line.get(), 3888 command_line.get(),
3890 install_dir, 3889 install_dir,
3891 false); 3890 false);
3892 EXPECT_FALSE(service->extensions_enabled()); 3891 EXPECT_FALSE(service->extensions_enabled());
3893 service->Init(); 3892 service->Init();
3894 loop.RunAllPending(); 3893 loop.RunAllPending();
3895 EXPECT_TRUE(recorder.ready()); 3894 EXPECT_TRUE(recorder.ready());
3896 3895
3897 recorder.set_ready(false); 3896 recorder.set_ready(false);
3898 profile.reset(new TestingProfile()); 3897 profile.reset(new TestingProfile());
3899 profile->GetPrefs()->SetBoolean(prefs::kDisableExtensions, true); 3898 profile->GetPrefs()->SetBoolean(prefs::kDisableExtensions, true);
3900 command_line.reset(new CommandLine(CommandLine::NO_PROGRAM)); 3899 command_line.reset(new CommandLine(CommandLine::NO_PROGRAM));
3901 service = static_cast<TestExtensionSystem*>( 3900 service = static_cast<TestExtensionSystem*>(
3902 ExtensionSystemFactory::GetForProfile(profile.get()))-> 3901 ExtensionSystem::Get(profile.get()))->
3903 CreateExtensionService( 3902 CreateExtensionService(
3904 command_line.get(), 3903 command_line.get(),
3905 install_dir, 3904 install_dir,
3906 false); 3905 false);
3907 EXPECT_FALSE(service->extensions_enabled()); 3906 EXPECT_FALSE(service->extensions_enabled());
3908 service->Init(); 3907 service->Init();
3909 loop.RunAllPending(); 3908 loop.RunAllPending();
3910 EXPECT_TRUE(recorder.ready()); 3909 EXPECT_TRUE(recorder.ready());
3911 3910
3912 // Explicitly delete all the resources used in this test. 3911 // Explicitly delete all the resources used in this test.
(...skipping 948 matching lines...) Expand 10 before | Expand all | Expand 10 after
4861 provider->UpdateOrAddExtension(hosted_app, "1.0.0.0", 4860 provider->UpdateOrAddExtension(hosted_app, "1.0.0.0",
4862 data_dir_.AppendASCII("hosted_app.crx")); 4861 data_dir_.AppendASCII("hosted_app.crx"));
4863 4862
4864 service_->CheckForExternalUpdates(); 4863 service_->CheckForExternalUpdates();
4865 loop_.RunAllPending(); 4864 loop_.RunAllPending();
4866 4865
4867 ASSERT_TRUE(service_->PopulateExtensionGlobalError( 4866 ASSERT_TRUE(service_->PopulateExtensionGlobalError(
4868 extension_global_error.get())); 4867 extension_global_error.get()));
4869 ASSERT_EQ(1u, extension_global_error->get_external_extension_ids()->size()); 4868 ASSERT_EQ(1u, extension_global_error->get_external_extension_ids()->size());
4870 } 4869 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698