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

Side by Side Diff: chrome/browser/extensions/api/web_request/web_request_api.cc

Issue 11946028: Record event activity to the extension activity log. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Rename ActivityLog::IsLoggingEnabled Created 7 years, 10 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) 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/extensions/api/web_request/web_request_api.h" 5 #include "chrome/browser/extensions/api/web_request/web_request_api.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 1043 matching lines...) Expand 10 before | Expand all | Expand 10 after
1054 request_time_tracker_->LogRequestEndTime(request->identifier(), 1054 request_time_tracker_->LogRequestEndTime(request->identifier(),
1055 base::Time::Now()); 1055 base::Time::Now());
1056 } 1056 }
1057 1057
1058 void ExtensionWebRequestEventRouter::ClearPendingCallbacks( 1058 void ExtensionWebRequestEventRouter::ClearPendingCallbacks(
1059 net::URLRequest* request) { 1059 net::URLRequest* request) {
1060 blocked_requests_.erase(request->identifier()); 1060 blocked_requests_.erase(request->identifier());
1061 } 1061 }
1062 1062
1063 bool ExtensionWebRequestEventRouter::DispatchEvent( 1063 bool ExtensionWebRequestEventRouter::DispatchEvent(
1064 void* profile, 1064 void* profile_id,
1065 net::URLRequest* request, 1065 net::URLRequest* request,
1066 const std::vector<const EventListener*>& listeners, 1066 const std::vector<const EventListener*>& listeners,
1067 const ListValue& args) { 1067 const ListValue& args) {
1068 // TODO(mpcomplete): Consider consolidating common (extension_id,json_args) 1068 // TODO(mpcomplete): Consider consolidating common (extension_id,json_args)
1069 // pairs into a single message sent to a list of sub_event_names. 1069 // pairs into a single message sent to a list of sub_event_names.
1070 int num_handlers_blocking = 0; 1070 int num_handlers_blocking = 0;
1071 for (std::vector<const EventListener*>::const_iterator it = listeners.begin(); 1071 for (std::vector<const EventListener*>::const_iterator it = listeners.begin();
1072 it != listeners.end(); ++it) { 1072 it != listeners.end(); ++it) {
1073 // Filter out the optional keys that this listener didn't request. 1073 // Filter out the optional keys that this listener didn't request.
1074 scoped_ptr<ListValue> args_filtered(args.DeepCopy()); 1074 scoped_ptr<ListValue> args_filtered(args.DeepCopy());
1075 DictionaryValue* dict = NULL; 1075 DictionaryValue* dict = NULL;
1076 CHECK(args_filtered->GetDictionary(0, &dict) && dict); 1076 CHECK(args_filtered->GetDictionary(0, &dict) && dict);
1077 if (!((*it)->extra_info_spec & ExtraInfoSpec::REQUEST_HEADERS)) 1077 if (!((*it)->extra_info_spec & ExtraInfoSpec::REQUEST_HEADERS))
1078 dict->Remove(keys::kRequestHeadersKey, NULL); 1078 dict->Remove(keys::kRequestHeadersKey, NULL);
1079 if (!((*it)->extra_info_spec & ExtraInfoSpec::RESPONSE_HEADERS)) 1079 if (!((*it)->extra_info_spec & ExtraInfoSpec::RESPONSE_HEADERS))
1080 dict->Remove(keys::kResponseHeadersKey, NULL); 1080 dict->Remove(keys::kResponseHeadersKey, NULL);
1081 1081
1082 extensions::EventRouter::DispatchEvent( 1082 extensions::EventRouter::DispatchEvent(
1083 (*it)->ipc_sender.get(), (*it)->extension_id, (*it)->sub_event_name, 1083 (*it)->ipc_sender.get(), profile_id,
1084 (*it)->extension_id, (*it)->sub_event_name,
1084 args_filtered.Pass(), GURL(), 1085 args_filtered.Pass(), GURL(),
1085 extensions::EventRouter::USER_GESTURE_UNKNOWN, 1086 extensions::EventRouter::USER_GESTURE_UNKNOWN,
1086 extensions::EventFilteringInfo()); 1087 extensions::EventFilteringInfo());
1087 if ((*it)->extra_info_spec & 1088 if ((*it)->extra_info_spec &
1088 (ExtraInfoSpec::BLOCKING | ExtraInfoSpec::ASYNC_BLOCKING)) { 1089 (ExtraInfoSpec::BLOCKING | ExtraInfoSpec::ASYNC_BLOCKING)) {
1089 (*it)->blocked_requests.insert(request->identifier()); 1090 (*it)->blocked_requests.insert(request->identifier());
1090 ++num_handlers_blocking; 1091 ++num_handlers_blocking;
1091 1092
1092 request->SetLoadStateParam( 1093 request->SetLoadStateParam(
1093 l10n_util::GetStringFUTF16(IDS_LOAD_STATE_PARAMETER_EXTENSION, 1094 l10n_util::GetStringFUTF16(IDS_LOAD_STATE_PARAMETER_EXTENSION,
(...skipping 934 matching lines...) Expand 10 before | Expand all | Expand 10 after
2028 } else if ((*it)->name().find("AdBlock") != std::string::npos) { 2029 } else if ((*it)->name().find("AdBlock") != std::string::npos) {
2029 adblock = true; 2030 adblock = true;
2030 } else { 2031 } else {
2031 other = true; 2032 other = true;
2032 } 2033 }
2033 } 2034 }
2034 } 2035 }
2035 2036
2036 host->Send(new ExtensionMsg_UsingWebRequestAPI(adblock, adblock_plus, other)); 2037 host->Send(new ExtensionMsg_UsingWebRequestAPI(adblock, adblock_plus, other));
2037 } 2038 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698