| 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/json/json_reader.h" | 7 #include "base/json/json_reader.h" |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 ui_test_utils::NavigateToURL(browser(), install_url); | 256 ui_test_utils::NavigateToURL(browser(), install_url); |
| 257 // The test page opens a popup which is a new |browser| window. | 257 // The test page opens a popup which is a new |browser| window. |
| 258 Browser* popup_browser = | 258 Browser* popup_browser = |
| 259 chrome::FindLastActiveWithProfile(browser()->profile()); | 259 chrome::FindLastActiveWithProfile(browser()->profile()); |
| 260 WebContents* popup_contents = | 260 WebContents* popup_contents = |
| 261 popup_browser->tab_strip_model()->GetActiveWebContents(); | 261 popup_browser->tab_strip_model()->GetActiveWebContents(); |
| 262 EXPECT_EQ(base::ASCIIToUTF16("POPUP"), popup_contents->GetTitle()); | 262 EXPECT_EQ(base::ASCIIToUTF16("POPUP"), popup_contents->GetTitle()); |
| 263 RunTest(popup_contents, "runTest"); | 263 RunTest(popup_contents, "runTest"); |
| 264 } | 264 } |
| 265 | 265 |
| 266 // Prevent inline install while in browser fullscreen mode. Browser fullscreen | 266 // Allow inline install while in browser fullscreen mode. Browser fullscreen |
| 267 // is initiated by the user using F11. | 267 // is initiated by the user using F11 (windows), ctrl+cmd+F (mac) or the green |
| 268 // maximize window button on mac. This will be allowed since it cannot be |
| 269 // initiated by an API and because of the nuance with mac windows. |
| 268 IN_PROC_BROWSER_TEST_F(WebstoreInlineInstallerTest, | 270 IN_PROC_BROWSER_TEST_F(WebstoreInlineInstallerTest, |
| 269 BlockInlineInstallFromFullscreenForBrowser) { | 271 AllowInlineInstallFromFullscreenForBrowser) { |
| 270 const GURL install_url = | 272 const GURL install_url = GenerateTestServerUrl(kAppDomain, "install.html"); |
| 271 GenerateTestServerUrl(kAppDomain, "install_from_fullscreen.html"); | |
| 272 ui_test_utils::NavigateToURL(browser(), install_url); | 273 ui_test_utils::NavigateToURL(browser(), install_url); |
| 273 AutoAcceptInstall(); | 274 AutoAcceptInstall(); |
| 274 | 275 |
| 275 // Enter browser fullscreen mode. | 276 // Enter browser fullscreen mode. |
| 276 FullscreenController* controller = | 277 FullscreenController* controller = |
| 277 browser()->exclusive_access_manager()->fullscreen_controller(); | 278 browser()->exclusive_access_manager()->fullscreen_controller(); |
| 278 controller->ToggleBrowserFullscreenMode(); | 279 controller->ToggleBrowserFullscreenMode(); |
| 279 | 280 |
| 280 RunTest("runTest"); | 281 RunTest("runTest"); |
| 281 | 282 |
| 282 // Ensure extension is not installed. | 283 // Ensure extension is installed. |
| 283 ExtensionRegistry* registry = ExtensionRegistry::Get(profile()); | 284 ExtensionRegistry* registry = ExtensionRegistry::Get(profile()); |
| 284 EXPECT_FALSE(registry->GenerateInstalledExtensionsSet()->Contains( | 285 EXPECT_TRUE( |
| 285 "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb")); | 286 registry->GenerateInstalledExtensionsSet()->Contains(kTestExtensionId)); |
| 286 } | 287 } |
| 287 | 288 |
| 288 // Prevent inline install while in tab fullscreen mode. Tab fullscreen is | 289 // Prevent inline install while in tab fullscreen mode. Tab fullscreen is |
| 289 // initiated using the browser API. | 290 // initiated using the browser API. |
| 290 IN_PROC_BROWSER_TEST_F(WebstoreInlineInstallerTest, | 291 IN_PROC_BROWSER_TEST_F(WebstoreInlineInstallerTest, |
| 291 BlockInlineInstallFromFullscreenForTab) { | 292 BlockInlineInstallFromFullscreenForTab) { |
| 292 const GURL install_url = | 293 const GURL install_url = |
| 293 GenerateTestServerUrl(kAppDomain, "install_from_fullscreen.html"); | 294 GenerateTestServerUrl(kAppDomain, "install_from_fullscreen.html"); |
| 294 ui_test_utils::NavigateToURL(browser(), install_url); | 295 ui_test_utils::NavigateToURL(browser(), install_url); |
| 295 AutoAcceptInstall(); | 296 AutoAcceptInstall(); |
| 296 WebContents* web_contents = | 297 WebContents* web_contents = |
| 297 browser()->tab_strip_model()->GetActiveWebContents(); | 298 browser()->tab_strip_model()->GetActiveWebContents(); |
| 298 FullscreenController* controller = | 299 FullscreenController* controller = |
| 299 browser()->exclusive_access_manager()->fullscreen_controller(); | 300 browser()->exclusive_access_manager()->fullscreen_controller(); |
| 300 | 301 |
| 301 // Enter tab fullscreen mode. | 302 // Enter tab fullscreen mode. |
| 302 controller->EnterFullscreenModeForTab(web_contents, install_url); | 303 controller->EnterFullscreenModeForTab(web_contents, install_url); |
| 303 | 304 |
| 304 RunTest("runTest"); | 305 RunTest("runTest"); |
| 305 | 306 |
| 306 // Ensure extension is not installed. | 307 // Ensure extension is not installed. |
| 307 ExtensionRegistry* registry = ExtensionRegistry::Get(profile()); | 308 ExtensionRegistry* registry = ExtensionRegistry::Get(profile()); |
| 308 EXPECT_FALSE(registry->GenerateInstalledExtensionsSet()->Contains( | 309 EXPECT_FALSE( |
| 309 "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb")); | 310 registry->GenerateInstalledExtensionsSet()->Contains(kTestExtensionId)); |
| 310 } | 311 } |
| 311 | 312 |
| 312 // Ensure that inline-installing a disabled extension simply re-enables it. | 313 // Ensure that inline-installing a disabled extension simply re-enables it. |
| 313 IN_PROC_BROWSER_TEST_F(WebstoreInlineInstallerTest, | 314 IN_PROC_BROWSER_TEST_F(WebstoreInlineInstallerTest, |
| 314 ReinstallDisabledExtension) { | 315 ReinstallDisabledExtension) { |
| 315 // Install an extension via inline install, and confirm it is successful. | 316 // Install an extension via inline install, and confirm it is successful. |
| 316 AutoAcceptInstall(); | 317 AutoAcceptInstall(); |
| 317 ui_test_utils::NavigateToURL( | 318 ui_test_utils::NavigateToURL( |
| 318 browser(), GenerateTestServerUrl(kAppDomain, "install.html")); | 319 browser(), GenerateTestServerUrl(kAppDomain, "install.html")); |
| 319 RunTest("runTest"); | 320 RunTest("runTest"); |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 482 WindowOpenDisposition::NEW_FOREGROUND_TAB, | 483 WindowOpenDisposition::NEW_FOREGROUND_TAB, |
| 483 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); | 484 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); |
| 484 DCHECK_NE(old_tab_index, browser()->tab_strip_model()->active_index()); | 485 DCHECK_NE(old_tab_index, browser()->tab_strip_model()->active_index()); |
| 485 browser()->tab_strip_model()->CloseWebContentsAt(old_tab_index, | 486 browser()->tab_strip_model()->CloseWebContentsAt(old_tab_index, |
| 486 TabStripModel::CLOSE_NONE); | 487 TabStripModel::CLOSE_NONE); |
| 487 WebstoreInstallerTest::RunTest("runTest"); | 488 WebstoreInstallerTest::RunTest("runTest"); |
| 488 EXPECT_TRUE(registry->enabled_extensions().GetByID(kTestExtensionId)); | 489 EXPECT_TRUE(registry->enabled_extensions().GetByID(kTestExtensionId)); |
| 489 } | 490 } |
| 490 | 491 |
| 491 } // namespace extensions | 492 } // namespace extensions |
| OLD | NEW |