diff options
author | benwells <benwells@chromium.org> | 2015-08-20 19:55:08 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-08-21 02:55:50 +0000 |
commit | 22ab8eef999925ec4d1671935954080df7eb6e7c (patch) | |
tree | cc3775290874b0702bd6fb6dcc15d4cb25f6130b | |
parent | 2b596cfc7ad1aeaa48ba6102b88f433a6a357b40 (diff) | |
download | chromium_src-22ab8eef999925ec4d1671935954080df7eb6e7c.zip chromium_src-22ab8eef999925ec4d1671935954080df7eb6e7c.tar.gz chromium_src-22ab8eef999925ec4d1671935954080df7eb6e7c.tar.bz2 |
Remove command line flag to install an ephemeral app.
As ephemeral apps were never released and are being removed, this is no
longer needed.
BUG=517735
Review URL: https://codereview.chromium.org/1291793005
Cr-Commit-Position: refs/heads/master@{#344664}
-rw-r--r-- | chrome/browser/extensions/extension_service.cc | 29 | ||||
-rw-r--r-- | chrome/browser/extensions/startup_helper.cc | 135 | ||||
-rw-r--r-- | chrome/browser/extensions/startup_helper.h | 5 | ||||
-rw-r--r-- | chrome/browser/extensions/webstore_startup_installer_browsertest.cc | 67 | ||||
-rw-r--r-- | chrome/browser/ui/startup/startup_browser_creator.cc | 8 | ||||
-rw-r--r-- | chrome/common/chrome_result_codes.h | 2 | ||||
-rw-r--r-- | chrome/common/chrome_switches.cc | 6 | ||||
-rw-r--r-- | chrome/common/chrome_switches.h | 1 |
8 files changed, 12 insertions, 241 deletions
diff --git a/chrome/browser/extensions/extension_service.cc b/chrome/browser/extensions/extension_service.cc index 3ed9706..96e5fbf 100644 --- a/chrome/browser/extensions/extension_service.cc +++ b/chrome/browser/extensions/extension_service.cc @@ -409,28 +409,19 @@ void ExtensionService::Init() { DCHECK(!is_ready()); // Can't redo init. DCHECK_EQ(registry_->enabled_extensions().size(), 0u); - const base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess(); - if (cmd_line->HasSwitch(switches::kInstallEphemeralAppFromWebstore)) { - // The sole purpose of this launch is to install a new extension from CWS - // and immediately terminate: loading already installed extensions is - // unnecessary and may interfere with the inline install dialog (e.g. if an - // extension listens to onStartup and opens a window). - SetReadyAndNotifyListeners(); - } else { - // LoadAllExtensions() calls OnLoadedInstalledExtensions(). - component_loader_->LoadAll(); - extensions::InstalledLoader(this).LoadAllExtensions(); + // LoadAllExtensions() calls OnLoadedInstalledExtensions(). + component_loader_->LoadAll(); + extensions::InstalledLoader(this).LoadAllExtensions(); - EnabledReloadableExtensions(); - MaybeFinishShutdownDelayed(); - SetReadyAndNotifyListeners(); + EnabledReloadableExtensions(); + MaybeFinishShutdownDelayed(); + SetReadyAndNotifyListeners(); - // TODO(erikkay): this should probably be deferred to a future point - // rather than running immediately at startup. - CheckForExternalUpdates(); + // TODO(erikkay): this should probably be deferred to a future point + // rather than running immediately at startup. + CheckForExternalUpdates(); - LoadGreylistFromPrefs(); - } + LoadGreylistFromPrefs(); } void ExtensionService::EnabledReloadableExtensions() { diff --git a/chrome/browser/extensions/startup_helper.cc b/chrome/browser/extensions/startup_helper.cc index c435799..49068c4 100644 --- a/chrome/browser/extensions/startup_helper.cc +++ b/chrome/browser/extensions/startup_helper.cc @@ -11,27 +11,13 @@ #include "base/message_loop/message_loop.h" #include "base/run_loop.h" #include "base/single_thread_task_runner.h" -#include "base/strings/string_util.h" #include "base/strings/stringprintf.h" #include "base/strings/utf_string_conversions.h" -#include "chrome/browser/extensions/extension_service.h" -#include "chrome/browser/extensions/webstore_startup_installer.h" -#include "chrome/browser/profiles/profile.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/extensions/chrome_extensions_client.h" -#include "components/crx_file/id_util.h" #include "content/public/browser/browser_thread.h" -#include "content/public/browser/web_contents.h" #include "extensions/browser/sandboxed_unpacker.h" #include "extensions/common/extension.h" -#include "ipc/ipc_message.h" - -#if defined(OS_WIN) -#include "extensions/browser/app_window/app_window.h" -#include "extensions/browser/app_window/app_window_registry.h" -#include "extensions/browser/extension_registry.h" -#include "extensions/browser/extension_util.h" -#endif using content::BrowserThread; @@ -43,37 +29,6 @@ void PrintPackExtensionMessage(const std::string& message) { VLOG(1) << message; } -// On Windows, the jumplist action for installing an ephemeral app has to use -// the --install-ephemeral-app-from-webstore command line arg to initiate an -// install. -scoped_refptr<WebstoreStandaloneInstaller> CreateEphemeralAppInstaller( - Profile* profile, - const std::string& app_id, - WebstoreStandaloneInstaller::Callback callback) { - scoped_refptr<WebstoreStandaloneInstaller> installer; - -#if defined(OS_WIN) - ExtensionRegistry* registry = ExtensionRegistry::Get(profile); - DCHECK(registry); - if (!registry->GetExtensionById(app_id, ExtensionRegistry::EVERYTHING) || - !util::IsEphemeralApp(app_id, profile)) { - return installer; - } - - AppWindowRegistry* app_window_registry = AppWindowRegistry::Get(profile); - DCHECK(app_window_registry); - AppWindow* app_window = - app_window_registry->GetCurrentAppWindowForApp(app_id); - if (!app_window) - return installer; - - installer = new WebstoreInstallWithPrompt( - app_id, profile, app_window->GetNativeWindow(), callback); -#endif - - return installer; -} - } // namespace StartupHelper::StartupHelper() : pack_job_succeeded_(false) { @@ -239,96 +194,6 @@ bool StartupHelper::ValidateCrx(const base::CommandLine& cmd_line, return success; } -namespace { - -class AppInstallHelper { - public: - // A callback for when the install process is done. - typedef base::Callback<void()> DoneCallback; - - AppInstallHelper(); - virtual ~AppInstallHelper(); - bool success() { return success_; } - const std::string& error() { return error_; } - void BeginInstall(Profile* profile, - const std::string& id, - bool show_prompt, - DoneCallback callback); - - private: - WebstoreStandaloneInstaller::Callback Callback(); - void OnAppInstallComplete(bool success, - const std::string& error, - webstore_install::Result result); - - DoneCallback done_callback_; - - // These hold on to the result of the app install when it is complete. - bool success_; - std::string error_; - - scoped_refptr<WebstoreStandaloneInstaller> installer_; -}; - -AppInstallHelper::AppInstallHelper() : success_(false) {} - -AppInstallHelper::~AppInstallHelper() {} - -WebstoreStandaloneInstaller::Callback AppInstallHelper::Callback() { - return base::Bind(&AppInstallHelper::OnAppInstallComplete, - base::Unretained(this)); -} - -void AppInstallHelper::BeginInstall( - Profile* profile, - const std::string& id, - bool show_prompt, - DoneCallback done_callback) { - done_callback_ = done_callback; - - WebstoreStandaloneInstaller::Callback callback = - base::Bind(&AppInstallHelper::OnAppInstallComplete, - base::Unretained(this)); - - installer_ = CreateEphemeralAppInstaller(profile, id, callback); - if (installer_.get()) { - installer_->BeginInstall(); - } else { - error_ = "Not a supported ephemeral app installation."; - done_callback_.Run(); - } -} - -void AppInstallHelper::OnAppInstallComplete(bool success, - const std::string& error, - webstore_install::Result result) { - success_ = success; - error_ = error; - done_callback_.Run(); -} - -} // namespace - -bool StartupHelper::InstallEphemeralApp(const base::CommandLine& cmd_line, - Profile* profile) { - std::string id = - cmd_line.GetSwitchValueASCII(switches::kInstallEphemeralAppFromWebstore); - if (!crx_file::id_util::IdIsValid(id)) { - LOG(ERROR) << "Invalid id for " - << switches::kInstallEphemeralAppFromWebstore << " : '" << id << "'"; - return false; - } - - AppInstallHelper helper; - base::RunLoop run_loop; - helper.BeginInstall(profile, id, true, run_loop.QuitClosure()); - run_loop.Run(); - - if (!helper.success()) - LOG(ERROR) << "InstallFromWebstore failed with error: " << helper.error(); - return helper.success(); -} - StartupHelper::~StartupHelper() { if (pack_job_.get()) pack_job_->ClearClient(); diff --git a/chrome/browser/extensions/startup_helper.h b/chrome/browser/extensions/startup_helper.h index c291e38..82cc596 100644 --- a/chrome/browser/extensions/startup_helper.h +++ b/chrome/browser/extensions/startup_helper.h @@ -37,11 +37,6 @@ class StartupHelper : public PackExtensionJob::Client { // into |error|. bool ValidateCrx(const base::CommandLine& cmd_line, std::string* error); - // Handle --install-ephemeral-app-from-webstore flag from |cmd_line| by - // downloading metadata from the webstore for the given id, prompting the - // user to confirm, and then downloading the crx and installing it. - bool InstallEphemeralApp(const base::CommandLine& cmd_line, Profile* profile); - private: scoped_refptr<PackExtensionJob> pack_job_; bool pack_job_succeeded_; diff --git a/chrome/browser/extensions/webstore_startup_installer_browsertest.cc b/chrome/browser/extensions/webstore_startup_installer_browsertest.cc index 2c142b4..e87138e 100644 --- a/chrome/browser/extensions/webstore_startup_installer_browsertest.cc +++ b/chrome/browser/extensions/webstore_startup_installer_browsertest.cc @@ -4,9 +4,7 @@ #include "base/command_line.h" #include "base/scoped_observer.h" -#include "chrome/browser/chrome_notification_types.h" #include "chrome/browser/extensions/extension_service.h" -#include "chrome/browser/extensions/startup_helper.h" #include "chrome/browser/extensions/webstore_installer_test.h" #include "chrome/browser/infobars/infobar_service.h" #include "chrome/browser/profiles/profile.h" @@ -16,14 +14,11 @@ #include "chrome/test/base/in_process_browser_test.h" #include "chrome/test/base/test_switches.h" #include "chrome/test/base/ui_test_utils.h" -#include "content/public/browser/notification_registrar.h" #include "content/public/browser/notification_service.h" -#include "content/public/browser/notification_types.h" #include "content/public/browser/web_contents.h" #include "content/public/test/browser_test_utils.h" #include "extensions/browser/extension_host.h" #include "extensions/browser/extension_registry.h" -#include "extensions/browser/extension_registry_observer.h" #include "extensions/browser/extension_system.h" #include "extensions/browser/install/extension_install_ui.h" #include "extensions/common/extension_builder.h" @@ -230,65 +225,3 @@ IN_PROC_BROWSER_TEST_F(WebstoreStartupInstallUnpackFailureTest, RunTest("runTest"); } - -class CommandLineWebstoreInstall - : public WebstoreStartupInstallerTest, - public content::NotificationObserver, - public extensions::ExtensionRegistryObserver { - public: - CommandLineWebstoreInstall() : saw_install_(false), browser_open_count_(0) {} - ~CommandLineWebstoreInstall() override {} - - void SetUpOnMainThread() override { - WebstoreStartupInstallerTest::SetUpOnMainThread(); - extensions::ExtensionRegistry::Get(browser()->profile())->AddObserver(this); - registrar_.Add(this, chrome::NOTIFICATION_BROWSER_OPENED, - content::NotificationService::AllSources()); - } - - void TearDownOnMainThread() override { - extensions::ExtensionRegistry::Get(browser()->profile()) - ->RemoveObserver(this); - WebstoreStartupInstallerTest::TearDownOnMainThread(); - } - - bool saw_install() { return saw_install_; } - - int browser_open_count() { return browser_open_count_; } - - // NotificationObserver interface. - void Observe(int type, - const content::NotificationSource& source, - const content::NotificationDetails& details) override { - DCHECK_EQ(type, chrome::NOTIFICATION_BROWSER_OPENED); - ++browser_open_count_; - } - - void OnExtensionWillBeInstalled(content::BrowserContext* browser_context, - const extensions::Extension* extension, - bool is_update, - bool from_ephemeral, - const std::string& old_name) override { - EXPECT_EQ(extension->id(), kTestExtensionId); - saw_install_ = true; - } - - content::NotificationRegistrar registrar_; - - // Have we seen an installation notification for kTestExtensionId ? - bool saw_install_; - - // How many NOTIFICATION_BROWSER_OPENED notifications have we seen? - int browser_open_count_; -}; - -IN_PROC_BROWSER_TEST_F(CommandLineWebstoreInstall, CannotInstallNonEphemeral) { - base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); - command_line->AppendSwitchASCII( - switches::kInstallEphemeralAppFromWebstore, kTestExtensionId); - AutoAcceptInstall(); - extensions::StartupHelper helper; - EXPECT_FALSE(helper.InstallEphemeralApp(*command_line, browser()->profile())); - EXPECT_FALSE(saw_install()); - EXPECT_EQ(0, browser_open_count()); -} diff --git a/chrome/browser/ui/startup/startup_browser_creator.cc b/chrome/browser/ui/startup/startup_browser_creator.cc index 031c009..f7fac34 100644 --- a/chrome/browser/ui/startup/startup_browser_creator.cc +++ b/chrome/browser/ui/startup/startup_browser_creator.cc @@ -537,14 +537,6 @@ bool StartupBrowserCreator::ProcessCmdLineImpl( net::SetExplicitlyAllowedPorts(allowed_ports); } - if (command_line.HasSwitch(switches::kInstallEphemeralAppFromWebstore)) { - extensions::StartupHelper helper; - helper.InstallEphemeralApp(command_line, last_used_profile); - // Nothing more needs to be done, so return false to stop launching and - // quit. - return false; - } - if (command_line.HasSwitch(switches::kValidateCrx)) { if (!process_startup) { LOG(ERROR) << "chrome is already running; you must close all running " diff --git a/chrome/common/chrome_result_codes.h b/chrome/common/chrome_result_codes.h index a5a0fc6..b93805e 100644 --- a/chrome/common/chrome_result_codes.h +++ b/chrome/common/chrome_result_codes.h @@ -77,6 +77,8 @@ enum ResultCode { // Failed to install an item from the webstore when the // kInstallEphemeralAppFromWebstore command line flag was present. + // As this flag is no longer supported, this return code should never be + // returned. RESULT_CODE_INSTALL_FROM_WEBSTORE_ERROR_2, // A dummy value we should not use. See crbug.com/152285. diff --git a/chrome/common/chrome_switches.cc b/chrome/common/chrome_switches.cc index a9902f4..efbc709 100644 --- a/chrome/common/chrome_switches.cc +++ b/chrome/common/chrome_switches.cc @@ -665,12 +665,6 @@ const char kIncognito[] = "incognito"; // Causes Chrome to initiate an installation flow for the given app. const char kInstallChromeApp[] = "install-chrome-app"; -// Causes Chrome to attempt to get metadata from the webstore for the -// app/extension ID given, and then prompt the user to download and install it. -// This is allowed *only* for ephemeral apps. All other ids will be ignored. -const char kInstallEphemeralAppFromWebstore[] = - "install-ephemeral-app-from-webstore"; - // A list of whitelists to install for a supervised user, for testing. // The list is of the following form: <id>[:<name>],[<id>[:<name>],...] const char kInstallSupervisedUserWhitelists[] = diff --git a/chrome/common/chrome_switches.h b/chrome/common/chrome_switches.h index 45bf40f..c3381f6 100644 --- a/chrome/common/chrome_switches.h +++ b/chrome/common/chrome_switches.h @@ -186,7 +186,6 @@ extern const char kHostResolverRetryAttempts[]; extern const char kIgnoreUrlFetcherCertRequests[]; extern const char kIncognito[]; extern const char kInstallChromeApp[]; -extern const char kInstallEphemeralAppFromWebstore[]; extern const char kInstallSupervisedUserWhitelists[]; extern const char kInstantProcess[]; extern const char kInvalidationUseGCMChannel[]; |