OSDN Git Service

Use one WebRequestContext per WebView
authorSteve Block <steveblock@google.com>
Mon, 29 Nov 2010 17:18:33 +0000 (17:18 +0000)
committerSteve Block <steveblock@google.com>
Wed, 1 Dec 2010 21:11:00 +0000 (21:11 +0000)
This change switches from using a pair of WebRequestContexts (one for
private browsing, one for regular browsing) to using one
WebRequestContext per WebView. This is required to allow us to set the
userAgent on each WebView.

The WebRequestContext is now owned by the WebView.

Bug: 3113804
Change-Id: Iba2b1490e7ce4ff65c08a04a310963fa2c7e4f83

20 files changed:
WebCore/platform/network/NetworkingContext.h
WebCore/platform/network/android/ResourceHandleAndroid.cpp
WebCore/platform/network/android/ResourceLoaderAndroid.h
WebKit/android/WebCoreSupport/FrameLoaderClientAndroid.h
WebKit/android/WebCoreSupport/FrameNetworkingContextAndroid.cpp
WebKit/android/WebCoreSupport/FrameNetworkingContextAndroid.h
WebKit/android/WebCoreSupport/ResourceLoaderAndroid.cpp
WebKit/android/WebCoreSupport/WebCache.cpp
WebKit/android/WebCoreSupport/WebRequest.cpp
WebKit/android/WebCoreSupport/WebRequest.h
WebKit/android/WebCoreSupport/WebRequestContext.cpp
WebKit/android/WebCoreSupport/WebRequestContext.h
WebKit/android/WebCoreSupport/WebUrlLoader.cpp
WebKit/android/WebCoreSupport/WebUrlLoader.h
WebKit/android/WebCoreSupport/WebUrlLoaderClient.cpp
WebKit/android/WebCoreSupport/WebUrlLoaderClient.h
WebKit/android/WebCoreSupport/autofill/WebAutoFill.cpp
WebKit/android/jni/WebSettings.cpp
WebKit/android/jni/WebViewCore.cpp
WebKit/android/jni/WebViewCore.h

index 47ec87a..e0cb4c5 100644 (file)
@@ -66,7 +66,6 @@ public:
 
 #if PLATFORM(ANDROID)
     virtual MainResourceLoader* mainResourceLoader() const = 0;
-    virtual bool isPrivateBrowsingEnabled() const = 0;
     virtual FrameLoaderClient* frameLoaderClient() const = 0;
 #endif
 
index 8e42643..412efda 100644 (file)
@@ -54,9 +54,8 @@ bool ResourceHandle::start(NetworkingContext* context)
     MainResourceLoader* mainLoader = context->mainResourceLoader();
     bool isMainResource =
             static_cast<void*>(mainLoader) == static_cast<void*>(client());
-    bool isPrivateBrowsing = context->isPrivateBrowsingEnabled();
 
