OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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.h" | 5 #include "chrome/browser/extensions/activity_log.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 #include <vector> | 8 #include <vector> |
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" |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "base/string_util.h" | 12 #include "base/string_util.h" |
13 #include "base/threading/thread_checker.h" | 13 #include "base/threading/thread_checker.h" |
14 #include "chrome/browser/extensions/api_actions.h" | 14 #include "chrome/browser/extensions/api_actions.h" |
15 #include "chrome/browser/extensions/blocked_actions.h" | 15 #include "chrome/browser/extensions/blocked_actions.h" |
16 #include "chrome/browser/extensions/extension_service.h" | 16 #include "chrome/browser/extensions/extension_service.h" |
17 #include "chrome/browser/extensions/extension_system.h" | 17 #include "chrome/browser/extensions/extension_system.h" |
18 #include "chrome/common/chrome_constants.h" | 18 #include "chrome/common/chrome_constants.h" |
19 #include "chrome/common/chrome_switches.h" | 19 #include "chrome/common/chrome_switches.h" |
20 #include "chrome/common/extensions/extension.h" | 20 #include "chrome/common/extensions/extension.h" |
21 #include "content/public/browser/web_contents.h" | 21 #include "content/public/browser/web_contents.h" |
22 #include "googleurl/src/gurl.h" | 22 #include "googleurl/src/gurl.h" |
23 #include "sql/error_delegate_util.h" | 23 #include "sql/error_delegate_util.h" |
24 #include "third_party/re2/re2/re2.h" | 24 #include "third_party/re2/re2/re2.h" |
25 | 25 |
26 namespace { | 26 namespace { |
27 | 27 |
28 // Concatenate arguments. | 28 // Concatenate arguments. |
29 std::string MakeArgList(const ListValue* args) { | 29 std::string MakeArgList(const ListValue* args) { |
30 std::string call_signature = ""; | 30 std::string call_signature; |
31 ListValue::const_iterator it = args->begin(); | 31 ListValue::const_iterator it = args->begin(); |
32 for (; it != args->end(); ++it) { | 32 for (; it != args->end(); ++it) { |
33 std::string arg; | 33 std::string arg; |
34 JSONStringValueSerializer serializer(&arg); | 34 JSONStringValueSerializer serializer(&arg); |
35 if (serializer.SerializeAndOmitBinaryValues(**it)) { | 35 if (serializer.SerializeAndOmitBinaryValues(**it)) { |
36 if (it != args->begin()) | 36 if (it != args->begin()) |
37 call_signature += ", "; | 37 call_signature += ", "; |
38 call_signature += arg; | 38 call_signature += arg; |
39 } | 39 } |
40 } | 40 } |
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
388 for (ExecutingScriptsMap::const_iterator it = extension_ids.begin(); | 388 for (ExecutingScriptsMap::const_iterator it = extension_ids.begin(); |
389 it != extension_ids.end(); ++it) { | 389 it != extension_ids.end(); ++it) { |
390 const Extension* extension = extensions->GetByID(it->first); | 390 const Extension* extension = extensions->GetByID(it->first); |
391 if (!extension) | 391 if (!extension) |
392 continue; | 392 continue; |
393 | 393 |
394 // If OnScriptsExecuted is fired because of tabs.executeScript, the list | 394 // If OnScriptsExecuted is fired because of tabs.executeScript, the list |
395 // of content scripts will be empty. We don't want to log it because | 395 // of content scripts will be empty. We don't want to log it because |
396 // the call to tabs.executeScript will have already been logged anyway. | 396 // the call to tabs.executeScript will have already been logged anyway. |
397 if (!it->second.empty()) { | 397 if (!it->second.empty()) { |
398 std::string ext_scripts_str = ""; | 398 std::string ext_scripts_str; |
399 for (std::set<std::string>::const_iterator it2 = it->second.begin(); | 399 for (std::set<std::string>::const_iterator it2 = it->second.begin(); |
400 it2 != it->second.end(); ++it2) { | 400 it2 != it->second.end(); |
| 401 ++it2) { |
401 ext_scripts_str += *it2; | 402 ext_scripts_str += *it2; |
402 ext_scripts_str += " "; | 403 ext_scripts_str += " "; |
403 } | 404 } |
404 scoped_ptr<ListValue> script_names(new ListValue()); | 405 scoped_ptr<ListValue> script_names(new ListValue()); |
405 script_names->Set(0, new StringValue(ext_scripts_str)); | 406 script_names->Set(0, new StringValue(ext_scripts_str)); |
406 LogDOMActionInternal(extension, | 407 LogDOMActionInternal(extension, |
407 on_url, | 408 on_url, |
408 web_contents->GetTitle(), | 409 web_contents->GetTitle(), |
409 "", // no api call here | 410 std::string(), // no api call here |
410 script_names.get(), | 411 script_names.get(), |
411 "", // no extras either | 412 std::string(), // no extras either |
412 DOMAction::INSERTED); | 413 DOMAction::INSERTED); |
413 } | 414 } |
414 } | 415 } |
415 } | 416 } |
416 | 417 |
417 void ActivityLog::KillActivityLogDatabase() { | 418 void ActivityLog::KillActivityLogDatabase() { |
418 if (db_.get()) { | 419 if (db_.get()) { |
419 ScheduleAndForget(&ActivityDatabase::KillDatabase); | 420 ScheduleAndForget(&ActivityDatabase::KillDatabase); |
420 } | 421 } |
421 } | 422 } |
422 | 423 |
423 // static | 424 // static |
424 const char* ActivityLog::ActivityToString(Activity activity) { | 425 const char* ActivityLog::ActivityToString(Activity activity) { |
425 switch (activity) { | 426 switch (activity) { |
426 case ActivityLog::ACTIVITY_EXTENSION_API_CALL: | 427 case ActivityLog::ACTIVITY_EXTENSION_API_CALL: |
427 return "api_call"; | 428 return "api_call"; |
428 case ActivityLog::ACTIVITY_EXTENSION_API_BLOCK: | 429 case ActivityLog::ACTIVITY_EXTENSION_API_BLOCK: |
429 return "api_block"; | 430 return "api_block"; |
430 case ActivityLog::ACTIVITY_CONTENT_SCRIPT: | 431 case ActivityLog::ACTIVITY_CONTENT_SCRIPT: |
431 return "content_script"; | 432 return "content_script"; |
432 case ActivityLog::ACTIVITY_EVENT_DISPATCH: | 433 case ActivityLog::ACTIVITY_EVENT_DISPATCH: |
433 return "event_dispatch"; | 434 return "event_dispatch"; |
434 default: | 435 default: |
435 NOTREACHED(); | 436 NOTREACHED(); |
436 return ""; | 437 return ""; |
437 } | 438 } |
438 } | 439 } |
439 | 440 |
440 } // namespace extensions | 441 } // namespace extensions |
OLD | NEW |