diff options
author | aa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-08 08:25:04 +0000 |
---|---|---|
committer | aa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-08 08:25:04 +0000 |
commit | d95c1050618dbf988a43c33bdd3011ccbe1419e5 (patch) | |
tree | 517d1b798053a2ab5a47e1105e0e9c2fb39988b5 | |
parent | 93d973a3dc873112e5df401a1826f1235dff66a6 (diff) | |
download | chromium_src-d95c1050618dbf988a43c33bdd3011ccbe1419e5.zip chromium_src-d95c1050618dbf988a43c33bdd3011ccbe1419e5.tar.gz chromium_src-d95c1050618dbf988a43c33bdd3011ccbe1419e5.tar.bz2 |
Revert 116835 - Add a commandline flag for auto confirm/deny of webstore install confirm dialog
This failed mac browser_tests PlatformAppBrowserTest.OpenAppInShellContainer:
http://build.chromium.org/p/chromium/builders/Mac%2010.6%20Tests%20%28dbg%29%282%29/builds/16631/steps/browser_tests/logs/stdio
The webstore testing folks asked me for this to use in their webdriver tests.
BUG=none
TEST=Run chrome with --apps-gallery-install-auto-confirm-for-tests=accept and
notice that all installs from the webstore immediately complete without the
confirmation prompt. Then run with =cancel instead and notice that all installs
fail to complete.
Review URL: http://codereview.chromium.org/9108032
TBR=asargent@chromium.org
Review URL: http://codereview.chromium.org/9145002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@116840 0039d316-1c4b-4281-b951-d872f2087c98
7 files changed, 43 insertions, 70 deletions
diff --git a/chrome/browser/extensions/extension_install_dialog.cc b/chrome/browser/extensions/extension_install_dialog.cc index 55b6b68..dad6d26 100644 --- a/chrome/browser/extensions/extension_install_dialog.cc +++ b/chrome/browser/extensions/extension_install_dialog.cc @@ -1,16 +1,14 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "chrome/browser/extensions/extension_install_dialog.h" #include "base/bind.h" -#include "base/command_line.h" #include "base/file_path.h" #include "base/message_loop.h" #include "base/memory/scoped_ptr.h" #include "base/values.h" -#include "chrome/common/chrome_switches.h" #include "chrome/common/extensions/extension.h" namespace { @@ -21,6 +19,7 @@ enum AutoConfirmForTest { PROCEED, ABORT }; +AutoConfirmForTest auto_confirm_for_tests = DO_NOT_SKIP; void AutoConfirmTask(ExtensionInstallUI::Delegate* delegate, bool proceed) { if (proceed) @@ -29,9 +28,8 @@ void AutoConfirmTask(ExtensionInstallUI::Delegate* delegate, bool proceed) { delegate->InstallUIAbort(true); } -void DoAutoConfirm(AutoConfirmForTest setting, - ExtensionInstallUI::Delegate* delegate) { - bool proceed = (setting == PROCEED); +void DoAutoConfirm(ExtensionInstallUI::Delegate* delegate) { + bool proceed = (auto_confirm_for_tests == PROCEED); // We use PostTask instead of calling the delegate directly here, because in // the real implementations it's highly likely the message loop will be // pumping a few times before the user clicks accept or cancel. @@ -40,21 +38,6 @@ void DoAutoConfirm(AutoConfirmForTest setting, base::Bind(&AutoConfirmTask, delegate, proceed)); } -AutoConfirmForTest CheckAutoConfirmCommandLineSwitch() { - const CommandLine* cmdline = CommandLine::ForCurrentProcess(); - if (!cmdline->HasSwitch(switches::kAppsGalleryInstallAutoConfirmForTests)) - return DO_NOT_SKIP; - std::string value = cmdline->GetSwitchValueASCII( - switches::kAppsGalleryInstallAutoConfirmForTests); - if (value == "accept") - return PROCEED; - else if (value == "cancel") - return ABORT; - else - NOTREACHED(); - return DO_NOT_SKIP; -} - } // namespace void ShowExtensionInstallDialog(Profile* profile, @@ -62,9 +45,8 @@ void ShowExtensionInstallDialog(Profile* profile, const Extension* extension, SkBitmap* icon, const ExtensionInstallUI::Prompt& prompt) { - AutoConfirmForTest auto_confirm = CheckAutoConfirmCommandLineSwitch(); - if (auto_confirm != DO_NOT_SKIP) { - DoAutoConfirm(auto_confirm, delegate); + if (auto_confirm_for_tests != DO_NOT_SKIP) { + DoAutoConfirm(delegate); return; } ShowExtensionInstallDialogImpl(profile, delegate, extension, icon, prompt); @@ -111,9 +93,8 @@ bool ShowExtensionInstallDialogForManifest( // In tests, we may have setup to proceed or abort without putting up the real // confirmation dialog. - AutoConfirmForTest auto_confirm = CheckAutoConfirmCommandLineSwitch(); - if (auto_confirm != DO_NOT_SKIP) { - DoAutoConfirm(auto_confirm, delegate); + if (auto_confirm_for_tests != DO_NOT_SKIP) { + DoAutoConfirm(delegate); return true; } @@ -128,3 +109,8 @@ bool ShowExtensionInstallDialogForManifest( filled_out_prompt); return true; } + +void SetExtensionInstallDialogAutoConfirmForTests( + bool should_proceed) { + auto_confirm_for_tests = should_proceed ? PROCEED : ABORT; +} diff --git a/chrome/browser/extensions/extension_install_dialog.h b/chrome/browser/extensions/extension_install_dialog.h index e4575c9..4124635 100644 --- a/chrome/browser/extensions/extension_install_dialog.h +++ b/chrome/browser/extensions/extension_install_dialog.h @@ -1,4 +1,4 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -54,4 +54,10 @@ bool ShowExtensionInstallDialogForManifest( const ExtensionInstallUI::Prompt& prompt, scoped_refptr<Extension>* dummy_extension); +// For use only in tests - sets a flag that makes invocations of +// ShowExtensionInstallDialog* skip putting up a real dialog, and +// instead act as if the dialog choice was to proceed or abort. +void SetExtensionInstallDialogAutoConfirmForTests( + bool should_proceed); + #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_INSTALL_DIALOG_H_ diff --git a/chrome/browser/extensions/extension_management_api_browsertest.cc b/chrome/browser/extensions/extension_management_api_browsertest.cc index 9966f01..c226902 100644 --- a/chrome/browser/extensions/extension_management_api_browsertest.cc +++ b/chrome/browser/extensions/extension_management_api_browsertest.cc @@ -1,8 +1,7 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "base/command_line.h" #include "base/stringprintf.h" #include "chrome/browser/extensions/extension_browsertest.h" #include "chrome/browser/extensions/extension_function_test_utils.h" @@ -14,7 +13,6 @@ #include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/browser.h" #include "chrome/common/chrome_notification_types.h" -#include "chrome/common/chrome_switches.h" namespace keys = extension_management_api_constants; namespace util = extension_function_test_utils; @@ -123,12 +121,10 @@ IN_PROC_BROWSER_TEST_F(ExtensionManagementApiEscalationTest, ReEnable(false, keys::kGestureNeededForEscalationError); // Expect an error that user cancelled the dialog. - CommandLine::ForCurrentProcess()->AppendSwitchASCII( - switches::kAppsGalleryInstallAutoConfirmForTests, "cancel"); + SetExtensionInstallDialogAutoConfirmForTests(false); ReEnable(true, keys::kUserDidNotReEnableError); // This should succeed when user accepts dialog. - CommandLine::ForCurrentProcess()->AppendSwitchASCII( - switches::kAppsGalleryInstallAutoConfirmForTests, "accept"); + SetExtensionInstallDialogAutoConfirmForTests(true); ReEnable(true, ""); } diff --git a/chrome/browser/extensions/extension_webstore_private_apitest.cc b/chrome/browser/extensions/extension_webstore_private_apitest.cc index 99b3f1e..b4b70b3 100644 --- a/chrome/browser/extensions/extension_webstore_private_apitest.cc +++ b/chrome/browser/extensions/extension_webstore_private_apitest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -90,10 +90,8 @@ class ExtensionWebstorePrivateApiTest : public ExtensionApiTest { public: void SetUpCommandLine(CommandLine* command_line) OVERRIDE { ExtensionApiTest::SetUpCommandLine(command_line); - command_line->AppendSwitchASCII( - switches::kAppsGalleryURL, "http://www.example.com"); - command_line->AppendSwitchASCII( - switches::kAppsGalleryInstallAutoConfirmForTests, "accept"); + command_line->AppendSwitchASCII(switches::kAppsGalleryURL, + "http://www.example.com"); } void SetUpInProcessBrowserTestFixture() OVERRIDE { @@ -101,6 +99,7 @@ class ExtensionWebstorePrivateApiTest : public ExtensionApiTest { // API functions. host_resolver()->AddRule("www.example.com", "127.0.0.1"); ASSERT_TRUE(test_server()->Start()); + SetExtensionInstallDialogAutoConfirmForTests(true); ExtensionInstallUI::DisableFailureUIForTests(); } @@ -234,8 +233,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionWebstorePrivateApiTest, InstallLocalized) { // Now test the case where the user cancels the confirmation dialog. IN_PROC_BROWSER_TEST_F(ExtensionWebstorePrivateApiTest, InstallCancelled) { - CommandLine::ForCurrentProcess()->AppendSwitchASCII( - switches::kAppsGalleryInstallAutoConfirmForTests, "cancel"); + SetExtensionInstallDialogAutoConfirmForTests(false); ASSERT_TRUE(RunInstallTest("cancelled.html", "extension.crx")); } diff --git a/chrome/browser/extensions/webstore_inline_install_browsertest.cc b/chrome/browser/extensions/webstore_inline_install_browsertest.cc index ea82dd0..664751d 100644 --- a/chrome/browser/extensions/webstore_inline_install_browsertest.cc +++ b/chrome/browser/extensions/webstore_inline_install_browsertest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -82,8 +82,7 @@ class WebstoreInlineInstallTest : public InProcessBrowserTest { }; IN_PROC_BROWSER_TEST_F(WebstoreInlineInstallTest, Install) { - CommandLine::ForCurrentProcess()->AppendSwitchASCII( - switches::kAppsGalleryInstallAutoConfirmForTests, "accept"); + SetExtensionInstallDialogAutoConfirmForTests(true); ui_test_utils::NavigateToURL( browser(), GenerateTestServerUrl(kAppDomain, "install.html")); @@ -97,8 +96,7 @@ IN_PROC_BROWSER_TEST_F(WebstoreInlineInstallTest, Install) { IN_PROC_BROWSER_TEST_F( WebstoreInlineInstallTest, InstallNotAllowedFromNonVerifiedDomains) { - CommandLine::ForCurrentProcess()->AppendSwitchASCII( - switches::kAppsGalleryInstallAutoConfirmForTests, "cancel"); + SetExtensionInstallDialogAutoConfirmForTests(false); ui_test_utils::NavigateToURL( browser(), GenerateTestServerUrl(kNonAppDomain, "install_non_verified_domain.html")); @@ -115,8 +113,7 @@ IN_PROC_BROWSER_TEST_F(WebstoreInlineInstallTest, FindLink) { } IN_PROC_BROWSER_TEST_F(WebstoreInlineInstallTest, ArgumentValidation) { - CommandLine::ForCurrentProcess()->AppendSwitchASCII( - switches::kAppsGalleryInstallAutoConfirmForTests, "cancel"); + SetExtensionInstallDialogAutoConfirmForTests(false); ui_test_utils::NavigateToURL( browser(), GenerateTestServerUrl(kAppDomain, "argument_validation.html")); @@ -124,8 +121,7 @@ IN_PROC_BROWSER_TEST_F(WebstoreInlineInstallTest, ArgumentValidation) { } IN_PROC_BROWSER_TEST_F(WebstoreInlineInstallTest, InstallNotSupported) { - CommandLine::ForCurrentProcess()->AppendSwitchASCII( - switches::kAppsGalleryInstallAutoConfirmForTests, "cancel"); + SetExtensionInstallDialogAutoConfirmForTests(false); ui_test_utils::NavigateToURL( browser(), GenerateTestServerUrl(kAppDomain, "install_not_supported.html")); @@ -162,8 +158,7 @@ class WebstoreInlineInstallUnpackFailureTest }; IN_PROC_BROWSER_TEST_F(WebstoreInlineInstallUnpackFailureTest, Test) { - CommandLine::ForCurrentProcess()->AppendSwitchASCII( - switches::kAppsGalleryInstallAutoConfirmForTests, "accept"); + SetExtensionInstallDialogAutoConfirmForTests(true); ui_test_utils::NavigateToURL(browser(), GenerateTestServerUrl(kAppDomain, "install_unpack_failure.html")); diff --git a/chrome/common/chrome_switches.cc b/chrome/common/chrome_switches.cc index c2af6c7..63fe16a 100644 --- a/chrome/common/chrome_switches.cc +++ b/chrome/common/chrome_switches.cc @@ -61,14 +61,14 @@ const char kAllowWebUICompositing[] = "allow-webui-compositing"; // but less commonly used plug-ins. const char kAlwaysAuthorizePlugins[] = "always-authorize-plugins"; -// Specifies that the extension-app with the specified id should be launched -// according to its configuration. -const char kAppId[] = "app-id"; - // Specifies that the associated value should be launched in "application" // mode. const char kApp[] = "app"; +// Specifies that the extension-app with the specified id should be launched +// according to its configuration. +const char kAppId[] = "app-id"; + // A URL for the server which assigns channel ids for server pushed app // notifications. const char kAppNotifyChannelServerURL[] = "app-notify-channel-server-url"; @@ -77,17 +77,6 @@ const char kAppNotifyChannelServerURL[] = "app-notify-channel-server-url"; // some private APIs. const char kAppsCheckoutURL[] = "apps-checkout-url"; -// The URL that the webstore APIs download extensions from. -// Note: the URL must contain one '%s' for the extension ID. -const char kAppsGalleryDownloadURL[] = "apps-gallery-download-url"; - -// A setting to cause extension/app installs from the webstore skip the normal -// confirmation dialog. A value of 'accept' means to always act as if the dialog -// was accepted, and 'cancel' means to always act as if the dialog was -// cancelled. -const char kAppsGalleryInstallAutoConfirmForTests[] = - "apps-gallery-install-auto-confirm-for-tests"; - // Allows the webstorePrivate APIs to return browser (aka sync) login tokens to // be used for auto-login in the Web Store (normally they do not). const char kAppsGalleryReturnTokens[] = "apps-gallery-return-tokens"; @@ -95,6 +84,10 @@ const char kAppsGalleryReturnTokens[] = "apps-gallery-return-tokens"; // The URL to use for the gallery link in the app launcher. const char kAppsGalleryURL[] = "apps-gallery-url"; +// The URL that the webstore APIs download extensions from. +// Note: the URL must contain one '%s' for the extension ID. +const char kAppsGalleryDownloadURL[] = "apps-gallery-download-url"; + // The update url used by gallery/webstore extensions. const char kAppsGalleryUpdateURL[] = "apps-gallery-update-url"; diff --git a/chrome/common/chrome_switches.h b/chrome/common/chrome_switches.h index eeae1e8..a113373 100644 --- a/chrome/common/chrome_switches.h +++ b/chrome/common/chrome_switches.h @@ -38,10 +38,9 @@ extern const char kAppId[]; extern const char kApp[]; extern const char kAppNotifyChannelServerURL[]; extern const char kAppsCheckoutURL[]; -extern const char kAppsGalleryDownloadURL[]; -extern const char kAppsGalleryInstallAutoConfirmForTests[]; extern const char kAppsGalleryReturnTokens[]; extern const char kAppsGalleryURL[]; +extern const char kAppsGalleryDownloadURL[]; extern const char kAppsGalleryUpdateURL[]; extern const char kAppsNewInstallBubble[]; extern const char kAppsNoThrob[]; |