diff options
Diffstat (limited to 'extensions')
-rw-r--r-- | extensions/browser/BUILD.gn | 3 | ||||
-rw-r--r-- | extensions/browser/install/crx_installer_error.h | 36 | ||||
-rw-r--r-- | extensions/browser/install/extension_install_ui.cc | 18 | ||||
-rw-r--r-- | extensions/browser/install/extension_install_ui.h | 70 | ||||
-rw-r--r-- | extensions/extensions.gyp | 3 |
5 files changed, 130 insertions, 0 deletions
diff --git a/extensions/browser/BUILD.gn b/extensions/browser/BUILD.gn index 3a0adfd..06ed416 100644 --- a/extensions/browser/BUILD.gn +++ b/extensions/browser/BUILD.gn @@ -395,6 +395,9 @@ source_set("browser") { "image_util.h", "info_map.cc", "info_map.h", + "install/crx_installer_error.h", + "install/extension_install_ui.cc", + "install/extension_install_ui.h", "install_flag.h", "lazy_background_task_queue.cc", "lazy_background_task_queue.h", diff --git a/extensions/browser/install/crx_installer_error.h b/extensions/browser/install/crx_installer_error.h new file mode 100644 index 0000000..0376a79 --- /dev/null +++ b/extensions/browser/install/crx_installer_error.h @@ -0,0 +1,36 @@ +// Copyright (c) 2012 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. + +#ifndef EXTENSIONS_BROWSER_INSTALL_CRX_INSTALLER_ERROR_H_ +#define EXTENSIONS_BROWSER_INSTALL_CRX_INSTALLER_ERROR_H_ + +#include "base/strings/string16.h" + +namespace extensions { + +// Simple error class for CrxInstaller. +class CrxInstallerError { + public: + // Typed errors that need to be handled specially by clients. + enum Type { ERROR_NONE, ERROR_OFF_STORE, ERROR_OTHER }; + + CrxInstallerError() : type_(ERROR_NONE) {} + + explicit CrxInstallerError(const base::string16& message) + : type_(message.empty() ? ERROR_NONE : ERROR_OTHER), message_(message) {} + + CrxInstallerError(Type type, const base::string16& message) + : type_(type), message_(message) {} + + Type type() const { return type_; } + const base::string16& message() const { return message_; } + + private: + Type type_; + base::string16 message_; +}; + +} // namespace extensions + +#endif // EXTENSIONS_BROWSER_INSTALL_CRX_INSTALLER_ERROR_H_ diff --git a/extensions/browser/install/extension_install_ui.cc b/extensions/browser/install/extension_install_ui.cc new file mode 100644 index 0000000..03441b6 --- /dev/null +++ b/extensions/browser/install/extension_install_ui.cc @@ -0,0 +1,18 @@ +// Copyright (c) 2012 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 "extensions/browser/install/extension_install_ui.h" + +namespace extensions { + +// static +bool ExtensionInstallUI::disable_failure_ui_for_tests_ = false; + +ExtensionInstallUI::ExtensionInstallUI() { +} + +ExtensionInstallUI::~ExtensionInstallUI() { +} + +} // namespace extensions diff --git a/extensions/browser/install/extension_install_ui.h b/extensions/browser/install/extension_install_ui.h new file mode 100644 index 0000000..f9cbe4b --- /dev/null +++ b/extensions/browser/install/extension_install_ui.h @@ -0,0 +1,70 @@ +// Copyright (c) 2012 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. + +#ifndef EXTENSIONS_BROWSER_INSTALL_EXTENSION_INSTALL_UI_H_ +#define EXTENSIONS_BROWSER_INSTALL_EXTENSION_INSTALL_UI_H_ + +#include <string> + +#include "base/basictypes.h" +#include "ui/gfx/native_widget_types.h" + +class SkBitmap; + +namespace extensions { +class CrxInstallerError; +class Extension; + +// Interface that should be implemented for each platform to display all the UI +// around extension installation. +class ExtensionInstallUI { + public: + ExtensionInstallUI(); + virtual ~ExtensionInstallUI(); + + // Called when an extension was installed. + virtual void OnInstallSuccess(const extensions::Extension* extension, + const SkBitmap* icon) = 0; + + // Called when an extension failed to install. + virtual void OnInstallFailure(const extensions::CrxInstallerError& error) = 0; + + // TODO(asargent) Normally we navigate to the new tab page when an app is + // installed, but we're experimenting with instead showing a bubble when + // an app is installed which points to the new tab button. This may become + // the default behavior in the future. + virtual void SetUseAppInstalledBubble(bool use_bubble) = 0; + + // Opens apps UI and animates the app icon for the app with id |app_id|. + virtual void OpenAppInstalledUI(const std::string& app_id) = 0; + + // Sets whether to show the default UI after completing the installation. + virtual void SetSkipPostInstallUI(bool skip_ui) = 0; + + // Returns the gfx::NativeWindow to use as the parent for install dialogs. + // Returns NULL if the install dialog should be a top level window. This + // method is deprecated - do not add new callers. + // TODO(pkotwicz): Remove this method. crbug.com/422474 + virtual gfx::NativeWindow GetDefaultInstallDialogParent() = 0; + +#if defined(UNIT_TEST) + static void set_disable_failure_ui_for_tests() { + disable_failure_ui_for_tests_ = true; + } +#endif + + protected: + static bool disable_failure_ui_for_tests() { + return disable_failure_ui_for_tests_; + } + + private: + static bool disable_failure_ui_for_tests_; + + DISALLOW_COPY_AND_ASSIGN(ExtensionInstallUI); +}; + +} // namespace extensions + +#endif // EXTENSIONS_BROWSER_INSTALL_EXTENSION_INSTALL_UI_H_ diff --git a/extensions/extensions.gyp b/extensions/extensions.gyp index 41c11b0..0c9a8ac 100644 --- a/extensions/extensions.gyp +++ b/extensions/extensions.gyp @@ -695,6 +695,9 @@ 'browser/image_util.h', 'browser/info_map.cc', 'browser/info_map.h', + 'browser/install/crx_installer_error.h', + 'browser/install/extension_install_ui.cc', + 'browser/install/extension_install_ui.h', 'browser/install_flag.h', 'browser/file_highlighter.cc', 'browser/file_highlighter.h', |