summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--android/autofill/android_url_request_context_getter.cc15
-rw-r--r--android/autofill/android_url_request_context_getter.h15
-rw-r--r--android/autofill/profile_android.cc9
-rw-r--r--android/autofill/profile_android.h6
-rw-r--r--android/autofill/url_fetcher_proxy.h5
-rw-r--r--chrome/browser/autofill/autofill_download.cc6
-rw-r--r--chrome/browser/tab_contents/tab_contents.h3
-rw-r--r--chrome/common/net/url_fetcher.cc6
-rw-r--r--chrome/common/net/url_fetcher.h4
9 files changed, 37 insertions, 32 deletions
diff --git a/android/autofill/android_url_request_context_getter.cc b/android/autofill/android_url_request_context_getter.cc
index 5038cd6..4dcf971 100644
--- a/android/autofill/android_url_request_context_getter.cc
+++ b/android/autofill/android_url_request_context_getter.cc
@@ -26,11 +26,9 @@
#include "android_url_request_context_getter.h"
-scoped_refptr<AndroidURLRequestContextGetter> AndroidURLRequestContextGetter::instance_ = NULL;
-
URLRequestContext* AndroidURLRequestContextGetter::GetURLRequestContext()
{
- return context_;
+ return context_.get();
}
scoped_refptr<base::MessageLoopProxy> AndroidURLRequestContextGetter::GetIOMessageLoopProxy() const
@@ -49,14 +47,3 @@ scoped_refptr<base::MessageLoopProxy> AndroidURLRequestContextGetter::GetIOMessa
return io_thread_->message_loop_proxy();
}
-AndroidURLRequestContextGetter* AndroidURLRequestContextGetter::Get()
-{
- if (!instance_)
- instance_ = new AndroidURLRequestContextGetter;
- return instance_;
-}
-
-void AndroidURLRequestContextGetter::SetURLRequestContext(URLRequestContext* context)
-{
- context_ = context;
-}
diff --git a/android/autofill/android_url_request_context_getter.h b/android/autofill/android_url_request_context_getter.h
index 81b2f56..80e9513 100644
--- a/android/autofill/android_url_request_context_getter.h
+++ b/android/autofill/android_url_request_context_getter.h
@@ -33,8 +33,11 @@
class AndroidURLRequestContextGetter : public URLRequestContextGetter {
public:
- AndroidURLRequestContextGetter()
- : context_(0), io_thread_(0) { };
+ AndroidURLRequestContextGetter(URLRequestContext* context, base::Thread* ioThread)
+ : context_(context)
+ , io_thread_(ioThread)
+ {
+ }
virtual ~AndroidURLRequestContextGetter() { }
@@ -42,14 +45,8 @@ public:
virtual URLRequestContext* GetURLRequestContext();
virtual scoped_refptr<base::MessageLoopProxy> GetIOMessageLoopProxy() const;
- static AndroidURLRequestContextGetter* Get();
-
- void SetURLRequestContext(URLRequestContext*);
- void SetIOThread(base::Thread* io_thread) { io_thread_ = io_thread; }
-
private:
- static scoped_refptr<AndroidURLRequestContextGetter> instance_;
- URLRequestContext* context_;
+ scoped_refptr<URLRequestContext> context_;
mutable base::Thread* io_thread_;
};
diff --git a/android/autofill/profile_android.cc b/android/autofill/profile_android.cc
index 4ea1b23..3cc51f1 100644
--- a/android/autofill/profile_android.cc
+++ b/android/autofill/profile_android.cc
@@ -60,11 +60,10 @@ PrefService* ProfileImplAndroid::GetPrefs() {
return preferences_.get();
}
-Profile* Profile::CreateProfile(const FilePath& path) {
- return new ProfileImplAndroid(path);
+URLRequestContextGetter* ProfileImplAndroid::GetRequestContext() {
+ return url_request_context_getter_.get();
}
-URLRequestContextGetter* Profile::GetDefaultRequestContext()
-{
- return AndroidURLRequestContextGetter::Get();
+Profile* Profile::CreateProfile(const FilePath& path) {
+ return new ProfileImplAndroid(path);
}
diff --git a/android/autofill/profile_android.h b/android/autofill/profile_android.h
index 1117636..b7a9545 100644
--- a/android/autofill/profile_android.h
+++ b/android/autofill/profile_android.h
@@ -112,11 +112,14 @@ class ProfileImplAndroid : public Profile {
public:
virtual ~ProfileImplAndroid();
+ void SetRequestContext(URLRequestContextGetter* context) { url_request_context_getter_ = context; }
+
// Profile implementation.
virtual Profile* GetOriginalProfile();
virtual PersonalDataManager* GetPersonalDataManager();
virtual PrefService* GetPrefs();
virtual FilePath GetPath() { return path_; }
+ virtual URLRequestContextGetter* GetRequestContext();
// Functions from Profile that we don't need on Android for AutoFill.
virtual ProfileId GetRuntimeId() { NOTREACHED(); return 0; }
@@ -154,7 +157,6 @@ class ProfileImplAndroid : public Profile {
virtual const Extension* GetTheme() { NOTREACHED(); return NULL; }
virtual BrowserThemeProvider* GetThemeProvider() { NOTREACHED(); return NULL; }
virtual bool HasCreatedDownloadManager() const { NOTREACHED(); return false; }
- virtual URLRequestContextGetter* GetRequestContext() { NOTREACHED(); return NULL; }
virtual URLRequestContextGetter* GetRequestContextForMedia() { NOTREACHED(); return NULL; }
virtual URLRequestContextGetter* GetRequestContextForExtensions() { NOTREACHED(); return NULL; }
virtual void RegisterExtensionWithRequestContexts(const Extension* extension) { NOTREACHED(); }
@@ -201,7 +203,6 @@ class ProfileImplAndroid : public Profile {
virtual BrowserSignin* GetBrowserSignin() { NOTREACHED(); return NULL; }
virtual bool HasProfileSyncService() const { NOTREACHED(); return false; }
-
private:
friend class Profile;
@@ -225,6 +226,7 @@ class ProfileImplAndroid : public Profile {
FilePath path_;
scoped_ptr<PrefService> preferences_;
scoped_refptr<PersonalDataManager> personal_data_;
+ scoped_refptr<URLRequestContextGetter> url_request_context_getter_;
DISALLOW_COPY_AND_ASSIGN(ProfileImplAndroid);
};
diff --git a/android/autofill/url_fetcher_proxy.h b/android/autofill/url_fetcher_proxy.h
index 415b730..19cabf3 100644
--- a/android/autofill/url_fetcher_proxy.h
+++ b/android/autofill/url_fetcher_proxy.h
@@ -98,7 +98,8 @@ public:
virtual void Start()
{
- URLRequestContextGetter* con = Profile::GetDefaultRequestContext();
+ scoped_refptr<URLRequestContextGetter> con = request_context();
+ CHECK(con.get()) << "No URLRequestContextGetter!";
scoped_refptr<base::MessageLoopProxy> mlp = con->GetIOMessageLoopProxy();
// TODO: See the template specialisation at the top of the file. Can we use
// an alternative to RunnableMethod that doesn't expect a ref counted object?
@@ -134,7 +135,7 @@ private:
real_fetcher_->set_automatically_retry_on_5xx(retry_);
// We expect set_upload_data() to have been called on this object.
real_fetcher_->set_upload_data(upload_content_type_, upload_content_);
- real_fetcher_->set_request_context(ProfileImplAndroid::GetDefaultRequestContext());
+ real_fetcher_->set_request_context(request_context());
real_fetcher_->Start();
};
diff --git a/chrome/browser/autofill/autofill_download.cc b/chrome/browser/autofill/autofill_download.cc
index fa819b8..a75cef6 100644
--- a/chrome/browser/autofill/autofill_download.cc
+++ b/chrome/browser/autofill/autofill_download.cc
@@ -179,7 +179,13 @@ bool AutoFillDownloadManager::StartRequest(
this);
url_fetchers_[fetcher] = request_data;
fetcher->set_automatically_retry_on_5xx(false);
+#ifdef ANDROID
+ // On Android, use the webview request context getter which was passed
+ // through in the WebAutoFill::init() method in WebKit.
+ fetcher->set_request_context(profile_->GetRequestContext());
+#else
fetcher->set_request_context(Profile::GetDefaultRequestContext());
+#endif
fetcher->set_upload_data("text/plain", form_xml);
fetcher->Start();
return true;
diff --git a/chrome/browser/tab_contents/tab_contents.h b/chrome/browser/tab_contents/tab_contents.h
index d4e0100..037ccb9 100644
--- a/chrome/browser/tab_contents/tab_contents.h
+++ b/chrome/browser/tab_contents/tab_contents.h
@@ -7,6 +7,7 @@
#pragma once
#ifdef ANDROID
+#include "android/autofill/profile_android.h"
#include "chrome/browser/profile.h"
#include "chrome/browser/autofill/autofill_host.h"
@@ -16,6 +17,7 @@
// data for AutoFill. Then Android won't care about this
// file which as it stands does not compile for us.
class RenderViewHost;
+class URLRequestContextGetter;
class TabContents {
public:
@@ -26,6 +28,7 @@ public:
}
Profile* profile() { return profile_; }
+ void SetProfileRequestContext(URLRequestContextGetter* context) { static_cast<ProfileImplAndroid*>(profile_)->SetRequestContext(context); }
AutoFillHost* autofill_host() { return autofill_host_; }
void SetAutoFillHost(AutoFillHost* autofill_host) { autofill_host_ = autofill_host; }
diff --git a/chrome/common/net/url_fetcher.cc b/chrome/common/net/url_fetcher.cc
index 9551255..e7fcbd2 100644
--- a/chrome/common/net/url_fetcher.cc
+++ b/chrome/common/net/url_fetcher.cc
@@ -419,6 +419,12 @@ void URLFetcher::set_request_context(
core_->request_context_getter_ = request_context_getter;
}
+#ifdef ANDROID
+URLRequestContextGetter* URLFetcher::request_context() {
+ return core_->request_context_getter_;
+}
+#endif
+
void URLFetcher::set_automatically_retry_on_5xx(bool retry) {
automatically_retry_on_5xx_ = retry;
}
diff --git a/chrome/common/net/url_fetcher.h b/chrome/common/net/url_fetcher.h
index b998df6..8566d42 100644
--- a/chrome/common/net/url_fetcher.h
+++ b/chrome/common/net/url_fetcher.h
@@ -155,6 +155,10 @@ class URLFetcher {
void set_request_context(
URLRequestContextGetter* request_context_getter);
+#ifdef ANDROID
+ URLRequestContextGetter* request_context();
+#endif
+
// If |retry| is false, 5xx responses will be propagated to the observer,
// if it is true URLFetcher will automatically re-execute the request,
// after backoff_delay() elapses. URLFetcher has it set to true by default.