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 EXTENSIONS_BROWSER_INSTALL_EXTENSION_INSTALL_UI_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_INSTALL_UI_H_ | 6 #define EXTENSIONS_BROWSER_INSTALL_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 #include "ui/gfx/native_widget_types.h" |
11 | 12 |
12 class Browser; | |
13 class ExtensionInstallPrompt; | |
14 class Profile; | |
15 class SkBitmap; | 13 class SkBitmap; |
16 | 14 |
17 namespace extensions { | 15 namespace extensions { |
18 class CrxInstallerError; | 16 class CrxInstallerError; |
19 class Extension; | 17 class Extension; |
20 class ExtensionWebstorePrivateApiTest; | |
21 } | |
22 | 18 |
23 // Interface that should be implemented for each platform to display all the UI | 19 // Interface that should be implemented for each platform to display all the UI |
24 // around extension installation. | 20 // around extension installation. |
25 class ExtensionInstallUI { | 21 class ExtensionInstallUI { |
26 public: | 22 public: |
27 static ExtensionInstallUI* Create(Profile* profile); | 23 ExtensionInstallUI(); |
28 | |
29 virtual ~ExtensionInstallUI(); | 24 virtual ~ExtensionInstallUI(); |
30 | 25 |
31 // Called when an extension was installed. | 26 // Called when an extension was installed. |
32 virtual void OnInstallSuccess(const extensions::Extension* extension, | 27 virtual void OnInstallSuccess(const extensions::Extension* extension, |
33 const SkBitmap* icon) = 0; | 28 const SkBitmap* icon) = 0; |
34 | 29 |
35 // Called when an extension failed to install. | 30 // Called when an extension failed to install. |
36 virtual void OnInstallFailure(const extensions::CrxInstallerError& error) = 0; | 31 virtual void OnInstallFailure(const extensions::CrxInstallerError& error) = 0; |
37 | 32 |
38 | |
39 // TODO(asargent) Normally we navigate to the new tab page when an app is | 33 // 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 | 34 // 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 | 35 // an app is installed which points to the new tab button. This may become |
42 // the default behavior in the future. | 36 // the default behavior in the future. |
43 virtual void SetUseAppInstalledBubble(bool use_bubble) = 0; | 37 virtual void SetUseAppInstalledBubble(bool use_bubble) = 0; |
44 | 38 |
45 // Whether or not to show the default UI after completing the installation. | 39 // Opens apps UI and animates the app icon for the app with id |app_id|. |
46 void set_skip_post_install_ui(bool skip_ui) { | 40 virtual void OpenAppInstalledUI(const std::string& app_id) = 0; |
47 skip_post_install_ui_ = skip_ui; | |
48 } | |
49 | 41 |
50 // Opens apps UI and animates the app icon for the app with id |app_id|. | 42 // Sets whether to show the default UI after completing the installation. |
51 static void OpenAppInstalledUI(Profile* profile, const std::string& app_id); | 43 virtual void SetSkipPostInstallUI(bool skip_ui) = 0; |
| 44 |
| 45 // Returns the gfx::NativeWindow to use as the parent for install dialogs. |
| 46 // Returns NULL if the install dialog should be a top level window. This |
| 47 // method is deprecated - do not add new callers. |
| 48 // TODO(pkotwicz): Remove this method. crbug.com/422474 |
| 49 virtual gfx::NativeWindow GetDefaultInstallDialogParent() = 0; |
52 | 50 |
53 #if defined(UNIT_TEST) | 51 #if defined(UNIT_TEST) |
54 static void set_disable_failure_ui_for_tests() { | 52 static void set_disable_failure_ui_for_tests() { |
55 disable_failure_ui_for_tests_ = true; | 53 disable_failure_ui_for_tests_ = true; |
56 } | 54 } |
57 #endif | 55 #endif |
58 | 56 |
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_; } | |
71 | |
72 protected: | 57 protected: |
73 explicit ExtensionInstallUI(Profile* profile); | |
74 | |
75 static bool disable_failure_ui_for_tests() { | 58 static bool disable_failure_ui_for_tests() { |
76 return disable_failure_ui_for_tests_; | 59 return disable_failure_ui_for_tests_; |
77 } | 60 } |
78 | 61 |
79 bool skip_post_install_ui() const { return skip_post_install_ui_; } | |
80 | |
81 private: | 62 private: |
82 static bool disable_failure_ui_for_tests_; | 63 static bool disable_failure_ui_for_tests_; |
83 | 64 |
84 Profile* profile_; | |
85 | |
86 // Whether or not to show the default UI after completing the installation. | |
87 bool skip_post_install_ui_; | |
88 | |
89 DISALLOW_COPY_AND_ASSIGN(ExtensionInstallUI); | 65 DISALLOW_COPY_AND_ASSIGN(ExtensionInstallUI); |
90 }; | 66 }; |
91 | 67 |
92 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_INSTALL_UI_H_ | 68 } // namespace extensions |
| 69 |
| 70 #endif // EXTENSIONS_BROWSER_INSTALL_EXTENSION_INSTALL_UI_H_ |
OLD | NEW |