summaryrefslogtreecommitdiffstats
path: root/WebKit/android
diff options
context:
space:
mode:
Diffstat (limited to 'WebKit/android')
-rw-r--r--WebKit/android/WebCoreSupport/ChromeClientAndroid.cpp2
-rw-r--r--WebKit/android/WebCoreSupport/GeolocationPermissions.h5
-rw-r--r--WebKit/android/WebCoreSupport/V8Counters.cpp2
-rw-r--r--WebKit/android/WebCoreSupport/WebRequest.cpp89
-rw-r--r--WebKit/android/WebCoreSupport/WebRequest.h12
-rw-r--r--WebKit/android/WebCoreSupport/WebRequestContext.cpp4
-rw-r--r--WebKit/android/WebCoreSupport/WebResourceRequest.cpp34
-rw-r--r--WebKit/android/WebCoreSupport/WebResourceRequest.h11
-rw-r--r--WebKit/android/WebCoreSupport/WebResponse.cpp1
-rw-r--r--WebKit/android/WebCoreSupport/WebUrlLoader.cpp19
-rw-r--r--WebKit/android/WebCoreSupport/WebUrlLoader.h7
-rw-r--r--WebKit/android/WebCoreSupport/WebUrlLoaderClient.cpp30
-rw-r--r--WebKit/android/WebCoreSupport/WebUrlLoaderClient.h9
-rw-r--r--WebKit/android/benchmark/Intercept.cpp3
-rw-r--r--WebKit/android/jni/JavaBridge.cpp2
-rw-r--r--WebKit/android/jni/WebCoreFrameBridge.cpp17
-rw-r--r--WebKit/android/jni/WebCoreFrameBridge.h2
-rw-r--r--WebKit/android/jni/WebViewCore.cpp30
-rw-r--r--WebKit/android/jni/WebViewCore.h2
-rw-r--r--WebKit/android/nav/CachedNode.h5
-rw-r--r--WebKit/android/nav/SelectText.cpp9
-rw-r--r--WebKit/android/nav/WebView.cpp2
22 files changed, 264 insertions, 33 deletions
diff --git a/WebKit/android/WebCoreSupport/ChromeClientAndroid.cpp b/WebKit/android/WebCoreSupport/ChromeClientAndroid.cpp
index ec1390e..d5cadad 100644
--- a/WebKit/android/WebCoreSupport/ChromeClientAndroid.cpp
+++ b/WebKit/android/WebCoreSupport/ChromeClientAndroid.cpp
@@ -163,7 +163,7 @@ Page* ChromeClientAndroid::createWindow(Frame* frame, const FrameLoadRequest&,
if (features.fullscreen)
dialog = false;
WebCore::Frame* newFrame = m_webFrame->createWindow(dialog,
- frame->script()->processingUserGesture(mainThreadNormalWorld()));
+ ScriptController::processingUserGesture());
if (newFrame) {
WebCore::Page* page = newFrame->page();
page->setGroupName(frame->page()->groupName());
diff --git a/WebKit/android/WebCoreSupport/GeolocationPermissions.h b/WebKit/android/WebCoreSupport/GeolocationPermissions.h
index 9a1966a..f40619b 100644
--- a/WebKit/android/WebCoreSupport/GeolocationPermissions.h
+++ b/WebKit/android/WebCoreSupport/GeolocationPermissions.h
@@ -27,14 +27,13 @@
#define GeolocationPermissions_h
#include "PlatformString.h"
-// We must include this before before HashMap.h, as it provides specalizations
-// for String hash types instantiated there.
-#include "StringHash.h"
#include "Timer.h"
+
#include <wtf/HashMap.h>
#include <wtf/HashSet.h>
#include <wtf/RefCounted.h>
#include <wtf/Vector.h>
+#include <wtf/text/StringHash.h>
namespace WebCore {
class Frame;
diff --git a/WebKit/android/WebCoreSupport/V8Counters.cpp b/WebKit/android/WebCoreSupport/V8Counters.cpp
index 7472447..4e7351d 100644
--- a/WebKit/android/WebCoreSupport/V8Counters.cpp
+++ b/WebKit/android/WebCoreSupport/V8Counters.cpp
@@ -33,9 +33,9 @@
#include "V8Counters.h"
#include "NotImplemented.h"
-#include <StringHash.h>
#include <utils/Log.h>
#include <wtf/text/CString.h>
+#include <wtf/text/StringHash.h>
namespace WebCore {
diff --git a/WebKit/android/WebCoreSupport/WebRequest.cpp b/WebKit/android/WebCoreSupport/WebRequest.cpp
index 79e780e..5e760ae 100644
--- a/WebKit/android/WebCoreSupport/WebRequest.cpp
+++ b/WebKit/android/WebCoreSupport/WebRequest.cpp
@@ -26,21 +26,23 @@
#include "config.h"
#include "WebRequest.h"
+#include "JNIUtility.h"
#include "MainThread.h"
#include "WebRequestContext.h"
#include "WebResourceRequest.h"
+#include "jni.h"
#include <net/base/data_url.h>
#include <net/base/io_buffer.h>
#include <net/http/http_response_headers.h>
#include <net/url_request/url_request.h>
#include <string>
+#include <utils/AssetManager.h>
+
+extern android::AssetManager* globalAssetManager();
// TODO:
-// - Get gmail log in to work
// - Finish the file upload. Testcase is mobile buzz
-// - Handle fails better
-// - Check the string conversion work for more than the general case
// - Add network throttle needed by Android plugins
namespace android {
@@ -51,8 +53,12 @@ namespace {
WebRequest::WebRequest(WebUrlLoaderClient* loader, WebResourceRequest webResourceRequest)
: m_urlLoader(loader)
+ , m_inputStream(0)
+ , m_androidUrl(false)
{
+ m_url = webResourceRequest.url();
GURL gurl(webResourceRequest.url());
+
m_request = new URLRequest(gurl, this);
m_request->SetExtraRequestHeaders(webResourceRequest.requestHeaders());
@@ -60,8 +66,23 @@ WebRequest::WebRequest(WebUrlLoaderClient* loader, WebResourceRequest webResourc
m_request->set_method(webResourceRequest.method());
}
+// This is a special URL for Android. Query the Java InputStream
+// for data and send to WebCore
+WebRequest::WebRequest(WebUrlLoaderClient* loader, WebResourceRequest webResourceRequest, int inputStream)
+ : m_urlLoader(loader)
+ , m_request(0)
+ , m_androidUrl(true)
+{
+ JNIEnv* env = JSC::Bindings::getJNIEnv();
+ m_inputStream = (int)env->NewGlobalRef((_jobject*)inputStream);
+ m_url = webResourceRequest.url();
+}
+
WebRequest::~WebRequest()
{
+ JNIEnv* env = JSC::Bindings::getJNIEnv();
+ if (m_inputStream)
+ env->DeleteGlobalRef((_jobject*)m_inputStream);
}
void WebRequest::finish(bool success)
@@ -86,10 +107,16 @@ void WebRequest::AppendBytesToUpload(const char* bytes, int bytesLen)
void WebRequest::start(bool isPrivateBrowsing)
{
+ if (m_androidUrl)
+ return handleAndroidURL();
+
// Handle data urls before we send it off to the http stack
if (m_request->url().SchemeIs("data"))
return handleDataURL(m_request->url());
+ if (m_request->url().SchemeIs("browser"))
+ return handleBrowserURL(m_request->url());
+
if (!isPrivateBrowsing)
m_request->set_context(WebRequestContext::GetAndroidContext());
else
@@ -110,6 +137,47 @@ void WebRequest::cancel()
finish(true);
}
+void WebRequest::handleAndroidURL()
+{
+ JNIEnv* env = JSC::Bindings::getJNIEnv();
+ if (m_inputStream == 0) {
+ WebResponse webResponse(m_url, "", 0, "", 0);
+ LoaderData* loaderData = new LoaderData(m_urlLoader, webResponse);
+ m_urlLoader->maybeCallOnMainThread(WebUrlLoaderClient::didFail, loaderData);
+ return;
+ }
+
+ WebResponse webResponse(m_url, "", 0, "", 200);
+ LoaderData* loaderResponse = new LoaderData(m_urlLoader, webResponse);
+ m_urlLoader->maybeCallOnMainThread(WebUrlLoaderClient::didReceiveResponse, loaderResponse);
+
+ int size = 0;
+ jclass bridgeClass = env->FindClass("android/webkit/BrowserFrame");
+ jmethodID method = env->GetStaticMethodID(bridgeClass, "readFromStream", "(Ljava/io/InputStream;[B)I");
+
+ jbyteArray jb = env->NewByteArray(kInitialReadBufSize);
+ do {
+ size = (int)env->CallStaticIntMethod(bridgeClass, method, m_inputStream, jb);
+ if (size < 0) // -1 is EOF
+ break;
+
+ // data is deleted in WebUrlLoaderClient::didReceiveAndroidFileData
+ // data is sent to the webcore thread
+ std::vector<char>* data = new std::vector<char>();
+ data->reserve(size);
+ env->GetByteArrayRegion(jb, 0, size, (jbyte*)&data->front());
+
+ // Passes ownership of data
+ LoaderData* loaderData = new LoaderData(m_urlLoader, data, size);
+ m_urlLoader->maybeCallOnMainThread(WebUrlLoaderClient::didReceiveAndroidFileData, loaderData);
+ } while (true);
+
+ env->DeleteLocalRef(jb);
+ env->DeleteLocalRef(bridgeClass);
+
+ finish(true);
+}
+
void WebRequest::handleDataURL(GURL url)
{
OwnPtr<std::string*> data(new std::string);
@@ -134,6 +202,21 @@ void WebRequest::handleDataURL(GURL url)
finish(true);
}
+void WebRequest::handleBrowserURL(GURL url)
+{
+ std::string data("data:text/html;charset=utf-8,");
+ if (url.spec() == "browser:incognito") {
+ AssetManager* assetManager = globalAssetManager();
+ Asset* asset = assetManager->open("webkit/incognito_mode_start_page.html", Asset::ACCESS_BUFFER);
+ if (asset) {
+ data.append((const char*)asset->getBuffer(false), asset->getLength());
+ delete asset;
+ }
+ }
+ GURL dataURL(data.c_str());
+ handleDataURL(dataURL);
+}
+
// Called upon a server-initiated redirect. The delegate may call the
// request's Cancel method to prevent the redirect from being followed.
// Since there may be multiple chained redirects, there may also be more
diff --git a/WebKit/android/WebCoreSupport/WebRequest.h b/WebKit/android/WebCoreSupport/WebRequest.h
index 9c9c830..b6b3ae2 100644
--- a/WebKit/android/WebCoreSupport/WebRequest.h
+++ b/WebKit/android/WebCoreSupport/WebRequest.h
@@ -42,6 +42,13 @@ class WebRequest : public URLRequest::Delegate, public base::RefCountedThreadSaf
public:
WebRequest(WebUrlLoaderClient*, WebResourceRequest);
+ // If this is an android specific url we load it with a java input stream
+ // Used for:
+ // - file:///android_asset
+ // - file:///android_res
+ // - content://
+ WebRequest(WebUrlLoaderClient*, WebResourceRequest, int inputStream);
+
// Optional, but if used has to be called before start
void AppendBytesToUpload(const char* bytes, int bytesLen);
@@ -61,6 +68,8 @@ private:
friend class base::RefCountedThreadSafe<WebRequest>;
virtual ~WebRequest();
void handleDataURL(GURL);
+ void handleBrowserURL(GURL);
+ void handleAndroidURL();
void finish(bool success);
// Not owned
@@ -68,6 +77,9 @@ private:
OwnPtr<URLRequest> m_request;
scoped_refptr<net::IOBuffer> m_networkBuffer;
+ int m_inputStream;
+ bool m_androidUrl;
+ std::string m_url;
};
} // namespace android
diff --git a/WebKit/android/WebCoreSupport/WebRequestContext.cpp b/WebKit/android/WebCoreSupport/WebRequestContext.cpp
index 6b2fe1b..1b7a5ee 100644
--- a/WebKit/android/WebCoreSupport/WebRequestContext.cpp
+++ b/WebKit/android/WebCoreSupport/WebRequestContext.cpp
@@ -120,6 +120,10 @@ WebRequestContext* WebRequestContext::GetAndroidContextForPath(const char* cooki
androidContext->http_transaction_factory_ = new net::HttpCache(androidContext->host_resolver(), net::ProxyService::CreateNull(), net::SSLConfigService::CreateSystemSSLConfigService(), 0, 0, 0, defaultBackend);
scoped_refptr<SQLitePersistentCookieStore> cookieDb = new SQLitePersistentCookieStore(cookiePath);
+
+ // This is needed for the page cycler
+ net::CookieMonster::EnableFileScheme();
+
androidContext->cookie_store_ = new net::CookieMonster(cookieDb.get(), 0);
return androidContext.release();
diff --git a/WebKit/android/WebCoreSupport/WebResourceRequest.cpp b/WebKit/android/WebCoreSupport/WebResourceRequest.cpp
index 5c7410c..f357119 100644
--- a/WebKit/android/WebCoreSupport/WebResourceRequest.cpp
+++ b/WebKit/android/WebCoreSupport/WebResourceRequest.cpp
@@ -31,6 +31,17 @@
#include <base/string_util.h>
#include <wtf/text/CString.h>
+namespace {
+const std::string android_asset("file:///android_asset/");
+const std::string android_res("file:///android_res/");
+const std::string android_content("content:");
+
+// Matched in BrowserFrame.java
+const int RESOURCE = 1;
+const int ASSET = 2;
+const int CONTENT = 3;
+}
+
namespace android {
WebResourceRequest::WebResourceRequest(const WebCore::ResourceRequest& resourceRequest)
@@ -64,7 +75,30 @@ WebResourceRequest::WebResourceRequest(const WebCore::ResourceRequest& resourceR
m_method = resourceRequest.httpMethod().utf8().data();
m_referrer = resourceRequest.httpReferrer().utf8().data();
+
m_url = resourceRequest.url().string().utf8().data();
+
+ // Android has special file urls, resolve these
+ m_specialAndroidFileType = 0;
+ std::string::size_type loc = m_url.find(android_asset);
+ if (loc != std::string::npos && loc == 0) {
+ m_url = m_url.erase(0, android_asset.length());
+ m_specialAndroidFileType = ASSET;
+ return;
+ }
+
+ loc = m_url.find(android_res);
+ if (loc != std::string::npos && loc == 0) {
+ m_url = m_url.erase(0, android_res.length());
+ m_specialAndroidFileType = RESOURCE;
+ return;
+ }
+
+ loc = m_url.find(android_content);
+ if (loc != std::string::npos && loc == 0) {
+ m_specialAndroidFileType = CONTENT;
+ return;
+ }
}
} // namespace android
diff --git a/WebKit/android/WebCoreSupport/WebResourceRequest.h b/WebKit/android/WebCoreSupport/WebResourceRequest.h
index 7064176..6880340 100644
--- a/WebKit/android/WebCoreSupport/WebResourceRequest.h
+++ b/WebKit/android/WebCoreSupport/WebResourceRequest.h
@@ -60,10 +60,21 @@ public:
return m_url;
}
+ const bool isAndroidUrl()
+ {
+ return m_specialAndroidFileType != 0;
+ }
+
+ const int androidFileType()
+ {
+ return m_specialAndroidFileType;
+ }
+
private:
std::string m_method;
std::string m_referrer;
net::HttpRequestHeaders m_requestHeaders;
+ int m_specialAndroidFileType;
std::string m_url;
};
diff --git a/WebKit/android/WebCoreSupport/WebResponse.cpp b/WebKit/android/WebCoreSupport/WebResponse.cpp
index fcd2127..cb10cba 100644
--- a/WebKit/android/WebCoreSupport/WebResponse.cpp
+++ b/WebKit/android/WebCoreSupport/WebResponse.cpp
@@ -57,6 +57,7 @@ WebResponse::WebResponse(URLRequest* request)
WebResponse::WebResponse(const std::string &url, const std::string &mimeType, const long long length, const std::string &encoding, const int httpStatusCode)
: m_encoding(encoding)
, m_httpStatusCode(httpStatusCode)
+ , m_httpStatusText("")
, m_length(length)
, m_mime(mimeType)
, m_url(url)
diff --git a/WebKit/android/WebCoreSupport/WebUrlLoader.cpp b/WebKit/android/WebCoreSupport/WebUrlLoader.cpp
index 4b815c6..cda02dd 100644
--- a/WebKit/android/WebCoreSupport/WebUrlLoader.cpp
+++ b/WebKit/android/WebCoreSupport/WebUrlLoader.cpp
@@ -27,14 +27,15 @@
#include "WebUrlLoader.h"
+#include "FrameLoaderClientAndroid.h"
#include "WebUrlLoaderClient.h"
namespace android {
// on main thread
-WebUrlLoader::WebUrlLoader(WebCore::ResourceHandle* resourceHandle, const WebCore::ResourceRequest& resourceRequest)
+WebUrlLoader::WebUrlLoader(WebFrame* webFrame, WebCore::ResourceHandle* resourceHandle, const WebCore::ResourceRequest& resourceRequest)
{
- m_loaderClient = new WebUrlLoaderClient(resourceHandle, resourceRequest);
+ m_loaderClient = new WebUrlLoaderClient(webFrame, resourceHandle, resourceRequest);
}
// on main thread
@@ -42,17 +43,19 @@ WebUrlLoader::~WebUrlLoader()
{
}
-PassRefPtr<WebUrlLoader> WebUrlLoader::start(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, bool isPrivateBrowsing)
{
- RefPtr<WebUrlLoader> loader = WebUrlLoader::create(resourceHandle, resourceRequest);
+ FrameLoaderClientAndroid* clientAndroid = static_cast<FrameLoaderClientAndroid*> (client);
+ RefPtr<WebUrlLoader> loader = WebUrlLoader::create(clientAndroid->webFrame(), resourceHandle, resourceRequest);
loader->m_loaderClient->start(isSync, isPrivateBrowsing);
return loader.release();
}
-PassRefPtr<WebUrlLoader> WebUrlLoader::create(WebCore::ResourceHandle* resourceHandle, const WebCore::ResourceRequest& resourceRequest)
+PassRefPtr<WebUrlLoader> WebUrlLoader::create(WebFrame* webFrame, WebCore::ResourceHandle* resourceHandle, const WebCore::ResourceRequest& resourceRequest)
{
- return adoptRef(new WebUrlLoader(resourceHandle, resourceRequest));
+ return adoptRef(new WebUrlLoader(webFrame, resourceHandle, resourceRequest));
}
// on main thread
@@ -69,9 +72,9 @@ namespace WebCore {
// static
// TODO: Implement sync requests
PassRefPtr<ResourceLoaderAndroid> ResourceLoaderAndroid::start(WebCore::ResourceHandle* resourceHandle, const WebCore::ResourceRequest& resourceRequest,
- FrameLoaderClient* /*client*/, bool /*isMainResource*/, bool isSync, bool isPrivateBrowsing)
+ FrameLoaderClient* client, bool /*isMainResource*/, bool isSync, bool isPrivateBrowsing)
{
- return android::WebUrlLoader::start(resourceHandle, resourceRequest, isSync, isPrivateBrowsing);
+ return android::WebUrlLoader::start(client, resourceHandle, resourceRequest, isSync, isPrivateBrowsing);
}
// static
diff --git a/WebKit/android/WebCoreSupport/WebUrlLoader.h b/WebKit/android/WebCoreSupport/WebUrlLoader.h
index c465b66..a8184c8 100644
--- a/WebKit/android/WebCoreSupport/WebUrlLoader.h
+++ b/WebKit/android/WebCoreSupport/WebUrlLoader.h
@@ -32,19 +32,20 @@ using namespace WebCore;
namespace android {
class WebUrlLoaderClient;
+class WebFrame;
class WebUrlLoader : public ResourceLoaderAndroid {
public:
virtual ~WebUrlLoader();
- static PassRefPtr<WebUrlLoader> start(WebCore::ResourceHandle*, const WebCore::ResourceRequest&, bool sync, bool isPrivateBrowsing);
+ static PassRefPtr<WebUrlLoader> start(FrameLoaderClient* client, WebCore::ResourceHandle*, const WebCore::ResourceRequest&, bool sync, bool isPrivateBrowsing);
virtual void cancel();
virtual void downloadFile() {} // Not implemented yet
virtual void pauseLoad(bool pause) {} // Android method, does nothing for now
private:
- WebUrlLoader(WebCore::ResourceHandle*, const WebCore::ResourceRequest&);
- static PassRefPtr<WebUrlLoader> create(WebCore::ResourceHandle*, const WebCore::ResourceRequest&);
+ WebUrlLoader(WebFrame*, WebCore::ResourceHandle*, const WebCore::ResourceRequest&);
+ static PassRefPtr<WebUrlLoader> create(WebFrame*, WebCore::ResourceHandle*, const WebCore::ResourceRequest&);
OwnPtr<WebUrlLoaderClient> m_loaderClient;
};
diff --git a/WebKit/android/WebCoreSupport/WebUrlLoaderClient.cpp b/WebKit/android/WebCoreSupport/WebUrlLoaderClient.cpp
index e3ee14c..80b1dbd 100644
--- a/WebKit/android/WebCoreSupport/WebUrlLoaderClient.cpp
+++ b/WebKit/android/WebCoreSupport/WebUrlLoaderClient.cpp
@@ -30,6 +30,7 @@
#include "ResourceHandle.h"
#include "ResourceHandleClient.h"
#include "ResourceResponse.h"
+#include "WebCoreFrameBridge.h"
#include "WebRequest.h"
#include "WebResourceRequest.h"
@@ -95,17 +96,22 @@ bool WebUrlLoaderClient::isActive() const
return true;
}
-WebUrlLoaderClient::WebUrlLoaderClient(WebCore::ResourceHandle* resourceHandle, const WebCore::ResourceRequest& resourceRequest)
+WebUrlLoaderClient::WebUrlLoaderClient(WebFrame* webFrame, WebCore::ResourceHandle* resourceHandle, const WebCore::ResourceRequest& resourceRequest)
: m_resourceHandle(resourceHandle)
, m_cancelling(false)
, m_sync(false)
, m_finished(false)
{
WebResourceRequest webResourceRequest(resourceRequest);
+ if (webResourceRequest.isAndroidUrl()) {
+ int inputStream = webFrame->inputStreamForAndroidResource(webResourceRequest.url().c_str(), webResourceRequest.androidFileType());
+ m_request = new WebRequest(this, webResourceRequest, inputStream);
+ m_request->AddRef(); // Matched by ReleaseSoon in destructor
+ return;
+ }
m_request = new WebRequest(this, webResourceRequest);
m_request->AddRef(); // Matched by ReleaseSoon in destructor
- base::Thread* thread = ioThread();
// Set uploads before start is called on the request
if (resourceRequest.httpBody() && !(webResourceRequest.method() == "GET" || webResourceRequest.method() == "HEAD")) {
@@ -245,18 +251,32 @@ void WebUrlLoaderClient::didReceiveData(void* data)
// For data url's
void WebUrlLoaderClient::didReceiveDataUrl(void* data)
{
- OwnPtr<LoaderData> ld(static_cast<LoaderData*>(data));
- const WebUrlLoaderClient* loader = ld->loader;
+ OwnPtr<LoaderData> loaderData(static_cast<LoaderData*>(data));
+ const WebUrlLoaderClient* loader = loaderData->loader;
if (!loader->isActive())
return;
- std::string* str = ld->string.get();
+ std::string* str = loaderData->string.get();
// didReceiveData will take a copy of the data
loader->m_resourceHandle->client()->didReceiveData(loader->m_resourceHandle.get(), str->data(), str->size(), str->size());
}
// static - on main thread
+// For special android files
+void WebUrlLoaderClient::didReceiveAndroidFileData(void* data)
+{
+ OwnPtr<LoaderData> loaderData(static_cast<LoaderData*>(data));
+ const WebUrlLoaderClient* loader = loaderData->loader;
+
+ if (!loader->isActive())
+ return;
+
+ // didReceiveData will take a copy of the data
+ loader->m_resourceHandle->client()->didReceiveData(loader->m_resourceHandle.get(), &(loaderData->vector->front()), loaderData->size, loaderData->size);
+}
+
+// static - on main thread
void WebUrlLoaderClient::didFail(void* data)
{
OwnPtr<LoaderData> loaderData(static_cast<LoaderData*>(data));
diff --git a/WebKit/android/WebCoreSupport/WebUrlLoaderClient.h b/WebKit/android/WebCoreSupport/WebUrlLoaderClient.h
index a761f15..1506e5e 100644
--- a/WebKit/android/WebCoreSupport/WebUrlLoaderClient.h
+++ b/WebKit/android/WebCoreSupport/WebUrlLoaderClient.h
@@ -48,6 +48,7 @@ class IOBuffer;
namespace android {
+class WebFrame;
class WebRequest;
// This class handles communication between the IO thread where loading happens
@@ -59,7 +60,7 @@ class WebRequest;
// - Implement pauseLoad
class WebUrlLoaderClient {
public:
- WebUrlLoaderClient(WebCore::ResourceHandle*, const WebCore::ResourceRequest&);
+ WebUrlLoaderClient(WebFrame*, WebCore::ResourceHandle*, const WebCore::ResourceRequest&);
~WebUrlLoaderClient();
// Called from WebCore, will be forwarded to the IO thread
@@ -78,6 +79,7 @@ public:
static void didReceiveResponse(void*);
static void didReceiveData(void*);
static void didReceiveDataUrl(void*);
+ static void didReceiveAndroidFileData(void*);
static void didFinishLoading(void*);
static void didFail(void*);
static void willSendRequest(void*);
@@ -117,6 +119,7 @@ struct LoaderData {
WebResponse webResponse;
const int size;
OwnPtr<std::string*> string;
+ OwnPtr<std::vector<char> > vector;
LoaderData(WebUrlLoaderClient* l) : buffer(0), loader(l), size(0)
{
@@ -134,6 +137,10 @@ struct LoaderData {
{
}
+ LoaderData(WebUrlLoaderClient* l, std::vector<char>* data, const int s) : buffer(0), loader(l), size(s), vector(data)
+ {
+ }
+
~LoaderData();
};
diff --git a/WebKit/android/benchmark/Intercept.cpp b/WebKit/android/benchmark/Intercept.cpp
index e5a98f1..1ae6d6f 100644
--- a/WebKit/android/benchmark/Intercept.cpp
+++ b/WebKit/android/benchmark/Intercept.cpp
@@ -33,11 +33,12 @@
#include "ResourceHandleClient.h"
#include "ResourceRequest.h"
#include "ResourceResponse.h"
-#include "StringHash.h"
#include "TextEncoding.h"
+
#include <utils/Log.h>
#include <wtf/HashMap.h>
#include <wtf/text/CString.h>
+#include <wtf/text/StringHash.h>
PassRefPtr<WebCore::ResourceLoaderAndroid> MyResourceLoader::create(
ResourceHandle* handle, String url)
diff --git a/WebKit/android/jni/JavaBridge.cpp b/WebKit/android/jni/JavaBridge.cpp
index 8e85896..5715ae5 100644
--- a/WebKit/android/jni/JavaBridge.cpp
+++ b/WebKit/android/jni/JavaBridge.cpp
@@ -27,7 +27,6 @@
#include "config.h"
-#include "AtomicString.h"
#include "Cache.h"
#include "Connection.h"
#include "CookieClient.h"
@@ -54,6 +53,7 @@
#include <utils/misc.h>
#include <wtf/Platform.h>
#include <wtf/StdLibExtras.h>
+#include <wtf/text/AtomicString.h>
namespace android {
diff --git a/WebKit/android/jni/WebCoreFrameBridge.cpp b/WebKit/android/jni/WebCoreFrameBridge.cpp
index a868260..0e8a7a2 100644
--- a/WebKit/android/jni/WebCoreFrameBridge.cpp
+++ b/WebKit/android/jni/WebCoreFrameBridge.cpp
@@ -29,7 +29,6 @@
#include "WebCoreFrameBridge.h"
#include "Arena.h"
-#include "AtomicString.h"
#include "BackForwardList.h"
#include "Cache.h"
#include "Chrome.h"
@@ -97,6 +96,7 @@
#include <utils/AssetManager.h>
#include <wtf/CurrentTime.h>
#include <wtf/Platform.h>
+#include <wtf/text/AtomicString.h>
#include <wtf/text/CString.h>
#if USE(JSC)
@@ -184,6 +184,7 @@ struct WebFrame::JavaBrowserFrame
{
jweak mObj;
jweak mHistoryList; // WebBackForwardList object
+ jmethodID mInputStreamForAndroidResource;
jmethodID mStartLoadingResource;
jmethodID mLoadStarted;
jmethodID mTransitionToCommitted;
@@ -225,6 +226,7 @@ WebFrame::WebFrame(JNIEnv* env, jobject obj, jobject historyList, WebCore::Page*
mJavaFrame = new JavaBrowserFrame;
mJavaFrame->mObj = env->NewWeakGlobalRef(obj);
mJavaFrame->mHistoryList = env->NewWeakGlobalRef(historyList);
+ mJavaFrame->mInputStreamForAndroidResource = env->GetMethodID(clazz, "inputStreamForAndroidResource", "(Ljava/lang/String;I)Ljava/io/InputStream;");
mJavaFrame->mStartLoadingResource = env->GetMethodID(clazz, "startLoadingResource",
"(ILjava/lang/String;Ljava/lang/String;Ljava/util/HashMap;[BJIZZZLjava/lang/String;Ljava/lang/String;)Landroid/webkit/LoadListener;");
mJavaFrame->mLoadStarted = env->GetMethodID(clazz, "loadStarted",
@@ -263,6 +265,7 @@ WebFrame::WebFrame(JNIEnv* env, jobject obj, jobject historyList, WebCore::Page*
mJavaFrame->mGetFileSize = env->GetMethodID(clazz, "getFileSize", "(Ljava/lang/String;)I");
mJavaFrame->mGetFile = env->GetMethodID(clazz, "getFile", "(Ljava/lang/String;[BII)I");
+ LOG_ASSERT(mJavaFrame->mInputStreamForAndroidResource, "Could not find method inputStreamForAndroidResource");
LOG_ASSERT(mJavaFrame->mStartLoadingResource, "Could not find method startLoadingResource");
LOG_ASSERT(mJavaFrame->mLoadStarted, "Could not find method loadStarted");
LOG_ASSERT(mJavaFrame->mTransitionToCommitted, "Could not find method transitionToCommitted");
@@ -363,6 +366,18 @@ private:
int m_size;
};
+int WebFrame::inputStreamForAndroidResource(const char* url, int type)
+{
+ JNIEnv* env = getJNIEnv();
+ AutoJObject obj = mJavaFrame->frame(env);
+ jstring jUrlStr = env->NewStringUTF(url);
+
+ jobject jInputStream = env->CallObjectMethod(obj.get(), mJavaFrame->mInputStreamForAndroidResource, jUrlStr, type);
+ env->DeleteLocalRef(jUrlStr);
+
+ return (int)jInputStream;
+}
+
PassRefPtr<WebCore::ResourceLoaderAndroid>
WebFrame::startLoadingResource(WebCore::ResourceHandle* loader,
const WebCore::ResourceRequest& request,
diff --git a/WebKit/android/jni/WebCoreFrameBridge.h b/WebKit/android/jni/WebCoreFrameBridge.h
index 5fd4da9..07bdc41 100644
--- a/WebKit/android/jni/WebCoreFrameBridge.h
+++ b/WebKit/android/jni/WebCoreFrameBridge.h
@@ -58,6 +58,8 @@ class WebFrame : public WebCoreRefObject {
// helper function
static WebFrame* getWebFrame(const WebCore::Frame* frame);
+ int inputStreamForAndroidResource(const char* url, int type);
+
virtual PassRefPtr<WebCore::ResourceLoaderAndroid> startLoadingResource(WebCore::ResourceHandle*,
const WebCore::ResourceRequest& request, bool mainResource,
bool synchronous);
diff --git a/WebKit/android/jni/WebViewCore.cpp b/WebKit/android/jni/WebViewCore.cpp
index 72b4eac..e81e335 100644
--- a/WebKit/android/jni/WebViewCore.cpp
+++ b/WebKit/android/jni/WebViewCore.cpp
@@ -28,7 +28,6 @@
#include "config.h"
#include "WebViewCore.h"
-#include "AtomicString.h"
#include "BaseLayerAndroid.h"
#include "CachedNode.h"
#include "CachedRoot.h"
@@ -101,7 +100,6 @@
#include "SkCanvas.h"
#include "SkPicture.h"
#include "SkUtils.h"
-#include "StringImpl.h"
#include "Text.h"
#include "TypingCommand.h"
#include "WebCoreFrameBridge.h"
@@ -113,6 +111,8 @@
#include <JNIUtility.h>
#include <ui/KeycodeLabels.h>
#include <wtf/CurrentTime.h>
+#include <wtf/text/AtomicString.h>
+#include <wtf/text/StringImpl.h>
#if USE(V8)
#include "ScriptController.h"
@@ -210,6 +210,7 @@ struct WebViewCoreFields {
jfieldID m_viewportUserScalable;
jfieldID m_viewportDensityDpi;
jfieldID m_webView;
+ jfieldID m_drawIsPaused;
} gWebViewCoreFields;
// ----------------------------------------------------------------------------
@@ -918,6 +919,13 @@ void WebViewCore::contentInvalidate(const WebCore::IntRect &r)
contentDraw();
}
+void WebViewCore::contentInvalidateAll()
+{
+ WebCore::FrameView* view = m_mainFrame->view();
+ contentInvalidate(WebCore::IntRect(0, 0,
+ view->contentsWidth(), view->contentsHeight()));
+}
+
void WebViewCore::offInvalidate(const WebCore::IntRect &r)
{
// FIXME: these invalidates are offscreen, and can be throttled or
@@ -2858,6 +2866,13 @@ void WebViewCore::notifyWebAppCanBeInstalled()
checkException(env);
}
+bool WebViewCore::drawIsPaused() const
+{
+ JNIEnv* env = JSC::Bindings::getJNIEnv();
+ return env->GetBooleanField(m_javaGlue->object(env).get(),
+ gWebViewCoreFields.m_drawIsPaused);
+}
+
//----------------------------------------------------------------------
// Native JNI methods
//----------------------------------------------------------------------
@@ -2952,6 +2967,11 @@ static void Click(JNIEnv *env, jobject obj, int framePtr, int nodePtr)
reinterpret_cast<WebCore::Node*>(nodePtr));
}
+static void ContentInvalidateAll(JNIEnv *env, jobject obj)
+{
+ GET_NATIVE_VIEW(env, obj)->contentInvalidateAll();
+}
+
static void DeleteSelection(JNIEnv *env, jobject obj, jint start, jint end,
jint textGeneration)
{
@@ -3512,6 +3532,8 @@ static JNINativeMethod gJavaWebViewCoreMethods[] = {
(void*) Key },
{ "nativeClick", "(II)V",
(void*) Click },
+ { "nativeContentInvalidateAll", "()V",
+ (void*) ContentInvalidateAll },
{ "nativeSendListBoxChoices", "([ZI)V",
(void*) SendListBoxChoices },
{ "nativeSendListBoxChoice", "(I)V",
@@ -3639,6 +3661,10 @@ int register_webviewcore(JNIEnv* env)
"mWebView", "Landroid/webkit/WebView;");
LOG_ASSERT(gWebViewCoreFields.m_webView,
"Unable to find android/webkit/WebViewCore.mWebView");
+ gWebViewCoreFields.m_drawIsPaused = env->GetFieldID(widget,
+ "mDrawIsPaused", "Z");
+ LOG_ASSERT(gWebViewCoreFields.m_drawIsPaused,
+ "Unable to find android/webkit/WebViewCore.mDrawIsPaused");
return jniRegisterNativeMethods(env, "android/webkit/WebViewCore",
gJavaWebViewCoreMethods, NELEM(gJavaWebViewCoreMethods));
diff --git a/WebKit/android/jni/WebViewCore.h b/WebKit/android/jni/WebViewCore.h
index 11a7228..89cdc8a 100644
--- a/WebKit/android/jni/WebViewCore.h
+++ b/WebKit/android/jni/WebViewCore.h
@@ -131,6 +131,7 @@ namespace android {
* Record the invalid rectangle
*/
void contentInvalidate(const WebCore::IntRect &rect);
+ void contentInvalidateAll();
/**
* Satisfy any outstanding invalidates, so that the current state
@@ -494,6 +495,7 @@ namespace android {
WTF::Vector<Container> m_buttons;
bool isPaused() const { return m_isPaused; }
void setIsPaused(bool isPaused) { m_isPaused = isPaused; }
+ bool drawIsPaused() const;
// end of shared members
// internal functions
diff --git a/WebKit/android/nav/CachedNode.h b/WebKit/android/nav/CachedNode.h
index 0014e07..db48a66 100644
--- a/WebKit/android/nav/CachedNode.h
+++ b/WebKit/android/nav/CachedNode.h
@@ -26,12 +26,13 @@
#ifndef CachedNode_H
#define CachedNode_H
-#include "AtomicString.h"
#include "CachedDebug.h"
#include "CachedNodeType.h"
#include "IntRect.h"
#include "PlatformString.h"
-#include "wtf/Vector.h"
+
+#include <wtf/Vector.h>
+#include <wtf/text/AtomicString.h>
class SkPicture;
diff --git a/WebKit/android/nav/SelectText.cpp b/WebKit/android/nav/SelectText.cpp
index 3716b03..45d7c0a 100644
--- a/WebKit/android/nav/SelectText.cpp
+++ b/WebKit/android/nav/SelectText.cpp
@@ -1239,12 +1239,15 @@ SelectText::SelectText()
paint.setColor(0xffaaaaaa);
canvas->drawPath(endPath, paint);
m_endControl.endRecording();
+ m_picture = 0;
}
void SelectText::draw(SkCanvas* canvas, LayerAndroid* layer)
{
// FIXME: layer may not own the original selected picture
m_picture = layer->picture();
+ if (!m_picture)
+ return;
DBG_NAV_LOGD("m_extendSelection=%d m_drawPointer=%d", m_extendSelection, m_drawPointer);
if (m_extendSelection)
drawSelectionRegion(canvas);
@@ -1316,6 +1319,8 @@ void SelectText::drawSelectionRegion(SkCanvas* canvas)
void SelectText::extendSelection(const SkPicture* picture, int x, int y)
{
+ if (!picture)
+ return;
SkIRect clipRect = m_visibleRect;
int base;
if (m_startSelection) {
@@ -1365,6 +1370,8 @@ void SelectText::extendSelection(const SkPicture* picture, int x, int y)
const String SelectText::getSelection()
{
+ if (!m_picture)
+ return String();
SkIRect clipRect;
clipRect.set(0, 0, m_picture->width(), m_picture->height());
String result = text(*m_picture, clipRect, m_selStart, m_startBase,
@@ -1424,6 +1431,8 @@ bool SelectText::hitSelection(int x, int y) const
void SelectText::moveSelection(const SkPicture* picture, int x, int y)
{
+ if (!picture)
+ return;
SkIRect clipRect = m_visibleRect;
clipRect.join(m_selStart);
clipRect.join(m_selEnd);
diff --git a/WebKit/android/nav/WebView.cpp b/WebKit/android/nav/WebView.cpp
index 2132957..a15ef39 100644
--- a/WebKit/android/nav/WebView.cpp
+++ b/WebKit/android/nav/WebView.cpp
@@ -29,7 +29,6 @@
#include "AndroidAnimation.h"
#include "AndroidLog.h"
-#include "AtomicString.h"
#include "BaseLayerAndroid.h"
#include "CachedFrame.h"
#include "CachedNode.h"
@@ -68,6 +67,7 @@
#include <JNIHelp.h>
#include <jni.h>
#include <ui/KeycodeLabels.h>
+#include <wtf/text/AtomicString.h>
#include <wtf/text/CString.h>
namespace android {