Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(171)

Side by Side Diff: chrome/browser/extensions/api/developer_private/developer_private_api.h

Issue 150663013: Integrate ErrorConsole with Apps Dev Tool (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove DeveloperPrivate.getStrings() Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <set>
9
8 #include "base/files/file.h" 10 #include "base/files/file.h"
9 #include "chrome/browser/extensions/api/developer_private/entry_picker.h" 11 #include "chrome/browser/extensions/api/developer_private/entry_picker.h"
10 #include "chrome/browser/extensions/api/file_system/file_system_api.h" 12 #include "chrome/browser/extensions/api/file_system/file_system_api.h"
11 #include "chrome/browser/extensions/chrome_extension_function.h" 13 #include "chrome/browser/extensions/chrome_extension_function.h"
14 #include "chrome/browser/extensions/error_console/error_console.h"
12 #include "chrome/browser/extensions/extension_install_prompt.h" 15 #include "chrome/browser/extensions/extension_install_prompt.h"
13 #include "chrome/browser/extensions/extension_uninstall_dialog.h" 16 #include "chrome/browser/extensions/extension_uninstall_dialog.h"
14 #include "chrome/browser/extensions/pack_extension_job.h" 17 #include "chrome/browser/extensions/pack_extension_job.h"
15 #include "chrome/browser/extensions/requirements_checker.h" 18 #include "chrome/browser/extensions/requirements_checker.h"
16 #include "components/browser_context_keyed_service/browser_context_keyed_service .h" 19 #include "components/browser_context_keyed_service/browser_context_keyed_service .h"
17 #include "content/public/browser/notification_observer.h" 20 #include "content/public/browser/notification_observer.h"
18 #include "content/public/browser/notification_registrar.h" 21 #include "content/public/browser/notification_registrar.h"
19 #include "content/public/browser/render_view_host.h" 22 #include "content/public/browser/render_view_host.h"
20 #include "extensions/browser/event_router.h" 23 #include "extensions/browser/event_router.h"
21 #include "ui/shell_dialogs/select_file_dialog.h" 24 #include "ui/shell_dialogs/select_file_dialog.h"
22 #include "webkit/browser/fileapi/file_system_context.h" 25 #include "webkit/browser/fileapi/file_system_context.h"
23 #include "webkit/browser/fileapi/file_system_operation.h" 26 #include "webkit/browser/fileapi/file_system_operation.h"
24 27
25 class ExtensionService; 28 class ExtensionService;
26 29
27 namespace extensions { 30 namespace extensions {
28 31
32 class ExtensionError;
29 class ExtensionSystem; 33 class ExtensionSystem;
30 class ManagementPolicy; 34 class ManagementPolicy;
31 35
32 namespace api { 36 namespace api {
33 37
34 class EntryPicker; 38 class EntryPicker;
35 class EntryPickerClient; 39 class EntryPickerClient;
36 40
37 namespace developer_private { 41 namespace developer_private {
38 42
39 struct ItemInfo; 43 struct ItemInfo;
40 struct ItemInspectView; 44 struct ItemInspectView;
41 struct ProjectInfo; 45 struct ProjectInfo;
42 46
43 } 47 }
Finnur 2014/02/11 13:11:28 nit: // namespace developer_private
Devlin 2014/02/11 18:41:16 Done.
44 48
45 } // namespace api 49 } // namespace api
46 50
47 } // namespace extensions 51 namespace developer = api::developer_private;
48
49 namespace developer = extensions::api::developer_private;
50 52
51 typedef std::vector<linked_ptr<developer::ItemInfo> > ItemInfoList; 53 typedef std::vector<linked_ptr<developer::ItemInfo> > ItemInfoList;
52 typedef std::vector<linked_ptr<developer::ProjectInfo> > ProjectInfoList; 54 typedef std::vector<linked_ptr<developer::ProjectInfo> > ProjectInfoList;
53 typedef std::vector<linked_ptr<developer::ItemInspectView> > 55 typedef std::vector<linked_ptr<developer::ItemInspectView> >
54 ItemInspectViewList; 56 ItemInspectViewList;
55 57
56 namespace extensions { 58 class DeveloperPrivateEventRouter : public content::NotificationObserver,
57 59 public ErrorConsole::Observer {
58 class DeveloperPrivateEventRouter : public content::NotificationObserver {
59 public: 60 public:
60 explicit DeveloperPrivateEventRouter(Profile* profile); 61 explicit DeveloperPrivateEventRouter(Profile* profile);
61 virtual ~DeveloperPrivateEventRouter(); 62 virtual ~DeveloperPrivateEventRouter();
62 63
64 // Add or remove an ID to the list of extensions subscribed to events.
65 void AddExtensionId(const std::string& extension_id);
66 void RemoveExtensionId(const std::string& extension_id);
67
63 private: 68 private:
64 // content::NotificationObserver implementation 69 // content::NotificationObserver implementation
65 virtual void Observe(int type, 70 virtual void Observe(int type,
66 const content::NotificationSource& source, 71 const content::NotificationSource& source,
67 const content::NotificationDetails& details) OVERRIDE; 72 const content::NotificationDetails& details) OVERRIDE;
68 73
74 // ErrorConsole::Observer implementation
75 virtual void OnErrorAdded(const ExtensionError* error) OVERRIDE;
76
69 content::NotificationRegistrar registrar_; 77 content::NotificationRegistrar registrar_;
70 78
71 Profile* profile_; 79 Profile* profile_;
72 80
81 // The set of IDs of the Extensions which have subscribed to the events,
82 // since we may treat events with these extensions differently.
Finnur 2014/02/11 13:11:28 nit: This comment leaves more questions than it an
Devlin 2014/02/11 18:41:16 Fair point. :) Done.
83 std::set<std::string> extension_ids_;
84
73 DISALLOW_COPY_AND_ASSIGN(DeveloperPrivateEventRouter); 85 DISALLOW_COPY_AND_ASSIGN(DeveloperPrivateEventRouter);
74 }; 86 };
75 87
76 // The profile-keyed service that manages the DeveloperPrivate API. 88 // The profile-keyed service that manages the DeveloperPrivate API.
77 class DeveloperPrivateAPI : public BrowserContextKeyedService, 89 class DeveloperPrivateAPI : public BrowserContextKeyedService,
78 public extensions::EventRouter::Observer { 90 public EventRouter::Observer {
79 public: 91 public:
80 // Convenience method to get the DeveloperPrivateAPI for a profile. 92 // Convenience method to get the DeveloperPrivateAPI for a profile.
81 static DeveloperPrivateAPI* Get(Profile* profile); 93 static DeveloperPrivateAPI* Get(Profile* profile);
82 94
83 explicit DeveloperPrivateAPI(Profile* profile); 95 explicit DeveloperPrivateAPI(Profile* profile);
84 virtual ~DeveloperPrivateAPI(); 96 virtual ~DeveloperPrivateAPI();
85 97
86 void SetLastUnpackedDirectory(const base::FilePath& path); 98 void SetLastUnpackedDirectory(const base::FilePath& path);
87 99
88 base::FilePath& GetLastUnpackedDirectory() { 100 base::FilePath& GetLastUnpackedDirectory() {
89 return last_unpacked_directory_; 101 return last_unpacked_directory_;
90 } 102 }
91 103
92 // BrowserContextKeyedService implementation 104 // BrowserContextKeyedService implementation
93 virtual void Shutdown() OVERRIDE; 105 virtual void Shutdown() OVERRIDE;
94 106
95 // EventRouter::Observer implementation. 107 // EventRouter::Observer implementation.
96 virtual void OnListenerAdded(const extensions::EventListenerInfo& details) 108 virtual void OnListenerAdded(const EventListenerInfo& details) OVERRIDE;
97 OVERRIDE; 109 virtual void OnListenerRemoved(const EventListenerInfo& details) OVERRIDE;
98 virtual void OnListenerRemoved(const extensions::EventListenerInfo& details)
99 OVERRIDE;
100 110
101 private: 111 private:
102 void RegisterNotifications(); 112 void RegisterNotifications();
103 113
104 Profile* profile_; 114 Profile* profile_;
105 115
106 // Used to start the load |load_extension_dialog_| in the last directory that 116 // Used to start the load |load_extension_dialog_| in the last directory that
107 // was loaded. 117 // was loaded.
108 base::FilePath last_unpacked_directory_; 118 base::FilePath last_unpacked_directory_;
109 119
(...skipping 24 matching lines...) Expand all
134 DECLARE_EXTENSION_FUNCTION("developerPrivate.getItemsInfo", 144 DECLARE_EXTENSION_FUNCTION("developerPrivate.getItemsInfo",
135 DEVELOPERPRIVATE_GETITEMSINFO) 145 DEVELOPERPRIVATE_GETITEMSINFO)
136 146
137 protected: 147 protected:
138 virtual ~DeveloperPrivateGetItemsInfoFunction(); 148 virtual ~DeveloperPrivateGetItemsInfoFunction();
139 149
140 // ExtensionFunction: 150 // ExtensionFunction:
141 virtual bool RunImpl() OVERRIDE; 151 virtual bool RunImpl() OVERRIDE;
142 152
143 private: 153 private:
144 154 scoped_ptr<developer::ItemInfo> CreateItemInfo(const Extension& item,
145 scoped_ptr<developer::ItemInfo> CreateItemInfo( 155 bool item_is_enabled);
146 const extensions::Extension& item,
147 bool item_is_enabled);
148 156
149 void GetIconsOnFileThread( 157 void GetIconsOnFileThread(
150 ItemInfoList item_list, 158 ItemInfoList item_list,
151 std::map<std::string, ExtensionResource> itemIdToIconResourceMap); 159 std::map<std::string, ExtensionResource> itemIdToIconResourceMap);
152 160
153 // Helper that lists the current inspectable html pages for the extension. 161 // Helper that lists the current inspectable html pages for the extension.
154 void GetInspectablePagesForExtensionProcess( 162 void GetInspectablePagesForExtensionProcess(
155 const Extension* extension, 163 const Extension* extension,
156 const std::set<content::RenderViewHost*>& views, 164 const std::set<content::RenderViewHost*>& views,
157 ItemInspectViewList* result); 165 ItemInspectViewList* result);
158 166
159 ItemInspectViewList GetInspectablePagesForExtension( 167 ItemInspectViewList GetInspectablePagesForExtension(
160 const extensions::Extension* extension, 168 const Extension* extension,
161 bool extension_is_enabled); 169 bool extension_is_enabled);
162 170
163 void GetShellWindowPagesForExtensionProfile( 171 void GetShellWindowPagesForExtensionProfile(const Extension* extension,
164 const extensions::Extension* extension, 172 ItemInspectViewList* result);
165 ItemInspectViewList* result);
166 173
167 linked_ptr<developer::ItemInspectView> constructInspectView( 174 linked_ptr<developer::ItemInspectView> constructInspectView(
168 const GURL& url, 175 const GURL& url,
169 int render_process_id, 176 int render_process_id,
170 int render_view_id, 177 int render_view_id,
171 bool incognito, 178 bool incognito,
172 bool generated_background_page); 179 bool generated_background_page);
173 }; 180 };
174 181
175 class DeveloperPrivateInspectFunction : public ChromeSyncExtensionFunction { 182 class DeveloperPrivateInspectFunction : public ChromeSyncExtensionFunction {
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 protected: 264 protected:
258 virtual ~DeveloperPrivateEnableFunction(); 265 virtual ~DeveloperPrivateEnableFunction();
259 266
260 // Callback for requirements checker. 267 // Callback for requirements checker.
261 void OnRequirementsChecked(std::string extension_id, 268 void OnRequirementsChecked(std::string extension_id,
262 std::vector<std::string> requirements_errors); 269 std::vector<std::string> requirements_errors);
263 // ExtensionFunction: 270 // ExtensionFunction:
264 virtual bool RunImpl() OVERRIDE; 271 virtual bool RunImpl() OVERRIDE;
265 272
266 private: 273 private:
267 scoped_ptr<extensions::RequirementsChecker> requirements_checker_; 274 scoped_ptr<RequirementsChecker> requirements_checker_;
268 }; 275 };
269 276
270 class DeveloperPrivateChooseEntryFunction : public ChromeAsyncExtensionFunction, 277 class DeveloperPrivateChooseEntryFunction : public ChromeAsyncExtensionFunction,
271 public EntryPickerClient { 278 public EntryPickerClient {
272 protected: 279 protected:
273 virtual ~DeveloperPrivateChooseEntryFunction(); 280 virtual ~DeveloperPrivateChooseEntryFunction();
274 virtual bool RunImpl() OVERRIDE; 281 virtual bool RunImpl() OVERRIDE;
275 bool ShowPicker(ui::SelectFileDialog::Type picker_type, 282 bool ShowPicker(ui::SelectFileDialog::Type picker_type,
276 const base::FilePath& last_directory, 283 const base::FilePath& last_directory,
277 const base::string16& select_title, 284 const base::string16& select_title,
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 virtual ~DeveloperPrivateChoosePathFunction(); 316 virtual ~DeveloperPrivateChoosePathFunction();
310 virtual bool RunImpl() OVERRIDE; 317 virtual bool RunImpl() OVERRIDE;
311 318
312 // EntryPickerClient functions. 319 // EntryPickerClient functions.
313 virtual void FileSelected(const base::FilePath& path) OVERRIDE; 320 virtual void FileSelected(const base::FilePath& path) OVERRIDE;
314 virtual void FileSelectionCanceled() OVERRIDE; 321 virtual void FileSelectionCanceled() OVERRIDE;
315 }; 322 };
316 323
317 class DeveloperPrivatePackDirectoryFunction 324 class DeveloperPrivatePackDirectoryFunction
318 : public ChromeAsyncExtensionFunction, 325 : public ChromeAsyncExtensionFunction,
319 public extensions::PackExtensionJob::Client { 326 public PackExtensionJob::Client {
320 327
321 public: 328 public:
322 DECLARE_EXTENSION_FUNCTION("developerPrivate.packDirectory", 329 DECLARE_EXTENSION_FUNCTION("developerPrivate.packDirectory",
323 DEVELOPERPRIVATE_PACKDIRECTORY); 330 DEVELOPERPRIVATE_PACKDIRECTORY);
324 331
325 DeveloperPrivatePackDirectoryFunction(); 332 DeveloperPrivatePackDirectoryFunction();
326 333
327 // ExtensionPackJob::Client implementation. 334 // ExtensionPackJob::Client implementation.
328 virtual void OnPackSuccess(const base::FilePath& crx_file, 335 virtual void OnPackSuccess(const base::FilePath& crx_file,
329 const base::FilePath& key_file) OVERRIDE; 336 const base::FilePath& key_file) OVERRIDE;
330 virtual void OnPackFailure( 337 virtual void OnPackFailure(const std::string& error,
331 const std::string& error, 338 ExtensionCreator::ErrorType error_type) OVERRIDE;
332 extensions::ExtensionCreator::ErrorType error_type) OVERRIDE;
333 339
334 protected: 340 protected:
335 virtual ~DeveloperPrivatePackDirectoryFunction(); 341 virtual ~DeveloperPrivatePackDirectoryFunction();
336 virtual bool RunImpl() OVERRIDE; 342 virtual bool RunImpl() OVERRIDE;
337 343
338 private: 344 private:
339 scoped_refptr<extensions::PackExtensionJob> pack_job_; 345 scoped_refptr<PackExtensionJob> pack_job_;
340 std::string item_path_str_; 346 std::string item_path_str_;
341 std::string key_path_str_; 347 std::string key_path_str_;
342 }; 348 };
343 349
344 class DeveloperPrivateGetStringsFunction : public ChromeSyncExtensionFunction {
345 public:
346 DECLARE_EXTENSION_FUNCTION("developerPrivate.getStrings",
347 DEVELOPERPRIVATE_GETSTRINGS);
348
349 protected:
350 virtual ~DeveloperPrivateGetStringsFunction();
351
352 // ExtensionFunction
353 virtual bool RunImpl() OVERRIDE;
354 };
355
356 class DeveloperPrivateIsProfileManagedFunction 350 class DeveloperPrivateIsProfileManagedFunction
357 : public ChromeSyncExtensionFunction { 351 : public ChromeSyncExtensionFunction {
358 public: 352 public:
359 DECLARE_EXTENSION_FUNCTION("developerPrivate.isProfileManaged", 353 DECLARE_EXTENSION_FUNCTION("developerPrivate.isProfileManaged",
360 DEVELOPERPRIVATE_ISPROFILEMANAGED); 354 DEVELOPERPRIVATE_ISPROFILEMANAGED);
361 355
362 protected: 356 protected:
363 virtual ~DeveloperPrivateIsProfileManagedFunction(); 357 virtual ~DeveloperPrivateIsProfileManagedFunction();
364 358
365 // ExtensionFunction 359 // ExtensionFunction
366 virtual bool RunImpl() OVERRIDE; 360 virtual bool RunImpl() OVERRIDE;
367 }; 361 };
368 362
369 class DeveloperPrivateLoadDirectoryFunction 363 class DeveloperPrivateLoadDirectoryFunction
370 : public ChromeAsyncExtensionFunction { 364 : public ChromeAsyncExtensionFunction {
371 public: 365 public:
372 DECLARE_EXTENSION_FUNCTION("developerPrivate.loadDirectory", 366 DECLARE_EXTENSION_FUNCTION("developerPrivate.loadDirectory",
373 DEVELOPERPRIVATE_LOADUNPACKEDCROS); 367 DEVELOPERPRIVATE_LOADUNPACKEDCROS);
374 368
375 DeveloperPrivateLoadDirectoryFunction(); 369 DeveloperPrivateLoadDirectoryFunction();
376 370
377 protected: 371 protected:
378 virtual ~DeveloperPrivateLoadDirectoryFunction(); 372 virtual ~DeveloperPrivateLoadDirectoryFunction();
379 373
380 // ExtensionFunction 374 // ExtensionFunction
381 virtual bool RunImpl() OVERRIDE; 375 virtual bool RunImpl() OVERRIDE;
382 376
383 void ClearExistingDirectoryContent(const base::FilePath& project_path); 377 void ClearExistingDirectoryContent(const base::FilePath& project_path);
384 378
385 void ReadSyncFileSystemDirectory(const base::FilePath& project_path, 379 void ReadSyncFileSystemDirectory(const base::FilePath& project_path,
386 const base::FilePath& destination_path); 380 const base::FilePath& destination_path);
387 381
388 void ReadSyncFileSystemDirectoryCb( 382 void ReadSyncFileSystemDirectoryCb(
389 const base::FilePath& project_path, 383 const base::FilePath& project_path,
390 const base::FilePath& destination_path, 384 const base::FilePath& destination_path,
391 base::File::Error result, 385 base::File::Error result,
392 const fileapi::FileSystemOperation::FileEntryList& file_list, 386 const fileapi::FileSystemOperation::FileEntryList& file_list,
393 bool has_more); 387 bool has_more);
394 388
395 void SnapshotFileCallback( 389 void SnapshotFileCallback(
396 const base::FilePath& target_path, 390 const base::FilePath& target_path,
397 base::File::Error result, 391 base::File::Error result,
398 const base::File::Info& file_info, 392 const base::File::Info& file_info,
399 const base::FilePath& platform_path, 393 const base::FilePath& platform_path,
400 const scoped_refptr<webkit_blob::ShareableFileReference>& file_ref); 394 const scoped_refptr<webkit_blob::ShareableFileReference>& file_ref);
401 395
402 void CopyFile(const base::FilePath& src_path, 396 void CopyFile(const base::FilePath& src_path,
403 const base::FilePath& dest_path); 397 const base::FilePath& dest_path);
404 398
405 void Load(); 399 void Load();
406 400
407 scoped_refptr<fileapi::FileSystemContext> context_; 401 scoped_refptr<fileapi::FileSystemContext> context_;
408 402
409 // syncfs url representing the root of the folder to be copied. 403 // syncfs url representing the root of the folder to be copied.
410 std::string project_base_url_; 404 std::string project_base_url_;
411 405
412 // physical path on disc of the folder to be copied. 406 // physical path on disc of the folder to be copied.
413 base::FilePath project_base_path_; 407 base::FilePath project_base_path_;
414 408
415 // Path of the current folder to be copied. 409 // Path of the current folder to be copied.
416 base::FilePath current_path_; 410 base::FilePath current_path_;
417 411
418 private: 412 private:
419 int pending_copy_operations_count_; 413 int pending_copy_operations_count_;
420 414
421 // This is set to false if any of the copyFile operations fail on 415 // This is set to false if any of the copyFile operations fail on
422 // call of the API. It is returned as a response of the API call. 416 // call of the API. It is returned as a response of the API call.
423 bool success_; 417 bool success_;
418 };
424 419
420 class DeveloperPrivateRequestFileSourceFunction
421 : public ChromeAsyncExtensionFunction {
422 public:
423 DECLARE_EXTENSION_FUNCTION("developerPrivate.requestFileSource",
424 DEVELOPERPRIVATE_REQUESTFILESOURCE);
425
426 DeveloperPrivateRequestFileSourceFunction();
427
428 protected:
429 virtual ~DeveloperPrivateRequestFileSourceFunction();
430
431 // ExtensionFunction
432 virtual bool RunImpl() OVERRIDE;
433
434 private:
435 void LaunchCallback(const base::DictionaryValue& results);
436 };
437
438 class DeveloperPrivateOpenDevToolsFunction
439 : public ChromeAsyncExtensionFunction {
440 public:
441 DECLARE_EXTENSION_FUNCTION("developerPrivate.openDevTools",
442 DEVELOPERPRIVATE_OPENDEVTOOLS);
443
444 DeveloperPrivateOpenDevToolsFunction();
445
446 protected:
447 virtual ~DeveloperPrivateOpenDevToolsFunction();
448
449 // ExtensionFunction
450 virtual bool RunImpl() OVERRIDE;
425 }; 451 };
426 452
427 } // namespace api 453 } // namespace api
428 454
429 } // namespace extensions 455 } // namespace extensions
430 456
431 #endif // CHROME_BROWSER_EXTENSIONS_API_DEVELOPER_PRIVATE_DEVELOPER_PRIVATE_API _H_ 457 #endif // CHROME_BROWSER_EXTENSIONS_API_DEVELOPER_PRIVATE_DEVELOPER_PRIVATE_API _H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698