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 base::FilePath& GetLastUnpackedDirectory() { |
64 return last_unpacked_directory_; | 65 return last_unpacked_directory_; |
65 } | 66 } |
66 | 67 |
67 // ProfileKeyedService implementation | 68 // ProfileKeyedService implementation |
68 virtual void Shutdown() OVERRIDE; | 69 virtual void Shutdown() OVERRIDE; |
69 | 70 |
70 // content::NotificationObserver implementation. | 71 // content::NotificationObserver implementation. |
71 virtual void Observe(int type, | 72 virtual void Observe(int type, |
72 const content::NotificationSource& source, | 73 const content::NotificationSource& source, |
73 const content::NotificationDetails& details) OVERRIDE; | 74 const content::NotificationDetails& details) OVERRIDE; |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 // Callback for requirements checker. | 191 // Callback for requirements checker. |
191 void OnRequirementsChecked(std::string extension_id, | 192 void OnRequirementsChecked(std::string extension_id, |
192 std::vector<std::string> requirements_errors); | 193 std::vector<std::string> requirements_errors); |
193 // ExtensionFunction: | 194 // ExtensionFunction: |
194 virtual bool RunImpl() OVERRIDE; | 195 virtual bool RunImpl() OVERRIDE; |
195 | 196 |
196 private: | 197 private: |
197 scoped_ptr<extensions::RequirementsChecker> requirements_checker_; | 198 scoped_ptr<extensions::RequirementsChecker> requirements_checker_; |
198 }; | 199 }; |
199 | 200 |
200 class DeveloperPrivateChooseEntryFunction : public SyncExtensionFunction, | 201 class DeveloperPrivateChooseEntryFunction : public AsyncExtensionFunction, |
201 public EntryPickerClient { | 202 public EntryPickerClient { |
202 protected: | 203 protected: |
203 virtual ~DeveloperPrivateChooseEntryFunction(); | 204 virtual ~DeveloperPrivateChooseEntryFunction(); |
204 virtual bool RunImpl() OVERRIDE; | 205 virtual bool RunImpl() OVERRIDE; |
205 bool ShowPicker(ui::SelectFileDialog::Type picker_type, | 206 bool ShowPicker(ui::SelectFileDialog::Type picker_type, |
206 const base::FilePath& last_directory, | 207 const base::FilePath& last_directory, |
207 const string16& select_title); | 208 const string16& select_title, |
| 209 const ui::SelectFileDialog::FileTypeInfo& info, |
| 210 int file_type_index); |
208 | 211 |
209 // EntryPickerCLient functions. | 212 // EntryPickerClient functions. |
210 virtual void FileSelected(const base::FilePath& path) = 0; | 213 virtual void FileSelected(const base::FilePath& path) = 0; |
211 virtual void FileSelectionCanceled() = 0; | 214 virtual void FileSelectionCanceled() = 0; |
212 }; | 215 }; |
213 | 216 |
214 | 217 |
215 class DeveloperPrivateLoadUnpackedFunction | 218 class DeveloperPrivateLoadUnpackedFunction |
216 : public DeveloperPrivateChooseEntryFunction { | 219 : public DeveloperPrivateChooseEntryFunction { |
217 public: | 220 public: |
218 DECLARE_EXTENSION_FUNCTION("developerPrivate.loadUnpacked", | 221 DECLARE_EXTENSION_FUNCTION("developerPrivate.loadUnpacked", |
219 DEVELOPERPRIVATE_LOADUNPACKED); | 222 DEVELOPERPRIVATE_LOADUNPACKED); |
220 | 223 |
221 protected: | 224 protected: |
222 virtual ~DeveloperPrivateLoadUnpackedFunction(); | 225 virtual ~DeveloperPrivateLoadUnpackedFunction(); |
223 virtual bool RunImpl() OVERRIDE; | 226 virtual bool RunImpl() OVERRIDE; |
224 | 227 |
225 // EntryPickerCLient implementation. | 228 // EntryPickerCLient implementation. |
226 virtual void FileSelected(const base::FilePath& path) OVERRIDE; | 229 virtual void FileSelected(const base::FilePath& path) OVERRIDE; |
227 virtual void FileSelectionCanceled() OVERRIDE; | 230 virtual void FileSelectionCanceled() OVERRIDE; |
| 231 }; |
228 | 232 |
| 233 class DeveloperPrivateChoosePathFunction |
| 234 : public DeveloperPrivateChooseEntryFunction { |
| 235 public: |
| 236 DECLARE_EXTENSION_FUNCTION("developerPrivate.choosePath", |
| 237 DEVELOPERPRIVATE_CHOOSEPATH); |
| 238 |
| 239 protected: |
| 240 virtual ~DeveloperPrivateChoosePathFunction(); |
| 241 virtual bool RunImpl() OVERRIDE; |
| 242 |
| 243 // EntryPickerClient functions. |
| 244 virtual void FileSelected(const base::FilePath& path) OVERRIDE; |
| 245 virtual void FileSelectionCanceled() OVERRIDE; |
| 246 }; |
| 247 |
| 248 class DeveloperPrivatePackDirectoryFunction |
| 249 : public AsyncExtensionFunction, |
| 250 public extensions::PackExtensionJob::Client { |
| 251 |
| 252 public: |
| 253 DECLARE_EXTENSION_FUNCTION("developerPrivate.packDirectory", |
| 254 DEVELOPERPRIVATE_PACKDIRECTORY); |
| 255 |
| 256 DeveloperPrivatePackDirectoryFunction(); |
| 257 |
| 258 // ExtensionPackJob::Client implementation. |
| 259 virtual void OnPackSuccess(const base::FilePath& crx_file, |
| 260 const base::FilePath& key_file) OVERRIDE; |
| 261 virtual void OnPackFailure( |
| 262 const std::string& error, |
| 263 extensions::ExtensionCreator::ErrorType error_type) OVERRIDE; |
| 264 |
| 265 protected: |
| 266 virtual ~DeveloperPrivatePackDirectoryFunction(); |
| 267 virtual bool RunImpl() OVERRIDE; |
| 268 |
| 269 private: |
| 270 scoped_refptr<extensions::PackExtensionJob> pack_job_; |
| 271 std::string item_path_str_; |
| 272 std::string key_path_str_; |
229 }; | 273 }; |
230 | 274 |
231 class DeveloperPrivateGetStringsFunction : public SyncExtensionFunction { | 275 class DeveloperPrivateGetStringsFunction : public SyncExtensionFunction { |
232 public: | 276 public: |
233 DECLARE_EXTENSION_FUNCTION("developerPrivate.getStrings", | 277 DECLARE_EXTENSION_FUNCTION("developerPrivate.getStrings", |
234 DEVELOPERPRIVATE_GETSTRINGS); | 278 DEVELOPERPRIVATE_GETSTRINGS); |
235 | 279 |
236 protected: | 280 protected: |
237 virtual ~DeveloperPrivateGetStringsFunction(); | 281 virtual ~DeveloperPrivateGetStringsFunction(); |
238 | 282 |
239 // ExtensionFunction | 283 // ExtensionFunction |
240 virtual bool RunImpl() OVERRIDE; | 284 virtual bool RunImpl() OVERRIDE; |
241 }; | 285 }; |
242 | 286 |
243 } // namespace api | 287 } // namespace api |
244 | 288 |
245 } // namespace extensions | 289 } // namespace extensions |
246 | 290 |
247 #endif // CHROME_BROWSER_EXTENSIONS_API_DEVELOPER_PRIVATE_DEVELOPER_PRIVATE_API
_H_ | 291 #endif // CHROME_BROWSER_EXTENSIONS_API_DEVELOPER_PRIVATE_DEVELOPER_PRIVATE_API
_H_ |
OLD | NEW |