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