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

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

Issue 601843002: Merge web_request_api_utils back into web_request_api_helpers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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 "extensions/browser/api/web_request/web_request_api.h" 5 #include "extensions/browser/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 12 matching lines...) Expand all
23 #include "content/public/browser/resource_request_info.h" 23 #include "content/public/browser/resource_request_info.h"
24 #include "content/public/browser/user_metrics.h" 24 #include "content/public/browser/user_metrics.h"
25 #include "extensions/browser/api/activity_log/web_request_constants.h" 25 #include "extensions/browser/api/activity_log/web_request_constants.h"
26 #include "extensions/browser/api/declarative_webrequest/request_stage.h" 26 #include "extensions/browser/api/declarative_webrequest/request_stage.h"
27 #include "extensions/browser/api/declarative_webrequest/webrequest_constants.h" 27 #include "extensions/browser/api/declarative_webrequest/webrequest_constants.h"
28 #include "extensions/browser/api/declarative_webrequest/webrequest_rules_registr y.h" 28 #include "extensions/browser/api/declarative_webrequest/webrequest_rules_registr y.h"
29 #include "extensions/browser/api/extensions_api_client.h" 29 #include "extensions/browser/api/extensions_api_client.h"
30 #include "extensions/browser/api/web_request/upload_data_presenter.h" 30 #include "extensions/browser/api/web_request/upload_data_presenter.h"
31 #include "extensions/browser/api/web_request/web_request_api_constants.h" 31 #include "extensions/browser/api/web_request/web_request_api_constants.h"
32 #include "extensions/browser/api/web_request/web_request_api_helpers.h" 32 #include "extensions/browser/api/web_request/web_request_api_helpers.h"
33 #include "extensions/browser/api/web_request/web_request_api_utils.h"
34 #include "extensions/browser/api/web_request/web_request_api_utils.h"
35 #include "extensions/browser/api/web_request/web_request_event_router_delegate.h " 33 #include "extensions/browser/api/web_request/web_request_event_router_delegate.h "
36 #include "extensions/browser/api/web_request/web_request_time_tracker.h" 34 #include "extensions/browser/api/web_request/web_request_time_tracker.h"
37 #include "extensions/browser/event_router.h" 35 #include "extensions/browser/event_router.h"
38 #include "extensions/browser/extension_message_filter.h" 36 #include "extensions/browser/extension_message_filter.h"
39 #include "extensions/browser/extension_prefs.h" 37 #include "extensions/browser/extension_prefs.h"
40 #include "extensions/browser/extension_registry.h" 38 #include "extensions/browser/extension_registry.h"
41 #include "extensions/browser/extension_system.h" 39 #include "extensions/browser/extension_system.h"
42 #include "extensions/browser/extensions_browser_client.h" 40 #include "extensions/browser/extensions_browser_client.h"
43 #include "extensions/browser/guest_view/web_view/web_view_constants.h" 41 #include "extensions/browser/guest_view/web_view/web_view_constants.h"
44 #include "extensions/browser/guest_view/web_view/web_view_renderer_state.h" 42 #include "extensions/browser/guest_view/web_view/web_view_renderer_state.h"
(...skipping 29 matching lines...) Expand all
74 using extensions::Extension; 72 using extensions::Extension;
75 using extensions::InfoMap; 73 using extensions::InfoMap;
76 using extensions::Feature; 74 using extensions::Feature;
77 using extensions::RulesRegistryService; 75 using extensions::RulesRegistryService;
78 using extensions::Warning; 76 using extensions::Warning;
79 using extensions::WarningService; 77 using extensions::WarningService;
80 using extensions::WarningSet; 78 using extensions::WarningSet;
81 79
82 namespace activitylog = activity_log_web_request_constants; 80 namespace activitylog = activity_log_web_request_constants;
83 namespace helpers = extension_web_request_api_helpers; 81 namespace helpers = extension_web_request_api_helpers;
84 namespace utils = extension_web_request_api_utils;
85 namespace keys = extension_web_request_api_constants; 82 namespace keys = extension_web_request_api_constants;
86 namespace web_request = extensions::core_api::web_request; 83 namespace web_request = extensions::core_api::web_request;
87 namespace declarative_keys = extensions::declarative_webrequest_constants; 84 namespace declarative_keys = extensions::declarative_webrequest_constants;
88 85
89 namespace { 86 namespace {
90 87
91 const char kWebRequestEventPrefix[] = "webRequest."; 88 const char kWebRequestEventPrefix[] = "webRequest.";
92 89
93 // List of all the webRequest events. 90 // List of all the webRequest events.
94 const char* const kWebRequestEvents[] = { 91 const char* const kWebRequestEvents[] = {
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 202
206 const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(request); 203 const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(request);
207 *frame_id = info->GetRenderFrameID(); 204 *frame_id = info->GetRenderFrameID();
208 *is_main_frame = info->IsMainFrame(); 205 *is_main_frame = info->IsMainFrame();
209 *parent_frame_id = info->GetParentRenderFrameID(); 206 *parent_frame_id = info->GetParentRenderFrameID();
210 *parent_is_main_frame = info->ParentIsMainFrame(); 207 *parent_is_main_frame = info->ParentIsMainFrame();
211 *render_process_host_id = info->GetChildID(); 208 *render_process_host_id = info->GetChildID();
212 *routing_id = info->GetRouteID(); 209 *routing_id = info->GetRouteID();
213 210
214 // Restrict the resource type to the values we care about. 211 // Restrict the resource type to the values we care about.
215 if (utils::IsRelevantResourceType(info->GetResourceType())) 212 if (helpers::IsRelevantResourceType(info->GetResourceType()))
216 *resource_type = info->GetResourceType(); 213 *resource_type = info->GetResourceType();
217 else 214 else
218 *resource_type = content::RESOURCE_TYPE_LAST_TYPE; 215 *resource_type = content::RESOURCE_TYPE_LAST_TYPE;
219 } 216 }
220 217
221 // Extracts the body from |request| and writes the data into |out|. 218 // Extracts the body from |request| and writes the data into |out|.
222 void ExtractRequestInfoBody(const net::URLRequest* request, 219 void ExtractRequestInfoBody(const net::URLRequest* request,
223 base::DictionaryValue* out) { 220 base::DictionaryValue* out) {
224 const net::UploadDataStream* upload_data = request->get_upload(); 221 const net::UploadDataStream* upload_data = request->get_upload();
225 if (!upload_data || 222 if (!upload_data ||
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after
570 urls.AddPattern(pattern); 567 urls.AddPattern(pattern);
571 } 568 }
572 } else if (it.key() == "types") { 569 } else if (it.key() == "types") {
573 const base::ListValue* types_value = NULL; 570 const base::ListValue* types_value = NULL;
574 if (!it.value().GetAsList(&types_value)) 571 if (!it.value().GetAsList(&types_value))
575 return false; 572 return false;
576 for (size_t i = 0; i < types_value->GetSize(); ++i) { 573 for (size_t i = 0; i < types_value->GetSize(); ++i) {
577 std::string type_str; 574 std::string type_str;
578 ResourceType type; 575 ResourceType type;
579 if (!types_value->GetString(i, &type_str) || 576 if (!types_value->GetString(i, &type_str) ||
580 !utils::ParseResourceType(type_str, &type)) 577 !helpers::ParseResourceType(type_str, &type))
581 return false; 578 return false;
582 types.push_back(type); 579 types.push_back(type);
583 } 580 }
584 } else if (it.key() == "tabId") { 581 } else if (it.key() == "tabId") {
585 if (!it.value().GetAsInteger(&tab_id)) 582 if (!it.value().GetAsInteger(&tab_id))
586 return false; 583 return false;
587 } else if (it.key() == "windowId") { 584 } else if (it.key() == "windowId") {
588 if (!it.value().GetAsInteger(&window_id)) 585 if (!it.value().GetAsInteger(&window_id))
589 return false; 586 return false;
590 } else { 587 } else {
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
689 frame_id_for_extension = GetFrameId(is_main_frame, frame_id); 686 frame_id_for_extension = GetFrameId(is_main_frame, frame_id);
690 parent_frame_id_for_extension = GetFrameId(parent_is_main_frame, 687 parent_frame_id_for_extension = GetFrameId(parent_is_main_frame,
691 parent_frame_id); 688 parent_frame_id);
692 689
693 out->SetString(keys::kRequestIdKey, 690 out->SetString(keys::kRequestIdKey,
694 base::Uint64ToString(request->identifier())); 691 base::Uint64ToString(request->identifier()));
695 out->SetString(keys::kUrlKey, request->url().spec()); 692 out->SetString(keys::kUrlKey, request->url().spec());
696 out->SetString(keys::kMethodKey, request->method()); 693 out->SetString(keys::kMethodKey, request->method());
697 out->SetInteger(keys::kFrameIdKey, frame_id_for_extension); 694 out->SetInteger(keys::kFrameIdKey, frame_id_for_extension);
698 out->SetInteger(keys::kParentFrameIdKey, parent_frame_id_for_extension); 695 out->SetInteger(keys::kParentFrameIdKey, parent_frame_id_for_extension);
699 out->SetString(keys::kTypeKey, utils::ResourceTypeToString(resource_type)); 696 out->SetString(keys::kTypeKey, helpers::ResourceTypeToString(resource_type));
700 out->SetDouble(keys::kTimeStampKey, base::Time::Now().ToDoubleT() * 1000); 697 out->SetDouble(keys::kTimeStampKey, base::Time::Now().ToDoubleT() * 1000);
701 if (web_request_event_router_delegate_) { 698 if (web_request_event_router_delegate_) {
702 web_request_event_router_delegate_->ExtractExtraRequestDetails( 699 web_request_event_router_delegate_->ExtractExtraRequestDetails(
703 request, out); 700 request, out);
704 } 701 }
705 } 702 }
706 703
707 int ExtensionWebRequestEventRouter::OnBeforeRequest( 704 int ExtensionWebRequestEventRouter::OnBeforeRequest(
708 void* browser_context, 705 void* browser_context,
709 InfoMap* extension_info_map, 706 InfoMap* extension_info_map,
(...skipping 1744 matching lines...) Expand 10 before | Expand all | Expand 10 after
2454 base::Bind(&WarningService::NotifyWarningsOnUI, profile_id(), warnings)); 2451 base::Bind(&WarningService::NotifyWarningsOnUI, profile_id(), warnings));
2455 2452
2456 // Continue gracefully. 2453 // Continue gracefully.
2457 RunSync(); 2454 RunSync();
2458 } 2455 }
2459 2456
2460 bool WebRequestHandlerBehaviorChangedFunction::RunSync() { 2457 bool WebRequestHandlerBehaviorChangedFunction::RunSync() {
2461 helpers::ClearCacheOnNavigation(); 2458 helpers::ClearCacheOnNavigation();
2462 return true; 2459 return true;
2463 } 2460 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698