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/extension_protocols.h" | 5 #include "chrome/browser/extensions/extension_protocols.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/base64.h" | 9 #include "base/base64.h" |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
11 #include "base/file_util.h" | 11 #include "base/file_util.h" |
12 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
13 #include "base/format_macros.h" | 13 #include "base/format_macros.h" |
14 #include "base/logging.h" | 14 #include "base/logging.h" |
15 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
16 #include "base/message_loop/message_loop.h" | 16 #include "base/message_loop/message_loop.h" |
17 #include "base/path_service.h" | 17 #include "base/path_service.h" |
18 #include "base/sha1.h" | 18 #include "base/sha1.h" |
19 #include "base/strings/string_util.h" | 19 #include "base/strings/string_util.h" |
20 #include "base/strings/stringprintf.h" | 20 #include "base/strings/stringprintf.h" |
21 #include "base/strings/utf_string_conversions.h" | 21 #include "base/strings/utf_string_conversions.h" |
22 #include "base/threading/sequenced_worker_pool.h" | 22 #include "base/threading/sequenced_worker_pool.h" |
23 #include "base/threading/thread_restrictions.h" | 23 #include "base/threading/thread_restrictions.h" |
24 #include "build/build_config.h" | 24 #include "build/build_config.h" |
25 #include "chrome/browser/extensions/extension_info_map.h" | 25 #include "chrome/browser/extensions/extension_info_map.h" |
26 #include "chrome/browser/extensions/extension_renderer_state.h" | |
26 #include "chrome/browser/extensions/image_loader.h" | 27 #include "chrome/browser/extensions/image_loader.h" |
27 #include "chrome/common/chrome_paths.h" | 28 #include "chrome/common/chrome_paths.h" |
28 #include "chrome/common/extensions/background_info.h" | 29 #include "chrome/common/extensions/background_info.h" |
29 #include "chrome/common/extensions/csp_handler.h" | 30 #include "chrome/common/extensions/csp_handler.h" |
30 #include "chrome/common/extensions/extension.h" | 31 #include "chrome/common/extensions/extension.h" |
31 #include "chrome/common/extensions/extension_file_util.h" | 32 #include "chrome/common/extensions/extension_file_util.h" |
32 #include "chrome/common/extensions/incognito_handler.h" | 33 #include "chrome/common/extensions/incognito_handler.h" |
33 #include "chrome/common/extensions/manifest_handlers/icons_handler.h" | 34 #include "chrome/common/extensions/manifest_handlers/icons_handler.h" |
34 #include "chrome/common/extensions/manifest_handlers/shared_module_info.h" | 35 #include "chrome/common/extensions/manifest_handlers/shared_module_info.h" |
35 #include "chrome/common/extensions/manifest_url_handler.h" | 36 #include "chrome/common/extensions/manifest_url_handler.h" |
36 #include "chrome/common/extensions/web_accessible_resources_handler.h" | 37 #include "chrome/common/extensions/web_accessible_resources_handler.h" |
38 #include "chrome/common/extensions/webview_accessible_resources_handler.h" | |
37 #include "chrome/common/url_constants.h" | 39 #include "chrome/common/url_constants.h" |
38 #include "content/public/browser/browser_thread.h" | 40 #include "content/public/browser/browser_thread.h" |
39 #include "content/public/browser/resource_request_info.h" | 41 #include "content/public/browser/resource_request_info.h" |
40 #include "extensions/common/constants.h" | 42 #include "extensions/common/constants.h" |
41 #include "extensions/common/extension_resource.h" | 43 #include "extensions/common/extension_resource.h" |
42 #include "grit/component_extension_resources_map.h" | 44 #include "grit/component_extension_resources_map.h" |
43 #include "net/base/mime_util.h" | 45 #include "net/base/mime_util.h" |
44 #include "net/base/net_errors.h" | 46 #include "net/base/net_errors.h" |
45 #include "net/http/http_response_headers.h" | 47 #include "net/http/http_response_headers.h" |
46 #include "net/http/http_response_info.h" | 48 #include "net/http/http_response_info.h" |
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
331 const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(request); | 333 const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(request); |
332 | 334 |
333 // We have seen crashes where info is NULL: crbug.com/52374. | 335 // We have seen crashes where info is NULL: crbug.com/52374. |
334 if (!info) { | 336 if (!info) { |
335 LOG(ERROR) << "Allowing load of " << request->url().spec() | 337 LOG(ERROR) << "Allowing load of " << request->url().spec() |
336 << "from unknown origin. Could not find user data for " | 338 << "from unknown origin. Could not find user data for " |
337 << "request."; | 339 << "request."; |
338 return true; | 340 return true; |
339 } | 341 } |
340 | 342 |
343 ExtensionRendererState* renderer_state = | |
Matt Perry
2013/09/24 21:06:54
Is there a reason you put this check here are the
Matt Perry
2013/09/24 23:09:29
ping
Fady Samuel
2013/09/24 23:35:15
Oops. I'm not sure how I missed this. It seems con
| |
344 ExtensionRendererState::GetInstance(); | |
345 ExtensionRendererState::WebViewInfo webview_info; | |
346 bool is_guest = renderer_state->GetWebViewInfo(info->GetChildID(), | |
347 info->GetRouteID(), | |
348 &webview_info); | |
349 std::string resource_path = request->url().path(); | |
350 if (is_guest && | |
351 extensions::WebviewAccessibleResourcesInfo::IsResourceWebviewAccessible( | |
352 extension, webview_info.partition_id, resource_path)) { | |
353 return true; | |
354 } | |
355 | |
341 if (is_incognito && !ExtensionCanLoadInIncognito(info, request->url().host(), | 356 if (is_incognito && !ExtensionCanLoadInIncognito(info, request->url().host(), |
342 extension_info_map)) { | 357 extension_info_map)) { |
343 return false; | 358 return false; |
344 } | 359 } |
345 | 360 |
346 // The following checks are meant to replicate similar set of checks in the | 361 // The following checks are meant to replicate similar set of checks in the |
347 // renderer process, performed by ResourceRequestPolicy::CanRequestResource. | 362 // renderer process, performed by ResourceRequestPolicy::CanRequestResource. |
348 // These are not exactly equivalent, because we don't have the same bits of | 363 // These are not exactly equivalent, because we don't have the same bits of |
349 // information. The two checks need to be kept in sync as much as possible, as | 364 // information. The two checks need to be kept in sync as much as possible, as |
350 // an exploited renderer can bypass the checks in ResourceRequestPolicy. | 365 // an exploited renderer can bypass the checks in ResourceRequestPolicy. |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
565 send_cors_header); | 580 send_cors_header); |
566 } | 581 } |
567 | 582 |
568 } // namespace | 583 } // namespace |
569 | 584 |
570 net::URLRequestJobFactory::ProtocolHandler* CreateExtensionProtocolHandler( | 585 net::URLRequestJobFactory::ProtocolHandler* CreateExtensionProtocolHandler( |
571 bool is_incognito, | 586 bool is_incognito, |
572 ExtensionInfoMap* extension_info_map) { | 587 ExtensionInfoMap* extension_info_map) { |
573 return new ExtensionProtocolHandler(is_incognito, extension_info_map); | 588 return new ExtensionProtocolHandler(is_incognito, extension_info_map); |
574 } | 589 } |
OLD | NEW |