| 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 <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "android_webview/browser/aw_contents_io_thread_client.h" | 9 #include "android_webview/browser/aw_contents_io_thread_client.h" |
| 10 #include "android_webview/browser/aw_login_delegate.h" | 10 #include "android_webview/browser/aw_login_delegate.h" |
| 11 #include "android_webview/browser/aw_resource_context.h" | 11 #include "android_webview/browser/aw_resource_context.h" |
| 12 #include "android_webview/common/url_constants.h" | 12 #include "android_webview/common/url_constants.h" |
| 13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 14 #include "base/memory/scoped_vector.h" | 14 #include "base/memory/scoped_vector.h" |
| 15 #include "components/auto_login_parser/auto_login_parser.h" | 15 #include "components/auto_login_parser/auto_login_parser.h" |
| 16 #include "components/navigation_interception/intercept_navigation_delegate.h" | 16 #include "components/navigation_interception/intercept_navigation_delegate.h" |
| 17 #include "content/public/browser/browser_thread.h" | 17 #include "content/public/browser/browser_thread.h" |
| 18 #include "content/public/browser/resource_controller.h" | 18 #include "content/public/browser/resource_controller.h" |
| 19 #include "content/public/browser/resource_dispatcher_host.h" | 19 #include "content/public/browser/resource_dispatcher_host.h" |
| 20 #include "content/public/browser/resource_dispatcher_host_login_delegate.h" | 20 #include "content/public/browser/resource_dispatcher_host_login_delegate.h" |
| 21 #include "content/public/browser/resource_request_info.h" | 21 #include "content/public/browser/resource_request_info.h" |
| 22 #include "content/public/browser/resource_throttle.h" | 22 #include "content/public/browser/resource_throttle.h" |
| 23 #include "content/public/common/url_constants.h" | |
| 24 #include "net/base/load_flags.h" | 23 #include "net/base/load_flags.h" |
| 25 #include "net/base/net_errors.h" | 24 #include "net/base/net_errors.h" |
| 26 #include "net/http/http_response_headers.h" | 25 #include "net/http/http_response_headers.h" |
| 27 #include "net/url_request/url_request.h" | 26 #include "net/url_request/url_request.h" |
| 27 #include "url/url_constants.h" |
| 28 | 28 |
| 29 using android_webview::AwContentsIoThreadClient; | 29 using android_webview::AwContentsIoThreadClient; |
| 30 using content::BrowserThread; | 30 using content::BrowserThread; |
| 31 using navigation_interception::InterceptNavigationDelegate; | 31 using navigation_interception::InterceptNavigationDelegate; |
| 32 | 32 |
| 33 namespace { | 33 namespace { |
| 34 | 34 |
| 35 base::LazyInstance<android_webview::AwResourceDispatcherHostDelegate> | 35 base::LazyInstance<android_webview::AwResourceDispatcherHostDelegate> |
| 36 g_webview_resource_dispatcher_host_delegate = LAZY_INSTANCE_INITIALIZER; | 36 g_webview_resource_dispatcher_host_delegate = LAZY_INSTANCE_INITIALIZER; |
| 37 | 37 |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 const GURL& url = request_->url(); | 163 const GURL& url = request_->url(); |
| 164 if (!url.has_path() || | 164 if (!url.has_path() || |
| 165 // Application's assets and resources are always available. | 165 // Application's assets and resources are always available. |
| 166 (url.path().find(android_webview::kAndroidResourcePath) != 0 && | 166 (url.path().find(android_webview::kAndroidResourcePath) != 0 && |
| 167 url.path().find(android_webview::kAndroidAssetPath) != 0)) { | 167 url.path().find(android_webview::kAndroidAssetPath) != 0)) { |
| 168 return true; | 168 return true; |
| 169 } | 169 } |
| 170 } | 170 } |
| 171 | 171 |
| 172 if (io_client->ShouldBlockNetworkLoads()) { | 172 if (io_client->ShouldBlockNetworkLoads()) { |
| 173 if (request_->url().SchemeIs(content::kFtpScheme)) { | 173 if (request_->url().SchemeIs(url::kFtpScheme)) { |
| 174 return true; | 174 return true; |
| 175 } | 175 } |
| 176 SetCacheControlFlag(request_, net::LOAD_ONLY_FROM_CACHE); | 176 SetCacheControlFlag(request_, net::LOAD_ONLY_FROM_CACHE); |
| 177 } else { | 177 } else { |
| 178 AwContentsIoThreadClient::CacheMode cache_mode = io_client->GetCacheMode(); | 178 AwContentsIoThreadClient::CacheMode cache_mode = io_client->GetCacheMode(); |
| 179 switch(cache_mode) { | 179 switch(cache_mode) { |
| 180 case AwContentsIoThreadClient::LOAD_CACHE_ELSE_NETWORK: | 180 case AwContentsIoThreadClient::LOAD_CACHE_ELSE_NETWORK: |
| 181 SetCacheControlFlag(request_, net::LOAD_PREFERRING_CACHE); | 181 SetCacheControlFlag(request_, net::LOAD_PREFERRING_CACHE); |
| 182 break; | 182 break; |
| 183 case AwContentsIoThreadClient::LOAD_NO_CACHE: | 183 case AwContentsIoThreadClient::LOAD_NO_CACHE: |
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 421 net::HttpRequestHeaders headers; | 421 net::HttpRequestHeaders headers; |
| 422 headers.AddHeadersFromString(extra_headers); | 422 headers.AddHeadersFromString(extra_headers); |
| 423 for (net::HttpRequestHeaders::Iterator it(headers); it.GetNext(); ) { | 423 for (net::HttpRequestHeaders::Iterator it(headers); it.GetNext(); ) { |
| 424 request->SetExtraRequestHeaderByName(it.name(), it.value(), false); | 424 request->SetExtraRequestHeaderByName(it.name(), it.value(), false); |
| 425 } | 425 } |
| 426 } | 426 } |
| 427 } | 427 } |
| 428 } | 428 } |
| 429 | 429 |
| 430 } // namespace android_webview | 430 } // namespace android_webview |
| OLD | NEW |