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_DEVELOPER_PRIVATE_DEVELOPER_PRIVATE_API_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_DEVELOPER_PRIVATE_DEVELOPER_PRIVATE_API_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_API_DEVELOPER_PRIVATE_DEVELOPER_PRIVATE_API_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_API_DEVELOPER_PRIVATE_DEVELOPER_PRIVATE_API_H_ |
7 | 7 |
8 #include "chrome/browser/extensions/api/developer_private/entry_picker.h" | 8 #include "chrome/browser/extensions/api/developer_private/entry_picker.h" |
9 #include "chrome/browser/extensions/api/file_system/file_system_api.h" | 9 #include "chrome/browser/extensions/api/file_system/file_system_api.h" |
10 #include "chrome/browser/extensions/extension_function.h" | 10 #include "chrome/browser/extensions/extension_function.h" |
11 #include "chrome/browser/extensions/extension_install_prompt.h" | 11 #include "chrome/browser/extensions/extension_install_prompt.h" |
12 #include "chrome/browser/extensions/extension_uninstall_dialog.h" | 12 #include "chrome/browser/extensions/extension_uninstall_dialog.h" |
| 13 #include "chrome/browser/extensions/pack_extension_job.h" |
13 #include "chrome/browser/extensions/requirements_checker.h" | 14 #include "chrome/browser/extensions/requirements_checker.h" |
14 #include "chrome/browser/profiles/profile_keyed_service.h" | 15 #include "chrome/browser/profiles/profile_keyed_service.h" |
15 #include "content/public/browser/notification_observer.h" | 16 #include "content/public/browser/notification_observer.h" |
16 #include "content/public/browser/notification_registrar.h" | 17 #include "content/public/browser/notification_registrar.h" |
17 #include "content/public/browser/render_view_host.h" | 18 #include "content/public/browser/render_view_host.h" |
18 #include "ui/shell_dialogs/select_file_dialog.h" | 19 #include "ui/shell_dialogs/select_file_dialog.h" |
19 | 20 |
20 class ExtensionService; | 21 class ExtensionService; |
21 | 22 |
22 namespace extensions { | 23 namespace extensions { |
(...skipping 30 matching lines...) Expand all Loading... |
53 public content::NotificationObserver { | 54 public content::NotificationObserver { |
54 public: | 55 public: |
55 // Convenience method to get the DeveloperPrivateAPI for a profile. | 56 // Convenience method to get the DeveloperPrivateAPI for a profile. |
56 static DeveloperPrivateAPI* Get(Profile* profile); | 57 static DeveloperPrivateAPI* Get(Profile* profile); |
57 | 58 |
58 explicit DeveloperPrivateAPI(Profile* profile); | 59 explicit DeveloperPrivateAPI(Profile* profile); |
59 virtual ~DeveloperPrivateAPI(); | 60 virtual ~DeveloperPrivateAPI(); |
60 | 61 |
61 void SetLastUnpackedDirectory(const base::FilePath& path); | 62 void SetLastUnpackedDirectory(const base::FilePath& path); |
62 | 63 |
63 base::FilePath& getLastUnpackedDirectory() { | 64 FilePath& GetLastUnpackedDirectory() { return last_unpacked_directory_; } |
64 return last_unpacked_directory_; | |
65 } | |
66 | 65 |
67 // ProfileKeyedService implementation | 66 // ProfileKeyedService implementation |
68 virtual void Shutdown() OVERRIDE; | 67 virtual void Shutdown() OVERRIDE; |
69 | 68 |
70 // content::NotificationObserver implementation. | 69 // content::NotificationObserver implementation. |
71 virtual void Observe(int type, | 70 virtual void Observe(int type, |
72 const content::NotificationSource& source, | 71 const content::NotificationSource& source, |
73 const content::NotificationDetails& details) OVERRIDE; | 72 const content::NotificationDetails& details) OVERRIDE; |
74 | 73 |
75 private: | 74 private: |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 // Callback for requirements checker. | 189 // Callback for requirements checker. |
191 void OnRequirementsChecked(std::string extension_id, | 190 void OnRequirementsChecked(std::string extension_id, |
192 std::vector<std::string> requirements_errors); | 191 std::vector<std::string> requirements_errors); |
193 // ExtensionFunction: | 192 // ExtensionFunction: |
194 virtual bool RunImpl() OVERRIDE; | 193 virtual bool RunImpl() OVERRIDE; |
195 | 194 |
196 private: | 195 private: |
197 scoped_ptr<extensions::RequirementsChecker> requirements_checker_; | 196 scoped_ptr<extensions::RequirementsChecker> requirements_checker_; |
198 }; | 197 }; |
199 | 198 |
200 class DeveloperPrivateChooseEntryFunction : public SyncExtensionFunction, | 199 class DeveloperPrivateChooseEntryFunction : public AsyncExtensionFunction, |
201 public EntryPickerClient { | 200 public EntryPickerClient { |
202 protected: | 201 protected: |
203 virtual ~DeveloperPrivateChooseEntryFunction(); | 202 virtual ~DeveloperPrivateChooseEntryFunction(); |
204 virtual bool RunImpl() OVERRIDE; | 203 virtual bool RunImpl() OVERRIDE; |
205 bool ShowPicker(ui::SelectFileDialog::Type picker_type, | 204 bool ShowPicker(ui::SelectFileDialog::Type picker_type, |
206 const base::FilePath& last_directory, | 205 const FilePath& last_directory, |
207 const string16& select_title); | 206 const string16& select_title, |
| 207 const ui::SelectFileDialog::FileTypeInfo& info, |
| 208 int file_type_index); |
208 | 209 |
209 // EntryPickerCLient functions. | 210 // EntryPickerClient functions. |
210 virtual void FileSelected(const base::FilePath& path) = 0; | 211 virtual void FileSelected(const FilePath& path) = 0; |
211 virtual void FileSelectionCanceled() = 0; | 212 virtual void FileSelectionCanceled() = 0; |
212 }; | 213 }; |
213 | 214 |
214 | 215 |
215 class DeveloperPrivateLoadUnpackedFunction | 216 class DeveloperPrivateLoadUnpackedFunction |
216 : public DeveloperPrivateChooseEntryFunction { | 217 : public DeveloperPrivateChooseEntryFunction { |
217 public: | 218 public: |
218 DECLARE_EXTENSION_FUNCTION("developerPrivate.loadUnpacked", | 219 DECLARE_EXTENSION_FUNCTION("developerPrivate.loadUnpacked", |
219 DEVELOPERPRIVATE_LOADUNPACKED); | 220 DEVELOPERPRIVATE_LOADUNPACKED); |
220 | 221 |
221 protected: | 222 protected: |
222 virtual ~DeveloperPrivateLoadUnpackedFunction(); | 223 virtual ~DeveloperPrivateLoadUnpackedFunction(); |
223 virtual bool RunImpl() OVERRIDE; | 224 virtual bool RunImpl() OVERRIDE; |
224 | 225 |
225 // EntryPickerCLient implementation. | 226 // EntryPickerCLient implementation. |
226 virtual void FileSelected(const base::FilePath& path) OVERRIDE; | 227 virtual void FileSelected(const base::FilePath& path) OVERRIDE; |
227 virtual void FileSelectionCanceled() OVERRIDE; | 228 virtual void FileSelectionCanceled() OVERRIDE; |
| 229 }; |
228 | 230 |
| 231 class DeveloperPrivateChoosePathFunction |
| 232 : public DeveloperPrivateChooseEntryFunction { |
| 233 public: |
| 234 DECLARE_EXTENSION_FUNCTION("developerPrivate.choosePath", |
| 235 DEVELOPERPRIVATE_CHOOSEPATH); |
| 236 |
| 237 protected: |
| 238 virtual ~DeveloperPrivateChoosePathFunction(); |
| 239 virtual bool RunImpl() OVERRIDE; |
| 240 |
| 241 // EntryPickerClient functions. |
| 242 virtual void FileSelected(const FilePath& path) OVERRIDE; |
| 243 virtual void FileSelectionCanceled() OVERRIDE; |
| 244 }; |
| 245 |
| 246 class DeveloperPrivatePackDirectoryFunction |
| 247 : public AsyncExtensionFunction, |
| 248 public extensions::PackExtensionJob::Client { |
| 249 |
| 250 public: |
| 251 DECLARE_EXTENSION_FUNCTION("developerPrivate.packDirectory", |
| 252 DEVELOPERPRIVATE_PACKDIRECTORY); |
| 253 |
| 254 DeveloperPrivatePackDirectoryFunction(); |
| 255 |
| 256 // ExtensionPackJob::Client implementation. |
| 257 virtual void OnPackSuccess(const FilePath& crx_file, |
| 258 const FilePath& key_file) OVERRIDE; |
| 259 virtual void OnPackFailure( |
| 260 const std::string& error, |
| 261 extensions::ExtensionCreator::ErrorType error_type) OVERRIDE; |
| 262 |
| 263 protected: |
| 264 virtual ~DeveloperPrivatePackDirectoryFunction(); |
| 265 virtual bool RunImpl() OVERRIDE; |
| 266 |
| 267 private: |
| 268 scoped_refptr<extensions::PackExtensionJob> pack_job_; |
| 269 std::string item_path_str_; |
| 270 std::string key_path_str_; |
229 }; | 271 }; |
230 | 272 |
231 class DeveloperPrivateGetStringsFunction : public SyncExtensionFunction { | 273 class DeveloperPrivateGetStringsFunction : public SyncExtensionFunction { |
232 public: | 274 public: |
233 DECLARE_EXTENSION_FUNCTION("developerPrivate.getStrings", | 275 DECLARE_EXTENSION_FUNCTION("developerPrivate.getStrings", |
234 DEVELOPERPRIVATE_GETSTRINGS); | 276 DEVELOPERPRIVATE_GETSTRINGS); |
235 | 277 |
236 protected: | 278 protected: |
237 virtual ~DeveloperPrivateGetStringsFunction(); | 279 virtual ~DeveloperPrivateGetStringsFunction(); |
238 | 280 |
239 // ExtensionFunction | 281 // ExtensionFunction |
240 virtual bool RunImpl() OVERRIDE; | 282 virtual bool RunImpl() OVERRIDE; |
241 }; | 283 }; |
242 | 284 |
243 } // namespace api | 285 } // namespace api |
244 | 286 |
245 } // namespace extensions | 287 } // namespace extensions |
246 | 288 |
247 #endif // CHROME_BROWSER_EXTENSIONS_API_DEVELOPER_PRIVATE_DEVELOPER_PRIVATE_API
_H_ | 289 #endif // CHROME_BROWSER_EXTENSIONS_API_DEVELOPER_PRIVATE_DEVELOPER_PRIVATE_API
_H_ |
OLD | NEW |