Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(529)

Side by Side Diff: chrome/browser/extensions/activity_log/activity_log.h

Issue 155183002: Add ApiActivityMonitor to decouple ActivityLog from low-level extensions code (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase3 (activity_log) Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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_ACTIVITY_LOG_ACTIVITY_LOG_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_ACTIVITY_LOG_ACTIVITY_LOG_H_
6 #define CHROME_BROWSER_EXTENSIONS_ACTIVITY_LOG_ACTIVITY_LOG_H_ 6 #define CHROME_BROWSER_EXTENSIONS_ACTIVITY_LOG_ACTIVITY_LOG_H_
7 7
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/callback.h" 12 #include "base/callback.h"
13 #include "base/memory/singleton.h" 13 #include "base/memory/singleton.h"
14 #include "base/observer_list_threadsafe.h" 14 #include "base/observer_list_threadsafe.h"
15 #include "base/synchronization/lock.h" 15 #include "base/synchronization/lock.h"
16 #include "base/threading/thread.h" 16 #include "base/threading/thread.h"
17 #include "chrome/browser/extensions/activity_log/activity_actions.h" 17 #include "chrome/browser/extensions/activity_log/activity_actions.h"
18 #include "chrome/browser/extensions/activity_log/activity_database.h"
19 #include "chrome/browser/extensions/activity_log/activity_log_policy.h" 18 #include "chrome/browser/extensions/activity_log/activity_log_policy.h"
20 #include "chrome/browser/extensions/install_observer.h" 19 #include "chrome/browser/extensions/install_observer.h"
21 #include "chrome/browser/extensions/install_tracker.h"
22 #include "chrome/browser/extensions/tab_helper.h" 20 #include "chrome/browser/extensions/tab_helper.h"
23 #include "chrome/browser/profiles/profile.h"
24 #include "chrome/common/extensions/dom_action_types.h" 21 #include "chrome/common/extensions/dom_action_types.h"
25 #include "components/browser_context_keyed_service/browser_context_keyed_service .h" 22 #include "components/browser_context_keyed_service/browser_context_keyed_service .h"
26 #include "components/browser_context_keyed_service/browser_context_keyed_service _factory.h" 23 #include "components/browser_context_keyed_service/browser_context_keyed_service _factory.h"
27 #include "extensions/browser/event_router.h" 24 #include "extensions/browser/api_activity_monitor.h"
28 25
29 class Profile; 26 class Profile;
30 using content::BrowserThread;
31 27
32 namespace content { 28 namespace content {
33 class BrowserContext; 29 class BrowserContext;
34 } 30 }
35 31
36 namespace user_prefs { 32 namespace user_prefs {
37 class PrefRegistrySyncable; 33 class PrefRegistrySyncable;
38 } 34 }
39 35
40 namespace extensions { 36 namespace extensions {
41 class Extension; 37 class Extension;
42 class ActivityLogPolicy; 38 class InstallTracker;
43 39
44 // A utility for tracing interesting activity for each extension. 40 // A utility for tracing interesting activity for each extension.
45 // It writes to an ActivityDatabase on a separate thread to record the activity. 41 // It writes to an ActivityDatabase on a separate thread to record the activity.
46 class ActivityLog : public BrowserContextKeyedService, 42 class ActivityLog : public BrowserContextKeyedService,
47 public EventRouter::EventDispatchObserver, 43 public ApiActivityMonitor,
48 public TabHelper::ScriptExecutionObserver, 44 public TabHelper::ScriptExecutionObserver,
49 public InstallObserver { 45 public InstallObserver {
50 public: 46 public:
51 // Observers can listen for activity events. There is probably only one 47 // Observers can listen for activity events. There is probably only one
52 // observer: the activityLogPrivate API. 48 // observer: the activityLogPrivate API.
53 class Observer { 49 class Observer {
54 public: 50 public:
55 virtual void OnExtensionActivity(scoped_refptr<Action> activity) = 0; 51 virtual void OnExtensionActivity(scoped_refptr<Action> activity) = 0;
56 }; 52 };
57 53
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 virtual void OnBeginExtensionInstall( 90 virtual void OnBeginExtensionInstall(
95 const ExtensionInstallParams& params) OVERRIDE {} 91 const ExtensionInstallParams& params) OVERRIDE {}
96 virtual void OnDownloadProgress(const std::string& extension_id, 92 virtual void OnDownloadProgress(const std::string& extension_id,
97 int percent_downloaded) OVERRIDE {} 93 int percent_downloaded) OVERRIDE {}
98 virtual void OnInstallFailure(const std::string& extension_id) OVERRIDE {} 94 virtual void OnInstallFailure(const std::string& extension_id) OVERRIDE {}
99 virtual void OnAppsReordered() OVERRIDE {} 95 virtual void OnAppsReordered() OVERRIDE {}
100 virtual void OnAppInstalledToAppList( 96 virtual void OnAppInstalledToAppList(
101 const std::string& extension_id) OVERRIDE {} 97 const std::string& extension_id) OVERRIDE {}
102 virtual void OnShutdown() OVERRIDE {} 98 virtual void OnShutdown() OVERRIDE {}
103 99
104 // EventRouter::EventDispatchObserver 100 // ApiActivityMonitor
105 virtual void OnWillDispatchEvent(scoped_ptr<EventDispatchInfo> details) 101 virtual void OnApiEventDispatched(
106 OVERRIDE; 102 const std::string& extension_id,
103 const std::string& event_name,
104 scoped_ptr<base::ListValue> event_args) OVERRIDE;
105 virtual void OnApiFunctionCalled(
106 const std::string& extension_id,
107 const std::string& api_name,
108 scoped_ptr<base::ListValue> event_args) OVERRIDE;
107 109
108 // BrowserContextKeyedService 110 // BrowserContextKeyedService
109 virtual void Shutdown() OVERRIDE; 111 virtual void Shutdown() OVERRIDE;
110 112
111 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); 113 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry);
112 114
113 // Clean up URLs from the activity log database. 115 // Clean up URLs from the activity log database.
114 // If restrict_urls is empty then all URLs in the activity log database are 116 // If restrict_urls is empty then all URLs in the activity log database are
115 // removed, otherwise only those in restrict_urls are removed. 117 // removed, otherwise only those in restrict_urls are removed.
116 void RemoveURLs(const std::vector<GURL>& restrict_urls); 118 void RemoveURLs(const std::vector<GURL>& restrict_urls);
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 virtual content::BrowserContext* GetBrowserContextToUse( 233 virtual content::BrowserContext* GetBrowserContextToUse(
232 content::BrowserContext* context) const OVERRIDE; 234 content::BrowserContext* context) const OVERRIDE;
233 235
234 DISALLOW_COPY_AND_ASSIGN(ActivityLogFactory); 236 DISALLOW_COPY_AND_ASSIGN(ActivityLogFactory);
235 }; 237 };
236 238
237 239
238 } // namespace extensions 240 } // namespace extensions
239 241
240 #endif // CHROME_BROWSER_EXTENSIONS_ACTIVITY_LOG_ACTIVITY_LOG_H_ 242 #endif // CHROME_BROWSER_EXTENSIONS_ACTIVITY_LOG_ACTIVITY_LOG_H_
OLDNEW
« no previous file with comments | « chrome/browser/extensions/activity_log/activity_database.h ('k') | chrome/browser/extensions/activity_log/activity_log.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698