Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1071)

Side by Side Diff: chrome/browser/extensions/activity_log/activity_actions.cc

Issue 1055673002: [Extensions API] Remove inline enums (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Latest master Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <algorithm> // for std::find. 7 #include <algorithm> // for std::find.
8 #include <string> 8 #include <string>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 13 matching lines...) Expand all
24 #include "chrome/browser/ui/browser.h" 24 #include "chrome/browser/ui/browser.h"
25 #include "chrome/common/chrome_switches.h" 25 #include "chrome/common/chrome_switches.h"
26 #include "components/rappor/rappor_service.h" 26 #include "components/rappor/rappor_service.h"
27 #include "content/public/browser/web_contents.h" 27 #include "content/public/browser/web_contents.h"
28 #include "extensions/common/constants.h" 28 #include "extensions/common/constants.h"
29 #include "extensions/common/dom_action_types.h" 29 #include "extensions/common/dom_action_types.h"
30 #include "sql/statement.h" 30 #include "sql/statement.h"
31 #include "url/gurl.h" 31 #include "url/gurl.h"
32 32
33 namespace constants = activity_log_constants; 33 namespace constants = activity_log_constants;
34 namespace activity_log = extensions::api::activity_log_private;
34 35
35 namespace extensions { 36 namespace extensions {
36 37
37 namespace { 38 namespace {
38 39
39 // The "Extensions.PossibleAdInjection2" metric uses different Rappor 40 // The "Extensions.PossibleAdInjection2" metric uses different Rappor
40 // parameters than the original metric. 41 // parameters than the original metric.
41 const char kExtensionAdInjectionRapporMetricName[] = 42 const char kExtensionAdInjectionRapporMetricName[] =
42 "Extensions.PossibleAdInjection2"; 43 "Extensions.PossibleAdInjection2";
43 44
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 } 212 }
212 213
213 scoped_ptr<ExtensionActivity> Action::ConvertToExtensionActivity() { 214 scoped_ptr<ExtensionActivity> Action::ConvertToExtensionActivity() {
214 scoped_ptr<ExtensionActivity> result(new ExtensionActivity); 215 scoped_ptr<ExtensionActivity> result(new ExtensionActivity);
215 216
216 // We do this translation instead of using the same enum because the database 217 // We do this translation instead of using the same enum because the database
217 // values need to be stable; this allows us to change the extension API 218 // values need to be stable; this allows us to change the extension API
218 // without affecting the database. 219 // without affecting the database.
219 switch (action_type()) { 220 switch (action_type()) {
220 case ACTION_API_CALL: 221 case ACTION_API_CALL:
221 result->activity_type = ExtensionActivity::ACTIVITY_TYPE_API_CALL; 222 result->activity_type = activity_log::EXTENSION_ACTIVITY_TYPE_API_CALL;
222 break; 223 break;
223 case ACTION_API_EVENT: 224 case ACTION_API_EVENT:
224 result->activity_type = ExtensionActivity::ACTIVITY_TYPE_API_EVENT; 225 result->activity_type = activity_log::EXTENSION_ACTIVITY_TYPE_API_EVENT;
225 break; 226 break;
226 case ACTION_CONTENT_SCRIPT: 227 case ACTION_CONTENT_SCRIPT:
227 result->activity_type = ExtensionActivity::ACTIVITY_TYPE_CONTENT_SCRIPT; 228 result->activity_type =
229 activity_log::EXTENSION_ACTIVITY_TYPE_CONTENT_SCRIPT;
228 break; 230 break;
229 case ACTION_DOM_ACCESS: 231 case ACTION_DOM_ACCESS:
230 result->activity_type = ExtensionActivity::ACTIVITY_TYPE_DOM_ACCESS; 232 result->activity_type = activity_log::EXTENSION_ACTIVITY_TYPE_DOM_ACCESS;
231 break; 233 break;
232 case ACTION_DOM_EVENT: 234 case ACTION_DOM_EVENT:
233 result->activity_type = ExtensionActivity::ACTIVITY_TYPE_DOM_EVENT; 235 result->activity_type = activity_log::EXTENSION_ACTIVITY_TYPE_DOM_EVENT;
234 break; 236 break;
235 case ACTION_WEB_REQUEST: 237 case ACTION_WEB_REQUEST:
236 result->activity_type = ExtensionActivity::ACTIVITY_TYPE_WEB_REQUEST; 238 result->activity_type = activity_log::EXTENSION_ACTIVITY_TYPE_WEB_REQUEST;
237 break; 239 break;
238 case UNUSED_ACTION_API_BLOCKED: 240 case UNUSED_ACTION_API_BLOCKED:
239 case ACTION_ANY: 241 case ACTION_ANY:
240 default: 242 default:
241 // This shouldn't be reached, but some people might have old or otherwise 243 // This shouldn't be reached, but some people might have old or otherwise
242 // weird db entries. Treat it like an API call if that happens. 244 // weird db entries. Treat it like an API call if that happens.
243 result->activity_type = ExtensionActivity::ACTIVITY_TYPE_API_CALL; 245 result->activity_type = activity_log::EXTENSION_ACTIVITY_TYPE_API_CALL;
244 break; 246 break;
245 } 247 }
246 248
247 result->extension_id.reset(new std::string(extension_id())); 249 result->extension_id.reset(new std::string(extension_id()));
248 result->time.reset(new double(time().ToJsTime())); 250 result->time.reset(new double(time().ToJsTime()));
249 result->count.reset(new double(count())); 251 result->count.reset(new double(count()));
250 result->api_call.reset(new std::string(api_name())); 252 result->api_call.reset(new std::string(api_name()));
251 result->args.reset(new std::string(Serialize(args()))); 253 result->args.reset(new std::string(Serialize(args())));
252 if (action_id() != -1) 254 if (action_id() != -1)
253 result->activity_id.reset( 255 result->activity_id.reset(
(...skipping 21 matching lines...) Expand all
275 ActivityLogPolicy::Util::Serialize(web_request))); 277 ActivityLogPolicy::Util::Serialize(web_request)));
276 } 278 }
277 std::string extra; 279 std::string extra;
278 if (other()->GetStringWithoutPathExpansion(constants::kActionExtra, &extra)) 280 if (other()->GetStringWithoutPathExpansion(constants::kActionExtra, &extra))
279 other_field->extra.reset(new std::string(extra)); 281 other_field->extra.reset(new std::string(extra));
280 int dom_verb; 282 int dom_verb;
281 if (other()->GetIntegerWithoutPathExpansion(constants::kActionDomVerb, 283 if (other()->GetIntegerWithoutPathExpansion(constants::kActionDomVerb,
282 &dom_verb)) { 284 &dom_verb)) {
283 switch (static_cast<DomActionType::Type>(dom_verb)) { 285 switch (static_cast<DomActionType::Type>(dom_verb)) {
284 case DomActionType::GETTER: 286 case DomActionType::GETTER:
285 other_field->dom_verb = ExtensionActivity::Other::DOM_VERB_GETTER; 287 other_field->dom_verb =
288 activity_log::EXTENSION_ACTIVITY_DOM_VERB_GETTER;
286 break; 289 break;
287 case DomActionType::SETTER: 290 case DomActionType::SETTER:
288 other_field->dom_verb = ExtensionActivity::Other::DOM_VERB_SETTER; 291 other_field->dom_verb =
292 activity_log::EXTENSION_ACTIVITY_DOM_VERB_SETTER;
289 break; 293 break;
290 case DomActionType::METHOD: 294 case DomActionType::METHOD:
291 other_field->dom_verb = ExtensionActivity::Other::DOM_VERB_METHOD; 295 other_field->dom_verb =
296 activity_log::EXTENSION_ACTIVITY_DOM_VERB_METHOD;
292 break; 297 break;
293 case DomActionType::INSERTED: 298 case DomActionType::INSERTED:
294 other_field->dom_verb = ExtensionActivity::Other::DOM_VERB_INSERTED; 299 other_field->dom_verb =
300 activity_log::EXTENSION_ACTIVITY_DOM_VERB_INSERTED;
295 break; 301 break;
296 case DomActionType::XHR: 302 case DomActionType::XHR:
297 other_field->dom_verb = ExtensionActivity::Other::DOM_VERB_XHR; 303 other_field->dom_verb = activity_log::EXTENSION_ACTIVITY_DOM_VERB_XHR;
298 break; 304 break;
299 case DomActionType::WEBREQUEST: 305 case DomActionType::WEBREQUEST:
300 other_field->dom_verb = ExtensionActivity::Other::DOM_VERB_WEBREQUEST; 306 other_field->dom_verb =
307 activity_log::EXTENSION_ACTIVITY_DOM_VERB_WEBREQUEST;
301 break; 308 break;
302 case DomActionType::MODIFIED: 309 case DomActionType::MODIFIED:
303 other_field->dom_verb = ExtensionActivity::Other::DOM_VERB_MODIFIED; 310 other_field->dom_verb =
311 activity_log::EXTENSION_ACTIVITY_DOM_VERB_MODIFIED;
304 break; 312 break;
305 default: 313 default:
306 other_field->dom_verb = ExtensionActivity::Other::DOM_VERB_NONE; 314 other_field->dom_verb =
315 activity_log::EXTENSION_ACTIVITY_DOM_VERB_NONE;
307 } 316 }
308 } else { 317 } else {
309 other_field->dom_verb = ExtensionActivity::Other::DOM_VERB_NONE; 318 other_field->dom_verb = activity_log::EXTENSION_ACTIVITY_DOM_VERB_NONE;
310 } 319 }
311 result->other.reset(other_field.release()); 320 result->other.reset(other_field.release());
312 } 321 }
313 322
314 return result.Pass(); 323 return result.Pass();
315 } 324 }
316 325
317 std::string Action::PrintForDebug() const { 326 std::string Action::PrintForDebug() const {
318 std::string result = base::StringPrintf("ACTION ID=%" PRId64, action_id()); 327 std::string result = base::StringPrintf("ACTION ID=%" PRId64, action_id());
319 result += " EXTENSION ID=" + extension_id() + " CATEGORY="; 328 result += " EXTENSION ID=" + extension_id() + " CATEGORY=";
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
545 std::string rhs_other = ActivityLogPolicy::Util::Serialize(rhs->other()); 554 std::string rhs_other = ActivityLogPolicy::Util::Serialize(rhs->other());
546 if (lhs_other != rhs_other) 555 if (lhs_other != rhs_other)
547 return lhs_other < rhs_other; 556 return lhs_other < rhs_other;
548 } 557 }
549 558
550 // All fields compare as equal if this point is reached. 559 // All fields compare as equal if this point is reached.
551 return false; 560 return false;
552 } 561 }
553 562
554 } // namespace extensions 563 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698