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

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

Issue 306053013: Use ExtensionRegistry in developer private api (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address review comments Created 6 years, 6 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
« no previous file with comments | « no previous file | chrome/browser/extensions/api/developer_private/developer_private_api.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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> 8 #include <set>
9 9
10 #include "base/files/file.h" 10 #include "base/files/file.h"
11 #include "base/scoped_observer.h"
11 #include "chrome/browser/extensions/api/developer_private/entry_picker.h" 12 #include "chrome/browser/extensions/api/developer_private/entry_picker.h"
12 #include "chrome/browser/extensions/api/file_system/file_system_api.h" 13 #include "chrome/browser/extensions/api/file_system/file_system_api.h"
13 #include "chrome/browser/extensions/chrome_extension_function.h" 14 #include "chrome/browser/extensions/chrome_extension_function.h"
14 #include "chrome/browser/extensions/error_console/error_console.h" 15 #include "chrome/browser/extensions/error_console/error_console.h"
15 #include "chrome/browser/extensions/extension_install_prompt.h" 16 #include "chrome/browser/extensions/extension_install_prompt.h"
16 #include "chrome/browser/extensions/extension_uninstall_dialog.h" 17 #include "chrome/browser/extensions/extension_uninstall_dialog.h"
17 #include "chrome/browser/extensions/pack_extension_job.h" 18 #include "chrome/browser/extensions/pack_extension_job.h"
18 #include "chrome/browser/extensions/requirements_checker.h" 19 #include "chrome/browser/extensions/requirements_checker.h"
19 #include "content/public/browser/notification_observer.h" 20 #include "content/public/browser/notification_observer.h"
20 #include "content/public/browser/notification_registrar.h" 21 #include "content/public/browser/notification_registrar.h"
21 #include "content/public/browser/render_view_host.h" 22 #include "content/public/browser/render_view_host.h"
22 #include "extensions/browser/browser_context_keyed_api_factory.h" 23 #include "extensions/browser/browser_context_keyed_api_factory.h"
23 #include "extensions/browser/event_router.h" 24 #include "extensions/browser/event_router.h"
25 #include "extensions/browser/extension_registry_observer.h"
24 #include "ui/shell_dialogs/select_file_dialog.h" 26 #include "ui/shell_dialogs/select_file_dialog.h"
25 #include "webkit/browser/fileapi/file_system_context.h" 27 #include "webkit/browser/fileapi/file_system_context.h"
26 #include "webkit/browser/fileapi/file_system_operation.h" 28 #include "webkit/browser/fileapi/file_system_operation.h"
27 29
28 class Profile; 30 class Profile;
29 31
30 namespace extensions { 32 namespace extensions {
31 33
32 class ExtensionError; 34 class ExtensionError;
35 class ExtensionRegistry;
33 class ExtensionSystem; 36 class ExtensionSystem;
34 class ManagementPolicy; 37 class ManagementPolicy;
35 38
36 namespace api { 39 namespace api {
37 40
38 class EntryPicker; 41 class EntryPicker;
39 class EntryPickerClient; 42 class EntryPickerClient;
40 43
41 namespace developer_private { 44 namespace developer_private {
42 45
43 struct ItemInfo; 46 struct ItemInfo;
44 struct ItemInspectView; 47 struct ItemInspectView;
45 struct ProjectInfo; 48 struct ProjectInfo;
46 49
47 } // namespace developer_private 50 } // namespace developer_private
48 51
49 } // namespace api 52 } // namespace api
50 53
51 namespace developer = api::developer_private; 54 namespace developer = api::developer_private;
52 55
53 typedef std::vector<linked_ptr<developer::ItemInfo> > ItemInfoList; 56 typedef std::vector<linked_ptr<developer::ItemInfo> > ItemInfoList;
54 typedef std::vector<linked_ptr<developer::ProjectInfo> > ProjectInfoList; 57 typedef std::vector<linked_ptr<developer::ProjectInfo> > ProjectInfoList;
55 typedef std::vector<linked_ptr<developer::ItemInspectView> > 58 typedef std::vector<linked_ptr<developer::ItemInspectView> >
56 ItemInspectViewList; 59 ItemInspectViewList;
57 60
58 class DeveloperPrivateEventRouter : public content::NotificationObserver, 61 class DeveloperPrivateEventRouter : public content::NotificationObserver,
62 public ExtensionRegistryObserver,
59 public ErrorConsole::Observer { 63 public ErrorConsole::Observer {
60 public: 64 public:
61 explicit DeveloperPrivateEventRouter(Profile* profile); 65 explicit DeveloperPrivateEventRouter(Profile* profile);
62 virtual ~DeveloperPrivateEventRouter(); 66 virtual ~DeveloperPrivateEventRouter();
63 67
64 // Add or remove an ID to the list of extensions subscribed to events. 68 // Add or remove an ID to the list of extensions subscribed to events.
65 void AddExtensionId(const std::string& extension_id); 69 void AddExtensionId(const std::string& extension_id);
66 void RemoveExtensionId(const std::string& extension_id); 70 void RemoveExtensionId(const std::string& extension_id);
67 71
68 private: 72 private:
69 // content::NotificationObserver implementation 73 // content::NotificationObserver implementation.
70 virtual void Observe(int type, 74 virtual void Observe(int type,
71 const content::NotificationSource& source, 75 const content::NotificationSource& source,
72 const content::NotificationDetails& details) OVERRIDE; 76 const content::NotificationDetails& details) OVERRIDE;
73 77
74 // ErrorConsole::Observer implementation 78 // ExtensionRegistryObserver implementation.
79 virtual void OnExtensionLoaded(content::BrowserContext* browser_context,
80 const Extension* extension) OVERRIDE;
81 virtual void OnExtensionUnloaded(
82 content::BrowserContext* browser_context,
83 const Extension* extension,
84 UnloadedExtensionInfo::Reason reason) OVERRIDE;
85 virtual void OnExtensionWillBeInstalled(
86 content::BrowserContext* browser_context,
87 const Extension* extension,
88 bool is_update,
89 bool from_ephemeral,
90 const std::string& old_name) OVERRIDE;
91 virtual void OnExtensionUninstalled(content::BrowserContext* browser_context,
92 const Extension* extension) OVERRIDE;
93
94 // ErrorConsole::Observer implementation.
75 virtual void OnErrorAdded(const ExtensionError* error) OVERRIDE; 95 virtual void OnErrorAdded(const ExtensionError* error) OVERRIDE;
76 96
77 content::NotificationRegistrar registrar_; 97 content::NotificationRegistrar registrar_;
78 98
99 ScopedObserver<extensions::ExtensionRegistry,
100 extensions::ExtensionRegistryObserver>
101 extension_registry_observer_;
102
79 Profile* profile_; 103 Profile* profile_;
80 104
81 // The set of IDs of the Extensions that have subscribed to DeveloperPrivate 105 // The set of IDs of the Extensions that have subscribed to DeveloperPrivate
82 // events. Since the only consumer of the DeveloperPrivate API is currently 106 // events. Since the only consumer of the DeveloperPrivate API is currently
83 // the Apps Developer Tool (which replaces the chrome://extensions page), we 107 // the Apps Developer Tool (which replaces the chrome://extensions page), we
84 // don't want to send information about the subscribing extension in an 108 // don't want to send information about the subscribing extension in an
85 // update. In particular, we want to avoid entering a loop, which could happen 109 // update. In particular, we want to avoid entering a loop, which could happen
86 // when, e.g., the Apps Developer Tool throws an error. 110 // when, e.g., the Apps Developer Tool throws an error.
87 std::set<std::string> extension_ids_; 111 std::set<std::string> extension_ids_;
88 112
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after
460 484
461 // ExtensionFunction: 485 // ExtensionFunction:
462 virtual bool RunAsync() OVERRIDE; 486 virtual bool RunAsync() OVERRIDE;
463 }; 487 };
464 488
465 } // namespace api 489 } // namespace api
466 490
467 } // namespace extensions 491 } // namespace extensions
468 492
469 #endif // CHROME_BROWSER_EXTENSIONS_API_DEVELOPER_PRIVATE_DEVELOPER_PRIVATE_API _H_ 493 #endif // CHROME_BROWSER_EXTENSIONS_API_DEVELOPER_PRIVATE_DEVELOPER_PRIVATE_API _H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/extensions/api/developer_private/developer_private_api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698