| 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/net/aw_url_request_context_getter.h" | 5 #include "android_webview/browser/net/aw_url_request_context_getter.h" | 
| 6 | 6 | 
| 7 #include <vector> | 7 #include <vector> | 
| 8 | 8 | 
| 9 #include "android_webview/browser/aw_browser_context.h" | 9 #include "android_webview/browser/aw_browser_context.h" | 
| 10 #include "android_webview/browser/aw_content_browser_client.h" | 10 #include "android_webview/browser/aw_content_browser_client.h" | 
| 11 #include "android_webview/browser/aw_request_interceptor.h" | 11 #include "android_webview/browser/aw_request_interceptor.h" | 
| 12 #include "android_webview/browser/net/aw_network_delegate.h" | 12 #include "android_webview/browser/net/aw_network_delegate.h" | 
| 13 #include "android_webview/browser/net/aw_url_request_job_factory.h" | 13 #include "android_webview/browser/net/aw_url_request_job_factory.h" | 
| 14 #include "android_webview/browser/net/init_native_callback.h" | 14 #include "android_webview/browser/net/init_native_callback.h" | 
| 15 #include "android_webview/common/aw_switches.h" | 15 #include "android_webview/common/aw_switches.h" | 
| 16 #include "base/command_line.h" | 16 #include "base/command_line.h" | 
| 17 #include "content/public/browser/browser_thread.h" | 17 #include "content/public/browser/browser_thread.h" | 
| 18 #include "content/public/browser/content_browser_client.h" | 18 #include "content/public/browser/content_browser_client.h" | 
| 19 #include "content/public/browser/cookie_store_factory.h" | 19 #include "content/public/browser/cookie_store_factory.h" | 
| 20 #include "content/public/common/content_client.h" | 20 #include "content/public/common/content_client.h" | 
|  | 21 #include "content/public/common/content_constants.h" | 
| 21 #include "content/public/common/url_constants.h" | 22 #include "content/public/common/url_constants.h" | 
| 22 #include "net/base/cache_type.h" | 23 #include "net/base/cache_type.h" | 
| 23 #include "net/cookies/cookie_store.h" | 24 #include "net/cookies/cookie_store.h" | 
| 24 #include "net/http/http_cache.h" | 25 #include "net/http/http_cache.h" | 
| 25 #include "net/proxy/proxy_service.h" | 26 #include "net/proxy/proxy_service.h" | 
| 26 #include "net/url_request/data_protocol_handler.h" | 27 #include "net/url_request/data_protocol_handler.h" | 
| 27 #include "net/url_request/file_protocol_handler.h" | 28 #include "net/url_request/file_protocol_handler.h" | 
| 28 #include "net/url_request/protocol_intercept_job_factory.h" | 29 #include "net/url_request/protocol_intercept_job_factory.h" | 
| 29 #include "net/url_request/url_request_context_builder.h" | 30 #include "net/url_request/url_request_context_builder.h" | 
| 30 #include "net/url_request/url_request_context.h" | 31 #include "net/url_request/url_request_context.h" | 
| (...skipping 16 matching lines...) Expand all  Loading... | 
| 47   BrowserThread::SetDelegate(BrowserThread::IO, this); | 48   BrowserThread::SetDelegate(BrowserThread::IO, this); | 
| 48 } | 49 } | 
| 49 | 50 | 
| 50 AwURLRequestContextGetter::~AwURLRequestContextGetter() { | 51 AwURLRequestContextGetter::~AwURLRequestContextGetter() { | 
| 51   BrowserThread::SetDelegate(BrowserThread::IO, NULL); | 52   BrowserThread::SetDelegate(BrowserThread::IO, NULL); | 
| 52 } | 53 } | 
| 53 | 54 | 
| 54 void AwURLRequestContextGetter::Init() { | 55 void AwURLRequestContextGetter::Init() { | 
| 55   DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 56   DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 
| 56 | 57 | 
| 57   cookie_store_ = content::CreatePersistentCookieStore( | 58   // By default session cookies are always restored. An Android application can | 
| 58       browser_context_->GetPath().Append(FILE_PATH_LITERAL("Cookies")), | 59   // control this policy by calling CookieManager.removeSessionCookie() when | 
| 59       true, | 60   // Activity.onCreate() is called with savedInstanceState == null. | 
| 60       NULL, | 61   cookie_store_ = content::CreateCookieStore( | 
| 61       NULL); | 62       content::CookieStoreConfig( | 
| 62   cookie_store_->GetCookieMonster()->SetPersistSessionCookies(true); | 63           browser_context_->GetPath().Append(content::kCookieFilename), | 
|  | 64           content::CookieStoreConfig::RESTORED_SESSION_COOKIES, | 
|  | 65           NULL, | 
|  | 66           NULL)); | 
| 63 | 67 | 
| 64   // The CookieMonster must be passed here so it happens synchronously to | 68   // The CookieMonster must be passed here so it happens synchronously to | 
| 65   // the main thread initialization (to avoid race condition in another | 69   // the main thread initialization (to avoid race condition in another | 
| 66   // thread trying to access the CookieManager API). | 70   // thread trying to access the CookieManager API). | 
| 67   DidCreateCookieMonster(cookie_store_->GetCookieMonster()); | 71   DidCreateCookieMonster(cookie_store_->GetCookieMonster()); | 
| 68 } | 72 } | 
| 69 | 73 | 
| 70 void AwURLRequestContextGetter::InitAsync() { | 74 void AwURLRequestContextGetter::InitAsync() { | 
| 71   DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 75   DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 
| 72 | 76 | 
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 189 AwURLRequestContextGetter::GetNetworkTaskRunner() const { | 193 AwURLRequestContextGetter::GetNetworkTaskRunner() const { | 
| 190   return BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO); | 194   return BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO); | 
| 191 } | 195 } | 
| 192 | 196 | 
| 193 void AwURLRequestContextGetter::SetProtocolHandlers( | 197 void AwURLRequestContextGetter::SetProtocolHandlers( | 
| 194     content::ProtocolHandlerMap* protocol_handlers) { | 198     content::ProtocolHandlerMap* protocol_handlers) { | 
| 195   std::swap(protocol_handlers_, *protocol_handlers); | 199   std::swap(protocol_handlers_, *protocol_handlers); | 
| 196 } | 200 } | 
| 197 | 201 | 
| 198 }  // namespace android_webview | 202 }  // namespace android_webview | 
| OLD | NEW | 
|---|