| 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 #ifndef CHROME_BROWSER_EXTENSIONS_ACTIVITY_LOG_FULLSTREAM_UI_POLICY_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_ACTIVITY_LOG_FULLSTREAM_UI_POLICY_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_ACTIVITY_LOG_FULLSTREAM_UI_POLICY_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_ACTIVITY_LOG_FULLSTREAM_UI_POLICY_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "chrome/browser/extensions/activity_log/activity_database.h" | 10 #include "chrome/browser/extensions/activity_log/activity_database.h" |
| 11 #include "chrome/browser/extensions/activity_log/activity_log_policy.h" | 11 #include "chrome/browser/extensions/activity_log/activity_log_policy.h" |
| 12 | 12 |
| 13 class GURL; | 13 class GURL; |
| 14 | 14 |
| 15 namespace extensions { | 15 namespace extensions { |
| 16 | 16 |
| 17 // A policy for logging the full stream of actions, including all arguments. | 17 // A policy for logging the full stream of actions, including all arguments. |
| 18 // It's mostly intended to be used in testing and analysis. | 18 // It's mostly intended to be used in testing and analysis. |
| 19 // |
| 20 // NOTE: The FullStreamUIPolicy deliberately keeps almost all information, |
| 21 // including some data that could be privacy sensitive (full URLs including |
| 22 // incognito URLs, full headers when WebRequest is used, etc.). It should not |
| 23 // be used during normal browsing if users care about privacy. |
| 19 class FullStreamUIPolicy : public ActivityLogDatabasePolicy { | 24 class FullStreamUIPolicy : public ActivityLogDatabasePolicy { |
| 20 public: | 25 public: |
| 21 // For more info about these member functions, see the super class. | 26 // For more info about these member functions, see the super class. |
| 22 explicit FullStreamUIPolicy(Profile* profile); | 27 explicit FullStreamUIPolicy(Profile* profile); |
| 23 | 28 |
| 24 virtual void ProcessAction(scoped_refptr<Action> action) OVERRIDE; | 29 virtual void ProcessAction(scoped_refptr<Action> action) OVERRIDE; |
| 25 | 30 |
| 26 // TODO(felt,dbabic) This is overly specific to FullStreamUIPolicy. | 31 // TODO(felt,dbabic) This is overly specific to FullStreamUIPolicy. |
| 27 // It assumes that the callback can return a sorted vector of actions. Some | 32 // It assumes that the callback can return a sorted vector of actions. Some |
| 28 // policies might not do that. For instance, imagine a trivial policy that | 33 // policies might not do that. For instance, imagine a trivial policy that |
| 29 // just counts the frequency of certain actions within some time period, | 34 // just counts the frequency of certain actions within some time period, |
| 30 // this call would be meaningless, as it couldn't return anything useful. | 35 // this call would be meaningless, as it couldn't return anything useful. |
| 31 virtual void ReadData( | 36 virtual void ReadData( |
| 32 const std::string& extension_id, | 37 const std::string& extension_id, |
| 33 const int day, | 38 const int day, |
| 34 const base::Callback | 39 const base::Callback |
| 35 <void(scoped_ptr<Action::ActionVector>)>& callback) OVERRIDE; | 40 <void(scoped_ptr<Action::ActionVector>)>& callback) OVERRIDE; |
| 36 | 41 |
| 37 // Returns the actual key for a given key type | |
| 38 virtual std::string GetKey(ActivityLogPolicy::KeyType key_id) const OVERRIDE; | |
| 39 | |
| 40 virtual void Close() OVERRIDE; | 42 virtual void Close() OVERRIDE; |
| 41 | 43 |
| 42 // Database table schema. | 44 // Database table schema. |
| 43 static const char* kTableName; | 45 static const char* kTableName; |
| 44 static const char* kTableContentFields[]; | 46 static const char* kTableContentFields[]; |
| 45 static const char* kTableFieldTypes[]; | 47 static const char* kTableFieldTypes[]; |
| 46 static const int kTableFieldCount; | 48 static const int kTableFieldCount; |
| 47 | 49 |
| 48 protected: | 50 protected: |
| 49 // Only ever run by OnDatabaseClose() below; see the comments on the | 51 // Only ever run by OnDatabaseClose() below; see the comments on the |
| 50 // ActivityDatabase class for an overall discussion of how cleanup works. | 52 // ActivityDatabase class for an overall discussion of how cleanup works. |
| 51 virtual ~FullStreamUIPolicy(); | 53 virtual ~FullStreamUIPolicy(); |
| 52 | 54 |
| 53 // The ActivityDatabase::PolicyDelegate interface. These are always called | 55 // The ActivityDatabase::Delegate interface. These are always called from |
| 54 // from the database thread. | 56 // the database thread. |
| 55 virtual bool InitDatabase(sql::Connection* db) OVERRIDE; | 57 virtual bool InitDatabase(sql::Connection* db) OVERRIDE; |
| 56 virtual bool FlushDatabase(sql::Connection* db) OVERRIDE; | 58 virtual bool FlushDatabase(sql::Connection* db) OVERRIDE; |
| 57 virtual void OnDatabaseFailure() OVERRIDE; | 59 virtual void OnDatabaseFailure() OVERRIDE; |
| 58 virtual void OnDatabaseClose() OVERRIDE; | 60 virtual void OnDatabaseClose() OVERRIDE; |
| 59 | 61 |
| 60 // Strips arguments if needed by policy. May return the original object (if | 62 // Strips arguments if needed by policy. May return the original object (if |
| 61 // unmodified), or a copy (if modifications were made). The implementation | 63 // unmodified), or a copy (if modifications were made). The implementation |
| 62 // in FullStreamUIPolicy returns the action unmodified. | 64 // in FullStreamUIPolicy returns the action unmodified. |
| 63 virtual scoped_refptr<Action> ProcessArguments( | 65 virtual scoped_refptr<Action> ProcessArguments( |
| 64 scoped_refptr<Action> action) const; | 66 scoped_refptr<Action> action) const; |
| 65 | 67 |
| 66 // Tracks any pending updates to be written to the database, if write | 68 // Tracks any pending updates to be written to the database, if write |
| 67 // batching is turned on. Should only be accessed from the database thread. | 69 // batching is turned on. Should only be accessed from the database thread. |
| 68 Action::ActionVector queued_actions_; | 70 Action::ActionVector queued_actions_; |
| 69 | 71 |
| 70 private: | 72 private: |
| 71 // Adds an Action to queued_actions_; this should be invoked only on the | 73 // Adds an Action to queued_actions_; this should be invoked only on the |
| 72 // database thread. | 74 // database thread. |
| 73 void QueueAction(scoped_refptr<Action> action); | 75 void QueueAction(scoped_refptr<Action> action); |
| 74 | 76 |
| 75 // The implementation of ReadData; this must only run on the database thread. | 77 // The implementation of ReadData; this must only run on the database thread. |
| 76 scoped_ptr<Action::ActionVector> DoReadData(const std::string& extension_id, | 78 scoped_ptr<Action::ActionVector> DoReadData(const std::string& extension_id, |
| 77 const int days_ago); | 79 const int days_ago); |
| 78 }; | 80 }; |
| 79 | 81 |
| 80 } // namespace extensions | 82 } // namespace extensions |
| 81 | 83 |
| 82 #endif // CHROME_BROWSER_EXTENSIONS_ACTIVITY_LOG_FULLSTREAM_UI_POLICY_H_ | 84 #endif // CHROME_BROWSER_EXTENSIONS_ACTIVITY_LOG_FULLSTREAM_UI_POLICY_H_ |
| OLD | NEW |