| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_INSTALL_UI_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_INSTALL_UI_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_INSTALL_UI_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_INSTALL_UI_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 | 11 |
| 12 class Browser; | 12 class Browser; |
| 13 class ExtensionInstallPrompt; | 13 class ExtensionInstallPrompt; |
| 14 class Profile; | 14 class Profile; |
| 15 class SkBitmap; | 15 class SkBitmap; |
| 16 | 16 |
| 17 namespace extensions { | 17 namespace extensions { |
| 18 class CrxInstallerError; | 18 class CrxInstallerError; |
| 19 class Extension; | 19 class Extension; |
| 20 class ExtensionWebstorePrivateApiTest; | 20 class ExtensionWebstorePrivateApiTest; |
| 21 } | 21 } |
| 22 | 22 |
| 23 // Interface that should be implemented for each platform to display all the UI | 23 // Interface that should be implemented for each platform to display all the UI |
| 24 // around extension installation. | 24 // around extension installation. |
| 25 class ExtensionInstallUI { | 25 class ExtensionInstallUI { |
| 26 public: | 26 public: |
| 27 static ExtensionInstallUI* Create(Profile* profile); | |
| 28 | |
| 29 virtual ~ExtensionInstallUI(); | 27 virtual ~ExtensionInstallUI(); |
| 30 | 28 |
| 31 // Called when an extension was installed. | 29 // Called when an extension was installed. |
| 32 virtual void OnInstallSuccess(const extensions::Extension* extension, | 30 virtual void OnInstallSuccess(const extensions::Extension* extension, |
| 33 const SkBitmap* icon) = 0; | 31 const SkBitmap* icon) = 0; |
| 34 | 32 |
| 35 // Called when an extension failed to install. | 33 // Called when an extension failed to install. |
| 36 virtual void OnInstallFailure(const extensions::CrxInstallerError& error) = 0; | 34 virtual void OnInstallFailure(const extensions::CrxInstallerError& error) = 0; |
| 37 | 35 |
| 38 | 36 |
| 39 // TODO(asargent) Normally we navigate to the new tab page when an app is | 37 // TODO(asargent) Normally we navigate to the new tab page when an app is |
| 40 // installed, but we're experimenting with instead showing a bubble when | 38 // installed, but we're experimenting with instead showing a bubble when |
| 41 // an app is installed which points to the new tab button. This may become | 39 // an app is installed which points to the new tab button. This may become |
| 42 // the default behavior in the future. | 40 // the default behavior in the future. |
| 43 virtual void SetUseAppInstalledBubble(bool use_bubble) = 0; | 41 virtual void SetUseAppInstalledBubble(bool use_bubble) = 0; |
| 44 | 42 |
| 45 // Whether or not to show the default UI after completing the installation. | 43 // Whether or not to show the default UI after completing the installation. |
| 46 void set_skip_post_install_ui(bool skip_ui) { | 44 void set_skip_post_install_ui(bool skip_ui) { |
| 47 skip_post_install_ui_ = skip_ui; | 45 skip_post_install_ui_ = skip_ui; |
| 48 } | 46 } |
| 49 | 47 |
| 50 // Opens apps UI and animates the app icon for the app with id |app_id|. | 48 // Opens apps UI and animates the app icon for the app with id |app_id|. |
| 51 static void OpenAppInstalledUI(Profile* profile, const std::string& app_id); | 49 virtual void OpenAppInstalledUI(const std::string& app_id) = 0; |
| 50 |
| 51 // Creates an ExtensionInstallPrompt. Caller assumes ownership. This method is |
| 52 // deprecated - do not add new callers. |
| 53 // TODO(pkotwicz): Remove this method. crbug.com/422474 |
| 54 virtual ExtensionInstallPrompt* CreateInstallPrompt() = 0; |
| 52 | 55 |
| 53 #if defined(UNIT_TEST) | 56 #if defined(UNIT_TEST) |
| 54 static void set_disable_failure_ui_for_tests() { | 57 static void set_disable_failure_ui_for_tests() { |
| 55 disable_failure_ui_for_tests_ = true; | 58 disable_failure_ui_for_tests_ = true; |
| 56 } | 59 } |
| 57 #endif | 60 #endif |
| 58 | 61 |
| 59 // Creates an ExtensionInstallPrompt from |browser|. | |
| 60 // Caller assumes ownership. | |
| 61 static ExtensionInstallPrompt* CreateInstallPromptWithBrowser( | |
| 62 Browser* browser); | |
| 63 | |
| 64 // Creates an ExtensionInstallPrompt from |profile|. | |
| 65 // Caller assumes ownership. This method is deprecated and should not be used | |
| 66 // in new code. | |
| 67 static ExtensionInstallPrompt* CreateInstallPromptWithProfile( | |
| 68 Profile* profile); | |
| 69 | |
| 70 Profile* profile() { return profile_; } | 62 Profile* profile() { return profile_; } |
| 71 | 63 |
| 72 protected: | 64 protected: |
| 73 explicit ExtensionInstallUI(Profile* profile); | 65 explicit ExtensionInstallUI(Profile* profile); |
| 74 | 66 |
| 75 static bool disable_failure_ui_for_tests() { | 67 static bool disable_failure_ui_for_tests() { |
| 76 return disable_failure_ui_for_tests_; | 68 return disable_failure_ui_for_tests_; |
| 77 } | 69 } |
| 78 | 70 |
| 79 bool skip_post_install_ui() const { return skip_post_install_ui_; } | 71 bool skip_post_install_ui() const { return skip_post_install_ui_; } |
| 80 | 72 |
| 81 private: | 73 private: |
| 82 static bool disable_failure_ui_for_tests_; | 74 static bool disable_failure_ui_for_tests_; |
| 83 | 75 |
| 84 Profile* profile_; | 76 Profile* profile_; |
| 85 | 77 |
| 86 // Whether or not to show the default UI after completing the installation. | 78 // Whether or not to show the default UI after completing the installation. |
| 87 bool skip_post_install_ui_; | 79 bool skip_post_install_ui_; |
| 88 | 80 |
| 89 DISALLOW_COPY_AND_ASSIGN(ExtensionInstallUI); | 81 DISALLOW_COPY_AND_ASSIGN(ExtensionInstallUI); |
| 90 }; | 82 }; |
| 91 | 83 |
| 84 namespace chrome { |
| 85 |
| 86 ExtensionInstallUI* CreateExtensionInstallUI(Profile* profile); |
| 87 |
| 88 } // namespace chrome |
| 89 |
| 92 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_INSTALL_UI_H_ | 90 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_INSTALL_UI_H_ |
| OLD | NEW |