OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CHROME_BROWSER_EXTENSIONS_ACTIVITY_LOG_FULLSTREAM_UI_POLICY_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_ACTIVITY_LOG_FULLSTREAM_UI_POLICY_H_ |
| 7 |
| 8 #include <string> |
| 9 #include <vector> |
| 10 #include "chrome/browser/extensions/activity_log/activity_log_policy.h" |
| 11 |
| 12 class GURL; |
| 13 |
| 14 namespace extensions { |
| 15 |
| 16 class ActivityDatabase; |
| 17 |
| 18 // A policy for logging the full stream of actions, including all arguments. |
| 19 // It's mostly intended to be used in testing and analysis. |
| 20 class FullStreamUIPolicy : public ActivityLogPolicy { |
| 21 public: |
| 22 // For more info about these member functions, see the super class. |
| 23 explicit FullStreamUIPolicy(Profile* profile, |
| 24 content::BrowserThread::ID thread_id); |
| 25 |
| 26 virtual ~FullStreamUIPolicy(); |
| 27 |
| 28 virtual void ProcessAction(ActionType action_type, |
| 29 const std::string& extension_id, |
| 30 const std::string& name, const GURL* gurl, |
| 31 const base::ListValue* args, |
| 32 const base::DictionaryValue* details) OVERRIDE; |
| 33 |
| 34 virtual void SaveState() OVERRIDE {} |
| 35 |
| 36 // TODO(felt,dbabic) This is overly specific to FullStreamUIPolicy. |
| 37 // It assumes that the callback can return a sorted vector of actions. Some |
| 38 // policies might not do that. For instance, imagine a trivial policy that |
| 39 // just counts the frequency of certain actions within some time period, |
| 40 // this call would be meaningless, as it couldn't return anything useful. |
| 41 virtual void ReadData( |
| 42 const std::string& extension_id, |
| 43 const int day, |
| 44 const base::Callback |
| 45 <void(scoped_ptr<std::vector<scoped_refptr<Action> > >)>& callback) |
| 46 const OVERRIDE; |
| 47 |
| 48 virtual void SetSaveStateOnRequestOnly() OVERRIDE; |
| 49 |
| 50 // Returns the actual key for a given key type |
| 51 virtual void GetKey(ActivityLogPolicy::KeyType key_id, |
| 52 std::string* key_string) const OVERRIDE; |
| 53 |
| 54 protected: |
| 55 // Concatenates arguments |
| 56 virtual void ProcessArguments(ActionType action_type, |
| 57 const std::string& name, |
| 58 const base::ListValue* args, |
| 59 std::string* args_string) const; |
| 60 |
| 61 virtual void ProcessWebRequestModifications( |
| 62 base::DictionaryValue& details, |
| 63 std::string& details_string) const; |
| 64 |
| 65 // We initialize this on the same thread as the ActivityLog and policy, but |
| 66 // then subsequent operations occur on the DB thread. Instead of destructing |
| 67 // the ActivityDatabase, we call its Close() method on the DB thread and it |
| 68 // commits suicide. |
| 69 ActivityDatabase* db_; |
| 70 }; |
| 71 |
| 72 } // namespace extensions |
| 73 |
| 74 #endif // CHROME_BROWSER_EXTENSIONS_ACTIVITY_LOG_FULLSTREAM_UI_POLICY_H_ |
OLD | NEW |