OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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_ACTIVITY_ACTIONS_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_ACTIVITY_LOG_ACTIVITY_ACTIONS_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_ACTIVITY_LOG_ACTIVITY_ACTIONS_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_ACTIVITY_LOG_ACTIVITY_ACTIONS_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 | 65 |
66 // The specific API call used or accessed, for example "chrome.tabs.get". | 66 // The specific API call used or accessed, for example "chrome.tabs.get". |
67 const std::string& api_name() const { return api_name_; } | 67 const std::string& api_name() const { return api_name_; } |
68 void set_api_name(const std::string api_name) { api_name_ = api_name; } | 68 void set_api_name(const std::string api_name) { api_name_ = api_name; } |
69 | 69 |
70 // Any applicable arguments. This might be null to indicate no data | 70 // Any applicable arguments. This might be null to indicate no data |
71 // available (a distinct condition from an empty argument list). | 71 // available (a distinct condition from an empty argument list). |
72 // mutable_args() returns a pointer to the list stored in the Action which | 72 // mutable_args() returns a pointer to the list stored in the Action which |
73 // can be modified in place; if the list was null an empty list is created | 73 // can be modified in place; if the list was null an empty list is created |
74 // first. | 74 // first. |
75 const ListValue* args() const { return args_.get(); } | 75 const base::ListValue* args() const { return args_.get(); } |
76 void set_args(scoped_ptr<ListValue> args); | 76 void set_args(scoped_ptr<base::ListValue> args); |
77 ListValue* mutable_args(); | 77 base::ListValue* mutable_args(); |
78 | 78 |
79 // The URL of the page which was modified or accessed. | 79 // The URL of the page which was modified or accessed. |
80 const GURL& page_url() const { return page_url_; } | 80 const GURL& page_url() const { return page_url_; } |
81 void set_page_url(const GURL& page_url); | 81 void set_page_url(const GURL& page_url); |
82 | 82 |
83 // The title of the above page if available. | 83 // The title of the above page if available. |
84 const std::string& page_title() const { return page_title_; } | 84 const std::string& page_title() const { return page_title_; } |
85 void set_page_title(const std::string& title) { page_title_ = title; } | 85 void set_page_title(const std::string& title) { page_title_ = title; } |
86 | 86 |
87 // A URL which appears in the arguments of the API call, if present. | 87 // A URL which appears in the arguments of the API call, if present. |
88 const GURL& arg_url() const { return arg_url_; } | 88 const GURL& arg_url() const { return arg_url_; } |
89 void set_arg_url(const GURL& arg_url); | 89 void set_arg_url(const GURL& arg_url); |
90 | 90 |
91 // Get or set a flag indicating whether the page or argument values above | 91 // Get or set a flag indicating whether the page or argument values above |
92 // refer to incognito pages. | 92 // refer to incognito pages. |
93 bool page_incognito() const { return page_incognito_; } | 93 bool page_incognito() const { return page_incognito_; } |
94 void set_page_incognito(bool incognito) { page_incognito_ = incognito; } | 94 void set_page_incognito(bool incognito) { page_incognito_ = incognito; } |
95 bool arg_incognito() const { return arg_incognito_; } | 95 bool arg_incognito() const { return arg_incognito_; } |
96 void set_arg_incognito(bool incognito) { arg_incognito_ = incognito; } | 96 void set_arg_incognito(bool incognito) { arg_incognito_ = incognito; } |
97 | 97 |
98 // A dictionary where any additional data can be stored. | 98 // A dictionary where any additional data can be stored. |
99 const DictionaryValue* other() const { return other_.get(); } | 99 const base::DictionaryValue* other() const { return other_.get(); } |
100 void set_other(scoped_ptr<DictionaryValue> other); | 100 void set_other(scoped_ptr<base::DictionaryValue> other); |
101 DictionaryValue* mutable_other(); | 101 base::DictionaryValue* mutable_other(); |
102 | 102 |
103 // Helper methods for serializing and deserializing URLs into strings. If | 103 // Helper methods for serializing and deserializing URLs into strings. If |
104 // the URL is marked as incognito, then the string is prefixed with | 104 // the URL is marked as incognito, then the string is prefixed with |
105 // kIncognitoUrl ("<incognito>"). | 105 // kIncognitoUrl ("<incognito>"). |
106 std::string SerializePageUrl() const; | 106 std::string SerializePageUrl() const; |
107 void ParsePageUrl(const std::string& url); | 107 void ParsePageUrl(const std::string& url); |
108 std::string SerializeArgUrl() const; | 108 std::string SerializeArgUrl() const; |
109 void ParseArgUrl(const std::string& url); | 109 void ParseArgUrl(const std::string& url); |
110 | 110 |
111 // Number of merged records for this action. | 111 // Number of merged records for this action. |
(...skipping 10 matching lines...) Expand all Loading... |
122 protected: | 122 protected: |
123 virtual ~Action(); | 123 virtual ~Action(); |
124 | 124 |
125 private: | 125 private: |
126 friend class base::RefCountedThreadSafe<Action>; | 126 friend class base::RefCountedThreadSafe<Action>; |
127 | 127 |
128 std::string extension_id_; | 128 std::string extension_id_; |
129 base::Time time_; | 129 base::Time time_; |
130 ActionType action_type_; | 130 ActionType action_type_; |
131 std::string api_name_; | 131 std::string api_name_; |
132 scoped_ptr<ListValue> args_; | 132 scoped_ptr<base::ListValue> args_; |
133 GURL page_url_; | 133 GURL page_url_; |
134 std::string page_title_; | 134 std::string page_title_; |
135 bool page_incognito_; | 135 bool page_incognito_; |
136 GURL arg_url_; | 136 GURL arg_url_; |
137 bool arg_incognito_; | 137 bool arg_incognito_; |
138 scoped_ptr<DictionaryValue> other_; | 138 scoped_ptr<base::DictionaryValue> other_; |
139 int count_; | 139 int count_; |
140 | 140 |
141 DISALLOW_COPY_AND_ASSIGN(Action); | 141 DISALLOW_COPY_AND_ASSIGN(Action); |
142 }; | 142 }; |
143 | 143 |
144 // A comparator for Action class objects; this performs a lexicographic | 144 // A comparator for Action class objects; this performs a lexicographic |
145 // comparison of the fields of the Action object (in an unspecfied order). | 145 // comparison of the fields of the Action object (in an unspecfied order). |
146 // This can be used to use Action objects as keys in STL containers. | 146 // This can be used to use Action objects as keys in STL containers. |
147 struct ActionComparator { | 147 struct ActionComparator { |
148 // Evaluates the comparison lhs < rhs. | 148 // Evaluates the comparison lhs < rhs. |
149 bool operator()(const scoped_refptr<Action>& lhs, | 149 bool operator()(const scoped_refptr<Action>& lhs, |
150 const scoped_refptr<Action>& rhs) const; | 150 const scoped_refptr<Action>& rhs) const; |
151 }; | 151 }; |
152 | 152 |
153 // Like ActionComparator, but ignores the time field in comparisons. | 153 // Like ActionComparator, but ignores the time field in comparisons. |
154 struct ActionComparatorExcludingTime { | 154 struct ActionComparatorExcludingTime { |
155 // Evaluates the comparison lhs < rhs. | 155 // Evaluates the comparison lhs < rhs. |
156 bool operator()(const scoped_refptr<Action>& lhs, | 156 bool operator()(const scoped_refptr<Action>& lhs, |
157 const scoped_refptr<Action>& rhs) const; | 157 const scoped_refptr<Action>& rhs) const; |
158 }; | 158 }; |
159 | 159 |
160 } // namespace extensions | 160 } // namespace extensions |
161 | 161 |
162 #endif // CHROME_BROWSER_EXTENSIONS_ACTIVITY_LOG_ACTIVITY_ACTIONS_H_ | 162 #endif // CHROME_BROWSER_EXTENSIONS_ACTIVITY_LOG_ACTIVITY_ACTIONS_H_ |
OLD | NEW |