OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 // This extension API provides access to the Activity Log, which is a | 5 // This extension API provides access to the Activity Log, which is a |
6 // monitoring framework for extension behavior. Only specific Google-produced | 6 // monitoring framework for extension behavior. Only specific Google-produced |
7 // extensions should have access to it. | 7 // extensions should have access to it. |
8 | 8 |
9 #ifndef CHROME_BROWSER_EXTENSIONS_API_ACTIVITY_LOG_PRIVATE_ACTIVITY_LOG_PRIVATE_
API_H_ | 9 #ifndef CHROME_BROWSER_EXTENSIONS_API_ACTIVITY_LOG_PRIVATE_ACTIVITY_LOG_PRIVATE_
API_H_ |
10 #define CHROME_BROWSER_EXTENSIONS_API_ACTIVITY_LOG_PRIVATE_ACTIVITY_LOG_PRIVATE_
API_H_ | 10 #define CHROME_BROWSER_EXTENSIONS_API_ACTIVITY_LOG_PRIVATE_ACTIVITY_LOG_PRIVATE_
API_H_ |
11 | 11 |
12 #include "base/synchronization/lock.h" | 12 #include "base/synchronization/lock.h" |
13 #include "chrome/browser/extensions/activity_log/activity_actions.h" | 13 #include "chrome/browser/extensions/activity_log/activity_actions.h" |
14 #include "chrome/browser/extensions/activity_log/activity_log.h" | 14 #include "chrome/browser/extensions/activity_log/activity_log.h" |
15 #include "chrome/browser/extensions/api/profile_keyed_api_factory.h" | 15 #include "chrome/browser/extensions/api/profile_keyed_api_factory.h" |
16 #include "chrome/browser/extensions/chrome_extension_function.h" | 16 #include "chrome/browser/extensions/chrome_extension_function.h" |
17 #include "extensions/browser/event_router.h" | 17 #include "extensions/browser/event_router.h" |
18 | 18 |
19 namespace extensions { | 19 namespace extensions { |
20 | 20 |
21 class ActivityLog; | 21 class ActivityLog; |
22 | 22 |
23 // Handles interactions between the Activity Log API and implementation. | 23 // Handles interactions between the Activity Log API and implementation. |
24 class ActivityLogAPI : public ProfileKeyedAPI, | 24 class ActivityLogAPI : public ProfileKeyedAPI, |
25 public extensions::ActivityLog::Observer, | 25 public extensions::ActivityLog::Observer, |
26 public EventRouter::Observer { | 26 public EventRouter::Observer { |
27 public: | 27 public: |
28 explicit ActivityLogAPI(Profile* profile); | 28 explicit ActivityLogAPI(content::BrowserContext* context); |
29 virtual ~ActivityLogAPI(); | 29 virtual ~ActivityLogAPI(); |
30 | 30 |
31 // ProfileKeyedAPI implementation. | 31 // ProfileKeyedAPI implementation. |
32 static ProfileKeyedAPIFactory<ActivityLogAPI>* GetFactoryInstance(); | 32 static ProfileKeyedAPIFactory<ActivityLogAPI>* GetFactoryInstance(); |
33 | 33 |
34 virtual void Shutdown() OVERRIDE; | 34 virtual void Shutdown() OVERRIDE; |
35 | 35 |
36 // Lookup whether the extension ID is whitelisted. | 36 // Lookup whether the extension ID is whitelisted. |
37 static bool IsExtensionWhitelisted(const std::string& extension_id); | 37 static bool IsExtensionWhitelisted(const std::string& extension_id); |
38 | 38 |
39 private: | 39 private: |
40 friend class ProfileKeyedAPIFactory<ActivityLogAPI>; | 40 friend class ProfileKeyedAPIFactory<ActivityLogAPI>; |
41 static const char* service_name() { return "ActivityLogPrivateAPI"; } | 41 static const char* service_name() { return "ActivityLogPrivateAPI"; } |
42 | 42 |
43 // ActivityLog::Observer | 43 // ActivityLog::Observer |
44 // We pass this along to activityLogPrivate.onExtensionActivity. | 44 // We pass this along to activityLogPrivate.onExtensionActivity. |
45 virtual void OnExtensionActivity(scoped_refptr<Action> activity) OVERRIDE; | 45 virtual void OnExtensionActivity(scoped_refptr<Action> activity) OVERRIDE; |
46 | 46 |
47 // EventRouter::Observer | 47 // EventRouter::Observer |
48 // We only keep track of OnExtensionActivity if we have any listeners. | 48 // We only keep track of OnExtensionActivity if we have any listeners. |
49 virtual void OnListenerAdded(const EventListenerInfo& details) OVERRIDE; | 49 virtual void OnListenerAdded(const EventListenerInfo& details) OVERRIDE; |
50 virtual void OnListenerRemoved(const EventListenerInfo& details) OVERRIDE; | 50 virtual void OnListenerRemoved(const EventListenerInfo& details) OVERRIDE; |
51 | 51 |
52 Profile* profile_; | 52 content::BrowserContext* browser_context_; |
53 ActivityLog* activity_log_; | 53 ActivityLog* activity_log_; |
54 bool initialized_; | 54 bool initialized_; |
55 | 55 |
56 DISALLOW_COPY_AND_ASSIGN(ActivityLogAPI); | 56 DISALLOW_COPY_AND_ASSIGN(ActivityLogAPI); |
57 }; | 57 }; |
58 | 58 |
59 template<> | 59 template<> |
60 void ProfileKeyedAPIFactory<ActivityLogAPI>::DeclareFactoryDependencies(); | 60 void ProfileKeyedAPIFactory<ActivityLogAPI>::DeclareFactoryDependencies(); |
61 | 61 |
62 // The implementation of activityLogPrivate.getExtensionActivities | 62 // The implementation of activityLogPrivate.getExtensionActivities |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 protected: | 115 protected: |
116 virtual ~ActivityLogPrivateDeleteUrlsFunction() {} | 116 virtual ~ActivityLogPrivateDeleteUrlsFunction() {} |
117 | 117 |
118 // ExtensionFunction: | 118 // ExtensionFunction: |
119 virtual bool RunImpl() OVERRIDE; | 119 virtual bool RunImpl() OVERRIDE; |
120 }; | 120 }; |
121 | 121 |
122 } // namespace extensions | 122 } // namespace extensions |
123 | 123 |
124 #endif // CHROME_BROWSER_EXTENSIONS_API_ACTIVITY_LOG_PRIVATE_ACTIVITY_LOG_PRIVA
TE_API_H_ | 124 #endif // CHROME_BROWSER_EXTENSIONS_API_ACTIVITY_LOG_PRIVATE_ACTIVITY_LOG_PRIVA
TE_API_H_ |
OLD | NEW |