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

Side by Side Diff: chrome/browser/renderer_host/chrome_render_message_filter.cc

Issue 13726026: Added ActivityLog tests and associated bugfixes/extra logging. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Wrapped line Created 7 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 | Annotate | Revision Log
OLDNEW
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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 #include "chrome/browser/browser_about_handler.h" 50 #include "chrome/browser/browser_about_handler.h"
51 #endif 51 #endif
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 enum ActivityLogCallType {
61 ACTIVITYAPI,
62 ACTIVITYEVENT
63 };
64
60 void AddAPIActionToExtensionActivityLog( 65 void AddAPIActionToExtensionActivityLog(
61 Profile* profile, 66 Profile* profile,
67 const ActivityLogCallType call_type,
62 const extensions::Extension* extension, 68 const extensions::Extension* extension,
63 const std::string& api_call, 69 const std::string& api_call,
64 scoped_ptr<ListValue> args, 70 scoped_ptr<ListValue> args,
65 const std::string& extra) { 71 const std::string& extra) {
66 // The ActivityLog can only be accessed from the main (UI) thread. If we're 72 // 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. 73 // running on the wrong thread, re-dispatch from the main thread.
68 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { 74 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) {
69 BrowserThread::PostTask(BrowserThread::UI, 75 BrowserThread::PostTask(BrowserThread::UI,
70 FROM_HERE, 76 FROM_HERE,
71 base::Bind(&AddAPIActionToExtensionActivityLog, 77 base::Bind(&AddAPIActionToExtensionActivityLog,
72 profile, 78 profile,
79 call_type,
73 extension, 80 extension,
74 api_call, 81 api_call,
75 base::Passed(&args), 82 base::Passed(&args),
76 extra)); 83 extra));
77 } else { 84 } else {
78 extensions::ActivityLog* activity_log = 85 extensions::ActivityLog* activity_log =
79 extensions::ActivityLog::GetInstance(profile); 86 extensions::ActivityLog::GetInstance(profile);
80 if (activity_log && activity_log->IsLogEnabled()) 87 if (activity_log && activity_log->IsLogEnabled()) {
81 activity_log->LogAPIAction(extension, api_call, args.get(), extra); 88 if (call_type == ACTIVITYAPI)
89 activity_log->LogAPIAction(extension, api_call, args.get(), extra);
90 else if (call_type == ACTIVITYEVENT)
91 activity_log->LogEventAction(extension, api_call, args.get(), extra);
92 }
82 } 93 }
83 } 94 }
84 95
85 void AddDOMActionToExtensionActivityLog( 96 void AddDOMActionToExtensionActivityLog(
86 Profile* profile, 97 Profile* profile,
87 const extensions::Extension* extension, 98 const extensions::Extension* extension,
88 const GURL& url, 99 const GURL& url,
89 const string16& url_title, 100 const string16& url_title,
90 const std::string& api_call, 101 const std::string& api_call,
91 scoped_ptr<ListValue> args, 102 scoped_ptr<ListValue> args,
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 OnExtensionShouldSuspendAck) 186 OnExtensionShouldSuspendAck)
176 IPC_MESSAGE_HANDLER(ExtensionHostMsg_GenerateUniqueID, 187 IPC_MESSAGE_HANDLER(ExtensionHostMsg_GenerateUniqueID,
177 OnExtensionGenerateUniqueID) 188 OnExtensionGenerateUniqueID)
178 IPC_MESSAGE_HANDLER(ExtensionHostMsg_SuspendAck, OnExtensionSuspendAck) 189 IPC_MESSAGE_HANDLER(ExtensionHostMsg_SuspendAck, OnExtensionSuspendAck)
179 IPC_MESSAGE_HANDLER(ExtensionHostMsg_ResumeRequests, 190 IPC_MESSAGE_HANDLER(ExtensionHostMsg_ResumeRequests,
180 OnExtensionResumeRequests); 191 OnExtensionResumeRequests);
181 IPC_MESSAGE_HANDLER(ExtensionHostMsg_AddAPIActionToActivityLog, 192 IPC_MESSAGE_HANDLER(ExtensionHostMsg_AddAPIActionToActivityLog,
182 OnAddAPIActionToExtensionActivityLog); 193 OnAddAPIActionToExtensionActivityLog);
183 IPC_MESSAGE_HANDLER(ExtensionHostMsg_AddDOMActionToActivityLog, 194 IPC_MESSAGE_HANDLER(ExtensionHostMsg_AddDOMActionToActivityLog,
184 OnAddDOMActionToExtensionActivityLog); 195 OnAddDOMActionToExtensionActivityLog);
196 IPC_MESSAGE_HANDLER(ExtensionHostMsg_AddEventToActivityLog,
197 OnAddEventToExtensionActivityLog);
185 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_AllowDatabase, OnAllowDatabase) 198 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_AllowDatabase, OnAllowDatabase)
186 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_AllowDOMStorage, OnAllowDOMStorage) 199 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_AllowDOMStorage, OnAllowDOMStorage)
187 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_AllowFileSystem, OnAllowFileSystem) 200 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_AllowFileSystem, OnAllowFileSystem)
188 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_AllowIndexedDB, OnAllowIndexedDB) 201 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_AllowIndexedDB, OnAllowIndexedDB)
189 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_CanTriggerClipboardRead, 202 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_CanTriggerClipboardRead,
190 OnCanTriggerClipboardRead) 203 OnCanTriggerClipboardRead)
191 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_CanTriggerClipboardWrite, 204 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_CanTriggerClipboardWrite,
192 OnCanTriggerClipboardWrite) 205 OnCanTriggerClipboardWrite)
193 IPC_MESSAGE_UNHANDLED(handled = false) 206 IPC_MESSAGE_UNHANDLED(handled = false)
194 IPC_END_MESSAGE_MAP() 207 IPC_END_MESSAGE_MAP()
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after
584 *unique_id = next_unique_id++; 597 *unique_id = next_unique_id++;
585 } 598 }
586 599
587 void ChromeRenderMessageFilter::OnExtensionResumeRequests(int route_id) { 600 void ChromeRenderMessageFilter::OnExtensionResumeRequests(int route_id) {
588 content::ResourceDispatcherHost::Get()->ResumeBlockedRequestsForRoute( 601 content::ResourceDispatcherHost::Get()->ResumeBlockedRequestsForRoute(
589 render_process_id_, route_id); 602 render_process_id_, route_id);
590 } 603 }
591 604
592 void ChromeRenderMessageFilter::OnAddAPIActionToExtensionActivityLog( 605 void ChromeRenderMessageFilter::OnAddAPIActionToExtensionActivityLog(
593 const std::string& extension_id, 606 const std::string& extension_id,
594 const ExtensionHostMsg_APIAction_Params& params) { 607 const ExtensionHostMsg_APIActionOrEvent_Params& params) {
595 const extensions::Extension* extension = 608 const extensions::Extension* extension =
596 extension_info_map_->extensions().GetByID(extension_id); 609 extension_info_map_->extensions().GetByID(extension_id);
597 scoped_ptr<ListValue> args(params.arguments.DeepCopy()); 610 scoped_ptr<ListValue> args(params.arguments.DeepCopy());
598 // The activity is recorded as an API action in the extension 611 // The activity is recorded as an API action in the extension
599 // activity log. 612 // activity log.
600 AddAPIActionToExtensionActivityLog(profile_, extension, 613 AddAPIActionToExtensionActivityLog(profile_, ACTIVITYAPI, extension,
601 params.api_call, args.Pass(), 614 params.api_call, args.Pass(),
602 params.extra); 615 params.extra);
603 } 616 }
604 617
605 void ChromeRenderMessageFilter::OnAddDOMActionToExtensionActivityLog( 618 void ChromeRenderMessageFilter::OnAddDOMActionToExtensionActivityLog(
606 const std::string& extension_id, 619 const std::string& extension_id,
607 const ExtensionHostMsg_DOMAction_Params& params) { 620 const ExtensionHostMsg_DOMAction_Params& params) {
608 const extensions::Extension* extension = 621 const extensions::Extension* extension =
609 extension_info_map_->extensions().GetByID(extension_id); 622 extension_info_map_->extensions().GetByID(extension_id);
610 scoped_ptr<ListValue> args(params.arguments.DeepCopy()); 623 scoped_ptr<ListValue> args(params.arguments.DeepCopy());
611 // The activity is recorded as a DOM action on the extension 624 // The activity is recorded as a DOM action on the extension
612 // activity log. 625 // activity log.
613 AddDOMActionToExtensionActivityLog(profile_, extension, 626 AddDOMActionToExtensionActivityLog(profile_, extension,
614 params.url, params.url_title, 627 params.url, params.url_title,
615 params.api_call, args.Pass(), 628 params.api_call, args.Pass(),
616 params.extra); 629 params.extra);
617 } 630 }
618 631
632 void ChromeRenderMessageFilter::OnAddEventToExtensionActivityLog(
633 const std::string& extension_id,
634 const ExtensionHostMsg_APIActionOrEvent_Params& params) {
635 const extensions::Extension* extension =
636 extension_info_map_->extensions().GetByID(extension_id);
637 scoped_ptr<ListValue> args(params.arguments.DeepCopy());
638 // The activity is recorded as an event in the extension
639 // activity log.
640 AddAPIActionToExtensionActivityLog(profile_, ACTIVITYEVENT, extension,
641 params.api_call, args.Pass(),
642 params.extra);
643 }
644
619 void ChromeRenderMessageFilter::OnAllowDatabase(int render_view_id, 645 void ChromeRenderMessageFilter::OnAllowDatabase(int render_view_id,
620 const GURL& origin_url, 646 const GURL& origin_url,
621 const GURL& top_origin_url, 647 const GURL& top_origin_url,
622 const string16& name, 648 const string16& name,
623 const string16& display_name, 649 const string16& display_name,
624 bool* allowed) { 650 bool* allowed) {
625 *allowed = cookie_settings_->IsSettingCookieAllowed(origin_url, 651 *allowed = cookie_settings_->IsSettingCookieAllowed(origin_url,
626 top_origin_url); 652 top_origin_url);
627 BrowserThread::PostTask( 653 BrowserThread::PostTask(
628 BrowserThread::UI, FROM_HERE, 654 BrowserThread::UI, FROM_HERE,
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
703 729
704 void ChromeRenderMessageFilter::OnSetCookie(const IPC::Message& message, 730 void ChromeRenderMessageFilter::OnSetCookie(const IPC::Message& message,
705 const GURL& url, 731 const GURL& url,
706 const GURL& first_party_for_cookies, 732 const GURL& first_party_for_cookies,
707 const std::string& cookie) { 733 const std::string& cookie) {
708 #if defined(ENABLE_AUTOMATION) 734 #if defined(ENABLE_AUTOMATION)
709 AutomationResourceMessageFilter::SetCookiesForUrl( 735 AutomationResourceMessageFilter::SetCookiesForUrl(
710 render_process_id_, message.routing_id(), url, cookie); 736 render_process_id_, message.routing_id(), url, cookie);
711 #endif 737 #endif
712 } 738 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698