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

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

Issue 464533002: Move guest_view to extensions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Small changes are made in guest_view_manager_unittest.cc Created 6 years, 4 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 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 return; 178 return;
179 const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(request); 179 const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(request);
180 *render_process_host_id = info->GetChildID(); 180 *render_process_host_id = info->GetChildID();
181 *routing_id = info->GetRouteID(); 181 *routing_id = info->GetRouteID();
182 } 182 }
183 183
184 // Given a |request|, this function determines whether it originated from 184 // Given a |request|, this function determines whether it originated from
185 // a <webview> guest process or not. If it is from a <webview> guest process, 185 // a <webview> guest process or not. If it is from a <webview> guest process,
186 // then |web_view_info| is returned with information about the instance ID 186 // then |web_view_info| is returned with information about the instance ID
187 // that uniquely identifies the <webview> and its embedder. 187 // that uniquely identifies the <webview> and its embedder.
188 bool GetWebViewInfo(net::URLRequest* request, 188 bool GetWebViewInfo(
189 WebViewRendererState::WebViewInfo* web_view_info) { 189 net::URLRequest* request,
190 extensions::WebViewRendererState::WebViewInfo* web_view_info) {
190 int render_process_host_id = -1; 191 int render_process_host_id = -1;
191 int routing_id = -1; 192 int routing_id = -1;
192 ExtractRequestRoutingInfo(request, &render_process_host_id, &routing_id); 193 ExtractRequestRoutingInfo(request, &render_process_host_id, &routing_id);
193 return WebViewRendererState::GetInstance()-> 194 return extensions::WebViewRendererState::GetInstance()->
194 GetInfo(render_process_host_id, routing_id, web_view_info); 195 GetInfo(render_process_host_id, routing_id, web_view_info);
195 } 196 }
196 197
197 void ExtractRequestInfoDetails(net::URLRequest* request, 198 void ExtractRequestInfoDetails(net::URLRequest* request,
198 bool* is_main_frame, 199 bool* is_main_frame,
199 int* frame_id, 200 int* frame_id,
200 bool* parent_is_main_frame, 201 bool* parent_is_main_frame,
201 int* parent_frame_id, 202 int* parent_frame_id,
202 int* tab_id, 203 int* tab_id,
203 int* window_id, 204 int* window_id,
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 // a <webview> guest renderer. 400 // a <webview> guest renderer.
400 // |extension_id| identifies the extension that sends and receives the event. 401 // |extension_id| identifies the extension that sends and receives the event.
401 // |is_web_view_guest| indicates whether the action is for a <webview>. 402 // |is_web_view_guest| indicates whether the action is for a <webview>.
402 // |web_view_info| is a struct containing information about the <webview> 403 // |web_view_info| is a struct containing information about the <webview>
403 // embedder. 404 // embedder.
404 // |event_argument| is passed to the event listener. 405 // |event_argument| is passed to the event listener.
405 void SendOnMessageEventOnUI( 406 void SendOnMessageEventOnUI(
406 void* profile_id, 407 void* profile_id,
407 const std::string& extension_id, 408 const std::string& extension_id,
408 bool is_web_view_guest, 409 bool is_web_view_guest,
409 const WebViewRendererState::WebViewInfo& web_view_info, 410 const extensions::WebViewRendererState::WebViewInfo& web_view_info,
410 scoped_ptr<base::DictionaryValue> event_argument) { 411 scoped_ptr<base::DictionaryValue> event_argument) {
411 DCHECK_CURRENTLY_ON(BrowserThread::UI); 412 DCHECK_CURRENTLY_ON(BrowserThread::UI);
412 413
413 Profile* profile = reinterpret_cast<Profile*>(profile_id); 414 Profile* profile = reinterpret_cast<Profile*>(profile_id);
414 if (!g_browser_process->profile_manager()->IsValidProfile(profile)) 415 if (!g_browser_process->profile_manager()->IsValidProfile(profile))
415 return; 416 return;
416 417
417 scoped_ptr<base::ListValue> event_args(new base::ListValue); 418 scoped_ptr<base::ListValue> event_args(new base::ListValue);
418 event_args->Append(event_argument.release()); 419 event_args->Append(event_argument.release());
419 420
(...skipping 1044 matching lines...) Expand 10 before | Expand all | Expand 10 after
1464 int window_id, 1465 int window_id,
1465 int render_process_host_id, 1466 int render_process_host_id,
1466 int routing_id, 1467 int routing_id,
1467 ResourceType resource_type, 1468 ResourceType resource_type,
1468 bool is_async_request, 1469 bool is_async_request,
1469 bool is_request_from_extension, 1470 bool is_request_from_extension,
1470 int* extra_info_spec, 1471 int* extra_info_spec,
1471 std::vector<const ExtensionWebRequestEventRouter::EventListener*>* 1472 std::vector<const ExtensionWebRequestEventRouter::EventListener*>*
1472 matching_listeners) { 1473 matching_listeners) {
1473 std::string web_request_event_name(event_name); 1474 std::string web_request_event_name(event_name);
1474 WebViewRendererState::WebViewInfo web_view_info; 1475 extensions::WebViewRendererState::WebViewInfo web_view_info;
1475 bool is_web_view_guest = WebViewRendererState::GetInstance()-> 1476 bool is_web_view_guest = extensions::WebViewRendererState::GetInstance()->
1476 GetInfo(render_process_host_id, routing_id, &web_view_info); 1477 GetInfo(render_process_host_id, routing_id, &web_view_info);
1477 if (is_web_view_guest) { 1478 if (is_web_view_guest) {
1478 web_request_event_name.replace( 1479 web_request_event_name.replace(
1479 0, sizeof(kWebRequestEventPrefix) - 1, webview::kWebViewEventPrefix); 1480 0, sizeof(kWebRequestEventPrefix) - 1, webview::kWebViewEventPrefix);
1480 } 1481 }
1481 1482
1482 std::set<EventListener>& listeners = 1483 std::set<EventListener>& listeners =
1483 listeners_[profile][web_request_event_name]; 1484 listeners_[profile][web_request_event_name];
1484 for (std::set<EventListener>::iterator it = listeners.begin(); 1485 for (std::set<EventListener>::iterator it = listeners.begin();
1485 it != listeners.end(); ++it) { 1486 it != listeners.end(); ++it) {
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
1841 void* profile, 1842 void* profile,
1842 const BlockedRequest& blocked_request) { 1843 const BlockedRequest& blocked_request) {
1843 const helpers::EventResponseDeltas& deltas = blocked_request.response_deltas; 1844 const helpers::EventResponseDeltas& deltas = blocked_request.response_deltas;
1844 for (helpers::EventResponseDeltas::const_iterator delta = deltas.begin(); 1845 for (helpers::EventResponseDeltas::const_iterator delta = deltas.begin();
1845 delta != deltas.end(); ++delta) { 1846 delta != deltas.end(); ++delta) {
1846 const std::set<std::string>& messages = (*delta)->messages_to_extension; 1847 const std::set<std::string>& messages = (*delta)->messages_to_extension;
1847 for (std::set<std::string>::const_iterator message = messages.begin(); 1848 for (std::set<std::string>::const_iterator message = messages.begin();
1848 message != messages.end(); ++message) { 1849 message != messages.end(); ++message) {
1849 scoped_ptr<base::DictionaryValue> argument(new base::DictionaryValue); 1850 scoped_ptr<base::DictionaryValue> argument(new base::DictionaryValue);
1850 ExtractRequestInfo(blocked_request.request, argument.get()); 1851 ExtractRequestInfo(blocked_request.request, argument.get());
1851 WebViewRendererState::WebViewInfo web_view_info; 1852 extensions::WebViewRendererState::WebViewInfo web_view_info;
1852 bool is_web_view_guest = GetWebViewInfo(blocked_request.request, 1853 bool is_web_view_guest = GetWebViewInfo(blocked_request.request,
1853 &web_view_info); 1854 &web_view_info);
1854 argument->SetString(keys::kMessageKey, *message); 1855 argument->SetString(keys::kMessageKey, *message);
1855 argument->SetString(keys::kStageKey, 1856 argument->SetString(keys::kStageKey,
1856 GetRequestStageAsString(blocked_request.event)); 1857 GetRequestStageAsString(blocked_request.event));
1857 1858
1858 BrowserThread::PostTask( 1859 BrowserThread::PostTask(
1859 BrowserThread::UI, 1860 BrowserThread::UI,
1860 FROM_HERE, 1861 FROM_HERE,
1861 base::Bind(&SendOnMessageEventOnUI, 1862 base::Bind(&SendOnMessageEventOnUI,
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
1970 return rv; 1971 return rv;
1971 } 1972 }
1972 1973
1973 bool ExtensionWebRequestEventRouter::ProcessDeclarativeRules( 1974 bool ExtensionWebRequestEventRouter::ProcessDeclarativeRules(
1974 void* profile, 1975 void* profile,
1975 InfoMap* extension_info_map, 1976 InfoMap* extension_info_map,
1976 const std::string& event_name, 1977 const std::string& event_name,
1977 net::URLRequest* request, 1978 net::URLRequest* request,
1978 extensions::RequestStage request_stage, 1979 extensions::RequestStage request_stage,
1979 const net::HttpResponseHeaders* original_response_headers) { 1980 const net::HttpResponseHeaders* original_response_headers) {
1980 WebViewRendererState::WebViewInfo web_view_info; 1981 extensions::WebViewRendererState::WebViewInfo web_view_info;
1981 bool is_web_view_guest = GetWebViewInfo(request, &web_view_info); 1982 bool is_web_view_guest = GetWebViewInfo(request, &web_view_info);
1982 1983
1983 RulesRegistryService::WebViewKey webview_key( 1984 RulesRegistryService::WebViewKey webview_key(
1984 is_web_view_guest ? web_view_info.embedder_process_id : 0, 1985 is_web_view_guest ? web_view_info.embedder_process_id : 0,
1985 is_web_view_guest ? web_view_info.instance_id : 0); 1986 is_web_view_guest ? web_view_info.instance_id : 0);
1986 RulesRegistryKey rules_key(profile, webview_key); 1987 RulesRegistryKey rules_key(profile, webview_key);
1987 // If this check fails, check that the active stages are up-to-date in 1988 // If this check fails, check that the active stages are up-to-date in
1988 // browser/extensions/api/declarative_webrequest/request_stage.h . 1989 // browser/extensions/api/declarative_webrequest/request_stage.h .
1989 DCHECK(request_stage & extensions::kActiveStages); 1990 DCHECK(request_stage & extensions::kActiveStages);
1990 1991
(...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after
2483 extensions::RuntimeData* runtime_data = 2484 extensions::RuntimeData* runtime_data =
2484 extensions::ExtensionSystem::Get(profile)->runtime_data(); 2485 extensions::ExtensionSystem::Get(profile)->runtime_data();
2485 for (extensions::ExtensionSet::const_iterator it = extensions.begin(); 2486 for (extensions::ExtensionSet::const_iterator it = extensions.begin();
2486 !webrequest_used && it != extensions.end(); 2487 !webrequest_used && it != extensions.end();
2487 ++it) { 2488 ++it) {
2488 webrequest_used |= runtime_data->HasUsedWebRequest(it->get()); 2489 webrequest_used |= runtime_data->HasUsedWebRequest(it->get());
2489 } 2490 }
2490 2491
2491 host->Send(new ExtensionMsg_UsingWebRequestAPI(webrequest_used)); 2492 host->Send(new ExtensionMsg_UsingWebRequestAPI(webrequest_used));
2492 } 2493 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698