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 #include "chrome/browser/extensions/activity_log/activity_actions.h" | 5 #include "chrome/browser/extensions/activity_log/activity_actions.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/json/json_string_value_serializer.h" | 10 #include "base/json/json_string_value_serializer.h" |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 clone->set_page_url(page_url()); | 68 clone->set_page_url(page_url()); |
69 clone->set_page_title(page_title()); | 69 clone->set_page_title(page_title()); |
70 clone->set_page_incognito(page_incognito()); | 70 clone->set_page_incognito(page_incognito()); |
71 clone->set_arg_url(arg_url()); | 71 clone->set_arg_url(arg_url()); |
72 clone->set_arg_incognito(arg_incognito()); | 72 clone->set_arg_incognito(arg_incognito()); |
73 if (other()) | 73 if (other()) |
74 clone->set_other(make_scoped_ptr(other()->DeepCopy())); | 74 clone->set_other(make_scoped_ptr(other()->DeepCopy())); |
75 return clone; | 75 return clone; |
76 } | 76 } |
77 | 77 |
78 void Action::set_args(scoped_ptr<ListValue> args) { | 78 void Action::set_args(scoped_ptr<base::ListValue> args) { |
79 args_.reset(args.release()); | 79 args_.reset(args.release()); |
80 } | 80 } |
81 | 81 |
82 ListValue* Action::mutable_args() { | 82 base::ListValue* Action::mutable_args() { |
83 if (!args_.get()) { | 83 if (!args_.get()) { |
84 args_.reset(new ListValue()); | 84 args_.reset(new base::ListValue()); |
85 } | 85 } |
86 return args_.get(); | 86 return args_.get(); |
87 } | 87 } |
88 | 88 |
89 void Action::set_page_url(const GURL& page_url) { | 89 void Action::set_page_url(const GURL& page_url) { |
90 page_url_ = page_url; | 90 page_url_ = page_url; |
91 } | 91 } |
92 | 92 |
93 void Action::set_arg_url(const GURL& arg_url) { | 93 void Action::set_arg_url(const GURL& arg_url) { |
94 arg_url_ = arg_url; | 94 arg_url_ = arg_url; |
95 } | 95 } |
96 | 96 |
97 void Action::set_other(scoped_ptr<DictionaryValue> other) { | 97 void Action::set_other(scoped_ptr<base::DictionaryValue> other) { |
98 other_.reset(other.release()); | 98 other_.reset(other.release()); |
99 } | 99 } |
100 | 100 |
101 DictionaryValue* Action::mutable_other() { | 101 base::DictionaryValue* Action::mutable_other() { |
102 if (!other_.get()) { | 102 if (!other_.get()) { |
103 other_.reset(new DictionaryValue()); | 103 other_.reset(new base::DictionaryValue()); |
104 } | 104 } |
105 return other_.get(); | 105 return other_.get(); |
106 } | 106 } |
107 | 107 |
108 std::string Action::SerializePageUrl() const { | 108 std::string Action::SerializePageUrl() const { |
109 return (page_incognito() ? constants::kIncognitoUrl : "") + page_url().spec(); | 109 return (page_incognito() ? constants::kIncognitoUrl : "") + page_url().spec(); |
110 } | 110 } |
111 | 111 |
112 void Action::ParsePageUrl(const std::string& url) { | 112 void Action::ParsePageUrl(const std::string& url) { |
113 set_page_incognito(StartsWithASCII(url, constants::kIncognitoUrl, true)); | 113 set_page_incognito(StartsWithASCII(url, constants::kIncognitoUrl, true)); |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 result->arg_url.reset(new std::string(SerializeArgUrl())); | 177 result->arg_url.reset(new std::string(SerializeArgUrl())); |
178 | 178 |
179 if (other()) { | 179 if (other()) { |
180 scoped_ptr<ExtensionActivity::Other> other_field( | 180 scoped_ptr<ExtensionActivity::Other> other_field( |
181 new ExtensionActivity::Other); | 181 new ExtensionActivity::Other); |
182 bool prerender; | 182 bool prerender; |
183 if (other()->GetBooleanWithoutPathExpansion(constants::kActionPrerender, | 183 if (other()->GetBooleanWithoutPathExpansion(constants::kActionPrerender, |
184 &prerender)) { | 184 &prerender)) { |
185 other_field->prerender.reset(new bool(prerender)); | 185 other_field->prerender.reset(new bool(prerender)); |
186 } | 186 } |
187 const DictionaryValue* web_request; | 187 const base::DictionaryValue* web_request; |
188 if (other()->GetDictionaryWithoutPathExpansion(constants::kActionWebRequest, | 188 if (other()->GetDictionaryWithoutPathExpansion(constants::kActionWebRequest, |
189 &web_request)) { | 189 &web_request)) { |
190 other_field->web_request.reset(new std::string( | 190 other_field->web_request.reset(new std::string( |
191 ActivityLogPolicy::Util::Serialize(web_request))); | 191 ActivityLogPolicy::Util::Serialize(web_request))); |
192 } | 192 } |
193 std::string extra; | 193 std::string extra; |
194 if (other()->GetStringWithoutPathExpansion(constants::kActionExtra, &extra)) | 194 if (other()->GetStringWithoutPathExpansion(constants::kActionExtra, &extra)) |
195 other_field->extra.reset(new std::string(extra)); | 195 other_field->extra.reset(new std::string(extra)); |
196 int dom_verb; | 196 int dom_verb; |
197 if (other()->GetIntegerWithoutPathExpansion(constants::kActionDomVerb, | 197 if (other()->GetIntegerWithoutPathExpansion(constants::kActionDomVerb, |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 if (args_.get()) { | 263 if (args_.get()) { |
264 result += " ARGS=" + Serialize(args_.get()); | 264 result += " ARGS=" + Serialize(args_.get()); |
265 } | 265 } |
266 if (page_url_.is_valid()) { | 266 if (page_url_.is_valid()) { |
267 if (page_incognito_) | 267 if (page_incognito_) |
268 result += " PAGE_URL=(incognito)" + page_url_.spec(); | 268 result += " PAGE_URL=(incognito)" + page_url_.spec(); |
269 else | 269 else |
270 result += " PAGE_URL=" + page_url_.spec(); | 270 result += " PAGE_URL=" + page_url_.spec(); |
271 } | 271 } |
272 if (!page_title_.empty()) { | 272 if (!page_title_.empty()) { |
273 StringValue title(page_title_); | 273 base::StringValue title(page_title_); |
274 result += " PAGE_TITLE=" + Serialize(&title); | 274 result += " PAGE_TITLE=" + Serialize(&title); |
275 } | 275 } |
276 if (arg_url_.is_valid()) { | 276 if (arg_url_.is_valid()) { |
277 if (arg_incognito_) | 277 if (arg_incognito_) |
278 result += " ARG_URL=(incognito)" + arg_url_.spec(); | 278 result += " ARG_URL=(incognito)" + arg_url_.spec(); |
279 else | 279 else |
280 result += " ARG_URL=" + arg_url_.spec(); | 280 result += " ARG_URL=" + arg_url_.spec(); |
281 } | 281 } |
282 if (other_.get()) { | 282 if (other_.get()) { |
283 result += " OTHER=" + Serialize(other_.get()); | 283 result += " OTHER=" + Serialize(other_.get()); |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
343 std::string rhs_other = ActivityLogPolicy::Util::Serialize(rhs->other()); | 343 std::string rhs_other = ActivityLogPolicy::Util::Serialize(rhs->other()); |
344 if (lhs_other != rhs_other) | 344 if (lhs_other != rhs_other) |
345 return lhs_other < rhs_other; | 345 return lhs_other < rhs_other; |
346 } | 346 } |
347 | 347 |
348 // All fields compare as equal if this point is reached. | 348 // All fields compare as equal if this point is reached. |
349 return false; | 349 return false; |
350 } | 350 } |
351 | 351 |
352 } // namespace extensions | 352 } // namespace extensions |
OLD | NEW |