OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CHROME_BROWSER_EXTENSIONS_API_DEVELOPER_PRIVATE_DEVELOPER_PRIVATE_API_H_ | |
6 #define CHROME_BROWSER_EXTENSIONS_API_DEVELOPER_PRIVATE_DEVELOPER_PRIVATE_API_H_ | |
7 | |
8 #include "chrome/browser/extensions/extension_function.h" | |
9 #include "chrome/browser/extensions/extension_install_prompt.h" | |
10 #include "chrome/browser/profiles/profile_keyed_service.h" | |
11 #include "content/public/browser/notification_observer.h" | |
12 #include "content/public/browser/notification_registrar.h" | |
13 #include "content/public/browser/render_view_host.h" | |
14 | |
15 namespace extensions { | |
16 | |
17 class ExtensionSystem; | |
18 | |
19 namespace api { | |
20 | |
21 namespace developer_private { | |
22 struct ItemInfo; | |
23 struct ItemInspectView; | |
24 } | |
25 | |
26 } // namespace api | |
27 | |
28 } // namespace extensions | |
29 | |
30 namespace developer = extensions::api::developer_private; | |
31 | |
32 typedef std::vector<linked_ptr<developer::ItemInfo> > ItemInfoList; | |
33 typedef std::vector<linked_ptr<developer::ItemInspectView> > | |
34 ItemInspectViewList; | |
35 | |
36 namespace extensions { | |
37 | |
38 // The profile-keyed service that manages the DeveloperPrivate API. | |
39 class DeveloperPrivateAPI : public ProfileKeyedService, | |
40 public content::NotificationObserver { | |
41 public: | |
42 // Convenience method to get the DeveloperPrivateAPI for a profile. | |
43 static DeveloperPrivateAPI* Get(Profile* profile); | |
44 | |
45 explicit DeveloperPrivateAPI(Profile* profile); | |
46 virtual ~DeveloperPrivateAPI(); | |
47 | |
48 void AddItemsInfo(const ExtensionSet& items, | |
49 ExtensionSystem* system, | |
50 ItemInfoList* item_list); | |
51 | |
52 // ProfileKeyedService implementation | |
53 virtual void Shutdown() OVERRIDE; | |
54 | |
55 // content::NotificationObserver implementation. | |
56 virtual void Observe(int type, | |
57 const content::NotificationSource& source, | |
58 const content::NotificationDetails& details) OVERRIDE; | |
59 | |
60 private: | |
61 void RegisterNotifications(); | |
62 | |
63 scoped_ptr<developer::ItemInfo> CreateItemInfo( | |
64 const extensions::Extension& item, | |
65 ExtensionSystem* system, | |
66 bool item_is_enabled); | |
67 | |
68 // Helper that lists the current inspectable html pages for the extension. | |
69 void GetInspectablePagesForExtensionProcess( | |
70 const std::set<content::RenderViewHost*>& views, | |
71 ItemInspectViewList* result); | |
72 | |
73 ItemInspectViewList GetInspectablePagesForExtension( | |
74 const extensions::Extension* extension, | |
75 bool extension_is_enabled); | |
76 | |
77 Profile* profile_; | |
78 | |
79 content::NotificationRegistrar registrar_; | |
80 | |
81 // The page may be refreshed in response to a RENDER_VIEW_HOST_DELETED, | |
82 // but the iteration over RenderViewHosts will include the host because the | |
83 // notification is sent when it is in the process of being deleted (and before | |
84 // it is removed from the process). Keep a pointer to it so we can exclude | |
85 // it from the active views. | |
86 content::RenderViewHost* deleting_render_view_host_; | |
87 }; | |
88 | |
89 namespace api { | |
90 | |
91 class DeveloperPrivateAutoUpdateFunction : public SyncExtensionFunction { | |
92 public: | |
93 DECLARE_EXTENSION_FUNCTION_NAME("developerPrivate.autoUpdate"); | |
94 | |
95 protected: | |
96 virtual ~DeveloperPrivateAutoUpdateFunction(); | |
97 | |
98 // ExtensionFunction: | |
99 virtual bool RunImpl() OVERRIDE; | |
100 }; | |
101 | |
102 class DeveloperPrivateGetItemsInfoFunction : public SyncExtensionFunction { | |
103 public: | |
104 DECLARE_EXTENSION_FUNCTION_NAME("developerPrivate.getItemsInfo"); | |
105 | |
106 protected: | |
107 virtual ~DeveloperPrivateGetItemsInfoFunction(); | |
108 | |
109 // ExtensionFunction: | |
110 virtual bool RunImpl() OVERRIDE; | |
111 }; | |
112 | |
113 class DeveloperPrivateInspectFunction : public SyncExtensionFunction { | |
114 public: | |
115 DECLARE_EXTENSION_FUNCTION_NAME("developerPrivate.inspect"); | |
116 | |
117 protected: | |
118 virtual ~DeveloperPrivateInspectFunction(); | |
119 | |
120 // ExtensionFunction: | |
121 virtual bool RunImpl() OVERRIDE; | |
122 }; | |
123 | |
124 } // namespace api | |
125 | |
126 } // namespace extensions | |
127 | |
128 #endif // CHROME_BROWSER_EXTENSIONS_API_DEVELOPER_PRIVATE_DEVELOPER_PRIVATE_API
_H_ | |
OLD | NEW |