OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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> |
| 9 |
8 #include "base/file_path.h" | 10 #include "base/file_path.h" |
9 #include "base/ref_counted.h" | 11 #include "base/ref_counted.h" |
10 #include "base/scoped_ptr.h" | 12 #include "base/scoped_ptr.h" |
| 13 #include "chrome/browser/extensions/image_loading_tracker.h" |
11 #include "gfx/native_widget_types.h" | 14 #include "gfx/native_widget_types.h" |
12 #include "third_party/skia/include/core/SkBitmap.h" | 15 #include "third_party/skia/include/core/SkBitmap.h" |
13 | 16 |
14 #include <string> | |
15 | |
16 class Extension; | 17 class Extension; |
17 class ExtensionsService; | 18 class ExtensionsService; |
18 class MessageLoop; | 19 class MessageLoop; |
19 class Profile; | 20 class Profile; |
20 class InfoBarDelegate; | 21 class InfoBarDelegate; |
21 class SandboxedExtensionUnpacker; | 22 class SandboxedExtensionUnpacker; |
22 class TabContents; | 23 class TabContents; |
23 | 24 |
24 // Displays all the UI around extension installation and uninstallation. | 25 // Displays all the UI around extension installation and uninstallation. |
25 class ExtensionInstallUI { | 26 class ExtensionInstallUI : public ImageLoadingTracker::Observer { |
26 public: | 27 public: |
27 enum PromptType { | 28 enum PromptType { |
28 INSTALL_PROMPT = 0, | 29 INSTALL_PROMPT = 0, |
29 UNINSTALL_PROMPT, | 30 UNINSTALL_PROMPT, |
30 ENABLE_INCOGNITO_PROMPT, | 31 ENABLE_INCOGNITO_PROMPT, |
31 NUM_PROMPT_TYPES | 32 NUM_PROMPT_TYPES |
32 }; | 33 }; |
33 | 34 |
34 // A mapping from PromptType to message ID for various dialog content. | 35 // A mapping from PromptType to message ID for various dialog content. |
35 static const int kTitleIds[NUM_PROMPT_TYPES]; | 36 static const int kTitleIds[NUM_PROMPT_TYPES]; |
(...skipping 13 matching lines...) Expand all Loading... |
49 | 50 |
50 explicit ExtensionInstallUI(Profile* profile); | 51 explicit ExtensionInstallUI(Profile* profile); |
51 | 52 |
52 virtual ~ExtensionInstallUI() {} | 53 virtual ~ExtensionInstallUI() {} |
53 | 54 |
54 // This is called by the installer to verify whether the installation should | 55 // This is called by the installer to verify whether the installation should |
55 // proceed. This is declared virtual for testing. | 56 // proceed. This is declared virtual for testing. |
56 // | 57 // |
57 // We *MUST* eventually call either Proceed() or Abort() | 58 // We *MUST* eventually call either Proceed() or Abort() |
58 // on |delegate|. | 59 // on |delegate|. |
59 virtual void ConfirmInstall(Delegate* delegate, Extension* extension, | 60 virtual void ConfirmInstall(Delegate* delegate, Extension* extension); |
60 SkBitmap* icon); | |
61 | 61 |
62 // This is called by the extensions management page to verify whether the | 62 // This is called by the extensions management page to verify whether the |
63 // uninstallation should proceed. This is declared virtual for testing. | 63 // uninstallation should proceed. This is declared virtual for testing. |
64 // | 64 // |
65 // We *MUST* eventually call either Proceed() or Abort() | 65 // We *MUST* eventually call either Proceed() or Abort() |
66 // on |delegate|. | 66 // on |delegate|. |
67 virtual void ConfirmUninstall(Delegate* delegate, Extension* extension, | 67 virtual void ConfirmUninstall(Delegate* delegate, Extension* extension); |
68 SkBitmap* icon); | |
69 | 68 |
70 // This is called by the extensions management page to verify whether the | 69 // This is called by the extensions management page to verify whether the |
71 // uninstallation should proceed. This is declared virtual for testing. | 70 // uninstallation should proceed. This is declared virtual for testing. |
72 // | 71 // |
73 // We *MUST* eventually call either Proceed() or Abort() | 72 // We *MUST* eventually call either Proceed() or Abort() |
74 // on |delegate|. | 73 // on |delegate|. |
75 virtual void ConfirmEnableIncognito(Delegate* delegate, Extension* extension, | 74 virtual void ConfirmEnableIncognito(Delegate* delegate, Extension* extension); |
76 SkBitmap* icon); | |
77 | 75 |
78 // Installation was successful. This is declared virtual for testing. | 76 // Installation was successful. This is declared virtual for testing. |
79 virtual void OnInstallSuccess(Extension* extension); | 77 virtual void OnInstallSuccess(Extension* extension); |
80 | 78 |
81 // Installation failed. This is declared virtual for testing. | 79 // Installation failed. This is declared virtual for testing. |
82 virtual void OnInstallFailure(const std::string& error); | 80 virtual void OnInstallFailure(const std::string& error); |
83 | 81 |
84 // The install was rejected because the same extension/version is already | 82 // The install was rejected because the same extension/version is already |
85 // installed. This is declared virtual for testing. | 83 // installed. This is declared virtual for testing. |
86 virtual void OnOverinstallAttempted(Extension* extension); | 84 virtual void OnOverinstallAttempted(Extension* extension); |
87 | 85 |
| 86 // ImageLoadingTracker::Observer overrides. |
| 87 virtual void OnImageLoaded( |
| 88 SkBitmap* image, ExtensionResource resource, int index); |
| 89 |
88 private: | 90 private: |
89 // When a Theme is downloaded it is applied and an info bar is shown to give | 91 // When a Theme is downloaded it is applied and an info bar is shown to give |
90 // the user a choice to keep it or undo the installation. | 92 // the user a choice to keep it or undo the installation. |
91 void ShowThemeInfoBar(Extension* new_theme); | 93 void ShowThemeInfoBar(Extension* new_theme); |
92 | 94 |
| 95 // Starts the process of showing a confirmation UI, which is split into two. |
| 96 // 1) Set of a load icon task. |
| 97 // 2) Handle the load icon response and show the UI (OnImageLoaded). |
| 98 void ShowConfirmation(PromptType prompt_type); |
| 99 |
93 #if defined(OS_MACOSX) | 100 #if defined(OS_MACOSX) |
94 // When an extension is installed on Mac with neither browser action nor | 101 // When an extension is installed on Mac with neither browser action nor |
95 // page action icons, show an infobar instead of a popup bubble. | 102 // page action icons, show an infobar instead of a popup bubble. |
96 void ShowGenericExtensionInstalledInfoBar(Extension* new_extension); | 103 void ShowGenericExtensionInstalledInfoBar(Extension* new_extension); |
97 #endif | 104 #endif |
98 | 105 |
99 // Returns the delegate to control the browser's info bar. This is within its | 106 // Returns the delegate to control the browser's info bar. This is within its |
100 // own function due to its platform-specific nature. | 107 // own function due to its platform-specific nature. |
101 InfoBarDelegate* GetNewInfoBarDelegate(Extension* new_theme, | 108 InfoBarDelegate* GetNewInfoBarDelegate(Extension* new_theme, |
102 TabContents* tab_contents); | 109 TabContents* tab_contents); |
103 | 110 |
104 // Implements the showing of the install/uninstall dialog prompt. | 111 // Implements the showing of the install/uninstall dialog prompt. |
105 // NOTE: The implementations of this function is platform-specific. | 112 // NOTE: The implementations of this function is platform-specific. |
106 static void ShowExtensionInstallUIPromptImpl( | 113 static void ShowExtensionInstallUIPromptImpl( |
107 Profile* profile, Delegate* delegate, Extension* extension, | 114 Profile* profile, Delegate* delegate, Extension* extension, |
108 SkBitmap* icon, const string16& warning_text, PromptType type); | 115 SkBitmap* icon, const string16& warning_text, PromptType type); |
109 | 116 |
110 Profile* profile_; | 117 Profile* profile_; |
111 MessageLoop* ui_loop_; | 118 MessageLoop* ui_loop_; |
112 std::string previous_theme_id_; // Used to undo theme installation. | 119 std::string previous_theme_id_; // Used to undo theme installation. |
113 SkBitmap icon_; // The extensions installation icon. | 120 SkBitmap icon_; // The extensions installation icon. |
| 121 Extension* extension_; // The extension we are showing the UI for. |
| 122 Delegate* delegate_; // The delegate we will call Proceed/Abort on after |
| 123 // confirmation UI. |
| 124 PromptType prompt_type_; // The type of prompt we are going to show. |
| 125 |
| 126 // Keeps track of extension images being loaded on the File thread for the |
| 127 // purpose of showing the install UI. |
| 128 ImageLoadingTracker tracker_; |
114 | 129 |
115 #if defined(TOOLKIT_GTK) | 130 #if defined(TOOLKIT_GTK) |
116 // Also needed to undo theme installation in the linux UI. | 131 // Also needed to undo theme installation in the Linux UI. |
117 bool previous_use_gtk_theme_; | 132 bool previous_use_gtk_theme_; |
118 #endif | 133 #endif |
119 }; | 134 }; |
120 | 135 |
121 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_INSTALL_UI_H_ | 136 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_INSTALL_UI_H_ |
OLD | NEW |