-    PassRefPtr<ResourceLoaderAndroid> loader = ResourceLoaderAndroid::start(this, d->m_firstRequest, context->frameLoaderClient(), isMainResource, false, isPrivateBrowsing);
+    PassRefPtr<ResourceLoaderAndroid> loader = ResourceLoaderAndroid::start(this, d->m_firstRequest, context->frameLoaderClient(), isMainResource, false);
 
     if (loader) {
         d->m_loader = loader;
@@ -156,13 +155,12 @@ void ResourceHandle::loadResourceSynchronously(NetworkingContext* context, const
 {
     SyncLoader s(error, response, data);
     RefPtr<ResourceHandle> h = adoptRef(new ResourceHandle(request, &s, false, false));
-    bool isPrivateBrowsing = context->isPrivateBrowsingEnabled();
     // This blocks until the load is finished.
     // Use the request owned by the ResourceHandle. This has had the username
     // and password (if present) stripped from the URL in
     // ResourceHandleInternal::ResourceHandleInternal(). This matches the
     // behaviour in the asynchronous case.
-    ResourceLoaderAndroid::start(h.get(), request, context->frameLoaderClient(), false, true, isPrivateBrowsing);
+    ResourceLoaderAndroid::start(h.get(), request, context->frameLoaderClient(), false, true);
 }
 
 } // namespace WebCore
index 93617f4..f627d62 100644 (file)
@@ -37,7 +37,7 @@ class ResourceHandle;
 
 class ResourceLoaderAndroid : public RefCounted<ResourceLoaderAndroid> {
 public:
-    static PassRefPtr<ResourceLoaderAndroid> start(ResourceHandle*, const ResourceRequest&, FrameLoaderClient*, bool isMainResource, bool isSync, bool isPrivateBrowsing);
+    static PassRefPtr<ResourceLoaderAndroid> start(ResourceHandle*, const ResourceRequest&, FrameLoaderClient*, bool isMainResource, bool isSync);
     virtual ~ResourceLoaderAndroid() { }
 
     virtual void cancel() = 0;
index 125b2fa..964ac6e 100644 (file)
@@ -168,8 +168,13 @@ namespace android {
         virtual PassRefPtr<DocumentLoader> createDocumentLoader(const ResourceRequest&, const SubstituteData&);
         virtual void setTitle(const String& title, const KURL&);
 
+        // This provides the userAgent to WebCore. It is used by WebCore to
+        // populate navigator.userAgent and to set the HTTP header in
+        // ResourceRequest objects. We also set a userAgent on WebRequestContext
+        // for the Chromium HTTP stack, which overrides the value on the
+        // ResourceRequest.
         virtual String userAgent(const KURL&);
-        
+
         virtual void savePlatformDataToCachedFrame(WebCore::CachedFrame*);
         virtual void transitionToCommittedFromCachedFrame(WebCore::CachedFrame*);
         virtual void transitionToCommittedForNewPage();
index 1d982cd..a5fe494 100644 (file)
@@ -44,11 +44,6 @@ MainResourceLoader* FrameNetworkingContextAndroid::mainResourceLoader() const
     return frame()->loader()->activeDocumentLoader()->mainResourceLoader();
 }
 
-bool FrameNetworkingContextAndroid::isPrivateBrowsingEnabled() const
-{
-    return frame()->settings() && frame()->settings()->privateBrowsingEnabled();
-}
-
 FrameLoaderClient* FrameNetworkingContextAndroid::frameLoaderClient() const
 {
     return frame()->loader()->client();
index d1b2ad2..d0ff979 100644 (file)
@@ -46,7 +46,6 @@ private:
     FrameNetworkingContextAndroid(WebCore::Frame*);
 
     virtual WebCore::MainResourceLoader* mainResourceLoader() const;
-    virtual bool isPrivateBrowsingEnabled() const;
     virtual WebCore::FrameLoaderClient* frameLoaderClient() const;
 };
 
index d04d71a..92a59a1 100644 (file)
 #include <config.h>
 #include <ResourceLoaderAndroid.h>
 
+#include "Frame.h"
 #include "FrameLoaderClientAndroid.h"
 #include "WebCoreFrameBridge.h"
 #include "WebCoreResourceLoader.h"
 #include "WebUrlLoader.h"
+#include "WebViewCore.h"
 
 using namespace android;
 
 namespace WebCore {
 
 PassRefPtr<ResourceLoaderAndroid> ResourceLoaderAndroid::start(
-        ResourceHandle* handle, const ResourceRequest& request, FrameLoaderClient* client, bool isMainResource, bool isSync, bool isPrivateBrowsing)
+        ResourceHandle* handle, const ResourceRequest& request, FrameLoaderClient* client, bool isMainResource, bool isSync)
 {
     // Called on main thread
+    FrameLoaderClientAndroid* clientAndroid = static_cast<FrameLoaderClientAndroid*>(client);
 #if USE(CHROME_NETWORK_STACK)
-    return WebUrlLoader::start(client, handle, request, isSync, isPrivateBrowsing);
+    WebViewCore* webViewCore = WebViewCore::getWebViewCore(clientAndroid->getFrame()->view());
+    return WebUrlLoader::start(client, handle, request, isSync, webViewCore->webRequestContext());
 #else
-    FrameLoaderClientAndroid* clientAndroid = static_cast<FrameLoaderClientAndroid*> (client);
     return clientAndroid->webFrame()->startLoadingResource(handle, request, isMainResource, isSync);
 #endif
 }
index d062bdc..16ec70f 100644 (file)
@@ -57,6 +57,8 @@ static const std::string& rootDirectory()
 
 static std::string storageDirectory(bool isPrivateBrowsing)
 {
+    // TODO: Where is the right place to put the db for private browsing? Should
+    // it be kept in memory?
     static const char* const kDirectory = "/webviewCacheChromium";
     static const char* const kDirectoryPrivate = "/webviewCacheChromiumPrivate";
 
index b7f2c8b..468a3cd 100644 (file)
@@ -145,7 +145,7 @@ void WebRequest::appendBytesToUpload(WTF::Vector<char>* data)
     delete data;
 }
 
-void WebRequest::start(bool isPrivateBrowsing)
+void WebRequest::start(WebRequestContext* context)
 {
     ASSERT(m_loadState == Created, "Start called on a WebRequest not in CREATED state: (%s)", m_url.c_str());
 
@@ -161,7 +161,6 @@ void WebRequest::start(bool isPrivateBrowsing)
     if (m_request->url().SchemeIs("browser"))
         return handleBrowserURL(m_request->url());
 
-    URLRequestContext* context = WebRequestContext::get(isPrivateBrowsing);
     m_request->set_context(context);
 
     m_request->Start();
index fb756ab..c78546c 100644 (file)
@@ -27,7 +27,7 @@
 #define WebRequest_h
 
 #include "ChromiumIncludes.h"
-#include "wtf/Vector.h"
+#include <wtf/Vector.h>
 
 class MessageLoop;
 
@@ -44,8 +44,9 @@ enum LoadState {
 };
 
 class UrlInterceptResponse;
-class WebResourceRequest;
 class WebFrame;
+class WebRequestContext;
+class WebResourceRequest;
 class WebUrlLoaderClient;
 
 // All methods in this class must be called on the io thread
@@ -65,7 +66,7 @@ public:
     void appendBytesToUpload(Vector<char>* data);
     void appendFileToUpload(const std::string& filename);
 
-    void start(bool isPrivateBrowsing);
+    void start(WebRequestContext*);
     void cancel();
 
     // From URLRequest::Delegate
index 9d0f6c9..3268abb 100644 (file)
 #include <dirent.h>
 #include <wtf/text/CString.h>
 
-namespace {
-// TODO: The userAgent should not be a static, as it can be set per WebView.
-// http://b/3113804
-std::string userAgent("");
-Lock userAgentLock;
-
-std::string acceptLanguageStdString("");
-WTF::String acceptLanguageWtfString("");
-WTF::Mutex acceptLanguageMutex;
-}
+static std::string acceptLanguageStdString("");
+static WTF::String acceptLanguageWtfString("");
+static WTF::Mutex acceptLanguageMutex;
+
+static int numPrivateBrowsingInstances;
+static WTF::Mutex numPrivateBrowsingInstancesMutex;
 
 using namespace WTF;
 
 namespace android {
 
-static scoped_refptr<WebRequestContext> privateBrowsingContext(0);
-static WTF::Mutex privateBrowsingContextMutex;
-
-WebRequestContext::WebRequestContext()
+WebRequestContext::WebRequestContext(bool isPrivateBrowsing)
+    : m_isPrivateBrowsing(isPrivateBrowsing)
 {
+    // Initialize chromium logging, needs to be done before any chromium code is called.
+    initChromiumLogging();
+
+    WebCache* cache = WebCache::get(m_isPrivateBrowsing);
+    host_resolver_ = cache->hostResolver();
+    http_transaction_factory_ = cache->cache();
+
+    WebCookieJar* cookieJar = WebCookieJar::get(m_isPrivateBrowsing);
+    cookie_store_ = cookieJar->cookieStore();
+    cookie_policy_ = cookieJar;
+
     // Also hardcoded in FrameLoader.java
     accept_charset_ = "utf-8, iso-8859-1, utf-16, *;q=0.7";
+
+    if (m_isPrivateBrowsing) {
+        MutexLocker lock(numPrivateBrowsingInstancesMutex);
+        numPrivateBrowsingInstances++;
+    }
 }
 
 WebRequestContext::~WebRequestContext()
 {
+    if (m_isPrivateBrowsing) {
+        MutexLocker lock(numPrivateBrowsingInstancesMutex);
+        numPrivateBrowsingInstances--;
+    }
 }
 
-void WebRequestContext::setUserAgent(String string)
+void WebRequestContext::setUserAgent(const String& string)
 {
-    // The useragent is set on the WebCore thread and read on the network
-    // stack's IO thread.
-    AutoLock aLock(userAgentLock);
-    userAgent = string.utf8().data();
+    MutexLocker lock(m_userAgentMutex);
+    m_userAgent = string.utf8().data();
 }
 
 const std::string& WebRequestContext::GetUserAgent(const GURL& url) const
 {
-    // The useragent is set on the WebCore thread and read on the network
-    // stack's IO thread.
-    AutoLock aLock(userAgentLock);
-    ASSERT(userAgent != "");
-    return userAgent;
+    MutexLocker lock(m_userAgentMutex);
+    return m_userAgent;
 }
 
 void WebRequestContext::setAcceptLanguage(const String& string)
@@ -98,48 +107,6 @@ const String& WebRequestContext::acceptLanguage()
     return acceptLanguageWtfString;
 }
 
-WebRequestContext* WebRequestContext::getImpl(bool isPrivateBrowsing)
-{
-    WebRequestContext* context = new WebRequestContext();
-
-    WebCache* cache = WebCache::get(isPrivateBrowsing);
-    context->host_resolver_ = cache->hostResolver();
-    context->http_transaction_factory_ = cache->cache();
-
-    WebCookieJar* cookieJar = WebCookieJar::get(isPrivateBrowsing);
-    context->cookie_store_ = cookieJar->cookieStore();
-    context->cookie_policy_ = cookieJar;
-
-    return context;
-}
-
-WebRequestContext* WebRequestContext::getRegularContext()
-{
-    static scoped_refptr<WebRequestContext> regularContext(0);
-    if (!regularContext)
-        regularContext = getImpl(false);
-    return regularContext;
-}
-
-WebRequestContext* WebRequestContext::getPrivateBrowsingContext()
-{
-    MutexLocker lock(privateBrowsingContextMutex);
-
-    // TODO: Where is the right place to put the temporary db? Should it be
-    // kept in memory?
-    if (!privateBrowsingContext)
-        privateBrowsingContext = getImpl(true);
-    return privateBrowsingContext;
-}
-
-WebRequestContext* WebRequestContext::get(bool isPrivateBrowsing)
-{
-    // Initialize chromium logging, needs to be done before any chromium code is called
-    initChromiumLogging();
-
-    return isPrivateBrowsing ? getPrivateBrowsingContext() : getRegularContext();
-}
-
 void WebRequestContext::removeFileOrDirectory(const char* filename)
 {
     struct stat filetype;
@@ -169,16 +136,15 @@ bool WebRequestContext::cleanupPrivateBrowsingFiles()
     // This is called on the UI thread.
     // TODO: This should be done on a different thread. Moving to the WebKit
     // thread should be straightforward and safe. See b/3243891.
-    MutexLocker lock(privateBrowsingContextMutex);
+    MutexLocker lock(numPrivateBrowsingInstancesMutex);
 
-    if (!privateBrowsingContext || privateBrowsingContext->HasOneRef()) {
-        privateBrowsingContext = 0;
+    // If there are private browsing contexts in use, do nothing.
+    if (numPrivateBrowsingInstances)
+        return false;
 
-        WebCookieJar::cleanup(true);
-        WebCache::cleanup(true);
-        return true;
-    }
-    return false;
+    WebCookieJar::cleanup(true);
+    WebCache::cleanup(true);
+    return true;
 }
 
 } // namespace android
index ec1561b..5827ce2 100644 (file)
 
 namespace android {
 
-// This class is generally not threadsafe. .get() is not threadsafe - instances
-// are created on the WebCore thread only.
+// This class is generally not threadsafe.
 class WebRequestContext : public URLRequestContext {
 public:
     // URLRequestContext overrides.
     virtual const std::string& GetUserAgent(const GURL&) const;
     virtual const std::string& GetAcceptLanguage() const;
 
-    // Lazily create the relevant context. This class holds a reference.
-    static WebRequestContext* get(bool isPrivateBrowsing);
+    WebRequestContext(bool isPrivateBrowsing);
 
     // These methods are threadsafe.
     static bool cleanupPrivateBrowsingFiles();
-    static void setUserAgent(WTF::String);
+    void setUserAgent(const WTF::String&);
     static void setAcceptLanguage(const WTF::String&);
     static const WTF::String& acceptLanguage();
 
@@ -59,10 +57,9 @@ private:
     WebRequestContext();
     ~WebRequestContext();
 
-    static WebRequestContext* getImpl(bool isPrivateBrowsing);
-    static WebRequestContext* getRegularContext();
-    static WebRequestContext* getPrivateBrowsingContext();
-
+    std::string m_userAgent;
+    mutable WTF::Mutex m_userAgentMutex;
+    bool m_isPrivateBrowsing;
 };
 
 } // namespace android
index 8c943a0..f634633 100644 (file)
@@ -44,8 +44,8 @@ WebUrlLoader::~WebUrlLoader()
 {
 }
 
-PassRefPtr<WebUrlLoader> WebUrlLoader::start(FrameLoaderClient* client, WebCore::ResourceHandle* resourceHandle, 
-        const WebCore::ResourceRequest& resourceRequest, bool isSync, bool isPrivateBrowsing)
+PassRefPtr<WebUrlLoader> WebUrlLoader::start(FrameLoaderClient* client, WebCore::ResourceHandle* resourceHandle,
+        const WebCore::ResourceRequest& resourceRequest, bool isSync, WebRequestContext* context)
 {
     FrameLoaderClientAndroid* androidClient = static_cast<FrameLoaderClientAndroid*>(client);
     WebFrame* webFrame = androidClient->webFrame();
@@ -58,7 +58,7 @@ PassRefPtr<WebUrlLoader> WebUrlLoader::start(FrameLoaderClient* client, WebCore:
     webFrame->maybeSavePassword(androidClient->getFrame(), resourceRequest);
 
     RefPtr<WebUrlLoader> loader = WebUrlLoader::create(webFrame, resourceHandle, resourceRequest);
-    loader->m_loaderClient->start(isSync, isPrivateBrowsing);
+    loader->m_loaderClient->start(isSync, context);
 
     return loader.release();
 }
index 2e76c14..d9515f8 100644 (file)
@@ -34,11 +34,12 @@ using namespace WebCore;
 namespace android {
 class WebUrlLoaderClient;
 class WebFrame;
+class WebRequestContext;
 
 class WebUrlLoader : public ResourceLoaderAndroid {
 public:
     virtual ~WebUrlLoader();
-    static PassRefPtr<WebUrlLoader> start(FrameLoaderClient* client, WebCore::ResourceHandle*, const WebCore::ResourceRequest&, bool sync, bool isPrivateBrowsing);
+    static PassRefPtr<WebUrlLoader> start(FrameLoaderClient* client, WebCore::ResourceHandle*, const WebCore::ResourceRequest&, bool sync, WebRequestContext*);
 
     virtual void cancel();
     virtual void downloadFile();
index d7df279..50defc2 100644 (file)
@@ -147,7 +147,7 @@ WebUrlLoaderClient::WebUrlLoaderClient(WebFrame* webFrame, WebCore::ResourceHand
     }
 }
 
-bool WebUrlLoaderClient::start(bool sync, bool isPrivateBrowsing)
+bool WebUrlLoaderClient::start(bool sync, WebRequestContext* context)
 {
     base::Thread* thread = ioThread();
     if (!thread) {
@@ -157,7 +157,7 @@ bool WebUrlLoaderClient::start(bool sync, bool isPrivateBrowsing)
     m_sync = sync;
     if (m_sync) {
         AutoLock autoLock(*syncLock());
-        thread->message_loop()->PostTask(FROM_HERE, NewRunnableMethod(m_request.get(), &WebRequest::start, isPrivateBrowsing));
+        thread->message_loop()->PostTask(FROM_HERE, NewRunnableMethod(m_request.get(), &WebRequest::start, context));
 
         // Run callbacks until the queue is exhausted and m_finished is true.
         while(!m_finished) {
@@ -176,7 +176,7 @@ bool WebUrlLoaderClient::start(bool sync, bool isPrivateBrowsing)
         m_resourceHandle = 0;
     } else {
         // Asynchronous start.
-        thread->message_loop()->PostTask(FROM_HERE, NewRunnableMethod(m_request.get(), &WebRequest::start, isPrivateBrowsing));
+        thread->message_loop()->PostTask(FROM_HERE, NewRunnableMethod(m_request.get(), &WebRequest::start, context));
     }
     return true;
 }
index 56d4289..d69bea6 100644 (file)
@@ -52,6 +52,7 @@ namespace android {
 
 class WebFrame;
 class WebRequest;
+class WebRequestContext;
 
 // This class handles communication between the IO thread where loading happens
 // and the webkit main thread.
@@ -65,7 +66,7 @@ public:
     WebUrlLoaderClient(WebFrame*, WebCore::ResourceHandle*, const WebCore::ResourceRequest&);
 
     // Called from WebCore, will be forwarded to the IO thread
-    bool start(bool sync, bool isPrivateBrowsing);
+    bool start(bool sync, WebRequestContext*);
     void cancel();
     void downloadFile();
     void pauseLoad(bool pause) {} // Android method, does nothing for now
index 73a8460..2d92b4b 100644 (file)
@@ -61,7 +61,9 @@ void WebAutoFill::init()
         return;
 
     mFormManager = new FormManager();
-    AndroidURLRequestContextGetter::Get()->SetURLRequestContext(WebRequestContext::get(false /* isPrivateBrowsing */));
+    // We use the WebView's WebRequestContext, which may be a private browsing context.
+    ASSERT(mWebViewCore);
+    AndroidURLRequestContextGetter::Get()->SetURLRequestContext(mWebViewCore->webRequestContext());
     AndroidURLRequestContextGetter::Get()->SetIOThread(WebUrlLoaderClient::ioThread());
     mTabContents = new TabContents();
     mAutoFillManager = new AutoFillManager(mTabContents.get());
index 737f107..6b40b65 100644 (file)
@@ -51,6 +51,7 @@
 #include "WorkerContextExecutionProxy.h"
 #endif
 #include "WebRequestContext.h"
+#include "WebViewCore.h"
 
 #include <JNIHelp.h>
 #include <utils/misc.h>
@@ -364,7 +365,8 @@ public:
         str = (jstring)env->GetObjectField(obj, gFieldIds->mUserAgent);
         WebFrame::getWebFrame(pFrame)->setUserAgent(jstringToWtfString(env, str));
 #if USE(CHROME_NETWORK_STACK)
-        WebRequestContext::setUserAgent(jstringToWtfString(env, str));
+        WebViewCore::getWebViewCore(pFrame->view())->setWebRequestContextUserAgent();
+
         str = (jstring)env->GetObjectField(obj, gFieldIds->mAcceptLanguage);
         WebRequestContext::setAcceptLanguage(jstringToWtfString(env, str));
 #endif
index 82ec3e2..ed397d3 100644 (file)
@@ -3336,6 +3336,24 @@ bool WebViewCore::drawIsPaused() const
         gWebViewCoreFields.m_drawIsPaused);
 }
 
+#if USE(CHROME_NETWORK_STACK)
+void WebViewCore::setWebRequestContextUserAgent()
+{
+    if (m_webRequestContext)
+        m_webRequestContext->setUserAgent(WebFrame::getWebFrame(m_mainFrame)->userAgentForURL(0)); // URL not used
+}
+
+WebRequestContext* WebViewCore::webRequestContext()
+{
+    if (!m_webRequestContext) {
+        Settings* settings = mainFrame()->settings();
+        m_webRequestContext = new WebRequestContext(settings && settings->privateBrowsingEnabled());
+        setWebRequestContextUserAgent();
+    }
+    return m_webRequestContext.get();
+}
+#endif
+
 //----------------------------------------------------------------------
 // Native JNI methods
 //----------------------------------------------------------------------
index 53cca79..4278261 100644 (file)
 #ifndef WEBVIEWCORE_H
 #define WEBVIEWCORE_H
 
-#include "android_npapi.h"
-#include "FileChooser.h"
 #include "CacheBuilder.h"
 #include "CachedHistory.h"
 #include "DeviceMotionAndOrientationManager.h"
 #include "DOMSelection.h"
+#include "FileChooser.h"
 #include "PictureSet.h"
 #include "PlatformGraphicsContext.h"
 #include "SkColor.h"
@@ -40,6 +39,9 @@
 #include "Timer.h"
 #include "WebCoreRefObject.h"
 #include "WebCoreJni.h"
+#include "WebRequestContext.h"
+#include "android_npapi.h"
+
 #include <jni.h>
 #include <ui/KeycodeLabels.h>
 #include <ui/PixelFormat.h>
@@ -536,6 +538,8 @@ namespace android {
         bool isPaused() const { return m_isPaused; }
         void setIsPaused(bool isPaused) { m_isPaused = isPaused; }
         bool drawIsPaused() const;
+        void setWebRequestContextUserAgent();
+        WebRequestContext* webRequestContext();
         // end of shared members
 
         // internal functions
@@ -619,16 +623,16 @@ namespace android {
         bool setSelection(DOMSelection* selection, Text* textNode, int direction);
         bool setSelection(DOMSelection* selection, Node* startNode, Node* endNode, int startOffset, int endOffset);
         Node* m_currentNodeDomNavigationAxis;
-
 #if ENABLE(TOUCH_EVENTS)
         bool m_forwardingTouchEvents;
 #endif
-
 #if DEBUG_NAV_UI
         uint32_t m_now;
 #endif
-
         DeviceMotionAndOrientationManager m_deviceMotionAndOrientationManager;
+#if USE(CHROME_NETWORK_STACK)
+        scoped_refptr<WebRequestContext> m_webRequestContext;
+#endif
 
     private:
         // called from constructor, to add this to a global list