Chromium Code Reviews| 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/webstore_inline_installer.h" | 5 #include "chrome/browser/extensions/webstore_inline_installer.h" |
| 6 | 6 |
| 7 #include "base/macros.h" | 7 #include "base/macros.h" |
| 8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" | 10 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 249 ui_test_utils::NavigateToURL(browser(), install_url); | 249 ui_test_utils::NavigateToURL(browser(), install_url); |
| 250 // The test page opens a popup which is a new |browser| window. | 250 // The test page opens a popup which is a new |browser| window. |
| 251 Browser* popup_browser = | 251 Browser* popup_browser = |
| 252 chrome::FindLastActiveWithProfile(browser()->profile()); | 252 chrome::FindLastActiveWithProfile(browser()->profile()); |
| 253 WebContents* popup_contents = | 253 WebContents* popup_contents = |
| 254 popup_browser->tab_strip_model()->GetActiveWebContents(); | 254 popup_browser->tab_strip_model()->GetActiveWebContents(); |
| 255 EXPECT_EQ(base::ASCIIToUTF16("POPUP"), popup_contents->GetTitle()); | 255 EXPECT_EQ(base::ASCIIToUTF16("POPUP"), popup_contents->GetTitle()); |
| 256 RunTest(popup_contents, "runTest"); | 256 RunTest(popup_contents, "runTest"); |
| 257 } | 257 } |
| 258 | 258 |
| 259 // Prevent inline install while in browser fullscreen mode. Browser fullscreen | |
| 260 // is initiated by the user using F11. | |
| 261 IN_PROC_BROWSER_TEST_F(WebstoreInlineInstallerTest, | |
| 262 BlockInlineInstallFromFullscreenForBrowser) { | |
| 263 const GURL install_url = | |
| 264 GenerateTestServerUrl(kAppDomain, "install_from_fullscreen.html"); | |
| 265 ui_test_utils::NavigateToURL(browser(), install_url); | |
| 266 AutoAcceptInstall(); | |
| 267 | |
| 268 // Enter browser fullscreen mode. | |
| 269 FullscreenController* controller = | |
| 270 browser()->exclusive_access_manager()->fullscreen_controller(); | |
| 271 controller->ToggleBrowserFullscreenMode(); | |
| 272 | |
| 273 RunTest("runTest"); | |
| 274 | |
| 275 // Ensure extension is not installed. | |
| 276 ExtensionRegistry* registry = ExtensionRegistry::Get(profile()); | |
| 277 EXPECT_FALSE(registry->GenerateInstalledExtensionsSet()->Contains( | |
| 278 "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb")); | |
| 279 } | |
| 280 | |
| 281 // Prevent inline install while in tab fullscreen mode. Tab fullscreen is | |
| 282 // initiated using the browser API. | |
|
meacer
2016/10/10 19:44:00
nit: ... initiated by the page using requestFullsc
| |
| 283 IN_PROC_BROWSER_TEST_F(WebstoreInlineInstallerTest, | |
| 284 BlockInlineInstallFromFullscreenForTab) { | |
| 285 const GURL install_url = | |
| 286 GenerateTestServerUrl(kAppDomain, "install_from_fullscreen.html"); | |
| 287 ui_test_utils::NavigateToURL(browser(), install_url); | |
| 288 AutoAcceptInstall(); | |
| 289 WebContents* web_contents = | |
| 290 browser()->tab_strip_model()->GetActiveWebContents(); | |
| 291 FullscreenController* controller = | |
| 292 browser()->exclusive_access_manager()->fullscreen_controller(); | |
| 293 | |
| 294 // Enter tab fullscreen mode. | |
| 295 controller->EnterFullscreenModeForTab(web_contents, install_url); | |
| 296 | |
| 297 RunTest("runTest"); | |
| 298 | |
| 299 // Ensure extension is not installed. | |
| 300 ExtensionRegistry* registry = ExtensionRegistry::Get(profile()); | |
| 301 EXPECT_FALSE(registry->GenerateInstalledExtensionsSet()->Contains( | |
| 302 "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb")); | |
| 303 } | |
| 304 | |
| 259 // Ensure that inline-installing a disabled extension simply re-enables it. | 305 // Ensure that inline-installing a disabled extension simply re-enables it. |
| 260 IN_PROC_BROWSER_TEST_F(WebstoreInlineInstallerTest, | 306 IN_PROC_BROWSER_TEST_F(WebstoreInlineInstallerTest, |
| 261 ReinstallDisabledExtension) { | 307 ReinstallDisabledExtension) { |
| 262 // Install an extension via inline install, and confirm it is successful. | 308 // Install an extension via inline install, and confirm it is successful. |
| 263 AutoAcceptInstall(); | 309 AutoAcceptInstall(); |
| 264 ui_test_utils::NavigateToURL( | 310 ui_test_utils::NavigateToURL( |
| 265 browser(), GenerateTestServerUrl(kAppDomain, "install.html")); | 311 browser(), GenerateTestServerUrl(kAppDomain, "install.html")); |
| 266 RunTest("runTest"); | 312 RunTest("runTest"); |
| 267 ExtensionRegistry* registry = ExtensionRegistry::Get(profile()); | 313 ExtensionRegistry* registry = ExtensionRegistry::Get(profile()); |
| 268 ASSERT_TRUE(registry->enabled_extensions().GetByID(kTestExtensionId)); | 314 ASSERT_TRUE(registry->enabled_extensions().GetByID(kTestExtensionId)); |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 359 browser(), GenerateTestServerUrl(kAppDomain, "both_listeners.html"), | 405 browser(), GenerateTestServerUrl(kAppDomain, "both_listeners.html"), |
| 360 NEW_FOREGROUND_TAB, ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); | 406 NEW_FOREGROUND_TAB, ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); |
| 361 DCHECK_NE(old_tab_index, browser()->tab_strip_model()->active_index()); | 407 DCHECK_NE(old_tab_index, browser()->tab_strip_model()->active_index()); |
| 362 browser()->tab_strip_model()->CloseWebContentsAt(old_tab_index, | 408 browser()->tab_strip_model()->CloseWebContentsAt(old_tab_index, |
| 363 TabStripModel::CLOSE_NONE); | 409 TabStripModel::CLOSE_NONE); |
| 364 WebstoreInstallerTest::RunTest("runTest"); | 410 WebstoreInstallerTest::RunTest("runTest"); |
| 365 EXPECT_TRUE(registry->enabled_extensions().GetByID(kTestExtensionId)); | 411 EXPECT_TRUE(registry->enabled_extensions().GetByID(kTestExtensionId)); |
| 366 } | 412 } |
| 367 | 413 |
| 368 } // namespace extensions | 414 } // namespace extensions |
| OLD | NEW |