OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/string16.h" | 12 #include "base/string16.h" |
13 #include "chrome/browser/extensions/image_loading_tracker.h" | 13 #include "chrome/browser/extensions/image_loading_tracker.h" |
14 #include "chrome/common/extensions/url_pattern.h" | 14 #include "chrome/common/extensions/url_pattern.h" |
15 #include "third_party/skia/include/core/SkBitmap.h" | 15 #include "third_party/skia/include/core/SkBitmap.h" |
16 #include "ui/gfx/native_widget_types.h" | 16 #include "ui/gfx/native_widget_types.h" |
17 | 17 |
18 class Extension; | 18 class Extension; |
| 19 class ExtensionPermissionSet; |
19 class MessageLoop; | 20 class MessageLoop; |
20 class Profile; | 21 class Profile; |
21 class InfoBarDelegate; | 22 class InfoBarDelegate; |
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 : public ImageLoadingTracker::Observer { | 26 class ExtensionInstallUI : public ImageLoadingTracker::Observer { |
26 public: | 27 public: |
27 enum PromptType { | 28 enum PromptType { |
28 UNSET_PROMPT_TYPE = -1, | 29 UNSET_PROMPT_TYPE = -1, |
29 INSTALL_PROMPT = 0, | 30 INSTALL_PROMPT = 0, |
30 RE_ENABLE_PROMPT, | 31 RE_ENABLE_PROMPT, |
| 32 PERMISSIONS_PROMPT, |
31 NUM_PROMPT_TYPES | 33 NUM_PROMPT_TYPES |
32 }; | 34 }; |
33 | 35 |
34 // A mapping from PromptType to message ID for various dialog content. | 36 // A mapping from PromptType to message ID for various dialog content. |
35 static const int kTitleIds[NUM_PROMPT_TYPES]; | 37 static const int kTitleIds[NUM_PROMPT_TYPES]; |
36 static const int kHeadingIds[NUM_PROMPT_TYPES]; | 38 static const int kHeadingIds[NUM_PROMPT_TYPES]; |
37 static const int kButtonIds[NUM_PROMPT_TYPES]; | 39 static const int kButtonIds[NUM_PROMPT_TYPES]; |
38 static const int kWarningIds[NUM_PROMPT_TYPES]; | 40 static const int kWarningIds[NUM_PROMPT_TYPES]; |
| 41 static const int kAbortButtonIds[NUM_PROMPT_TYPES]; |
39 | 42 |
40 class Delegate { | 43 class Delegate { |
41 public: | 44 public: |
42 // We call this method to signal that the installation should continue. | 45 // We call this method to signal that the installation should continue. |
43 virtual void InstallUIProceed() = 0; | 46 virtual void InstallUIProceed() = 0; |
44 | 47 |
45 // We call this method to signal that the installation should stop, with | 48 // We call this method to signal that the installation should stop, with |
46 // |user_initiated| true if the installation was stopped by the user. | 49 // |user_initiated| true if the installation was stopped by the user. |
47 virtual void InstallUIAbort(bool user_initiated) = 0; | 50 virtual void InstallUIAbort(bool user_initiated) = 0; |
48 | 51 |
49 protected: | 52 protected: |
50 virtual ~Delegate() {} | 53 virtual ~Delegate() {} |
51 }; | 54 }; |
52 | 55 |
53 explicit ExtensionInstallUI(Profile* profile); | 56 explicit ExtensionInstallUI(Profile* profile); |
54 virtual ~ExtensionInstallUI(); | 57 virtual ~ExtensionInstallUI(); |
55 | 58 |
56 // This is called by the installer to verify whether the installation should | 59 // This is called by the installer to verify whether the installation should |
57 // proceed. This is declared virtual for testing. | 60 // proceed. This is declared virtual for testing. |
58 // | 61 // |
59 // We *MUST* eventually call either Proceed() or Abort() on |delegate|. | 62 // We *MUST* eventually call either Proceed() or Abort() on |delegate|. |
60 virtual void ConfirmInstall(Delegate* delegate, const Extension* extension); | 63 virtual void ConfirmInstall(Delegate* delegate, const Extension* extension); |
61 | 64 |
62 // This is called by the app handler launcher to verify whether the app | 65 // This is called by the app handler launcher to verify whether the app |
63 // should be re-enabled. This is declared virtual for testing. | 66 // should be re-enabled. This is declared virtual for testing. |
64 // | 67 // |
65 // We *MUST* eventually call either Proceed() or Abort() on |delegate|. | 68 // We *MUST* eventually call either Proceed() or Abort() on |delegate|. |
66 virtual void ConfirmReEnable(Delegate* delegate, const Extension* extension); | 69 virtual void ConfirmReEnable(Delegate* delegate, const Extension* extension); |
67 | 70 |
| 71 // This is called by the extension permissions API to verify whether an |
| 72 // extension may be granted additional permissions. |
| 73 // |
| 74 // We *MUST* eventually call either Proceed() or Abort() on |delegate|. |
| 75 virtual void ConfirmPermissions(Delegate* delegate, |
| 76 const Extension* extension, |
| 77 const ExtensionPermissionSet* permissions); |
| 78 |
68 // Installation was successful. This is declared virtual for testing. | 79 // Installation was successful. This is declared virtual for testing. |
69 virtual void OnInstallSuccess(const Extension* extension, SkBitmap* icon); | 80 virtual void OnInstallSuccess(const Extension* extension, SkBitmap* icon); |
70 | 81 |
71 // Installation failed. This is declared virtual for testing. | 82 // Installation failed. This is declared virtual for testing. |
72 virtual void OnInstallFailure(const std::string& error); | 83 virtual void OnInstallFailure(const std::string& error); |
73 | 84 |
74 // ImageLoadingTracker::Observer: | 85 // ImageLoadingTracker::Observer: |
75 virtual void OnImageLoaded( | 86 virtual void OnImageLoaded( |
76 SkBitmap* image, const ExtensionResource& resource, int index); | 87 SkBitmap* image, const ExtensionResource& resource, int index); |
77 | 88 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 // Used to undo theme installation. | 126 // Used to undo theme installation. |
116 std::string previous_theme_id_; | 127 std::string previous_theme_id_; |
117 bool previous_using_native_theme_; | 128 bool previous_using_native_theme_; |
118 | 129 |
119 // The extensions installation icon. | 130 // The extensions installation icon. |
120 SkBitmap icon_; | 131 SkBitmap icon_; |
121 | 132 |
122 // The extension we are showing the UI for. | 133 // The extension we are showing the UI for. |
123 const Extension* extension_; | 134 const Extension* extension_; |
124 | 135 |
| 136 // The permissions being prompted for. |
| 137 const ExtensionPermissionSet* permissions_; |
| 138 |
125 // The delegate we will call Proceed/Abort on after confirmation UI. | 139 // The delegate we will call Proceed/Abort on after confirmation UI. |
126 Delegate* delegate_; | 140 Delegate* delegate_; |
127 | 141 |
128 // The type of prompt we are going to show. | 142 // The type of prompt we are going to show. |
129 PromptType prompt_type_; | 143 PromptType prompt_type_; |
130 | 144 |
131 // Keeps track of extension images being loaded on the File thread for the | 145 // Keeps track of extension images being loaded on the File thread for the |
132 // purpose of showing the install UI. | 146 // purpose of showing the install UI. |
133 ImageLoadingTracker tracker_; | 147 ImageLoadingTracker tracker_; |
134 }; | 148 }; |
135 | 149 |
136 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_INSTALL_UI_H_ | 150 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_INSTALL_UI_H_ |
OLD | NEW |