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

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

Issue 709813004: Remove the deprecated function ExtensionService::extensions(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed thestig@'s comments. Created 6 years, 1 month 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
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/crx_installer.h" 5 #include "chrome/browser/extensions/crx_installer.h"
6 #include "chrome/browser/extensions/extension_browsertest.h" 6 #include "chrome/browser/extensions/extension_browsertest.h"
7 #include "chrome/browser/extensions/extension_service.h" 7 #include "chrome/browser/extensions/extension_service.h"
8 #include "chrome/browser/extensions/extension_util.h" 8 #include "chrome/browser/extensions/extension_util.h"
9 #include "chrome/browser/profiles/profile.h" 9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/browser/ui/browser_commands.h" 10 #include "chrome/browser/ui/browser_commands.h"
11 #include "content/public/browser/notification_service.h" 11 #include "content/public/browser/notification_service.h"
12 #include "content/public/test/test_utils.h" 12 #include "content/public/test/test_utils.h"
13 #include "extensions/browser/extension_registry.h"
13 #include "extensions/browser/extension_system.h" 14 #include "extensions/browser/extension_system.h"
14 #include "extensions/browser/notification_types.h" 15 #include "extensions/browser/notification_types.h"
15 16
16 namespace extensions { 17 namespace extensions {
17 18
18 class ExtensionFunctionalTest : public ExtensionBrowserTest { 19 class ExtensionFunctionalTest : public ExtensionBrowserTest {
19 public: 20 public:
20 void InstallExtensionSilently(ExtensionService* service, 21 void InstallExtensionSilently(ExtensionService* service,
21 const char* filename) { 22 const char* filename) {
22 service->set_show_extensions_prompts(false); 23 service->set_show_extensions_prompts(false);
23 size_t num_before = service->extensions()->size(); 24 ExtensionRegistry* registry = ExtensionRegistry::Get(profile());
25 size_t num_before = registry->enabled_extensions().size();
24 26
25 base::FilePath path = test_data_dir_.AppendASCII(filename); 27 base::FilePath path = test_data_dir_.AppendASCII(filename);
26 28
27 content::WindowedNotificationObserver extension_loaded_observer( 29 content::WindowedNotificationObserver extension_loaded_observer(
28 extensions::NOTIFICATION_EXTENSION_LOADED_DEPRECATED, 30 extensions::NOTIFICATION_EXTENSION_LOADED_DEPRECATED,
29 content::NotificationService::AllSources()); 31 content::NotificationService::AllSources());
30 32
31 scoped_refptr<extensions::CrxInstaller> installer( 33 scoped_refptr<extensions::CrxInstaller> installer(
32 extensions::CrxInstaller::CreateSilent(service)); 34 extensions::CrxInstaller::CreateSilent(service));
33 installer->set_is_gallery_install(false); 35 installer->set_is_gallery_install(false);
34 installer->set_allow_silent_install(true); 36 installer->set_allow_silent_install(true);
35 installer->set_install_source(Manifest::INTERNAL); 37 installer->set_install_source(Manifest::INTERNAL);
36 installer->set_off_store_install_allow_reason( 38 installer->set_off_store_install_allow_reason(
37 extensions::CrxInstaller::OffStoreInstallAllowedInTest); 39 extensions::CrxInstaller::OffStoreInstallAllowedInTest);
38 40
39 observer_->Watch( 41 observer_->Watch(
40 extensions::NOTIFICATION_CRX_INSTALLER_DONE, 42 extensions::NOTIFICATION_CRX_INSTALLER_DONE,
41 content::Source<extensions::CrxInstaller>(installer.get())); 43 content::Source<extensions::CrxInstaller>(installer.get()));
42 44
43 installer->InstallCrx(path); 45 installer->InstallCrx(path);
44 observer_->Wait(); 46 observer_->Wait();
45 47
46 size_t num_after = service->extensions()->size(); 48 size_t num_after = registry->enabled_extensions().size();
47 EXPECT_EQ(num_before + 1, num_after); 49 EXPECT_EQ(num_before + 1, num_after);
48 50
49 extension_loaded_observer.Wait(); 51 extension_loaded_observer.Wait();
50 const Extension* extension = service->GetExtensionById( 52 const Extension* extension =
51 last_loaded_extension_id(), false); 53 registry->enabled_extensions().GetByID(last_loaded_extension_id());
52 EXPECT_TRUE(extension != NULL); 54 EXPECT_TRUE(extension);
53 }
54
55 ExtensionService* GetExtensionService() {
56 return ExtensionSystem::Get(profile())->extension_service();
57 } 55 }
58 }; 56 };
59 57
60 IN_PROC_BROWSER_TEST_F(ExtensionFunctionalTest, 58 IN_PROC_BROWSER_TEST_F(ExtensionFunctionalTest,
61 PRE_TestAdblockExtensionCrash) { 59 PRE_TestAdblockExtensionCrash) {
62 InstallExtensionSilently(GetExtensionService(), "adblock.crx"); 60 InstallExtensionSilently(extension_service(), "adblock.crx");
63 } 61 }
64 62
65 // Timing out on XP and Vista: http://crbug.com/387866 63 // Timing out on XP and Vista: http://crbug.com/387866
66 #if defined(OS_WIN) 64 #if defined(OS_WIN)
67 #define MAYBE_TestAdblockExtensionCrash DISABLED_TestAdblockExtensionCrash 65 #define MAYBE_TestAdblockExtensionCrash DISABLED_TestAdblockExtensionCrash
68 #else 66 #else
69 #define MAYBE_TestAdblockExtensionCrash TestAdblockExtensionCrash 67 #define MAYBE_TestAdblockExtensionCrash TestAdblockExtensionCrash
70 #endif 68 #endif
71 IN_PROC_BROWSER_TEST_F(ExtensionFunctionalTest, 69 IN_PROC_BROWSER_TEST_F(ExtensionFunctionalTest,
72 MAYBE_TestAdblockExtensionCrash) { 70 MAYBE_TestAdblockExtensionCrash) {
73 ExtensionService* service = GetExtensionService(); 71 ExtensionService* service = extension_service();
74 // Verify that the extension is enabled and allowed in incognito 72 // Verify that the extension is enabled and allowed in incognito
75 // is disabled. 73 // is disabled.
76 EXPECT_TRUE(service->IsExtensionEnabled(last_loaded_extension_id())); 74 EXPECT_TRUE(service->IsExtensionEnabled(last_loaded_extension_id()));
77 EXPECT_FALSE(util::IsIncognitoEnabled(last_loaded_extension_id(), profile())); 75 EXPECT_FALSE(util::IsIncognitoEnabled(last_loaded_extension_id(), profile()));
78 } 76 }
79 77
80 // Failing on XP: http://crbug.com/389545 78 // Failing on XP: http://crbug.com/389545
81 #if defined(OS_WIN) 79 #if defined(OS_WIN)
82 #define MAYBE_TestSetExtensionsState DISABLED_TestSetExtensionsState 80 #define MAYBE_TestSetExtensionsState DISABLED_TestSetExtensionsState
83 #else 81 #else
84 #define MAYBE_TestSetExtensionsState TestSetExtensionsState 82 #define MAYBE_TestSetExtensionsState TestSetExtensionsState
85 #endif 83 #endif
86 IN_PROC_BROWSER_TEST_F(ExtensionFunctionalTest, MAYBE_TestSetExtensionsState) { 84 IN_PROC_BROWSER_TEST_F(ExtensionFunctionalTest, MAYBE_TestSetExtensionsState) {
87 InstallExtensionSilently(GetExtensionService(), "google_talk.crx"); 85 InstallExtensionSilently(extension_service(), "google_talk.crx");
88 86
89 // Disable the extension and verify. 87 // Disable the extension and verify.
90 util::SetIsIncognitoEnabled(last_loaded_extension_id(), profile(), false); 88 util::SetIsIncognitoEnabled(last_loaded_extension_id(), profile(), false);
91 ExtensionService* service = GetExtensionService(); 89 ExtensionService* service = extension_service();
92 service->DisableExtension(last_loaded_extension_id(), 90 service->DisableExtension(last_loaded_extension_id(),
93 Extension::DISABLE_USER_ACTION); 91 Extension::DISABLE_USER_ACTION);
94 EXPECT_FALSE(service->IsExtensionEnabled(last_loaded_extension_id())); 92 EXPECT_FALSE(service->IsExtensionEnabled(last_loaded_extension_id()));
95 93
96 // Enable the extension and verify. 94 // Enable the extension and verify.
97 util::SetIsIncognitoEnabled(last_loaded_extension_id(), profile(), false); 95 util::SetIsIncognitoEnabled(last_loaded_extension_id(), profile(), false);
98 service->EnableExtension(last_loaded_extension_id()); 96 service->EnableExtension(last_loaded_extension_id());
99 EXPECT_TRUE(service->IsExtensionEnabled(last_loaded_extension_id())); 97 EXPECT_TRUE(service->IsExtensionEnabled(last_loaded_extension_id()));
100 98
101 // Allow extension in incognito mode and verify. 99 // Allow extension in incognito mode and verify.
102 service->EnableExtension(last_loaded_extension_id()); 100 service->EnableExtension(last_loaded_extension_id());
103 util::SetIsIncognitoEnabled(last_loaded_extension_id(), profile(), true); 101 util::SetIsIncognitoEnabled(last_loaded_extension_id(), profile(), true);
104 EXPECT_TRUE(util::IsIncognitoEnabled(last_loaded_extension_id(), profile())); 102 EXPECT_TRUE(util::IsIncognitoEnabled(last_loaded_extension_id(), profile()));
105 103
106 // Disallow extension in incognito mode and verify. 104 // Disallow extension in incognito mode and verify.
107 service->EnableExtension(last_loaded_extension_id()); 105 service->EnableExtension(last_loaded_extension_id());
108 util::SetIsIncognitoEnabled(last_loaded_extension_id(), profile(), false); 106 util::SetIsIncognitoEnabled(last_loaded_extension_id(), profile(), false);
109 EXPECT_FALSE(util::IsIncognitoEnabled(last_loaded_extension_id(), profile())); 107 EXPECT_FALSE(util::IsIncognitoEnabled(last_loaded_extension_id(), profile()));
110 } 108 }
111 } // namespace extensions 109 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_browsertest.cc ('k') | chrome/browser/extensions/extension_keybinding_registry.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698