| OLD | NEW |
| 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_PROCESSES_PROCESSES_API_H__ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_PROCESSES_PROCESSES_API_H__ |
| 6 #define CHROME_BROWSER_EXTENSIONS_API_PROCESSES_PROCESSES_API_H__ | 6 #define CHROME_BROWSER_EXTENSIONS_API_PROCESSES_PROCESSES_API_H__ |
| 7 | 7 |
| 8 #include <set> | 8 #include <set> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "chrome/browser/extensions/api/profile_keyed_api_factory.h" | |
| 13 #include "chrome/browser/extensions/chrome_extension_function.h" | 12 #include "chrome/browser/extensions/chrome_extension_function.h" |
| 14 #include "chrome/browser/task_manager/task_manager.h" | 13 #include "chrome/browser/task_manager/task_manager.h" |
| 15 #include "components/browser_context_keyed_service/browser_context_keyed_service
.h" | 14 #include "components/browser_context_keyed_service/browser_context_keyed_service
.h" |
| 16 #include "content/public/browser/notification_registrar.h" | 15 #include "content/public/browser/notification_registrar.h" |
| 17 #include "content/public/browser/render_process_host.h" | 16 #include "content/public/browser/render_process_host.h" |
| 18 #include "content/public/browser/render_widget_host.h" | 17 #include "content/public/browser/render_widget_host.h" |
| 18 #include "extensions/browser/browser_context_keyed_api_factory.h" |
| 19 #include "extensions/browser/event_router.h" | 19 #include "extensions/browser/event_router.h" |
| 20 | 20 |
| 21 namespace base { | 21 namespace base { |
| 22 class ListValue; | 22 class ListValue; |
| 23 } | 23 } |
| 24 | 24 |
| 25 namespace content { | 25 namespace content { |
| 26 class BrowserContext; | 26 class BrowserContext; |
| 27 } | 27 } |
| 28 | 28 |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 int listeners_; | 87 int listeners_; |
| 88 | 88 |
| 89 // Indicator whether we've initialized the Task Manager listeners. This is | 89 // Indicator whether we've initialized the Task Manager listeners. This is |
| 90 // done once for the lifetime of this object. | 90 // done once for the lifetime of this object. |
| 91 bool task_manager_listening_; | 91 bool task_manager_listening_; |
| 92 | 92 |
| 93 DISALLOW_COPY_AND_ASSIGN(ProcessesEventRouter); | 93 DISALLOW_COPY_AND_ASSIGN(ProcessesEventRouter); |
| 94 }; | 94 }; |
| 95 | 95 |
| 96 // The profile-keyed service that manages the processes extension API. | 96 // The profile-keyed service that manages the processes extension API. |
| 97 class ProcessesAPI : public ProfileKeyedAPI, | 97 class ProcessesAPI : public BrowserContextKeyedAPI, |
| 98 public EventRouter::Observer { | 98 public EventRouter::Observer { |
| 99 public: | 99 public: |
| 100 explicit ProcessesAPI(content::BrowserContext* context); | 100 explicit ProcessesAPI(content::BrowserContext* context); |
| 101 virtual ~ProcessesAPI(); | 101 virtual ~ProcessesAPI(); |
| 102 | 102 |
| 103 // BrowserContextKeyedService implementation. | 103 // BrowserContextKeyedService implementation. |
| 104 virtual void Shutdown() OVERRIDE; | 104 virtual void Shutdown() OVERRIDE; |
| 105 | 105 |
| 106 // ProfileKeyedAPI implementation. | 106 // BrowserContextKeyedAPI implementation. |
| 107 static ProfileKeyedAPIFactory<ProcessesAPI>* GetFactoryInstance(); | 107 static BrowserContextKeyedAPIFactory<ProcessesAPI>* GetFactoryInstance(); |
| 108 | 108 |
| 109 // Convenience method to get the ProcessesAPI for a profile. | 109 // Convenience method to get the ProcessesAPI for a profile. |
| 110 static ProcessesAPI* Get(content::BrowserContext* context); | 110 static ProcessesAPI* Get(content::BrowserContext* context); |
| 111 | 111 |
| 112 ProcessesEventRouter* processes_event_router(); | 112 ProcessesEventRouter* processes_event_router(); |
| 113 | 113 |
| 114 // EventRouter::Observer implementation. | 114 // EventRouter::Observer implementation. |
| 115 virtual void OnListenerAdded(const EventListenerInfo& details) OVERRIDE; | 115 virtual void OnListenerAdded(const EventListenerInfo& details) OVERRIDE; |
| 116 virtual void OnListenerRemoved(const EventListenerInfo& details) OVERRIDE; | 116 virtual void OnListenerRemoved(const EventListenerInfo& details) OVERRIDE; |
| 117 | 117 |
| 118 private: | 118 private: |
| 119 friend class ProfileKeyedAPIFactory<ProcessesAPI>; | 119 friend class BrowserContextKeyedAPIFactory<ProcessesAPI>; |
| 120 | 120 |
| 121 content::BrowserContext* browser_context_; | 121 content::BrowserContext* browser_context_; |
| 122 | 122 |
| 123 // ProfileKeyedAPI implementation. | 123 // BrowserContextKeyedAPI implementation. |
| 124 static const char* service_name() { | 124 static const char* service_name() { |
| 125 return "ProcessesAPI"; | 125 return "ProcessesAPI"; |
| 126 } | 126 } |
| 127 static const bool kServiceRedirectedInIncognito = true; | 127 static const bool kServiceRedirectedInIncognito = true; |
| 128 static const bool kServiceIsNULLWhileTesting = true; | 128 static const bool kServiceIsNULLWhileTesting = true; |
| 129 | 129 |
| 130 // Created lazily on first access. | 130 // Created lazily on first access. |
| 131 scoped_ptr<ProcessesEventRouter> processes_event_router_; | 131 scoped_ptr<ProcessesEventRouter> processes_event_router_; |
| 132 }; | 132 }; |
| 133 | 133 |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 bool memory_; | 191 bool memory_; |
| 192 #endif | 192 #endif |
| 193 | 193 |
| 194 DECLARE_EXTENSION_FUNCTION("processes.getProcessInfo", | 194 DECLARE_EXTENSION_FUNCTION("processes.getProcessInfo", |
| 195 PROCESSES_GETPROCESSINFO) | 195 PROCESSES_GETPROCESSINFO) |
| 196 }; | 196 }; |
| 197 | 197 |
| 198 } // namespace extensions | 198 } // namespace extensions |
| 199 | 199 |
| 200 #endif // CHROME_BROWSER_EXTENSIONS_API_PROCESSES_PROCESSES_API_H__ | 200 #endif // CHROME_BROWSER_EXTENSIONS_API_PROCESSES_PROCESSES_API_H__ |
| OLD | NEW |