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 "android_webview/browser/renderer_host/aw_resource_dispatcher_host_dele
gate.h" | 5 #include "android_webview/browser/renderer_host/aw_resource_dispatcher_host_dele
gate.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "android_webview/browser/aw_browser_context.h" | 10 #include "android_webview/browser/aw_browser_context.h" |
11 #include "android_webview/browser/aw_contents_client_bridge_base.h" | 11 #include "android_webview/browser/aw_contents_client_bridge.h" |
12 #include "android_webview/browser/aw_contents_io_thread_client.h" | 12 #include "android_webview/browser/aw_contents_io_thread_client.h" |
13 #include "android_webview/browser/aw_login_delegate.h" | 13 #include "android_webview/browser/aw_login_delegate.h" |
14 #include "android_webview/browser/aw_resource_context.h" | 14 #include "android_webview/browser/aw_resource_context.h" |
15 #include "android_webview/browser/aw_safe_browsing_config_helper.h" | 15 #include "android_webview/browser/aw_safe_browsing_config_helper.h" |
16 #include "android_webview/browser/aw_safe_browsing_resource_throttle.h" | 16 #include "android_webview/browser/aw_safe_browsing_resource_throttle.h" |
17 #include "android_webview/browser/net/aw_web_resource_request.h" | 17 #include "android_webview/browser/net/aw_web_resource_request.h" |
18 #include "android_webview/browser/renderer_host/auto_login_parser.h" | 18 #include "android_webview/browser/renderer_host/auto_login_parser.h" |
19 #include "android_webview/common/url_constants.h" | 19 #include "android_webview/common/url_constants.h" |
20 #include "base/memory/scoped_vector.h" | 20 #include "base/memory/scoped_vector.h" |
21 #include "components/navigation_interception/intercept_navigation_delegate.h" | 21 #include "components/navigation_interception/intercept_navigation_delegate.h" |
22 #include "components/safe_browsing_db/safe_browsing_api_handler.h" | 22 #include "components/safe_browsing_db/safe_browsing_api_handler.h" |
23 #include "components/web_restrictions/browser/web_restrictions_resource_throttle
.h" | 23 #include "components/web_restrictions/browser/web_restrictions_resource_throttle
.h" |
24 #include "content/public/browser/browser_thread.h" | 24 #include "content/public/browser/browser_thread.h" |
25 #include "content/public/browser/resource_dispatcher_host.h" | 25 #include "content/public/browser/resource_dispatcher_host.h" |
26 #include "content/public/browser/resource_dispatcher_host_login_delegate.h" | 26 #include "content/public/browser/resource_dispatcher_host_login_delegate.h" |
27 #include "content/public/browser/resource_request_info.h" | 27 #include "content/public/browser/resource_request_info.h" |
28 #include "content/public/browser/web_contents.h" | 28 #include "content/public/browser/web_contents.h" |
29 #include "net/base/load_flags.h" | 29 #include "net/base/load_flags.h" |
30 #include "net/base/net_errors.h" | 30 #include "net/base/net_errors.h" |
31 #include "net/http/http_response_headers.h" | 31 #include "net/http/http_response_headers.h" |
32 #include "net/url_request/url_request.h" | 32 #include "net/url_request/url_request.h" |
33 #include "net/url_request/url_request_status.h" | 33 #include "net/url_request/url_request_status.h" |
34 #include "url/url_constants.h" | 34 #include "url/url_constants.h" |
35 | 35 |
36 using android_webview::AwContentsIoThreadClient; | 36 using android_webview::AwContentsIoThreadClient; |
37 using android_webview::AwContentsClientBridgeBase; | 37 using android_webview::AwContentsClientBridge; |
38 using android_webview::AwWebResourceRequest; | 38 using android_webview::AwWebResourceRequest; |
39 using content::BrowserThread; | 39 using content::BrowserThread; |
40 using content::ResourceType; | 40 using content::ResourceType; |
41 using content::WebContents; | 41 using content::WebContents; |
42 using navigation_interception::InterceptNavigationDelegate; | 42 using navigation_interception::InterceptNavigationDelegate; |
43 | 43 |
44 namespace { | 44 namespace { |
45 | 45 |
46 base::LazyInstance<android_webview::AwResourceDispatcherHostDelegate>:: | 46 base::LazyInstance<android_webview::AwResourceDispatcherHostDelegate>:: |
47 DestructorAtExit g_webview_resource_dispatcher_host_delegate = | 47 DestructorAtExit g_webview_resource_dispatcher_host_delegate = |
(...skipping 14 matching lines...) Expand all Loading... |
62 // Called when ResourceDispathcerHost detects a download request. | 62 // Called when ResourceDispathcerHost detects a download request. |
63 // The download is already cancelled when this is called, since | 63 // The download is already cancelled when this is called, since |
64 // relevant for DownloadListener is already extracted. | 64 // relevant for DownloadListener is already extracted. |
65 void DownloadStartingOnUIThread( | 65 void DownloadStartingOnUIThread( |
66 const content::ResourceRequestInfo::WebContentsGetter& web_contents_getter, | 66 const content::ResourceRequestInfo::WebContentsGetter& web_contents_getter, |
67 const GURL& url, | 67 const GURL& url, |
68 const std::string& user_agent, | 68 const std::string& user_agent, |
69 const std::string& content_disposition, | 69 const std::string& content_disposition, |
70 const std::string& mime_type, | 70 const std::string& mime_type, |
71 int64_t content_length) { | 71 int64_t content_length) { |
72 AwContentsClientBridgeBase* client = | 72 AwContentsClientBridge* client = |
73 AwContentsClientBridgeBase::FromWebContentsGetter(web_contents_getter); | 73 AwContentsClientBridge::FromWebContentsGetter(web_contents_getter); |
74 if (!client) | 74 if (!client) |
75 return; | 75 return; |
76 client->NewDownload(url, user_agent, content_disposition, mime_type, | 76 client->NewDownload(url, user_agent, content_disposition, mime_type, |
77 content_length); | 77 content_length); |
78 } | 78 } |
79 | 79 |
80 void NewLoginRequestOnUIThread( | 80 void NewLoginRequestOnUIThread( |
81 const content::ResourceRequestInfo::WebContentsGetter& web_contents_getter, | 81 const content::ResourceRequestInfo::WebContentsGetter& web_contents_getter, |
82 const std::string& realm, | 82 const std::string& realm, |
83 const std::string& account, | 83 const std::string& account, |
84 const std::string& args) { | 84 const std::string& args) { |
85 AwContentsClientBridgeBase* client = | 85 AwContentsClientBridge* client = |
86 AwContentsClientBridgeBase::FromWebContentsGetter(web_contents_getter); | 86 AwContentsClientBridge::FromWebContentsGetter(web_contents_getter); |
87 if (!client) | 87 if (!client) |
88 return; | 88 return; |
89 client->NewLoginRequest(realm, account, args); | 89 client->NewLoginRequest(realm, account, args); |
90 } | 90 } |
91 | 91 |
92 void OnReceivedErrorOnUiThread( | 92 void OnReceivedErrorOnUiThread( |
93 const content::ResourceRequestInfo::WebContentsGetter& web_contents_getter, | 93 const content::ResourceRequestInfo::WebContentsGetter& web_contents_getter, |
94 const AwWebResourceRequest& request, | 94 const AwWebResourceRequest& request, |
95 int error_code) { | 95 int error_code) { |
96 AwContentsClientBridgeBase* client = | 96 AwContentsClientBridge* client = |
97 AwContentsClientBridgeBase::FromWebContentsGetter(web_contents_getter); | 97 AwContentsClientBridge::FromWebContentsGetter(web_contents_getter); |
98 if (!client) { | 98 if (!client) { |
99 DLOG(WARNING) << "client is null, onReceivedError dropped for " | 99 DLOG(WARNING) << "client is null, onReceivedError dropped for " |
100 << request.url; | 100 << request.url; |
101 return; | 101 return; |
102 } | 102 } |
103 client->OnReceivedError(request, error_code); | 103 client->OnReceivedError(request, error_code); |
104 } | 104 } |
105 | 105 |
106 } // namespace | 106 } // namespace |
107 | 107 |
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
514 net::HttpRequestHeaders headers; | 514 net::HttpRequestHeaders headers; |
515 headers.AddHeadersFromString(extra_headers); | 515 headers.AddHeadersFromString(extra_headers); |
516 for (net::HttpRequestHeaders::Iterator it(headers); it.GetNext(); ) { | 516 for (net::HttpRequestHeaders::Iterator it(headers); it.GetNext(); ) { |
517 request->SetExtraRequestHeaderByName(it.name(), it.value(), false); | 517 request->SetExtraRequestHeaderByName(it.name(), it.value(), false); |
518 } | 518 } |
519 } | 519 } |
520 } | 520 } |
521 } | 521 } |
522 | 522 |
523 } // namespace android_webview | 523 } // namespace android_webview |
OLD | NEW |