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

Side by Side Diff: chrome/browser/extensions/webstore_startup_installer_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 "base/command_line.h" 5 #include "base/command_line.h"
6 #include "base/scoped_observer.h" 6 #include "base/scoped_observer.h"
7 #include "chrome/browser/chrome_notification_types.h" 7 #include "chrome/browser/chrome_notification_types.h"
8 #include "chrome/browser/extensions/extension_install_prompt.h" 8 #include "chrome/browser/extensions/extension_install_prompt.h"
9 #include "chrome/browser/extensions/extension_service.h" 9 #include "chrome/browser/extensions/extension_service.h"
10 #include "chrome/browser/extensions/startup_helper.h" 10 #include "chrome/browser/extensions/startup_helper.h"
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 58
59 IN_PROC_BROWSER_TEST_F(WebstoreStartupInstallerTest, Install) { 59 IN_PROC_BROWSER_TEST_F(WebstoreStartupInstallerTest, Install) {
60 ExtensionInstallPrompt::g_auto_confirm_for_tests = 60 ExtensionInstallPrompt::g_auto_confirm_for_tests =
61 ExtensionInstallPrompt::ACCEPT; 61 ExtensionInstallPrompt::ACCEPT;
62 62
63 ui_test_utils::NavigateToURL( 63 ui_test_utils::NavigateToURL(
64 browser(), GenerateTestServerUrl(kAppDomain, "install.html")); 64 browser(), GenerateTestServerUrl(kAppDomain, "install.html"));
65 65
66 RunTest("runTest"); 66 RunTest("runTest");
67 67
68 extensions::ExtensionRegistry* registry =
69 extensions::ExtensionRegistry::Get(browser()->profile());
68 const extensions::Extension* extension = 70 const extensions::Extension* extension =
69 extensions::ExtensionRegistry::Get( 71 registry->enabled_extensions().GetByID(kTestExtensionId);
70 browser()->profile())->enabled_extensions().GetByID(kTestExtensionId);
71 EXPECT_TRUE(extension); 72 EXPECT_TRUE(extension);
72 } 73 }
73 74
74 IN_PROC_BROWSER_TEST_F(WebstoreStartupInstallerTest, 75 IN_PROC_BROWSER_TEST_F(WebstoreStartupInstallerTest,
75 InstallNotAllowedFromNonVerifiedDomains) { 76 InstallNotAllowedFromNonVerifiedDomains) {
76 ExtensionInstallPrompt::g_auto_confirm_for_tests = 77 ExtensionInstallPrompt::g_auto_confirm_for_tests =
77 ExtensionInstallPrompt::CANCEL; 78 ExtensionInstallPrompt::CANCEL;
78 ui_test_utils::NavigateToURL( 79 ui_test_utils::NavigateToURL(
79 browser(), 80 browser(),
80 GenerateTestServerUrl(kNonAppDomain, "install_non_verified_domain.html")); 81 GenerateTestServerUrl(kNonAppDomain, "install_non_verified_domain.html"));
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 .Set("urls", ListBuilder().Append(kInstallUrl.spec())) 156 .Set("urls", ListBuilder().Append(kInstallUrl.spec()))
156 .Set("launch", DictionaryBuilder() 157 .Set("launch", DictionaryBuilder()
157 .Set("web_url", kInstallUrl.spec()))) 158 .Set("web_url", kInstallUrl.spec())))
158 .Set("manifest_version", 2)) 159 .Set("manifest_version", 2))
159 .Build(); 160 .Build();
160 ASSERT_TRUE(hosted_app.get()); 161 ASSERT_TRUE(hosted_app.get());
161 162
162 ExtensionService* extension_service = 163 ExtensionService* extension_service =
163 extensions::ExtensionSystem::Get(browser()->profile())-> 164 extensions::ExtensionSystem::Get(browser()->profile())->
164 extension_service(); 165 extension_service();
166 extensions::ExtensionRegistry* registry =
167 extensions::ExtensionRegistry::Get(browser()->profile());
165 168
166 extension_service->AddExtension(hosted_app.get()); 169 extension_service->AddExtension(hosted_app.get());
167 EXPECT_TRUE(extension_service->extensions()->Contains(hosted_app->id())); 170 EXPECT_TRUE(registry->enabled_extensions().GetByID(hosted_app->id()));
168 171
169 ui_test_utils::NavigateToURL(browser(), kInstallUrl); 172 ui_test_utils::NavigateToURL(browser(), kInstallUrl);
170 173
171 EXPECT_FALSE(extension_service->extensions()->Contains(kTestExtensionId)); 174 EXPECT_FALSE(registry->enabled_extensions().GetByID(kTestExtensionId));
172 RunTest("runTest"); 175 RunTest("runTest");
173 EXPECT_TRUE(extension_service->extensions()->Contains(kTestExtensionId)); 176 EXPECT_TRUE(registry->enabled_extensions().GetByID(kTestExtensionId));
174 } 177 }
175 178
176 class WebstoreStartupInstallerSupervisedUsersTest 179 class WebstoreStartupInstallerSupervisedUsersTest
177 : public WebstoreStartupInstallerTest { 180 : public WebstoreStartupInstallerTest {
178 public: 181 public:
179 // InProcessBrowserTest overrides: 182 // InProcessBrowserTest overrides:
180 void SetUpCommandLine(base::CommandLine* command_line) override { 183 void SetUpCommandLine(base::CommandLine* command_line) override {
181 WebstoreStartupInstallerTest::SetUpCommandLine(command_line); 184 WebstoreStartupInstallerTest::SetUpCommandLine(command_line);
182 command_line->AppendSwitchASCII(switches::kSupervisedUserId, "asdf"); 185 command_line->AppendSwitchASCII(switches::kSupervisedUserId, "asdf");
183 } 186 }
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); 295 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
293 command_line->AppendSwitchASCII( 296 command_line->AppendSwitchASCII(
294 switches::kInstallEphemeralAppFromWebstore, kTestExtensionId); 297 switches::kInstallEphemeralAppFromWebstore, kTestExtensionId);
295 ExtensionInstallPrompt::g_auto_confirm_for_tests = 298 ExtensionInstallPrompt::g_auto_confirm_for_tests =
296 ExtensionInstallPrompt::ACCEPT; 299 ExtensionInstallPrompt::ACCEPT;
297 extensions::StartupHelper helper; 300 extensions::StartupHelper helper;
298 EXPECT_FALSE(helper.InstallEphemeralApp(*command_line, browser()->profile())); 301 EXPECT_FALSE(helper.InstallEphemeralApp(*command_line, browser()->profile()));
299 EXPECT_FALSE(saw_install()); 302 EXPECT_FALSE(saw_install());
300 EXPECT_EQ(0, browser_open_count()); 303 EXPECT_EQ(0, browser_open_count());
301 } 304 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698