Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/renderer_host/chrome_render_message_filter.h" | 5 #include "chrome/browser/renderer_host/chrome_render_message_filter.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 52 | 52 |
| 53 using content::BrowserThread; | 53 using content::BrowserThread; |
| 54 using extensions::APIPermission; | 54 using extensions::APIPermission; |
| 55 using WebKit::WebCache; | 55 using WebKit::WebCache; |
| 56 using WebKit::WebSecurityOrigin; | 56 using WebKit::WebSecurityOrigin; |
| 57 | 57 |
| 58 namespace { | 58 namespace { |
| 59 | 59 |
| 60 void AddAPIActionToExtensionActivityLog( | 60 void AddAPIActionToExtensionActivityLog( |
| 61 Profile* profile, | 61 Profile* profile, |
| 62 const std::string& call_type, | |
| 62 const extensions::Extension* extension, | 63 const extensions::Extension* extension, |
| 63 const std::string& api_call, | 64 const std::string& api_call, |
| 64 scoped_ptr<ListValue> args, | 65 scoped_ptr<ListValue> args, |
| 65 const std::string& extra) { | 66 const std::string& extra) { |
| 66 // The ActivityLog can only be accessed from the main (UI) thread. If we're | 67 // The ActivityLog can only be accessed from the main (UI) thread. If we're |
| 67 // running on the wrong thread, re-dispatch from the main thread. | 68 // running on the wrong thread, re-dispatch from the main thread. |
| 68 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { | 69 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { |
| 69 BrowserThread::PostTask(BrowserThread::UI, | 70 BrowserThread::PostTask(BrowserThread::UI, |
| 70 FROM_HERE, | 71 FROM_HERE, |
| 71 base::Bind(&AddAPIActionToExtensionActivityLog, | 72 base::Bind(&AddAPIActionToExtensionActivityLog, |
| 72 profile, | 73 profile, |
| 74 call_type, | |
| 73 extension, | 75 extension, |
| 74 api_call, | 76 api_call, |
| 75 base::Passed(&args), | 77 base::Passed(&args), |
| 76 extra)); | 78 extra)); |
| 77 } else { | 79 } else { |
| 78 extensions::ActivityLog* activity_log = | 80 extensions::ActivityLog* activity_log = |
| 79 extensions::ActivityLog::GetInstance(profile); | 81 extensions::ActivityLog::GetInstance(profile); |
| 80 if (activity_log && activity_log->IsLogEnabled()) | 82 if (activity_log && activity_log->IsLogEnabled()) { |
| 81 activity_log->LogAPIAction(extension, api_call, args.get(), extra); | 83 if (call_type == "API") |
|
palmer
2013/04/10 23:52:48
Hmm, how open-ended are these call types? Maybe an
| |
| 84 activity_log->LogAPIAction(extension, api_call, args.get(), extra); | |
| 85 else if (call_type == "EVENT") | |
| 86 activity_log->LogEventAction(extension, api_call, args.get(), extra); | |
| 87 } | |
| 82 } | 88 } |
| 83 } | 89 } |
| 84 | 90 |
| 85 void AddDOMActionToExtensionActivityLog( | 91 void AddDOMActionToExtensionActivityLog( |
| 86 Profile* profile, | 92 Profile* profile, |
| 87 const extensions::Extension* extension, | 93 const extensions::Extension* extension, |
| 88 const GURL& url, | 94 const GURL& url, |
| 89 const string16& url_title, | 95 const string16& url_title, |
| 90 const std::string& api_call, | 96 const std::string& api_call, |
| 91 scoped_ptr<ListValue> args, | 97 scoped_ptr<ListValue> args, |
| (...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 583 static int next_unique_id = 1; | 589 static int next_unique_id = 1; |
| 584 *unique_id = next_unique_id++; | 590 *unique_id = next_unique_id++; |
| 585 } | 591 } |
| 586 | 592 |
| 587 void ChromeRenderMessageFilter::OnExtensionResumeRequests(int route_id) { | 593 void ChromeRenderMessageFilter::OnExtensionResumeRequests(int route_id) { |
| 588 content::ResourceDispatcherHost::Get()->ResumeBlockedRequestsForRoute( | 594 content::ResourceDispatcherHost::Get()->ResumeBlockedRequestsForRoute( |
| 589 render_process_id_, route_id); | 595 render_process_id_, route_id); |
| 590 } | 596 } |
| 591 | 597 |
| 592 void ChromeRenderMessageFilter::OnAddAPIActionToExtensionActivityLog( | 598 void ChromeRenderMessageFilter::OnAddAPIActionToExtensionActivityLog( |
| 599 const std::string& call_type, | |
| 593 const std::string& extension_id, | 600 const std::string& extension_id, |
| 594 const ExtensionHostMsg_APIAction_Params& params) { | 601 const ExtensionHostMsg_APIAction_Params& params) { |
| 595 const extensions::Extension* extension = | 602 const extensions::Extension* extension = |
| 596 extension_info_map_->extensions().GetByID(extension_id); | 603 extension_info_map_->extensions().GetByID(extension_id); |
| 597 scoped_ptr<ListValue> args(params.arguments.DeepCopy()); | 604 scoped_ptr<ListValue> args(params.arguments.DeepCopy()); |
| 598 // The activity is recorded as an API action in the extension | 605 // The activity is recorded as an API action in the extension |
| 599 // activity log. | 606 // activity log. |
| 600 AddAPIActionToExtensionActivityLog(profile_, extension, | 607 AddAPIActionToExtensionActivityLog(profile_, call_type, extension, |
| 601 params.api_call, args.Pass(), | 608 params.api_call, args.Pass(), |
| 602 params.extra); | 609 params.extra); |
| 603 } | 610 } |
| 604 | 611 |
| 605 void ChromeRenderMessageFilter::OnAddDOMActionToExtensionActivityLog( | 612 void ChromeRenderMessageFilter::OnAddDOMActionToExtensionActivityLog( |
| 606 const std::string& extension_id, | 613 const std::string& extension_id, |
| 607 const ExtensionHostMsg_DOMAction_Params& params) { | 614 const ExtensionHostMsg_DOMAction_Params& params) { |
| 608 const extensions::Extension* extension = | 615 const extensions::Extension* extension = |
| 609 extension_info_map_->extensions().GetByID(extension_id); | 616 extension_info_map_->extensions().GetByID(extension_id); |
| 610 scoped_ptr<ListValue> args(params.arguments.DeepCopy()); | 617 scoped_ptr<ListValue> args(params.arguments.DeepCopy()); |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 703 | 710 |
| 704 void ChromeRenderMessageFilter::OnSetCookie(const IPC::Message& message, | 711 void ChromeRenderMessageFilter::OnSetCookie(const IPC::Message& message, |
| 705 const GURL& url, | 712 const GURL& url, |
| 706 const GURL& first_party_for_cookies, | 713 const GURL& first_party_for_cookies, |
| 707 const std::string& cookie) { | 714 const std::string& cookie) { |
| 708 #if defined(ENABLE_AUTOMATION) | 715 #if defined(ENABLE_AUTOMATION) |
| 709 AutomationResourceMessageFilter::SetCookiesForUrl( | 716 AutomationResourceMessageFilter::SetCookiesForUrl( |
| 710 render_process_id_, message.routing_id(), url, cookie); | 717 render_process_id_, message.routing_id(), url, cookie); |
| 711 #endif | 718 #endif |
| 712 } | 719 } |
| OLD | NEW |