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

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

Issue 1092953004: [Extensions] Update developerPrivate API to use base-64 data urls for icons (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Latest master Created 5 years, 8 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/memory/weak_ptr.h"
11 #include "base/scoped_observer.h" 12 #include "base/scoped_observer.h"
12 #include "chrome/browser/extensions/api/developer_private/entry_picker.h" 13 #include "chrome/browser/extensions/api/developer_private/entry_picker.h"
13 #include "chrome/browser/extensions/api/extension_action/extension_action_api.h" 14 #include "chrome/browser/extensions/api/extension_action/extension_action_api.h"
14 #include "chrome/browser/extensions/api/file_system/file_system_api.h" 15 #include "chrome/browser/extensions/api/file_system/file_system_api.h"
15 #include "chrome/browser/extensions/chrome_extension_function.h" 16 #include "chrome/browser/extensions/chrome_extension_function.h"
16 #include "chrome/browser/extensions/error_console/error_console.h" 17 #include "chrome/browser/extensions/error_console/error_console.h"
17 #include "chrome/browser/extensions/extension_uninstall_dialog.h" 18 #include "chrome/browser/extensions/extension_uninstall_dialog.h"
18 #include "chrome/browser/extensions/pack_extension_job.h" 19 #include "chrome/browser/extensions/pack_extension_job.h"
20 #include "chrome/common/extensions/api/developer_private.h"
19 #include "chrome/common/extensions/webstore_install_result.h" 21 #include "chrome/common/extensions/webstore_install_result.h"
20 #include "extensions/browser/app_window/app_window_registry.h" 22 #include "extensions/browser/app_window/app_window_registry.h"
21 #include "extensions/browser/browser_context_keyed_api_factory.h" 23 #include "extensions/browser/browser_context_keyed_api_factory.h"
22 #include "extensions/browser/event_router.h" 24 #include "extensions/browser/event_router.h"
23 #include "extensions/browser/extension_registry_observer.h" 25 #include "extensions/browser/extension_registry_observer.h"
24 #include "extensions/browser/process_manager_observer.h" 26 #include "extensions/browser/process_manager_observer.h"
25 #include "storage/browser/fileapi/file_system_context.h" 27 #include "storage/browser/fileapi/file_system_context.h"
26 #include "storage/browser/fileapi/file_system_operation.h" 28 #include "storage/browser/fileapi/file_system_operation.h"
27 #include "ui/shell_dialogs/select_file_dialog.h" 29 #include "ui/shell_dialogs/select_file_dialog.h"
28 30
29 class Profile; 31 class Profile;
30 32
31 namespace extensions { 33 namespace extensions {
32 34
35 class EventRouter;
33 class ExtensionError; 36 class ExtensionError;
37 class ExtensionInfoGenerator;
34 class ExtensionRegistry; 38 class ExtensionRegistry;
35 class ExtensionSystem; 39 class ExtensionSystem;
36 class ManagementPolicy; 40 class ManagementPolicy;
37 class ProcessManager; 41 class ProcessManager;
38 class RequirementsChecker; 42 class RequirementsChecker;
39 43
40 namespace api { 44 namespace api {
41 45
42 class EntryPicker; 46 class EntryPicker;
43 class EntryPickerClient; 47 class EntryPickerClient;
44 48
45 namespace developer_private {
46
47 struct ItemInfo;
48 struct ItemInspectView;
49 struct ProjectInfo;
50
51 namespace RequestFileSource {
52 struct Params;
53 }
54
55 } // namespace developer_private
56
57 } // namespace api 49 } // namespace api
58 50
59 namespace developer = api::developer_private;
60
61 typedef std::vector<linked_ptr<developer::ItemInfo> > ItemInfoList;
62 typedef std::vector<linked_ptr<developer::ProjectInfo> > ProjectInfoList;
63 typedef std::vector<linked_ptr<developer::ItemInspectView> >
64 ItemInspectViewList;
65
66 class DeveloperPrivateEventRouter : public ExtensionRegistryObserver, 51 class DeveloperPrivateEventRouter : public ExtensionRegistryObserver,
67 public ErrorConsole::Observer, 52 public ErrorConsole::Observer,
68 public ProcessManagerObserver, 53 public ProcessManagerObserver,
69 public AppWindowRegistry::Observer, 54 public AppWindowRegistry::Observer,
70 public ExtensionActionAPI::Observer { 55 public ExtensionActionAPI::Observer {
71 public: 56 public:
72 explicit DeveloperPrivateEventRouter(Profile* profile); 57 explicit DeveloperPrivateEventRouter(Profile* profile);
73 ~DeveloperPrivateEventRouter() override; 58 ~DeveloperPrivateEventRouter() override;
74 59
75 // Add or remove an ID to the list of extensions subscribed to events. 60 // Add or remove an ID to the list of extensions subscribed to events.
(...skipping 28 matching lines...) Expand all
104 content::RenderFrameHost* render_frame_host) override; 89 content::RenderFrameHost* render_frame_host) override;
105 90
106 // AppWindowRegistry::Observer: 91 // AppWindowRegistry::Observer:
107 void OnAppWindowAdded(AppWindow* window) override; 92 void OnAppWindowAdded(AppWindow* window) override;
108 void OnAppWindowRemoved(AppWindow* window) override; 93 void OnAppWindowRemoved(AppWindow* window) override;
109 94
110 // ExtensionActionAPI::Observer: 95 // ExtensionActionAPI::Observer:
111 void OnExtensionActionVisibilityChanged(const std::string& extension_id, 96 void OnExtensionActionVisibilityChanged(const std::string& extension_id,
112 bool is_now_visible) override; 97 bool is_now_visible) override;
113 98
99 // Broadcasts an event to all listeners.
100 void BroadcastItemStateChanged(api::developer_private::EventType event_type,
101 const std::string& id);
102 void BroadcastItemStateChangedHelper(
103 api::developer_private::EventType event_type,
104 const std::string& extension_id,
105 scoped_ptr<ExtensionInfoGenerator> info_generator,
106 const std::vector<linked_ptr<api::developer_private::ExtensionInfo>>&
107 infos);
108
114 ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver> 109 ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver>
115 extension_registry_observer_; 110 extension_registry_observer_;
116 ScopedObserver<ErrorConsole, ErrorConsole::Observer> error_console_observer_; 111 ScopedObserver<ErrorConsole, ErrorConsole::Observer> error_console_observer_;
117 ScopedObserver<ProcessManager, ProcessManagerObserver> 112 ScopedObserver<ProcessManager, ProcessManagerObserver>
118 process_manager_observer_; 113 process_manager_observer_;
119 ScopedObserver<AppWindowRegistry, AppWindowRegistry::Observer> 114 ScopedObserver<AppWindowRegistry, AppWindowRegistry::Observer>
120 app_window_registry_observer_; 115 app_window_registry_observer_;
121 ScopedObserver<ExtensionActionAPI, ExtensionActionAPI::Observer> 116 ScopedObserver<ExtensionActionAPI, ExtensionActionAPI::Observer>
122 extension_action_api_observer_; 117 extension_action_api_observer_;
123 118
124 Profile* profile_; 119 Profile* profile_;
125 120
121 EventRouter* event_router_;
122
126 // The set of IDs of the Extensions that have subscribed to DeveloperPrivate 123 // The set of IDs of the Extensions that have subscribed to DeveloperPrivate
127 // events. Since the only consumer of the DeveloperPrivate API is currently 124 // events. Since the only consumer of the DeveloperPrivate API is currently
128 // the Apps Developer Tool (which replaces the chrome://extensions page), we 125 // the Apps Developer Tool (which replaces the chrome://extensions page), we
129 // don't want to send information about the subscribing extension in an 126 // don't want to send information about the subscribing extension in an
130 // update. In particular, we want to avoid entering a loop, which could happen 127 // update. In particular, we want to avoid entering a loop, which could happen
131 // when, e.g., the Apps Developer Tool throws an error. 128 // when, e.g., the Apps Developer Tool throws an error.
132 std::set<std::string> extension_ids_; 129 std::set<std::string> extension_ids_;
133 130
131 base::WeakPtrFactory<DeveloperPrivateEventRouter> weak_factory_;
132
134 DISALLOW_COPY_AND_ASSIGN(DeveloperPrivateEventRouter); 133 DISALLOW_COPY_AND_ASSIGN(DeveloperPrivateEventRouter);
135 }; 134 };
136 135
137 // The profile-keyed service that manages the DeveloperPrivate API. 136 // The profile-keyed service that manages the DeveloperPrivate API.
138 class DeveloperPrivateAPI : public BrowserContextKeyedAPI, 137 class DeveloperPrivateAPI : public BrowserContextKeyedAPI,
139 public EventRouter::Observer { 138 public EventRouter::Observer {
140 public: 139 public:
141 static BrowserContextKeyedAPIFactory<DeveloperPrivateAPI>* 140 static BrowserContextKeyedAPIFactory<DeveloperPrivateAPI>*
142 GetFactoryInstance(); 141 GetFactoryInstance();
143 142
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 : public DeveloperPrivateAPIFunction { 210 : public DeveloperPrivateAPIFunction {
212 public: 211 public:
213 DECLARE_EXTENSION_FUNCTION("developerPrivate.getItemsInfo", 212 DECLARE_EXTENSION_FUNCTION("developerPrivate.getItemsInfo",
214 DEVELOPERPRIVATE_GETITEMSINFO) 213 DEVELOPERPRIVATE_GETITEMSINFO)
215 DeveloperPrivateGetItemsInfoFunction(); 214 DeveloperPrivateGetItemsInfoFunction();
216 215
217 private: 216 private:
218 ~DeveloperPrivateGetItemsInfoFunction() override; 217 ~DeveloperPrivateGetItemsInfoFunction() override;
219 ResponseAction Run() override; 218 ResponseAction Run() override;
220 219
221 void GetIconsOnFileThread( 220 void OnInfosGenerated(
222 std::map<std::string, ExtensionResource> resource_map); 221 const std::vector<linked_ptr<api::developer_private::ExtensionInfo>>&
223 void Finish(); 222 infos);
224 223
225 ItemInfoList item_list_; 224 scoped_ptr<ExtensionInfoGenerator> info_generator_;
225
226 DISALLOW_COPY_AND_ASSIGN(DeveloperPrivateGetItemsInfoFunction);
226 }; 227 };
227 228
228 class DeveloperPrivateGetExtensionsInfoFunction 229 class DeveloperPrivateGetExtensionsInfoFunction
229 : public DeveloperPrivateAPIFunction { 230 : public DeveloperPrivateAPIFunction {
230 public: 231 public:
232 DeveloperPrivateGetExtensionsInfoFunction();
231 DECLARE_EXTENSION_FUNCTION("developerPrivate.getExtensionsInfo", 233 DECLARE_EXTENSION_FUNCTION("developerPrivate.getExtensionsInfo",
232 DEVELOPERPRIVATE_GETEXTENSIONSINFO); 234 DEVELOPERPRIVATE_GETEXTENSIONSINFO);
233 235
234 private: 236 private:
235 ~DeveloperPrivateGetExtensionsInfoFunction() override; 237 ~DeveloperPrivateGetExtensionsInfoFunction() override;
236 ResponseAction Run() override; 238 ResponseAction Run() override;
239
240 void OnInfosGenerated(
241 const std::vector<linked_ptr<api::developer_private::ExtensionInfo>>&
242 infos);
243
244 scoped_ptr<ExtensionInfoGenerator> info_generator_;
245
246 DISALLOW_COPY_AND_ASSIGN(DeveloperPrivateGetExtensionsInfoFunction);
237 }; 247 };
238 248
239 class DeveloperPrivateGetExtensionInfoFunction 249 class DeveloperPrivateGetExtensionInfoFunction
240 : public DeveloperPrivateAPIFunction { 250 : public DeveloperPrivateAPIFunction {
241 public: 251 public:
252 DeveloperPrivateGetExtensionInfoFunction();
242 DECLARE_EXTENSION_FUNCTION("developerPrivate.getExtensionInfo", 253 DECLARE_EXTENSION_FUNCTION("developerPrivate.getExtensionInfo",
243 DEVELOPERPRIVATE_GETEXTENSIONINFO); 254 DEVELOPERPRIVATE_GETEXTENSIONINFO);
244 255
245 private: 256 private:
246 ~DeveloperPrivateGetExtensionInfoFunction() override; 257 ~DeveloperPrivateGetExtensionInfoFunction() override;
247 ResponseAction Run() override; 258 ResponseAction Run() override;
259
260 void OnInfosGenerated(
261 const std::vector<linked_ptr<api::developer_private::ExtensionInfo>>&
262 infos);
263
264 scoped_ptr<ExtensionInfoGenerator> info_generator_;
265
266 DISALLOW_COPY_AND_ASSIGN(DeveloperPrivateGetExtensionInfoFunction);
248 }; 267 };
249 268
250 class DeveloperPrivateGetProfileConfigurationFunction 269 class DeveloperPrivateGetProfileConfigurationFunction
251 : public DeveloperPrivateAPIFunction { 270 : public DeveloperPrivateAPIFunction {
252 public: 271 public:
253 DECLARE_EXTENSION_FUNCTION("developerPrivate.getProfileConfiguration", 272 DECLARE_EXTENSION_FUNCTION("developerPrivate.getProfileConfiguration",
254 DEVELOPERPRIVATE_GETPROFILECONFIGURATION); 273 DEVELOPERPRIVATE_GETPROFILECONFIGURATION);
255 274
256 private: 275 private:
257 ~DeveloperPrivateGetProfileConfigurationFunction() override; 276 ~DeveloperPrivateGetProfileConfigurationFunction() override;
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
528 protected: 547 protected:
529 ~DeveloperPrivateShowPathFunction() override; 548 ~DeveloperPrivateShowPathFunction() override;
530 ResponseAction Run() override; 549 ResponseAction Run() override;
531 }; 550 };
532 551
533 } // namespace api 552 } // namespace api
534 553
535 } // namespace extensions 554 } // namespace extensions
536 555
537 #endif // CHROME_BROWSER_EXTENSIONS_API_DEVELOPER_PRIVATE_DEVELOPER_PRIVATE_API _H_ 556 #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