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