summaryrefslogtreecommitdiff
path: root/android_webview/browser
diff options
context:
space:
mode:
authorTorne (Richard Coles) <torne@google.com>2013-08-30 15:14:49 +0100
committerTorne (Richard Coles) <torne@google.com>2013-08-30 15:14:49 +0100
commit424c4d7b64af9d0d8fd9624f381f469654d5e3d2 (patch)
treeaf8b16dc2ba7fc8c8bb1c9fa18b907c847f3883d /android_webview/browser
parentc70ef2906f891fe7d218980660e4cda465717916 (diff)
downloadchromium_org-424c4d7b64af9d0d8fd9624f381f469654d5e3d2.tar.gz
Merge from Chromium at DEPS revision r220549
This commit was generated by merge_to_master.py. Change-Id: I8fcb82db764ec1eb0294280936c177bd9ba8a9e9
Diffstat (limited to 'android_webview/browser')
-rw-r--r--android_webview/browser/aw_browser_context.cc39
-rw-r--r--android_webview/browser/aw_browser_context.h16
-rw-r--r--android_webview/browser/aw_browser_main_parts.cc2
-rw-r--r--android_webview/browser/aw_javascript_dialog_manager.cc1
-rw-r--r--android_webview/browser/aw_javascript_dialog_manager.h1
-rw-r--r--android_webview/browser/aw_pref_store.cc4
-rw-r--r--android_webview/browser/aw_pref_store.h2
-rw-r--r--android_webview/browser/in_process_view_renderer.cc8
-rw-r--r--android_webview/browser/net/aw_url_request_context_getter.cc207
-rw-r--r--android_webview/browser/net/aw_url_request_context_getter.h20
-rw-r--r--android_webview/browser/renderer_host/aw_render_view_host_ext.cc4
-rw-r--r--android_webview/browser/renderer_host/aw_render_view_host_ext.h1
-rw-r--r--android_webview/browser/renderer_host/aw_resource_dispatcher_host_delegate.cc20
13 files changed, 174 insertions, 151 deletions
diff --git a/android_webview/browser/aw_browser_context.cc b/android_webview/browser/aw_browser_context.cc
index 51f1c17bc1..9700645683 100644
--- a/android_webview/browser/aw_browser_context.cc
+++ b/android_webview/browser/aw_browser_context.cc
@@ -9,6 +9,7 @@
#include "android_webview/browser/aw_quota_manager_bridge.h"
#include "android_webview/browser/jni_dependency_factory.h"
#include "android_webview/browser/net/aw_url_request_context_getter.h"
+#include "android_webview/browser/net/init_native_callback.h"
#include "base/prefs/pref_registry_simple.h"
#include "base/prefs/pref_service.h"
#include "base/prefs/pref_service_builder.h"
@@ -16,6 +17,7 @@
#include "components/user_prefs/user_prefs.h"
#include "components/visitedlink/browser/visitedlink_master.h"
#include "content/public/browser/browser_thread.h"
+#include "content/public/browser/cookie_store_factory.h"
#include "content/public/browser/resource_context.h"
#include "content/public/browser/storage_partition.h"
#include "content/public/browser/web_contents.h"
@@ -32,7 +34,9 @@ void HandleReadError(PersistentPrefStore::PrefReadError error) {
class AwResourceContext : public content::ResourceContext {
public:
explicit AwResourceContext(net::URLRequestContextGetter* getter)
- : getter_(getter) {}
+ : getter_(getter) {
+ DCHECK(getter_);
+ }
virtual ~AwResourceContext() {}
// content::ResourceContext implementation.
@@ -90,12 +94,18 @@ AwBrowserContext* AwBrowserContext::FromWebContents(
return static_cast<AwBrowserContext*>(web_contents->GetBrowserContext());
}
-void AwBrowserContext::InitializeBeforeThreadCreation() {
- DCHECK(!url_request_context_getter_.get());
- url_request_context_getter_ = new AwURLRequestContextGetter(this);
-}
-
void AwBrowserContext::PreMainMessageLoopRun() {
+ cookie_store_ = content::CreatePersistentCookieStore(
+ GetPath().Append(FILE_PATH_LITERAL("Cookies")),
+ true,
+ NULL,
+ NULL);
+ cookie_store_->GetCookieMonster()->SetPersistSessionCookies(true);
+ url_request_context_getter_ =
+ new AwURLRequestContextGetter(GetPath(), cookie_store_.get());
+
+ DidCreateCookieMonster(cookie_store_->GetCookieMonster());
+
visitedlink_master_.reset(
new visitedlink::VisitedLinkMaster(this, this, false));
visitedlink_master_->Init();
@@ -108,9 +118,14 @@ void AwBrowserContext::AddVisitedURLs(const std::vector<GURL>& urls) {
net::URLRequestContextGetter* AwBrowserContext::CreateRequestContext(
content::ProtocolHandlerMap* protocol_handlers) {
- CHECK(url_request_context_getter_.get());
+ // This function cannot actually create the request context because
+ // there is a reentrant dependency on GetResourceContext() via
+ // content::StoragePartitionImplMap::Create(). This is not fixable
+ // until http://crbug.com/159193. Until then, assert that the context
+ // has already been allocated and just handle setting the protocol_handlers.
+ DCHECK(url_request_context_getter_);
url_request_context_getter_->SetProtocolHandlers(protocol_handlers);
- return url_request_context_getter_.get();
+ return url_request_context_getter_;
}
net::URLRequestContextGetter*
@@ -118,8 +133,8 @@ AwBrowserContext::CreateRequestContextForStoragePartition(
const base::FilePath& partition_path,
bool in_memory,
content::ProtocolHandlerMap* protocol_handlers) {
- CHECK(url_request_context_getter_.get());
- return url_request_context_getter_.get();
+ NOTREACHED();
+ return NULL;
}
AwQuotaManagerBridge* AwBrowserContext::GetQuotaManagerBridge() {
@@ -205,12 +220,12 @@ net::URLRequestContextGetter*
AwBrowserContext::GetMediaRequestContextForStoragePartition(
const base::FilePath& partition_path,
bool in_memory) {
- return GetRequestContext();
+ NOTREACHED();
+ return NULL;
}
content::ResourceContext* AwBrowserContext::GetResourceContext() {
if (!resource_context_) {
- CHECK(url_request_context_getter_.get());
resource_context_.reset(
new AwResourceContext(url_request_context_getter_.get()));
}
diff --git a/android_webview/browser/aw_browser_context.h b/android_webview/browser/aw_browser_context.h
index 8d1ff97581..1654d9a867 100644
--- a/android_webview/browser/aw_browser_context.h
+++ b/android_webview/browser/aw_browser_context.h
@@ -21,15 +21,19 @@
class GURL;
-namespace visitedlink {
-class VisitedLinkMaster;
-}
-
namespace content {
class ResourceContext;
class WebContents;
}
+namespace net {
+class CookieStore;
+}
+
+namespace visitedlink {
+class VisitedLinkMaster;
+}
+
namespace android_webview {
class AwFormDatabaseService;
@@ -53,9 +57,6 @@ class AwBrowserContext : public content::BrowserContext,
static AwBrowserContext* FromWebContents(
content::WebContents* web_contents);
- // Called before BrowserThreads are created.
- void InitializeBeforeThreadCreation();
-
// Maps to BrowserMainParts::PreMainMessageLoopRun.
void PreMainMessageLoopRun();
@@ -107,6 +108,7 @@ class AwBrowserContext : public content::BrowserContext,
base::FilePath context_storage_path_;
JniDependencyFactory* native_factory_;
+ scoped_refptr<net::CookieStore> cookie_store_;
scoped_refptr<AwURLRequestContextGetter> url_request_context_getter_;
scoped_refptr<content::GeolocationPermissionContext>
geolocation_permission_context_;
diff --git a/android_webview/browser/aw_browser_main_parts.cc b/android_webview/browser/aw_browser_main_parts.cc
index b54e65b201..8cd57c38e5 100644
--- a/android_webview/browser/aw_browser_main_parts.cc
+++ b/android_webview/browser/aw_browser_main_parts.cc
@@ -44,8 +44,6 @@ void AwBrowserMainParts::PreEarlyInitialization() {
}
int AwBrowserMainParts::PreCreateThreads() {
- browser_context_->InitializeBeforeThreadCreation();
-
ui::ResourceBundle::InitSharedInstanceLocaleOnly(
l10n_util::GetDefaultLocale(), NULL);
diff --git a/android_webview/browser/aw_javascript_dialog_manager.cc b/android_webview/browser/aw_javascript_dialog_manager.cc
index 1690eac737..d9ec1c138b 100644
--- a/android_webview/browser/aw_javascript_dialog_manager.cc
+++ b/android_webview/browser/aw_javascript_dialog_manager.cc
@@ -21,6 +21,7 @@ void AwJavaScriptDialogManager::RunJavaScriptDialog(
content::JavaScriptMessageType message_type,
const string16& message_text,
const string16& default_prompt_text,
+ bool user_gesture,
const DialogClosedCallback& callback,
bool* did_suppress_message) {
AwContentsClientBridgeBase* bridge =
diff --git a/android_webview/browser/aw_javascript_dialog_manager.h b/android_webview/browser/aw_javascript_dialog_manager.h
index f8db746edc..0abb432c4a 100644
--- a/android_webview/browser/aw_javascript_dialog_manager.h
+++ b/android_webview/browser/aw_javascript_dialog_manager.h
@@ -22,6 +22,7 @@ class AwJavaScriptDialogManager : public content::JavaScriptDialogManager {
content::JavaScriptMessageType message_type,
const string16& message_text,
const string16& default_prompt_text,
+ bool user_gesture,
const DialogClosedCallback& callback,
bool* did_suppress_message) OVERRIDE;
virtual void RunBeforeUnloadDialog(
diff --git a/android_webview/browser/aw_pref_store.cc b/android_webview/browser/aw_pref_store.cc
index 613a847412..0720ee9c56 100644
--- a/android_webview/browser/aw_pref_store.cc
+++ b/android_webview/browser/aw_pref_store.cc
@@ -29,8 +29,8 @@ void AwPrefStore::RemoveObserver(PrefStore::Observer* observer) {
observers_.RemoveObserver(observer);
}
-size_t AwPrefStore::NumberOfObservers() const {
- return observers_.size();
+bool AwPrefStore::HasObservers() const {
+ return observers_.might_have_observers();
}
bool AwPrefStore::IsInitializationComplete() const {
diff --git a/android_webview/browser/aw_pref_store.h b/android_webview/browser/aw_pref_store.h
index e636e1bd99..8581a03443 100644
--- a/android_webview/browser/aw_pref_store.h
+++ b/android_webview/browser/aw_pref_store.h
@@ -26,7 +26,7 @@ class AwPrefStore : public PersistentPrefStore {
const base::Value** result) const OVERRIDE;
virtual void AddObserver(PrefStore::Observer* observer) OVERRIDE;
virtual void RemoveObserver(PrefStore::Observer* observer) OVERRIDE;
- virtual size_t NumberOfObservers() const OVERRIDE;
+ virtual bool HasObservers() const OVERRIDE;
virtual bool IsInitializationComplete() const OVERRIDE;
// PersistentPrefStore overrides:
diff --git a/android_webview/browser/in_process_view_renderer.cc b/android_webview/browser/in_process_view_renderer.cc
index 3f935ffb12..49be2cc956 100644
--- a/android_webview/browser/in_process_view_renderer.cc
+++ b/android_webview/browser/in_process_view_renderer.cc
@@ -23,8 +23,8 @@
#include "content/public/browser/web_contents.h"
#include "gpu/command_buffer/service/in_process_command_buffer.h"
#include "third_party/skia/include/core/SkBitmap.h"
+#include "third_party/skia/include/core/SkBitmapDevice.h"
#include "third_party/skia/include/core/SkCanvas.h"
-#include "third_party/skia/include/core/SkDevice.h"
#include "third_party/skia/include/core/SkGraphics.h"
#include "third_party/skia/include/core/SkPicture.h"
#include "ui/gfx/skia_util.h"
@@ -91,7 +91,7 @@ bool RasterizeIntoBitmap(JNIEnv* env,
bitmap_info.stride);
bitmap.setPixels(pixels);
- SkDevice device(bitmap);
+ SkBitmapDevice device(bitmap);
SkCanvas canvas(&device);
canvas.translate(-scroll_x, -scroll_y);
succeeded = renderer.Run(&canvas);
@@ -505,7 +505,7 @@ bool InProcessViewRenderer::RenderViaAuxilaryBitmapIfNeeded(
pixels->height,
pixels->row_bytes);
bitmap.setPixels(pixels->pixels);
- SkDevice device(bitmap);
+ SkBitmapDevice device(bitmap);
SkCanvas canvas(&device);
canvas.setMatrix(matrix);
@@ -802,7 +802,7 @@ void InProcessViewRenderer::FallbackTickFired() {
// means block_invalidates_ must still be true.
DCHECK(block_invalidates_);
if (compositor_needs_continuous_invalidate_ && compositor_) {
- SkDevice device(SkBitmap::kARGB_8888_Config, 1, 1);
+ SkBitmapDevice device(SkBitmap::kARGB_8888_Config, 1, 1);
SkCanvas canvas(&device);
block_invalidates_ = true;
CompositeSW(&canvas);
diff --git a/android_webview/browser/net/aw_url_request_context_getter.cc b/android_webview/browser/net/aw_url_request_context_getter.cc
index 4017c18794..4a5ea4161a 100644
--- a/android_webview/browser/net/aw_url_request_context_getter.cc
+++ b/android_webview/browser/net/aw_url_request_context_getter.cc
@@ -6,7 +6,6 @@
#include <vector>
-#include "android_webview/browser/aw_browser_context.h"
#include "android_webview/browser/aw_content_browser_client.h"
#include "android_webview/browser/aw_request_interceptor.h"
#include "android_webview/browser/net/aw_network_delegate.h"
@@ -34,42 +33,110 @@ using content::BrowserThread;
namespace android_webview {
+
+namespace {
+
+void PopulateNetworkSessionParams(
+ net::URLRequestContext* context,
+ net::HttpNetworkSession::Params* params) {
+ params->host_resolver = context->host_resolver();
+ params->cert_verifier = context->cert_verifier();
+ params->server_bound_cert_service = context->server_bound_cert_service();
+ params->transport_security_state = context->transport_security_state();
+ params->proxy_service = context->proxy_service();
+ params->ssl_config_service = context->ssl_config_service();
+ params->http_auth_handler_factory = context->http_auth_handler_factory();
+ params->network_delegate = context->network_delegate();
+ params->http_server_properties = context->http_server_properties();
+ params->net_log = context->net_log();
+}
+
+scoped_ptr<net::URLRequestJobFactory> CreateJobFactory(
+ content::ProtocolHandlerMap* protocol_handlers) {
+ scoped_ptr<AwURLRequestJobFactory> aw_job_factory(new AwURLRequestJobFactory);
+ bool set_protocol = aw_job_factory->SetProtocolHandler(
+ chrome::kFileScheme,
+ new net::FileProtocolHandler(
+ content::BrowserThread::GetBlockingPool()->
+ GetTaskRunnerWithShutdownBehavior(
+ base::SequencedWorkerPool::SKIP_ON_SHUTDOWN)));
+ DCHECK(set_protocol);
+ set_protocol = aw_job_factory->SetProtocolHandler(
+ chrome::kDataScheme, new net::DataProtocolHandler());
+ DCHECK(set_protocol);
+ set_protocol = aw_job_factory->SetProtocolHandler(
+ chrome::kBlobScheme, (*protocol_handlers)[chrome::kBlobScheme].release());
+ DCHECK(set_protocol);
+ set_protocol = aw_job_factory->SetProtocolHandler(
+ chrome::kFileSystemScheme,
+ (*protocol_handlers)[chrome::kFileSystemScheme].release());
+ DCHECK(set_protocol);
+ set_protocol = aw_job_factory->SetProtocolHandler(
+ chrome::kChromeUIScheme,
+ (*protocol_handlers)[chrome::kChromeUIScheme].release());
+ DCHECK(set_protocol);
+ set_protocol = aw_job_factory->SetProtocolHandler(
+ chrome::kChromeDevToolsScheme,
+ (*protocol_handlers)[chrome::kChromeDevToolsScheme].release());
+ DCHECK(set_protocol);
+ protocol_handlers->clear();
+
+ // Create a chain of URLRequestJobFactories. The handlers will be invoked
+ // in the order in which they appear in the protocol_handlers vector.
+ typedef std::vector<net::URLRequestJobFactory::ProtocolHandler*>
+ ProtocolHandlerVector;
+ ProtocolHandlerVector protocol_interceptors;
+
+ // Note that even though the content:// scheme handler is created here,
+ // it cannot be used by child processes until access to it is granted via
+ // ChildProcessSecurityPolicy::GrantScheme(). This is done in
+ // AwContentBrowserClient.
+ protocol_interceptors.push_back(
+ CreateAndroidContentProtocolHandler().release());
+ protocol_interceptors.push_back(
+ CreateAndroidAssetFileProtocolHandler().release());
+ // The AwRequestInterceptor must come after the content and asset file job
+ // factories. This for WebViewClassic compatibility where it was not
+ // possible to intercept resource loads to resolvable content:// and
+ // file:// URIs.
+ // This logical dependency is also the reason why the Content
+ // ProtocolHandler has to be added as a ProtocolInterceptJobFactory rather
+ // than via SetProtocolHandler.
+ protocol_interceptors.push_back(new AwRequestInterceptor());
+
+ // The chain of responsibility will execute the handlers in reverse to the
+ // order in which the elements of the chain are created.
+ scoped_ptr<net::URLRequestJobFactory> job_factory(aw_job_factory.Pass());
+ for (ProtocolHandlerVector::reverse_iterator
+ i = protocol_interceptors.rbegin();
+ i != protocol_interceptors.rend();
+ ++i) {
+ job_factory.reset(new net::ProtocolInterceptJobFactory(
+ job_factory.Pass(), make_scoped_ptr(*i)));
+ }
+
+ return job_factory.Pass();
+}
+
+} // namespace
+
AwURLRequestContextGetter::AwURLRequestContextGetter(
- AwBrowserContext* browser_context)
- : browser_context_(browser_context),
+ const base::FilePath& partition_path, net::CookieStore* cookie_store)
+ : partition_path_(partition_path),
+ cookie_store_(cookie_store),
proxy_config_service_(net::ProxyService::CreateSystemProxyConfigService(
GetNetworkTaskRunner(),
NULL /* Ignored on Android */)) {
// CreateSystemProxyConfigService for Android must be called on main thread.
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
-
- // All network stack initialization is done on the synchronous Init call when
- // the IO thread is created.
- BrowserThread::SetDelegate(BrowserThread::IO, this);
}
AwURLRequestContextGetter::~AwURLRequestContextGetter() {
- BrowserThread::SetDelegate(BrowserThread::IO, NULL);
-}
-
-void AwURLRequestContextGetter::Init() {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
-
- cookie_store_ = content::CreatePersistentCookieStore(
- browser_context_->GetPath().Append(FILE_PATH_LITERAL("Cookies")),
- true,
- NULL,
- NULL);
- cookie_store_->GetCookieMonster()->SetPersistSessionCookies(true);
-
- // The CookieMonster must be passed here so it happens synchronously to
- // the main thread initialization (to avoid race condition in another
- // thread trying to access the CookieManager API).
- DidCreateCookieMonster(cookie_store_->GetCookieMonster());
}
-void AwURLRequestContextGetter::InitAsync() {
+void AwURLRequestContextGetter::InitializeURLRequestContext() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
+ DCHECK(!url_request_context_);
net::URLRequestContextBuilder builder;
builder.set_user_agent(content::GetUserAgent(GURL()));
@@ -90,102 +157,28 @@ void AwURLRequestContextGetter::InitAsync() {
switches::kDisableSimpleCache)) {
cache_type = net::CACHE_BACKEND_BLOCKFILE;
}
- PopulateNetworkSessionParams(&network_session_params);
+ PopulateNetworkSessionParams(url_request_context_.get(),
+ &network_session_params);
net::HttpCache* main_cache = new net::HttpCache(
network_session_params,
new net::HttpCache::DefaultBackend(
net::DISK_CACHE,
cache_type,
- browser_context_->GetPath().Append(FILE_PATH_LITERAL("Cache")),
+ partition_path_.Append(FILE_PATH_LITERAL("Cache")),
10 * 1024 * 1024, // 10M
BrowserThread::GetMessageLoopProxyForThread(BrowserThread::CACHE)));
main_http_factory_.reset(main_cache);
url_request_context_->set_http_transaction_factory(main_cache);
- url_request_context_->set_cookie_store(cookie_store_.get());
-}
+ url_request_context_->set_cookie_store(cookie_store_);
-void AwURLRequestContextGetter::PopulateNetworkSessionParams(
- net::HttpNetworkSession::Params* params) {
- net::URLRequestContext* context = url_request_context_.get();
- params->host_resolver = context->host_resolver();
- params->cert_verifier = context->cert_verifier();
- params->server_bound_cert_service = context->server_bound_cert_service();
- params->transport_security_state = context->transport_security_state();
- params->proxy_service = context->proxy_service();
- params->ssl_config_service = context->ssl_config_service();
- params->http_auth_handler_factory = context->http_auth_handler_factory();
- params->network_delegate = context->network_delegate();
- params->http_server_properties = context->http_server_properties();
- params->net_log = context->net_log();
+ job_factory_ = CreateJobFactory(&protocol_handlers_);
+ url_request_context_->set_job_factory(job_factory_.get());
}
net::URLRequestContext* AwURLRequestContextGetter::GetURLRequestContext() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
- if (!job_factory_) {
- scoped_ptr<AwURLRequestJobFactory> job_factory(new AwURLRequestJobFactory);
- bool set_protocol = job_factory->SetProtocolHandler(
- chrome::kFileScheme,
- new net::FileProtocolHandler(
- content::BrowserThread::GetBlockingPool()->
- GetTaskRunnerWithShutdownBehavior(
- base::SequencedWorkerPool::SKIP_ON_SHUTDOWN)));
- DCHECK(set_protocol);
- set_protocol = job_factory->SetProtocolHandler(
- chrome::kDataScheme, new net::DataProtocolHandler());
- DCHECK(set_protocol);
- set_protocol = job_factory->SetProtocolHandler(
- chrome::kBlobScheme, protocol_handlers_[chrome::kBlobScheme].release());
- DCHECK(set_protocol);
- set_protocol = job_factory->SetProtocolHandler(
- chrome::kFileSystemScheme,
- protocol_handlers_[chrome::kFileSystemScheme].release());
- DCHECK(set_protocol);
- set_protocol = job_factory->SetProtocolHandler(
- chrome::kChromeUIScheme,
- protocol_handlers_[chrome::kChromeUIScheme].release());
- DCHECK(set_protocol);
- set_protocol = job_factory->SetProtocolHandler(
- chrome::kChromeDevToolsScheme,
- protocol_handlers_[chrome::kChromeDevToolsScheme].release());
- DCHECK(set_protocol);
- protocol_handlers_.clear();
-
- // Create a chain of URLRequestJobFactories. The handlers will be invoked
- // in the order in which they appear in the protocol_handlers vector.
- typedef std::vector<net::URLRequestJobFactory::ProtocolHandler*>
- ProtocolHandlerVector;
- ProtocolHandlerVector protocol_interceptors;
-
- // Note that even though the content:// scheme handler is created here,
- // it cannot be used by child processes until access to it is granted via
- // ChildProcessSecurityPolicy::GrantScheme(). This is done in
- // AwContentBrowserClient.
- protocol_interceptors.push_back(
- CreateAndroidContentProtocolHandler().release());
- protocol_interceptors.push_back(
- CreateAndroidAssetFileProtocolHandler().release());
- // The AwRequestInterceptor must come after the content and asset file job
- // factories. This for WebViewClassic compatibility where it was not
- // possible to intercept resource loads to resolvable content:// and
- // file:// URIs.
- // This logical dependency is also the reason why the Content
- // ProtocolHandler has to be added as a ProtocolInterceptJobFactory rather
- // than via SetProtocolHandler.
- protocol_interceptors.push_back(new AwRequestInterceptor());
-
- // The chain of responsibility will execute the handlers in reverse to the
- // order in which the elements of the chain are created.
- job_factory_ = job_factory.PassAs<net::URLRequestJobFactory>();
- for (ProtocolHandlerVector::reverse_iterator
- i = protocol_interceptors.rbegin();
- i != protocol_interceptors.rend();
- ++i) {
- job_factory_.reset(new net::ProtocolInterceptJobFactory(
- job_factory_.Pass(), make_scoped_ptr(*i)));
- }
-
- url_request_context_->set_job_factory(job_factory_.get());
- }
+ if (!url_request_context_)
+ InitializeURLRequestContext();
return url_request_context_.get();
}
diff --git a/android_webview/browser/net/aw_url_request_context_getter.h b/android_webview/browser/net/aw_url_request_context_getter.h
index 93d59aa0e4..c16098e060 100644
--- a/android_webview/browser/net/aw_url_request_context_getter.h
+++ b/android_webview/browser/net/aw_url_request_context_getter.h
@@ -7,14 +7,15 @@
#include "base/basictypes.h"
#include "base/compiler_specific.h"
+#include "base/files/file_path.h"
#include "base/memory/scoped_ptr.h"
-#include "content/public/browser/browser_thread_delegate.h"
#include "content/public/browser/content_browser_client.h"
#include "net/http/http_network_session.h"
#include "net/url_request/url_request_context_getter.h"
#include "net/url_request/url_request_job_factory.h"
namespace net {
+class CookieStore;
class HttpTransactionFactory;
class ProxyConfigService;
class URLRequestContext;
@@ -23,21 +24,15 @@ class URLRequestJobFactory;
namespace android_webview {
-class AwBrowserContext;
class AwNetworkDelegate;
-class AwURLRequestContextGetter : public net::URLRequestContextGetter,
- public content::BrowserThreadDelegate {
+class AwURLRequestContextGetter : public net::URLRequestContextGetter {
public:
- explicit AwURLRequestContextGetter(AwBrowserContext* browser_context);
+ AwURLRequestContextGetter(const base::FilePath& partition_path,
+ net::CookieStore* cookie_store);
void InitializeOnNetworkThread();
- // content::BrowserThreadDelegate implementation.
- virtual void Init() OVERRIDE;
- virtual void InitAsync() OVERRIDE;
- virtual void CleanUp() OVERRIDE {}
-
// net::URLRequestContextGetter implementation.
virtual net::URLRequestContext* GetURLRequestContext() OVERRIDE;
virtual scoped_refptr<base::SingleThreadTaskRunner>
@@ -45,7 +40,6 @@ class AwURLRequestContextGetter : public net::URLRequestContextGetter,
private:
friend class AwBrowserContext;
-
virtual ~AwURLRequestContextGetter();
// Prior to GetURLRequestContext() being called, SetProtocolHandlers() is
@@ -56,9 +50,9 @@ class AwURLRequestContextGetter : public net::URLRequestContextGetter,
// on the UI thread while |job_factory_| must be created on the IO thread.
void SetProtocolHandlers(content::ProtocolHandlerMap* protocol_handlers);
- void PopulateNetworkSessionParams(net::HttpNetworkSession::Params* params);
+ void InitializeURLRequestContext();
- AwBrowserContext* browser_context_; // weak
+ const base::FilePath partition_path_;
scoped_refptr<net::CookieStore> cookie_store_;
scoped_ptr<net::URLRequestContext> url_request_context_;
scoped_ptr<net::ProxyConfigService> proxy_config_service_;
diff --git a/android_webview/browser/renderer_host/aw_render_view_host_ext.cc b/android_webview/browser/renderer_host/aw_render_view_host_ext.cc
index 95f235857e..78d6cf4b4e 100644
--- a/android_webview/browser/renderer_host/aw_render_view_host_ext.cc
+++ b/android_webview/browser/renderer_host/aw_render_view_host_ext.cc
@@ -96,6 +96,10 @@ void AwRenderViewHostExt::SetBackgroundColor(SkColor c) {
}
}
+void AwRenderViewHostExt::SetJsOnlineProperty(bool network_up) {
+ Send(new AwViewMsg_SetJsOnlineProperty(network_up));
+}
+
void AwRenderViewHostExt::RenderViewCreated(
content::RenderViewHost* render_view_host) {
Send(new AwViewMsg_SetBackgroundColor(web_contents()->GetRoutingID(),
diff --git a/android_webview/browser/renderer_host/aw_render_view_host_ext.h b/android_webview/browser/renderer_host/aw_render_view_host_ext.h
index da9bcac860..3007f15556 100644
--- a/android_webview/browser/renderer_host/aw_render_view_host_ext.h
+++ b/android_webview/browser/renderer_host/aw_render_view_host_ext.h
@@ -72,6 +72,7 @@ class AwRenderViewHostExt : public content::WebContentsObserver,
// the meta viewport tag.
void SetInitialPageScale(double page_scale_factor);
void SetBackgroundColor(SkColor c);
+ void SetJsOnlineProperty(bool network_up);
private:
// content::WebContentsObserver implementation.
diff --git a/android_webview/browser/renderer_host/aw_resource_dispatcher_host_delegate.cc b/android_webview/browser/renderer_host/aw_resource_dispatcher_host_delegate.cc
index 2e59cd5199..1bab66bfba 100644
--- a/android_webview/browser/renderer_host/aw_resource_dispatcher_host_delegate.cc
+++ b/android_webview/browser/renderer_host/aw_resource_dispatcher_host_delegate.cc
@@ -21,6 +21,7 @@
#include "content/public/browser/resource_throttle.h"
#include "content/public/common/url_constants.h"
#include "net/base/load_flags.h"
+#include "net/http/http_response_headers.h"
#include "net/url_request/url_request.h"
using android_webview::AwContentsIoThreadClient;
@@ -93,6 +94,13 @@ IoThreadClientThrottle::~IoThreadClientThrottle() {
}
void IoThreadClientThrottle::WillStartRequest(bool* defer) {
+ // TODO(sgurun): This block can be removed when crbug.com/277937 is fixed.
+ if (route_id_ < 1) {
+ // OPTIONS is used for preflighted requests which are generated internally.
+ DCHECK_EQ("OPTIONS", request_->method());
+ return;
+ }
+ DCHECK(child_id_);
if (!MaybeDeferRequest(defer)) {
MaybeBlockRequest();
}
@@ -223,7 +231,7 @@ void AwResourceDispatcherHostDelegate::RequestBeginning(
(resource_type == ResourceType::MAIN_FRAME ||
(resource_type == ResourceType::SUB_FRAME &&
!request->url().SchemeIs(chrome::kHttpScheme) &&
- !request->url().SchemeIs(chrome::kHttpsScheme)));
+ !request->url().SchemeIs(content::kHttpsScheme)));
if (allow_intercepting) {
throttles->push_back(InterceptNavigationDelegate::CreateThrottleFor(
request));
@@ -245,10 +253,16 @@ void AwResourceDispatcherHostDelegate::DownloadStarting(
std::string mime_type;
int64 content_length = request->GetExpectedContentSize();
- request->GetResponseHeaderByName("content-disposition", &content_disposition);
request->extra_request_headers().GetHeader(
net::HttpRequestHeaders::kUserAgent, &user_agent);
- request->GetMimeType(&mime_type);
+
+
+ net::HttpResponseHeaders* response_headers = request->response_headers();
+ if (response_headers) {
+ response_headers->GetNormalizedHeader("content-disposition",
+ &content_disposition);
+ response_headers->GetMimeType(&mime_type);
+ }
request->Cancel();