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.
5 #ifndef CHROME_BROWSER_EXTENSIONS_ACTIVITY_LOG_FULLSTREAM_UI_POLICY_H_
6 #define CHROME_BROWSER_EXTENSIONS_ACTIVITY_LOG_FULLSTREAM_UI_POLICY_H_
10 #include "chrome/browser/extensions/activity_log/activity_database.h"
11 #include "chrome/browser/extensions/activity_log/activity_log_policy.h"
15 namespace extensions
{
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.
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.
24 class FullStreamUIPolicy
: public ActivityLogDatabasePolicy
{
26 // For more info about these member functions, see the super class.
27 explicit FullStreamUIPolicy(Profile
* profile
);
29 virtual void ProcessAction(scoped_refptr
<Action
> action
) OVERRIDE
;
31 virtual void ReadFilteredData(
32 const std::string
& extension_id
,
33 const Action::ActionType type
,
34 const std::string
& api_name
,
35 const std::string
& page_url
,
36 const std::string
& arg_url
,
39 <void(scoped_ptr
<Action::ActionVector
>)>& callback
) OVERRIDE
;
41 virtual void Close() OVERRIDE
;
43 // Clean the URL data stored for this policy.
44 virtual void RemoveURLs(const std::vector
<GURL
>& restrict_urls
) OVERRIDE
;
46 // Clean the data related to this extension for this policy.
47 virtual void RemoveExtensionData(const std::string
& extension_id
) OVERRIDE
;
49 // Delete everything in the database.
50 virtual void DeleteDatabase() OVERRIDE
;
52 // Database table schema.
53 static const char* kTableName
;
54 static const char* kTableContentFields
[];
55 static const char* kTableFieldTypes
[];
56 static const int kTableFieldCount
;
59 // Only ever run by OnDatabaseClose() below; see the comments on the
60 // ActivityDatabase class for an overall discussion of how cleanup works.
61 virtual ~FullStreamUIPolicy();
63 // The ActivityDatabase::Delegate interface. These are always called from
64 // the database thread.
65 virtual bool InitDatabase(sql::Connection
* db
) OVERRIDE
;
66 virtual bool FlushDatabase(sql::Connection
* db
) OVERRIDE
;
67 virtual void OnDatabaseFailure() OVERRIDE
;
68 virtual void OnDatabaseClose() OVERRIDE
;
70 // Strips arguments if needed by policy. May return the original object (if
71 // unmodified), or a copy (if modifications were made). The implementation
72 // in FullStreamUIPolicy returns the action unmodified.
73 virtual scoped_refptr
<Action
> ProcessArguments(
74 scoped_refptr
<Action
> action
) const;
76 // The implementation of RemoveURLs; this must only run on the database
78 void DoRemoveURLs(const std::vector
<GURL
>& restrict_urls
);
80 // The implementation of RemoveExtensionData; this must only run on the
82 void DoRemoveExtensionData(const std::string
& extension_id
);
84 // The implementation of DeleteDatabase; this must only run on the database
86 void DoDeleteDatabase();
88 // Tracks any pending updates to be written to the database, if write
89 // batching is turned on. Should only be accessed from the database thread.
90 Action::ActionVector queued_actions_
;
93 // Adds an Action to queued_actions_; this should be invoked only on the
95 void QueueAction(scoped_refptr
<Action
> action
);
97 // Internal method to read data from the database; called on the database
99 scoped_ptr
<Action::ActionVector
> DoReadFilteredData(
100 const std::string
& extension_id
,
101 const Action::ActionType type
,
102 const std::string
& api_name
,
103 const std::string
& page_url
,
104 const std::string
& arg_url
,
108 } // namespace extensions
110 #endif // CHROME_BROWSER_EXTENSIONS_ACTIVITY_LOG_FULLSTREAM_UI_POLICY_H_