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/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 15 matching lines...) Expand all Loading... | |
26 #include "chrome/browser/extensions/api/declarative_webrequest/webrequest_consta nts.h" | 26 #include "chrome/browser/extensions/api/declarative_webrequest/webrequest_consta nts.h" |
27 #include "chrome/browser/extensions/api/declarative_webrequest/webrequest_rules_ registry.h" | 27 #include "chrome/browser/extensions/api/declarative_webrequest/webrequest_rules_ registry.h" |
28 #include "chrome/browser/extensions/api/web_navigation/web_navigation_api_helper s.h" | 28 #include "chrome/browser/extensions/api/web_navigation/web_navigation_api_helper s.h" |
29 #include "chrome/browser/extensions/api/web_request/upload_data_presenter.h" | 29 #include "chrome/browser/extensions/api/web_request/upload_data_presenter.h" |
30 #include "chrome/browser/extensions/api/web_request/web_request_api_constants.h" | 30 #include "chrome/browser/extensions/api/web_request/web_request_api_constants.h" |
31 #include "chrome/browser/extensions/api/web_request/web_request_api_helpers.h" | 31 #include "chrome/browser/extensions/api/web_request/web_request_api_helpers.h" |
32 #include "chrome/browser/extensions/api/web_request/web_request_time_tracker.h" | 32 #include "chrome/browser/extensions/api/web_request/web_request_time_tracker.h" |
33 #include "chrome/browser/extensions/extension_renderer_state.h" | 33 #include "chrome/browser/extensions/extension_renderer_state.h" |
34 #include "chrome/browser/extensions/extension_warning_service.h" | 34 #include "chrome/browser/extensions/extension_warning_service.h" |
35 #include "chrome/browser/extensions/extension_warning_set.h" | 35 #include "chrome/browser/extensions/extension_warning_set.h" |
36 #include "chrome/browser/guest_view/web_view/web_view_constants.h" | |
36 #include "chrome/browser/profiles/profile.h" | 37 #include "chrome/browser/profiles/profile.h" |
37 #include "chrome/browser/profiles/profile_manager.h" | 38 #include "chrome/browser/profiles/profile_manager.h" |
38 #include "chrome/common/extensions/api/web_request.h" | 39 #include "chrome/common/extensions/api/web_request.h" |
39 #include "chrome/common/extensions/extension_constants.h" | 40 #include "chrome/common/extensions/extension_constants.h" |
40 #include "chrome/common/url_constants.h" | 41 #include "chrome/common/url_constants.h" |
41 #include "content/public/browser/browser_message_filter.h" | 42 #include "content/public/browser/browser_message_filter.h" |
42 #include "content/public/browser/browser_thread.h" | 43 #include "content/public/browser/browser_thread.h" |
43 #include "content/public/browser/render_process_host.h" | 44 #include "content/public/browser/render_process_host.h" |
44 #include "content/public/browser/resource_request_info.h" | 45 #include "content/public/browser/resource_request_info.h" |
45 #include "content/public/browser/user_metrics.h" | 46 #include "content/public/browser/user_metrics.h" |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
156 const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(request); | 157 const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(request); |
157 | 158 |
158 // If this request was not created by the ResourceDispatcher, |info| is NULL. | 159 // If this request was not created by the ResourceDispatcher, |info| is NULL. |
159 // All requests from extensions are created by the ResourceDispatcher. | 160 // All requests from extensions are created by the ResourceDispatcher. |
160 if (!info) | 161 if (!info) |
161 return false; | 162 return false; |
162 | 163 |
163 return extension_info_map->process_map().Contains(info->GetChildID()); | 164 return extension_info_map->process_map().Contains(info->GetChildID()); |
164 } | 165 } |
165 | 166 |
167 void ExtractRequestRoutingInfo(net::URLRequest* request, | |
168 int* render_process_host_id, | |
169 int* routing_id) { | |
170 if (!request->GetUserData(NULL)) | |
171 return; | |
172 const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(request); | |
173 *render_process_host_id = info->GetChildID(); | |
174 *routing_id = info->GetRouteID(); | |
175 } | |
176 | |
177 // Given a |request|, this function determines whether it originated from | |
178 // a <webview> guest process or not. If it is from a <webview> guest process, | |
179 // then |web_view_info| is returned with information about the instance ID | |
180 // that uniquely identifies the <webview> and its embedder. | |
181 bool GetWebViewInfo(net::URLRequest* request, | |
182 ExtensionRendererState::WebViewInfo* web_view_info) { | |
183 int render_process_host_id = -1; | |
184 int routing_id = -1; | |
185 ExtractRequestRoutingInfo(request, &render_process_host_id, &routing_id); | |
186 return ExtensionRendererState::GetInstance()-> | |
187 GetWebViewInfo(render_process_host_id, routing_id, web_view_info); | |
188 } | |
189 | |
166 void ExtractRequestInfoDetails(net::URLRequest* request, | 190 void ExtractRequestInfoDetails(net::URLRequest* request, |
167 bool* is_main_frame, | 191 bool* is_main_frame, |
168 int64* frame_id, | 192 int64* frame_id, |
169 bool* parent_is_main_frame, | 193 bool* parent_is_main_frame, |
170 int64* parent_frame_id, | 194 int64* parent_frame_id, |
171 int* tab_id, | 195 int* tab_id, |
172 int* window_id, | 196 int* window_id, |
173 int* render_process_host_id, | 197 int* render_process_host_id, |
174 int* routing_id, | 198 int* routing_id, |
175 ResourceType::Type* resource_type) { | 199 ResourceType::Type* resource_type) { |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
356 return; | 380 return; |
357 | 381 |
358 content::RenderProcessHost* process = | 382 content::RenderProcessHost* process = |
359 content::RenderProcessHost::FromID(process_id); | 383 content::RenderProcessHost::FromID(process_id); |
360 if (!process) | 384 if (!process) |
361 return; | 385 return; |
362 | 386 |
363 event_router->RemoveEventListener(event_name, process, extension_id); | 387 event_router->RemoveEventListener(event_name, process, extension_id); |
364 } | 388 } |
365 | 389 |
366 // Sends an event to subscribers of chrome.declarativeWebRequest.onMessage. | 390 // Sends an event to subscribers of chrome.declarativeWebRequest.onMessage or |
391 // to subscribers of webview.onMessage if the action is being operated upon | |
392 // a <webview> guest renderer. | |
367 // |extension_id| identifies the extension that sends and receives the event. | 393 // |extension_id| identifies the extension that sends and receives the event. |
394 // |is_web_view_guest| indicates whether the action is for a <webview>. | |
395 // |web_view_info| is a struct containing information about the <webview> | |
396 // embedder. | |
368 // |event_argument| is passed to the event listener. | 397 // |event_argument| is passed to the event listener. |
369 void SendOnMessageEventOnUI( | 398 void SendOnMessageEventOnUI( |
370 void* profile_id, | 399 void* profile_id, |
371 const std::string& extension_id, | 400 const std::string& extension_id, |
401 int is_web_view_guest, | |
battre
2014/05/28 15:15:21
bool?
Fady Samuel
2014/05/29 15:13:27
Done.
| |
402 const ExtensionRendererState::WebViewInfo& web_view_info, | |
372 scoped_ptr<base::DictionaryValue> event_argument) { | 403 scoped_ptr<base::DictionaryValue> event_argument) { |
373 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 404 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
374 | 405 |
375 Profile* profile = reinterpret_cast<Profile*>(profile_id); | 406 Profile* profile = reinterpret_cast<Profile*>(profile_id); |
376 if (!g_browser_process->profile_manager()->IsValidProfile(profile)) | 407 if (!g_browser_process->profile_manager()->IsValidProfile(profile)) |
377 return; | 408 return; |
378 | 409 |
379 scoped_ptr<base::ListValue> event_args(new base::ListValue); | 410 scoped_ptr<base::ListValue> event_args(new base::ListValue); |
380 event_args->Append(event_argument.release()); | 411 event_args->Append(event_argument.release()); |
381 | 412 |
382 extensions::EventRouter* event_router = extensions::EventRouter::Get(profile); | 413 extensions::EventRouter* event_router = extensions::EventRouter::Get(profile); |
383 | 414 |
415 extensions::EventFilteringInfo event_filtering_info; | |
battre
2014/05/28 15:15:21
More stuff that could use some documentation. ;-)
Fady Samuel
2014/05/29 15:13:27
I have no clue what service_type_ is but instance_
| |
416 event_filtering_info.SetURL(GURL()); | |
battre
2014/05/28 15:15:21
This looks crude... You set a URL such that EventF
Fady Samuel
2014/05/29 15:13:27
This is actually unnecessary. I've removed it.
| |
417 if (is_web_view_guest) | |
418 event_filtering_info.SetInstanceID(web_view_info.instance_id); | |
419 | |
384 scoped_ptr<extensions::Event> event(new extensions::Event( | 420 scoped_ptr<extensions::Event> event(new extensions::Event( |
385 declarative_keys::kOnMessage, event_args.Pass(), profile, | 421 is_web_view_guest ? webview::kEventMessage : declarative_keys::kOnMessage, |
386 GURL(), extensions::EventRouter::USER_GESTURE_UNKNOWN, | 422 event_args.Pass(), profile, GURL(), |
387 extensions::EventFilteringInfo())); | 423 extensions::EventRouter::USER_GESTURE_UNKNOWN, |
424 event_filtering_info)); | |
388 event_router->DispatchEventToExtension(extension_id, event.Pass()); | 425 event_router->DispatchEventToExtension(extension_id, event.Pass()); |
389 } | 426 } |
390 | 427 |
391 void RemoveEventListenerOnIOThread( | 428 void RemoveEventListenerOnIOThread( |
392 content::BrowserContext* browser_context, | 429 content::BrowserContext* browser_context, |
393 const std::string& extension_id, | 430 const std::string& extension_id, |
394 const std::string& sub_event_name) { | 431 const std::string& sub_event_name) { |
395 ExtensionWebRequestEventRouter::GetInstance()->RemoveEventListener( | 432 ExtensionWebRequestEventRouter::GetInstance()->RemoveEventListener( |
396 browser_context, extension_id, sub_event_name); | 433 browser_context, extension_id, sub_event_name); |
397 } | 434 } |
(...skipping 1014 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1412 int window_id, | 1449 int window_id, |
1413 int render_process_host_id, | 1450 int render_process_host_id, |
1414 int routing_id, | 1451 int routing_id, |
1415 ResourceType::Type resource_type, | 1452 ResourceType::Type resource_type, |
1416 bool is_async_request, | 1453 bool is_async_request, |
1417 bool is_request_from_extension, | 1454 bool is_request_from_extension, |
1418 int* extra_info_spec, | 1455 int* extra_info_spec, |
1419 std::vector<const ExtensionWebRequestEventRouter::EventListener*>* | 1456 std::vector<const ExtensionWebRequestEventRouter::EventListener*>* |
1420 matching_listeners) { | 1457 matching_listeners) { |
1421 std::string web_request_event_name(event_name); | 1458 std::string web_request_event_name(event_name); |
1422 ExtensionRendererState::WebViewInfo webview_info; | 1459 ExtensionRendererState::WebViewInfo web_view_info; |
1423 bool is_guest = ExtensionRendererState::GetInstance()-> | 1460 bool is_web_view_guest = ExtensionRendererState::GetInstance()-> |
1424 GetWebViewInfo(render_process_host_id, routing_id, &webview_info); | 1461 GetWebViewInfo(render_process_host_id, routing_id, &web_view_info); |
1425 if (is_guest) | 1462 if (is_web_view_guest) |
1426 web_request_event_name.replace(0, sizeof(kWebRequest) - 1, kWebView); | 1463 web_request_event_name.replace(0, sizeof(kWebRequest) - 1, kWebView); |
1427 | 1464 |
1428 std::set<EventListener>& listeners = | 1465 std::set<EventListener>& listeners = |
1429 listeners_[profile][web_request_event_name]; | 1466 listeners_[profile][web_request_event_name]; |
1430 for (std::set<EventListener>::iterator it = listeners.begin(); | 1467 for (std::set<EventListener>::iterator it = listeners.begin(); |
1431 it != listeners.end(); ++it) { | 1468 it != listeners.end(); ++it) { |
1432 if (!it->ipc_sender.get()) { | 1469 if (!it->ipc_sender.get()) { |
1433 // The IPC sender has been deleted. This listener will be removed soon | 1470 // The IPC sender has been deleted. This listener will be removed soon |
1434 // via a call to RemoveEventListener. For now, just skip it. | 1471 // via a call to RemoveEventListener. For now, just skip it. |
1435 continue; | 1472 continue; |
1436 } | 1473 } |
1437 | 1474 |
1438 if (is_guest && | 1475 if (is_web_view_guest && |
1439 (it->embedder_process_id != webview_info.embedder_process_id || | 1476 (it->embedder_process_id != web_view_info.embedder_process_id || |
1440 it->webview_instance_id != webview_info.instance_id)) | 1477 it->webview_instance_id != web_view_info.instance_id)) |
1441 continue; | 1478 continue; |
1442 | 1479 |
1443 if (!it->filter.urls.is_empty() && !it->filter.urls.MatchesURL(url)) | 1480 if (!it->filter.urls.is_empty() && !it->filter.urls.MatchesURL(url)) |
1444 continue; | 1481 continue; |
1445 if (it->filter.tab_id != -1 && tab_id != it->filter.tab_id) | 1482 if (it->filter.tab_id != -1 && tab_id != it->filter.tab_id) |
1446 continue; | 1483 continue; |
1447 if (it->filter.window_id != -1 && window_id != it->filter.window_id) | 1484 if (it->filter.window_id != -1 && window_id != it->filter.window_id) |
1448 continue; | 1485 continue; |
1449 if (!it->filter.types.empty() && | 1486 if (!it->filter.types.empty() && |
1450 std::find(it->filter.types.begin(), it->filter.types.end(), | 1487 std::find(it->filter.types.begin(), it->filter.types.end(), |
1451 resource_type) == it->filter.types.end()) | 1488 resource_type) == it->filter.types.end()) |
1452 continue; | 1489 continue; |
1453 | 1490 |
1454 if (!is_guest && !WebRequestPermissions::CanExtensionAccessURL( | 1491 if (!is_web_view_guest && !WebRequestPermissions::CanExtensionAccessURL( |
1455 extension_info_map, it->extension_id, url, crosses_incognito, | 1492 extension_info_map, it->extension_id, url, crosses_incognito, |
1456 WebRequestPermissions::REQUIRE_HOST_PERMISSION)) | 1493 WebRequestPermissions::REQUIRE_HOST_PERMISSION)) |
1457 continue; | 1494 continue; |
1458 | 1495 |
1459 bool blocking_listener = | 1496 bool blocking_listener = |
1460 (it->extra_info_spec & | 1497 (it->extra_info_spec & |
1461 (ExtraInfoSpec::BLOCKING | ExtraInfoSpec::ASYNC_BLOCKING)) != 0; | 1498 (ExtraInfoSpec::BLOCKING | ExtraInfoSpec::ASYNC_BLOCKING)) != 0; |
1462 | 1499 |
1463 // We do not want to notify extensions about XHR requests that are | 1500 // We do not want to notify extensions about XHR requests that are |
1464 // triggered by themselves. This is a workaround to prevent deadlocks | 1501 // triggered by themselves. This is a workaround to prevent deadlocks |
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1786 void* profile, | 1823 void* profile, |
1787 const BlockedRequest& blocked_request) { | 1824 const BlockedRequest& blocked_request) { |
1788 const helpers::EventResponseDeltas& deltas = blocked_request.response_deltas; | 1825 const helpers::EventResponseDeltas& deltas = blocked_request.response_deltas; |
1789 for (helpers::EventResponseDeltas::const_iterator delta = deltas.begin(); | 1826 for (helpers::EventResponseDeltas::const_iterator delta = deltas.begin(); |
1790 delta != deltas.end(); ++delta) { | 1827 delta != deltas.end(); ++delta) { |
1791 const std::set<std::string>& messages = (*delta)->messages_to_extension; | 1828 const std::set<std::string>& messages = (*delta)->messages_to_extension; |
1792 for (std::set<std::string>::const_iterator message = messages.begin(); | 1829 for (std::set<std::string>::const_iterator message = messages.begin(); |
1793 message != messages.end(); ++message) { | 1830 message != messages.end(); ++message) { |
1794 scoped_ptr<base::DictionaryValue> argument(new base::DictionaryValue); | 1831 scoped_ptr<base::DictionaryValue> argument(new base::DictionaryValue); |
1795 ExtractRequestInfo(blocked_request.request, argument.get()); | 1832 ExtractRequestInfo(blocked_request.request, argument.get()); |
1833 ExtensionRendererState::WebViewInfo web_view_info; | |
1834 bool is_web_view_guest = GetWebViewInfo(blocked_request.request, | |
1835 &web_view_info); | |
1796 argument->SetString(keys::kMessageKey, *message); | 1836 argument->SetString(keys::kMessageKey, *message); |
1797 argument->SetString(keys::kStageKey, | 1837 argument->SetString(keys::kStageKey, |
1798 GetRequestStageAsString(blocked_request.event)); | 1838 GetRequestStageAsString(blocked_request.event)); |
1799 | 1839 |
1800 BrowserThread::PostTask( | 1840 BrowserThread::PostTask( |
1801 BrowserThread::UI, | 1841 BrowserThread::UI, |
1802 FROM_HERE, | 1842 FROM_HERE, |
1803 base::Bind(&SendOnMessageEventOnUI, | 1843 base::Bind(&SendOnMessageEventOnUI, |
1804 profile, | 1844 profile, |
1805 (*delta)->extension_id, | 1845 (*delta)->extension_id, |
1846 is_web_view_guest, | |
1847 web_view_info, | |
1806 base::Passed(&argument))); | 1848 base::Passed(&argument))); |
1807 } | 1849 } |
1808 } | 1850 } |
1809 } | 1851 } |
1810 | 1852 |
1811 int ExtensionWebRequestEventRouter::ExecuteDeltas( | 1853 int ExtensionWebRequestEventRouter::ExecuteDeltas( |
1812 void* profile, | 1854 void* profile, |
1813 uint64 request_id, | 1855 uint64 request_id, |
1814 bool call_callback) { | 1856 bool call_callback) { |
1815 BlockedRequest& blocked_request = blocked_requests_[request_id]; | 1857 BlockedRequest& blocked_request = blocked_requests_[request_id]; |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1910 return rv; | 1952 return rv; |
1911 } | 1953 } |
1912 | 1954 |
1913 bool ExtensionWebRequestEventRouter::ProcessDeclarativeRules( | 1955 bool ExtensionWebRequestEventRouter::ProcessDeclarativeRules( |
1914 void* profile, | 1956 void* profile, |
1915 InfoMap* extension_info_map, | 1957 InfoMap* extension_info_map, |
1916 const std::string& event_name, | 1958 const std::string& event_name, |
1917 net::URLRequest* request, | 1959 net::URLRequest* request, |
1918 extensions::RequestStage request_stage, | 1960 extensions::RequestStage request_stage, |
1919 const net::HttpResponseHeaders* original_response_headers) { | 1961 const net::HttpResponseHeaders* original_response_headers) { |
1920 bool is_main_frame = false; | 1962 ExtensionRendererState::WebViewInfo web_view_info; |
1921 int64 frame_id = -1; | 1963 bool is_web_view_guest = GetWebViewInfo(request, &web_view_info); |
1922 bool parent_is_main_frame = false; | |
1923 int64 parent_frame_id = -1; | |
1924 int tab_id = -1; | |
1925 int window_id = -1; | |
1926 int render_process_host_id = -1; | |
1927 int routing_id = -1; | |
1928 ResourceType::Type resource_type = ResourceType::LAST_TYPE; | |
1929 | |
1930 ExtractRequestInfoDetails(request, &is_main_frame, &frame_id, | |
1931 &parent_is_main_frame, &parent_frame_id, | |
1932 &tab_id, &window_id, &render_process_host_id, | |
1933 &routing_id, &resource_type); | |
1934 ExtensionRendererState::WebViewInfo webview_info; | |
1935 bool is_guest = ExtensionRendererState::GetInstance()-> | |
1936 GetWebViewInfo(render_process_host_id, routing_id, &webview_info); | |
1937 | 1964 |
1938 RulesRegistryService::WebViewKey webview_key( | 1965 RulesRegistryService::WebViewKey webview_key( |
1939 is_guest ? webview_info.embedder_process_id : 0, | 1966 is_web_view_guest ? web_view_info.embedder_process_id : 0, |
1940 is_guest ? webview_info.instance_id : 0); | 1967 is_web_view_guest ? web_view_info.instance_id : 0); |
1941 RulesRegistryKey rules_key(profile, webview_key); | 1968 RulesRegistryKey rules_key(profile, webview_key); |
1942 | |
1943 // If this check fails, check that the active stages are up-to-date in | 1969 // If this check fails, check that the active stages are up-to-date in |
1944 // browser/extensions/api/declarative_webrequest/request_stage.h . | 1970 // browser/extensions/api/declarative_webrequest/request_stage.h . |
1945 DCHECK(request_stage & extensions::kActiveStages); | 1971 DCHECK(request_stage & extensions::kActiveStages); |
1946 | 1972 |
1947 // Rules of the current |profile| may apply but we need to check also whether | 1973 // Rules of the current |profile| may apply but we need to check also whether |
1948 // there are applicable rules from extensions whose background page | 1974 // there are applicable rules from extensions whose background page |
1949 // spans from regular to incognito mode. | 1975 // spans from regular to incognito mode. |
1950 | 1976 |
1951 // First parameter identifies the registry, the second indicates whether the | 1977 // First parameter identifies the registry, the second indicates whether the |
1952 // registry belongs to the cross profile. | 1978 // registry belongs to the cross profile. |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2176 | 2202 |
2177 base::WeakPtr<extensions::ExtensionMessageFilter> ipc_sender = | 2203 base::WeakPtr<extensions::ExtensionMessageFilter> ipc_sender = |
2178 ipc_sender_weak(); | 2204 ipc_sender_weak(); |
2179 int embedder_process_id = | 2205 int embedder_process_id = |
2180 ipc_sender.get() ? ipc_sender->render_process_id() : -1; | 2206 ipc_sender.get() ? ipc_sender->render_process_id() : -1; |
2181 | 2207 |
2182 const Extension* extension = | 2208 const Extension* extension = |
2183 extension_info_map()->extensions().GetByID(extension_id()); | 2209 extension_info_map()->extensions().GetByID(extension_id()); |
2184 std::string extension_name = extension ? extension->name() : extension_id(); | 2210 std::string extension_name = extension ? extension->name() : extension_id(); |
2185 | 2211 |
2186 bool is_guest = webview_instance_id != 0; | 2212 bool is_web_view_guest = webview_instance_id != 0; |
2187 // We check automatically whether the extension has the 'webRequest' | 2213 // We check automatically whether the extension has the 'webRequest' |
2188 // permission. For blocking calls we require the additional permission | 2214 // permission. For blocking calls we require the additional permission |
2189 // 'webRequestBlocking'. | 2215 // 'webRequestBlocking'. |
2190 if ((!is_guest && extra_info_spec & | 2216 if ((!is_web_view_guest && extra_info_spec & |
2191 (ExtensionWebRequestEventRouter::ExtraInfoSpec::BLOCKING | | 2217 (ExtensionWebRequestEventRouter::ExtraInfoSpec::BLOCKING | |
2192 ExtensionWebRequestEventRouter::ExtraInfoSpec::ASYNC_BLOCKING)) && | 2218 ExtensionWebRequestEventRouter::ExtraInfoSpec::ASYNC_BLOCKING)) && |
2193 !extension->HasAPIPermission( | 2219 !extension->HasAPIPermission( |
2194 extensions::APIPermission::kWebRequestBlocking)) { | 2220 extensions::APIPermission::kWebRequestBlocking)) { |
2195 error_ = keys::kBlockingPermissionRequired; | 2221 error_ = keys::kBlockingPermissionRequired; |
2196 return false; | 2222 return false; |
2197 } | 2223 } |
2198 | 2224 |
2199 // We allow to subscribe to patterns that are broader than the host | 2225 // We allow to subscribe to patterns that are broader than the host |
2200 // permissions. E.g., we could subscribe to http://www.example.com/* | 2226 // permissions. E.g., we could subscribe to http://www.example.com/* |
2201 // while having host permissions for http://www.example.com/foo/* and | 2227 // while having host permissions for http://www.example.com/foo/* and |
2202 // http://www.example.com/bar/*. | 2228 // http://www.example.com/bar/*. |
2203 // For this reason we do only a coarse check here to warn the extension | 2229 // For this reason we do only a coarse check here to warn the extension |
2204 // developer if he does something obviously wrong. | 2230 // developer if he does something obviously wrong. |
2205 if (!is_guest && extensions::PermissionsData::GetEffectiveHostPermissions( | 2231 if (!is_web_view_guest && |
2232 extensions::PermissionsData::GetEffectiveHostPermissions( | |
2206 extension).is_empty()) { | 2233 extension).is_empty()) { |
2207 error_ = keys::kHostPermissionsRequired; | 2234 error_ = keys::kHostPermissionsRequired; |
2208 return false; | 2235 return false; |
2209 } | 2236 } |
2210 | 2237 |
2211 bool success = | 2238 bool success = |
2212 ExtensionWebRequestEventRouter::GetInstance()->AddEventListener( | 2239 ExtensionWebRequestEventRouter::GetInstance()->AddEventListener( |
2213 profile_id(), extension_id(), extension_name, | 2240 profile_id(), extension_id(), extension_name, |
2214 event_name, sub_event_name, filter, extra_info_spec, | 2241 event_name, sub_event_name, filter, extra_info_spec, |
2215 embedder_process_id, webview_instance_id, ipc_sender_weak()); | 2242 embedder_process_id, webview_instance_id, ipc_sender_weak()); |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2445 } else if ((*it)->name().find("AdBlock") != std::string::npos) { | 2472 } else if ((*it)->name().find("AdBlock") != std::string::npos) { |
2446 adblock = true; | 2473 adblock = true; |
2447 } else { | 2474 } else { |
2448 other = true; | 2475 other = true; |
2449 } | 2476 } |
2450 } | 2477 } |
2451 } | 2478 } |
2452 | 2479 |
2453 host->Send(new ExtensionMsg_UsingWebRequestAPI(adblock, adblock_plus, other)); | 2480 host->Send(new ExtensionMsg_UsingWebRequestAPI(adblock, adblock_plus, other)); |
2454 } | 2481 } |
OLD | NEW |