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_API_MANAGEMENT_MANAGEMENT_API_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_MANAGEMENT_MANAGEMENT_API_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_API_MANAGEMENT_MANAGEMENT_API_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_API_MANAGEMENT_MANAGEMENT_API_H_ |
7 | 7 |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "chrome/browser/extensions/chrome_extension_function.h" | 9 #include "chrome/browser/extensions/chrome_extension_function.h" |
10 #include "chrome/browser/extensions/extension_install_prompt.h" | 10 #include "chrome/browser/extensions/extension_install_prompt.h" |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 MANAGEMENT_GETPERMISSIONWARNINGSBYMANIFEST); | 76 MANAGEMENT_GETPERMISSIONWARNINGSBYMANIFEST); |
77 | 77 |
78 // Called when utility process finishes. | 78 // Called when utility process finishes. |
79 void OnParseSuccess(scoped_ptr<base::DictionaryValue> parsed_manifest); | 79 void OnParseSuccess(scoped_ptr<base::DictionaryValue> parsed_manifest); |
80 void OnParseFailure(const std::string& error); | 80 void OnParseFailure(const std::string& error); |
81 | 81 |
82 protected: | 82 protected: |
83 virtual ~ManagementGetPermissionWarningsByManifestFunction() {} | 83 virtual ~ManagementGetPermissionWarningsByManifestFunction() {} |
84 | 84 |
85 // ExtensionFunction: | 85 // ExtensionFunction: |
86 virtual bool RunImpl() OVERRIDE; | 86 virtual bool RunAsync() OVERRIDE; |
87 }; | 87 }; |
88 | 88 |
89 class ManagementLaunchAppFunction : public ManagementFunction { | 89 class ManagementLaunchAppFunction : public ManagementFunction { |
90 public: | 90 public: |
91 DECLARE_EXTENSION_FUNCTION("management.launchApp", MANAGEMENT_LAUNCHAPP) | 91 DECLARE_EXTENSION_FUNCTION("management.launchApp", MANAGEMENT_LAUNCHAPP) |
92 | 92 |
93 protected: | 93 protected: |
94 virtual ~ManagementLaunchAppFunction() {} | 94 virtual ~ManagementLaunchAppFunction() {} |
95 | 95 |
96 // ExtensionFunction: | 96 // ExtensionFunction: |
97 virtual bool RunSync() OVERRIDE; | 97 virtual bool RunSync() OVERRIDE; |
98 }; | 98 }; |
99 | 99 |
100 class ManagementSetEnabledFunction : public AsyncManagementFunction, | 100 class ManagementSetEnabledFunction : public AsyncManagementFunction, |
101 public ExtensionInstallPrompt::Delegate { | 101 public ExtensionInstallPrompt::Delegate { |
102 public: | 102 public: |
103 DECLARE_EXTENSION_FUNCTION("management.setEnabled", MANAGEMENT_SETENABLED) | 103 DECLARE_EXTENSION_FUNCTION("management.setEnabled", MANAGEMENT_SETENABLED) |
104 | 104 |
105 ManagementSetEnabledFunction(); | 105 ManagementSetEnabledFunction(); |
106 | 106 |
107 protected: | 107 protected: |
108 virtual ~ManagementSetEnabledFunction(); | 108 virtual ~ManagementSetEnabledFunction(); |
109 | 109 |
110 // ExtensionFunction: | 110 // ExtensionFunction: |
111 virtual bool RunImpl() OVERRIDE; | 111 virtual bool RunAsync() OVERRIDE; |
112 | 112 |
113 // ExtensionInstallPrompt::Delegate. | 113 // ExtensionInstallPrompt::Delegate. |
114 virtual void InstallUIProceed() OVERRIDE; | 114 virtual void InstallUIProceed() OVERRIDE; |
115 virtual void InstallUIAbort(bool user_initiated) OVERRIDE; | 115 virtual void InstallUIAbort(bool user_initiated) OVERRIDE; |
116 | 116 |
117 private: | 117 private: |
118 std::string extension_id_; | 118 std::string extension_id_; |
119 | 119 |
120 // Used for prompting to re-enable items with permissions escalation updates. | 120 // Used for prompting to re-enable items with permissions escalation updates. |
121 scoped_ptr<ExtensionInstallPrompt> install_prompt_; | 121 scoped_ptr<ExtensionInstallPrompt> install_prompt_; |
(...skipping 11 matching lines...) Expand all Loading... |
133 virtual void ExtensionUninstallCanceled() OVERRIDE; | 133 virtual void ExtensionUninstallCanceled() OVERRIDE; |
134 | 134 |
135 protected: | 135 protected: |
136 virtual ~ManagementUninstallFunctionBase(); | 136 virtual ~ManagementUninstallFunctionBase(); |
137 | 137 |
138 bool Uninstall(const std::string& extension_id, bool show_confirm_dialog); | 138 bool Uninstall(const std::string& extension_id, bool show_confirm_dialog); |
139 private: | 139 private: |
140 | 140 |
141 // If should_uninstall is true, this method does the actual uninstall. | 141 // If should_uninstall is true, this method does the actual uninstall. |
142 // If |show_uninstall_dialog|, then this function will be called by one of the | 142 // If |show_uninstall_dialog|, then this function will be called by one of the |
143 // Accepted/Canceled callbacks. Otherwise, it's called directly from RunImpl. | 143 // Accepted/Canceled callbacks. Otherwise, it's called directly from RunAsync. |
144 void Finish(bool should_uninstall); | 144 void Finish(bool should_uninstall); |
145 | 145 |
146 std::string extension_id_; | 146 std::string extension_id_; |
147 scoped_ptr<ExtensionUninstallDialog> extension_uninstall_dialog_; | 147 scoped_ptr<ExtensionUninstallDialog> extension_uninstall_dialog_; |
148 }; | 148 }; |
149 | 149 |
150 class ManagementUninstallFunction : public ManagementUninstallFunctionBase { | 150 class ManagementUninstallFunction : public ManagementUninstallFunctionBase { |
151 public: | 151 public: |
152 DECLARE_EXTENSION_FUNCTION("management.uninstall", MANAGEMENT_UNINSTALL) | 152 DECLARE_EXTENSION_FUNCTION("management.uninstall", MANAGEMENT_UNINSTALL) |
153 | 153 |
154 ManagementUninstallFunction(); | 154 ManagementUninstallFunction(); |
155 | 155 |
156 private: | 156 private: |
157 virtual ~ManagementUninstallFunction(); | 157 virtual ~ManagementUninstallFunction(); |
158 | 158 |
159 virtual bool RunImpl() OVERRIDE; | 159 virtual bool RunAsync() OVERRIDE; |
160 }; | 160 }; |
161 | 161 |
162 class ManagementUninstallSelfFunction : public ManagementUninstallFunctionBase { | 162 class ManagementUninstallSelfFunction : public ManagementUninstallFunctionBase { |
163 public: | 163 public: |
164 DECLARE_EXTENSION_FUNCTION("management.uninstallSelf", | 164 DECLARE_EXTENSION_FUNCTION("management.uninstallSelf", |
165 MANAGEMENT_UNINSTALLSELF); | 165 MANAGEMENT_UNINSTALLSELF); |
166 | 166 |
167 ManagementUninstallSelfFunction(); | 167 ManagementUninstallSelfFunction(); |
168 | 168 |
169 private: | 169 private: |
170 virtual ~ManagementUninstallSelfFunction(); | 170 virtual ~ManagementUninstallSelfFunction(); |
171 | 171 |
172 virtual bool RunImpl() OVERRIDE; | 172 virtual bool RunAsync() OVERRIDE; |
173 }; | 173 }; |
174 | 174 |
175 class ManagementCreateAppShortcutFunction : public AsyncManagementFunction { | 175 class ManagementCreateAppShortcutFunction : public AsyncManagementFunction { |
176 public: | 176 public: |
177 DECLARE_EXTENSION_FUNCTION("management.createAppShortcut", | 177 DECLARE_EXTENSION_FUNCTION("management.createAppShortcut", |
178 MANAGEMENT_CREATEAPPSHORTCUT); | 178 MANAGEMENT_CREATEAPPSHORTCUT); |
179 | 179 |
180 ManagementCreateAppShortcutFunction(); | 180 ManagementCreateAppShortcutFunction(); |
181 | 181 |
182 void OnCloseShortcutPrompt(bool created); | 182 void OnCloseShortcutPrompt(bool created); |
183 | 183 |
184 static void SetAutoConfirmForTest(bool should_proceed); | 184 static void SetAutoConfirmForTest(bool should_proceed); |
185 | 185 |
186 protected: | 186 protected: |
187 virtual ~ManagementCreateAppShortcutFunction(); | 187 virtual ~ManagementCreateAppShortcutFunction(); |
188 | 188 |
189 virtual bool RunImpl() OVERRIDE; | 189 virtual bool RunAsync() OVERRIDE; |
190 }; | 190 }; |
191 | 191 |
192 class ManagementEventRouter : public content::NotificationObserver { | 192 class ManagementEventRouter : public content::NotificationObserver { |
193 public: | 193 public: |
194 explicit ManagementEventRouter(Profile* profile); | 194 explicit ManagementEventRouter(Profile* profile); |
195 virtual ~ManagementEventRouter(); | 195 virtual ~ManagementEventRouter(); |
196 | 196 |
197 private: | 197 private: |
198 // content::NotificationObserver implementation. | 198 // content::NotificationObserver implementation. |
199 virtual void Observe(int type, | 199 virtual void Observe(int type, |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 | 236 |
237 // Created lazily upon OnListenerAdded. | 237 // Created lazily upon OnListenerAdded. |
238 scoped_ptr<ManagementEventRouter> management_event_router_; | 238 scoped_ptr<ManagementEventRouter> management_event_router_; |
239 | 239 |
240 DISALLOW_COPY_AND_ASSIGN(ManagementAPI); | 240 DISALLOW_COPY_AND_ASSIGN(ManagementAPI); |
241 }; | 241 }; |
242 | 242 |
243 } // namespace extensions | 243 } // namespace extensions |
244 | 244 |
245 #endif // CHROME_BROWSER_EXTENSIONS_API_MANAGEMENT_MANAGEMENT_API_H_ | 245 #endif // CHROME_BROWSER_EXTENSIONS_API_MANAGEMENT_MANAGEMENT_API_H_ |
OLD | NEW |