Chromium Code Reviews| 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_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" | 18 #include "chrome/browser/extensions/activity_log/activity_database.h" |
| 19 #include "chrome/browser/extensions/activity_log/activity_log_policy.h" | 19 #include "chrome/browser/extensions/activity_log/activity_log_policy.h" |
| 20 #include "chrome/browser/extensions/activity_log/api_actions.h" | |
| 21 #include "chrome/browser/extensions/install_observer.h" | 20 #include "chrome/browser/extensions/install_observer.h" |
| 22 #include "chrome/browser/extensions/install_tracker.h" | 21 #include "chrome/browser/extensions/install_tracker.h" |
| 23 #include "chrome/browser/extensions/tab_helper.h" | 22 #include "chrome/browser/extensions/tab_helper.h" |
| 24 #include "chrome/browser/profiles/profile.h" | 23 #include "chrome/browser/profiles/profile.h" |
| 25 #include "chrome/common/extensions/dom_action_types.h" | 24 #include "chrome/common/extensions/dom_action_types.h" |
| 26 #include "components/browser_context_keyed_service/browser_context_dependency_ma nager.h" | 25 #include "components/browser_context_keyed_service/browser_context_dependency_ma nager.h" |
| 27 #include "components/browser_context_keyed_service/browser_context_keyed_service .h" | 26 #include "components/browser_context_keyed_service/browser_context_keyed_service .h" |
| 28 #include "components/browser_context_keyed_service/browser_context_keyed_service _factory.h" | 27 #include "components/browser_context_keyed_service/browser_context_keyed_service _factory.h" |
| 29 | 28 |
| 30 class Profile; | 29 class Profile; |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 59 // If you want to know whether the log is enabled but DON'T have a profile | 58 // If you want to know whether the log is enabled but DON'T have a profile |
| 60 // object yet, use this method. However, it's preferable for the caller to | 59 // object yet, use this method. However, it's preferable for the caller to |
| 61 // use IsLogEnabled when possible. | 60 // use IsLogEnabled when possible. |
| 62 static bool IsLogEnabledOnAnyProfile(); | 61 static bool IsLogEnabledOnAnyProfile(); |
| 63 | 62 |
| 64 // Add/remove observer: the activityLogPrivate API only listens when the | 63 // Add/remove observer: the activityLogPrivate API only listens when the |
| 65 // ActivityLog extension is registered for an event. | 64 // ActivityLog extension is registered for an event. |
| 66 void AddObserver(Observer* observer); | 65 void AddObserver(Observer* observer); |
| 67 void RemoveObserver(Observer* observer); | 66 void RemoveObserver(Observer* observer); |
| 68 | 67 |
| 68 // Logs an extension action: passes it to any installed policy to be logged | |
| 69 // to the database, to any observers, and logs to the console if in testing | |
| 70 // mode. | |
| 71 // | |
| 72 // The convenience Log*Action methods below can be used as well if the caller | |
| 73 // does not which to construct the Action object itself, however those | |
|
felt
2013/07/23 17:07:17
*does not wish
mvrable
2013/07/23 18:16:56
Done.
| |
| 74 // methods are somewhat deprecated. | |
| 75 void LogAction(scoped_refptr<Action> action); | |
|
felt
2013/07/23 17:07:17
I'm not entirely sure how I feel about forcing the
mvrable
2013/07/23 18:16:56
I haven't noticed cases where the caller wouldn't
felt
2013/07/23 19:06:33
Well, I'm worried about a few things, another one
mvrable
2013/07/23 19:17:55
The current plan is to keep URL scanning through t
felt
2013/07/23 19:22:33
Ah, OK. I am happy with this plan, where the objec
felt
2013/07/23 19:22:33
We want to send along incognito URLs to the API an
mvrable
2013/07/23 21:54:03
I think this answers my question. I think we don'
| |
| 76 | |
| 77 // TODO(mvrable): The calls below take args as a raw pointer Document the | |
| 78 // ownership transfer: either make it const or a scoped_ptr. | |
|
felt
2013/07/23 17:07:17
I'm confused, maybe there is a word missing in thi
mvrable
2013/07/23 18:16:56
Reworded. I understand the code a bit better sinc
| |
| 79 | |
| 69 // Log a successful API call made by an extension. | 80 // Log a successful API call made by an extension. |
| 70 // This will create an APIAction for storage in the database. | 81 // This will create an APIAction for storage in the database. |
| 71 // (Note: implemented as a wrapper for LogAPIActionInternal.) | 82 // (Note: implemented as a wrapper for LogAPIActionInternal.) |
| 72 void LogAPIAction(const std::string& extension_id, | 83 void LogAPIAction(const std::string& extension_id, |
| 73 const std::string& name, // e.g., tabs.get | 84 const std::string& name, // e.g., tabs.get |
| 74 base::ListValue* args, // the argument values e.g. 46 | 85 base::ListValue* args, // the argument values e.g. 46 |
| 75 const std::string& extra); // any extra logging info | 86 const std::string& extra); // any extra logging info |
| 76 | 87 |
| 77 // Log an event notification delivered to an extension. | 88 // Log an event notification delivered to an extension. |
| 78 // This will create an APIAction for storage in the database. | 89 // This will create an APIAction for storage in the database. |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 241 virtual content::BrowserContext* GetBrowserContextToUse( | 252 virtual content::BrowserContext* GetBrowserContextToUse( |
| 242 content::BrowserContext* context) const OVERRIDE; | 253 content::BrowserContext* context) const OVERRIDE; |
| 243 | 254 |
| 244 DISALLOW_COPY_AND_ASSIGN(ActivityLogFactory); | 255 DISALLOW_COPY_AND_ASSIGN(ActivityLogFactory); |
| 245 }; | 256 }; |
| 246 | 257 |
| 247 | 258 |
| 248 } // namespace extensions | 259 } // namespace extensions |
| 249 | 260 |
| 250 #endif // CHROME_BROWSER_EXTENSIONS_ACTIVITY_LOG_ACTIVITY_LOG_H_ | 261 #endif // CHROME_BROWSER_EXTENSIONS_ACTIVITY_LOG_ACTIVITY_LOG_H_ |
| OLD | NEW |