OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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_install_prompt.h" | 5 #include "chrome/browser/extensions/extension_install_prompt.h" |
6 #include "chrome/browser/extensions/extension_service.h" | 6 #include "chrome/browser/extensions/extension_service.h" |
7 #include "chrome/browser/extensions/tab_helper.h" | 7 #include "chrome/browser/extensions/tab_helper.h" |
8 #include "chrome/browser/extensions/webstore_inline_installer.h" | 8 #include "chrome/browser/extensions/webstore_inline_installer.h" |
9 #include "chrome/browser/extensions/webstore_inline_installer_factory.h" | 9 #include "chrome/browser/extensions/webstore_inline_installer_factory.h" |
10 #include "chrome/browser/extensions/webstore_installer_test.h" | 10 #include "chrome/browser/extensions/webstore_installer_test.h" |
11 #include "chrome/browser/extensions/webstore_standalone_installer.h" | 11 #include "chrome/browser/extensions/webstore_standalone_installer.h" |
12 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
13 #include "chrome/browser/ui/browser.h" | 13 #include "chrome/browser/ui/browser.h" |
14 #include "chrome/browser/ui/browser_finder.h" | |
Devlin
2015/02/12 17:18:21
needed?
meacer
2015/02/12 21:12:05
Not anymore :)
| |
14 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 15 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
15 #include "chrome/test/base/ui_test_utils.h" | 16 #include "chrome/test/base/ui_test_utils.h" |
16 #include "content/public/browser/web_contents.h" | 17 #include "content/public/browser/web_contents.h" |
18 #include "content/public/test/browser_test_utils.h" | |
17 #include "extensions/browser/extension_registry.h" | 19 #include "extensions/browser/extension_registry.h" |
18 #include "extensions/browser/extension_system.h" | 20 #include "extensions/browser/extension_system.h" |
19 #include "url/gurl.h" | 21 #include "url/gurl.h" |
20 | 22 |
21 using content::WebContents; | 23 using content::WebContents; |
22 | 24 |
23 namespace extensions { | 25 namespace extensions { |
24 | 26 |
25 namespace { | 27 namespace { |
26 | 28 |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
119 WebContents* contents, | 121 WebContents* contents, |
120 const std::string& webstore_item_id, | 122 const std::string& webstore_item_id, |
121 const GURL& requestor_url, | 123 const GURL& requestor_url, |
122 const WebstoreStandaloneInstaller::Callback& callback) override { | 124 const WebstoreStandaloneInstaller::Callback& callback) override { |
123 return new WebstoreInlineInstallerForTest( | 125 return new WebstoreInlineInstallerForTest( |
124 contents, webstore_item_id, requestor_url, callback); | 126 contents, webstore_item_id, requestor_url, callback); |
125 } | 127 } |
126 }; | 128 }; |
127 | 129 |
128 IN_PROC_BROWSER_TEST_F(WebstoreInlineInstallerTest, | 130 IN_PROC_BROWSER_TEST_F(WebstoreInlineInstallerTest, |
129 CloseTabBeforeInstallConfirmation) { | 131 CloseTabBeforeInstallConfirmation) { |
130 GURL install_url = GenerateTestServerUrl(kAppDomain, "install.html"); | 132 GURL install_url = GenerateTestServerUrl(kAppDomain, "install.html"); |
131 ui_test_utils::NavigateToURL(browser(), install_url); | 133 ui_test_utils::NavigateToURL(browser(), install_url); |
132 WebContents* web_contents = | 134 WebContents* web_contents = |
133 browser()->tab_strip_model()->GetActiveWebContents(); | 135 browser()->tab_strip_model()->GetActiveWebContents(); |
134 TabHelper* tab_helper = TabHelper::FromWebContents(web_contents); | 136 TabHelper* tab_helper = TabHelper::FromWebContents(web_contents); |
135 tab_helper->SetWebstoreInlineInstallerFactoryForTests( | 137 tab_helper->SetWebstoreInlineInstallerFactoryForTests( |
136 new WebstoreInlineInstallerForTestFactory()); | 138 new WebstoreInlineInstallerForTestFactory()); |
137 RunTestAsync("runTest"); | 139 RunTestAsync("runTest"); |
138 while (!ProgrammableInstallPrompt::Ready()) | 140 while (!ProgrammableInstallPrompt::Ready()) |
139 base::RunLoop().RunUntilIdle(); | 141 base::RunLoop().RunUntilIdle(); |
140 web_contents->Close(); | 142 web_contents->Close(); |
141 ProgrammableInstallPrompt::Accept(); | 143 ProgrammableInstallPrompt::Accept(); |
142 } | 144 } |
143 | 145 |
146 IN_PROC_BROWSER_TEST_F(WebstoreInlineInstallerTest, | |
147 ShouldBlockInlineInstallFromPopupWindow) { | |
148 GURL install_url = | |
149 GenerateTestServerUrl(kAppDomain, "install_from_popup.html"); | |
150 content::OpenURLParams params(install_url, content::Referrer(), NEW_POPUP, | |
151 ui::PAGE_TRANSITION_TYPED, false); | |
152 params.user_gesture = true; | |
153 WebContents* web_contents = browser()->OpenURL(params); | |
154 WaitForLoadStop(web_contents); | |
155 RunTest(web_contents, "runTest"); | |
156 } | |
157 | |
144 // Ensure that inline-installing a disabled extension simply re-enables it. | 158 // Ensure that inline-installing a disabled extension simply re-enables it. |
145 IN_PROC_BROWSER_TEST_F(WebstoreInlineInstallerTest, | 159 IN_PROC_BROWSER_TEST_F(WebstoreInlineInstallerTest, |
146 ReinstallDisabledExtension) { | 160 ReinstallDisabledExtension) { |
147 // Install an extension via inline install, and confirm it is successful. | 161 // Install an extension via inline install, and confirm it is successful. |
148 ExtensionInstallPrompt::g_auto_confirm_for_tests = | 162 ExtensionInstallPrompt::g_auto_confirm_for_tests = |
149 ExtensionInstallPrompt::ACCEPT; | 163 ExtensionInstallPrompt::ACCEPT; |
150 ui_test_utils::NavigateToURL( | 164 ui_test_utils::NavigateToURL( |
151 browser(), GenerateTestServerUrl(kAppDomain, "install.html")); | 165 browser(), GenerateTestServerUrl(kAppDomain, "install.html")); |
152 RunTest("runTest"); | 166 RunTest("runTest"); |
153 ExtensionRegistry* registry = ExtensionRegistry::Get(profile()); | 167 ExtensionRegistry* registry = ExtensionRegistry::Get(profile()); |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
218 IN_PROC_BROWSER_TEST_F(WebstoreInlineInstallerListenerTest, | 232 IN_PROC_BROWSER_TEST_F(WebstoreInlineInstallerListenerTest, |
219 DownloadProgressListenerTest) { | 233 DownloadProgressListenerTest) { |
220 RunTest("download_progress_listener.html"); | 234 RunTest("download_progress_listener.html"); |
221 } | 235 } |
222 | 236 |
223 IN_PROC_BROWSER_TEST_F(WebstoreInlineInstallerListenerTest, BothListenersTest) { | 237 IN_PROC_BROWSER_TEST_F(WebstoreInlineInstallerListenerTest, BothListenersTest) { |
224 RunTest("both_listeners.html"); | 238 RunTest("both_listeners.html"); |
225 } | 239 } |
226 | 240 |
227 } // namespace extensions | 241 } // namespace extensions |
OLD | NEW |