Revert "Revert 158067 - Remove native side of content_view_client"
The previous CL broke the build, because the changes in net_errors_java.template didn't get the net_error_java target to be rebuilt. We needed a net.gyp change that makes sure NetError.java gets recreated after the changes. BUG=137967 TBR=jam@chromium.org, mkosiba@chromium.org, willchan@chromium.org Review URL: https://chromiumcodereview.appspot.com/10963041 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@158146 0039d316-1c4b-4281-b951-d872f2087c98
This commit is contained in:
android_webview
java
src
org
chromium
android_webview
javatests
src
org
chromium
android_webview
base/android/jni_generator
build
content
browser
android
public
android
java
src
org
chromium
content
javatests
src
org
chromium
net
@ -11,6 +11,8 @@ import android.view.KeyEvent;
|
||||
import android.webkit.ConsoleMessage;
|
||||
|
||||
import org.chromium.content.browser.ContentViewClient;
|
||||
import org.chromium.content.browser.ContentViewCore;
|
||||
import org.chromium.content.browser.WebContentsObserverAndroid;
|
||||
|
||||
/**
|
||||
* Base-class that an AwContents embedder derives from to receive callbacks.
|
||||
@ -102,6 +104,29 @@ public abstract class AwContentsClient extends ContentViewClient {
|
||||
}
|
||||
}
|
||||
|
||||
class WebContentsObserverAdapter extends WebContentsObserverAndroid {
|
||||
public WebContentsObserverAdapter(ContentViewCore contentViewCore) {
|
||||
super(contentViewCore);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void didStartLoading(String url) {
|
||||
AwContentsClient.this.onPageStarted(url);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void didStopLoading(String url) {
|
||||
AwContentsClient.this.onPageFinished(url);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void didFailLoad(boolean isProvisionalLoad,
|
||||
boolean isMainFrame, int errorCode, String description, String failingUrl) {
|
||||
AwContentsClient.this.onReceivedError(
|
||||
ErrorCodeConversionHelper.convertErrorCode(errorCode), description, failingUrl);
|
||||
}
|
||||
}
|
||||
|
||||
final AwWebContentsDelegate getWebContentsDelegate() {
|
||||
return mWebContentsDelegateAdapter;
|
||||
}
|
||||
@ -140,15 +165,17 @@ public abstract class AwContentsClient extends ContentViewClient {
|
||||
public abstract void onFindResultReceived(int activeMatchOrdinal, int numberOfMatches,
|
||||
boolean isDoneCounting);
|
||||
|
||||
public abstract void onPageStarted(String url);
|
||||
|
||||
public abstract void onPageFinished(String url);
|
||||
|
||||
public abstract void onReceivedError(int errorCode, String description, String failingUrl);
|
||||
|
||||
//--------------------------------------------------------------------------------------------
|
||||
// Stuff that we ignore since it only makes sense for Chrome browser
|
||||
//--------------------------------------------------------------------------------------------
|
||||
//
|
||||
|
||||
@Override
|
||||
final public void onMainFrameCommitted(String url, String baseUrl) {
|
||||
}
|
||||
|
||||
@Override
|
||||
final public boolean shouldOverrideScroll(float dx, float dy, float scrollX, float scrollY) {
|
||||
return false;
|
||||
|
143
android_webview/java/src/org/chromium/android_webview/ErrorCodeConversionHelper.java
Normal file
143
android_webview/java/src/org/chromium/android_webview/ErrorCodeConversionHelper.java
Normal file
@ -0,0 +1,143 @@
|
||||
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
package org.chromium.android_webview;
|
||||
|
||||
import org.chromium.net.NetError;
|
||||
|
||||
/**
|
||||
* This is a helper class to map native error code about loading a page to Android specific ones.
|
||||
*/
|
||||
class ErrorCodeConversionHelper {
|
||||
// Success
|
||||
public static final int ERROR_OK = 0;
|
||||
// Generic error
|
||||
public static final int ERROR_UNKNOWN = -1;
|
||||
// Server or proxy hostname lookup failed
|
||||
public static final int ERROR_HOST_LOOKUP = -2;
|
||||
// Unsupported authentication scheme (not basic or digest)
|
||||
public static final int ERROR_UNSUPPORTED_AUTH_SCHEME = -3;
|
||||
// User authentication failed on server
|
||||
public static final int ERROR_AUTHENTICATION = -4;
|
||||
// User authentication failed on proxy
|
||||
public static final int ERROR_PROXY_AUTHENTICATION = -5;
|
||||
// Failed to connect to the server
|
||||
public static final int ERROR_CONNECT = -6;
|
||||
// Failed to read or write to the server
|
||||
public static final int ERROR_IO = -7;
|
||||
// Connection timed out
|
||||
public static final int ERROR_TIMEOUT = -8;
|
||||
// Too many redirects
|
||||
public static final int ERROR_REDIRECT_LOOP = -9;
|
||||
// Unsupported URI scheme
|
||||
public static final int ERROR_UNSUPPORTED_SCHEME = -10;
|
||||
// Failed to perform SSL handshake
|
||||
public static final int ERROR_FAILED_SSL_HANDSHAKE = -11;
|
||||
// Malformed URL
|
||||
public static final int ERROR_BAD_URL = -12;
|
||||
// Generic file error
|
||||
public static final int ERROR_FILE = -13;
|
||||
// File not found
|
||||
public static final int ERROR_FILE_NOT_FOUND = -14;
|
||||
// Too many requests during this load
|
||||
public static final int ERROR_TOO_MANY_REQUESTS = -15;
|
||||
|
||||
static int convertErrorCode(int netError) {
|
||||
// Note: many NetError.Error constants don't have an obvious mapping.
|
||||
// These will be handled by the default case, ERROR_UNKNOWN.
|
||||
switch (netError) {
|
||||
case NetError.ERR_UNSUPPORTED_AUTH_SCHEME:
|
||||
return ERROR_UNSUPPORTED_AUTH_SCHEME;
|
||||
|
||||
case NetError.ERR_INVALID_AUTH_CREDENTIALS:
|
||||
case NetError.ERR_MISSING_AUTH_CREDENTIALS:
|
||||
case NetError.ERR_MISCONFIGURED_AUTH_ENVIRONMENT:
|
||||
return ERROR_AUTHENTICATION;
|
||||
|
||||
case NetError.ERR_TOO_MANY_REDIRECTS:
|
||||
return ERROR_REDIRECT_LOOP;
|
||||
|
||||
case NetError.ERR_UPLOAD_FILE_CHANGED:
|
||||
return ERROR_FILE_NOT_FOUND;
|
||||
|
||||
case NetError.ERR_INVALID_URL:
|
||||
return ERROR_BAD_URL;
|
||||
|
||||
case NetError.ERR_DISALLOWED_URL_SCHEME:
|
||||
case NetError.ERR_UNKNOWN_URL_SCHEME:
|
||||
return ERROR_UNSUPPORTED_SCHEME;
|
||||
|
||||
case NetError.ERR_IO_PENDING:
|
||||
case NetError.ERR_NETWORK_IO_SUSPENDED:
|
||||
return ERROR_IO;
|
||||
|
||||
case NetError.ERR_CONNECTION_TIMED_OUT:
|
||||
case NetError.ERR_TIMED_OUT:
|
||||
return ERROR_TIMEOUT;
|
||||
|
||||
case NetError.ERR_FILE_TOO_BIG:
|
||||
return ERROR_FILE;
|
||||
|
||||
case NetError.ERR_HOST_RESOLVER_QUEUE_TOO_LARGE:
|
||||
case NetError.ERR_INSUFFICIENT_RESOURCES:
|
||||
case NetError.ERR_OUT_OF_MEMORY:
|
||||
return ERROR_TOO_MANY_REQUESTS;
|
||||
|
||||
case NetError.ERR_CONNECTION_CLOSED:
|
||||
case NetError.ERR_CONNECTION_RESET:
|
||||
case NetError.ERR_CONNECTION_REFUSED:
|
||||
case NetError.ERR_CONNECTION_ABORTED:
|
||||
case NetError.ERR_CONNECTION_FAILED:
|
||||
case NetError.ERR_SOCKET_NOT_CONNECTED:
|
||||
return ERROR_CONNECT;
|
||||
|
||||
case NetError.ERR_INTERNET_DISCONNECTED:
|
||||
case NetError.ERR_ADDRESS_INVALID:
|
||||
case NetError.ERR_ADDRESS_UNREACHABLE:
|
||||
case NetError.ERR_NAME_NOT_RESOLVED:
|
||||
case NetError.ERR_NAME_RESOLUTION_FAILED:
|
||||
return ERROR_HOST_LOOKUP;
|
||||
|
||||
case NetError.ERR_SSL_PROTOCOL_ERROR:
|
||||
case NetError.ERR_SSL_CLIENT_AUTH_CERT_NEEDED:
|
||||
case NetError.ERR_TUNNEL_CONNECTION_FAILED:
|
||||
case NetError.ERR_NO_SSL_VERSIONS_ENABLED:
|
||||
case NetError.ERR_SSL_VERSION_OR_CIPHER_MISMATCH:
|
||||
case NetError.ERR_SSL_RENEGOTIATION_REQUESTED:
|
||||
case NetError.ERR_CERT_ERROR_IN_SSL_RENEGOTIATION:
|
||||
case NetError.ERR_BAD_SSL_CLIENT_AUTH_CERT:
|
||||
case NetError.ERR_SSL_NO_RENEGOTIATION:
|
||||
case NetError.ERR_SSL_DECOMPRESSION_FAILURE_ALERT:
|
||||
case NetError.ERR_SSL_BAD_RECORD_MAC_ALERT:
|
||||
case NetError.ERR_SSL_UNSAFE_NEGOTIATION:
|
||||
case NetError.ERR_SSL_WEAK_SERVER_EPHEMERAL_DH_KEY:
|
||||
case NetError.ERR_SSL_CLIENT_AUTH_PRIVATE_KEY_ACCESS_DENIED:
|
||||
case NetError.ERR_SSL_CLIENT_AUTH_CERT_NO_PRIVATE_KEY:
|
||||
return ERROR_FAILED_SSL_HANDSHAKE;
|
||||
|
||||
case NetError.ERR_PROXY_AUTH_UNSUPPORTED:
|
||||
case NetError.ERR_PROXY_AUTH_REQUESTED:
|
||||
case NetError.ERR_PROXY_CONNECTION_FAILED:
|
||||
case NetError.ERR_UNEXPECTED_PROXY_AUTH:
|
||||
return ERROR_PROXY_AUTHENTICATION;
|
||||
|
||||
// The certificate errors are handled by onReceivedSslError
|
||||
// and don't need to be reported here.
|
||||
case NetError.ERR_CERT_COMMON_NAME_INVALID:
|
||||
case NetError.ERR_CERT_DATE_INVALID:
|
||||
case NetError.ERR_CERT_AUTHORITY_INVALID:
|
||||
case NetError.ERR_CERT_CONTAINS_ERRORS:
|
||||
case NetError.ERR_CERT_NO_REVOCATION_MECHANISM:
|
||||
case NetError.ERR_CERT_UNABLE_TO_CHECK_REVOCATION:
|
||||
case NetError.ERR_CERT_REVOKED:
|
||||
case NetError.ERR_CERT_INVALID:
|
||||
case NetError.ERR_CERT_WEAK_SIGNATURE_ALGORITHM:
|
||||
case NetError.ERR_CERT_NON_UNIQUE_NAME:
|
||||
return ERROR_OK;
|
||||
|
||||
default:
|
||||
return ERROR_UNKNOWN;
|
||||
}
|
||||
}
|
||||
}
|
@ -62,4 +62,16 @@ class NullContentsClient extends AwContentsClient {
|
||||
public void onFindResultReceived(int activeMatchOrdinal, int numberOfMatches,
|
||||
boolean isDoneCounting) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPageStarted(String url) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPageFinished(String url) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReceivedError(int errorCode, String description, String failingUrl) {
|
||||
}
|
||||
}
|
||||
|
@ -38,27 +38,18 @@ class TestAwContentsClient extends NullContentsClient {
|
||||
return mOnEvaluateJavaScriptResultHelper;
|
||||
}
|
||||
|
||||
/**
|
||||
* ATTENTION!: When overriding the following methods, be sure to call
|
||||
* the corresponding methods in the super class. Otherwise
|
||||
* {@link CallbackHelper#waitForCallback()} methods will
|
||||
* stop working!
|
||||
*/
|
||||
@Override
|
||||
public void onPageStarted(String url) {
|
||||
super.onPageStarted(url);
|
||||
mOnPageStartedHelper.notifyCalled(url);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPageFinished(String url) {
|
||||
super.onPageFinished(url);
|
||||
mOnPageFinishedHelper.notifyCalled(url);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReceivedError(int errorCode, String description, String failingUrl) {
|
||||
super.onReceivedError(errorCode, description, failingUrl);
|
||||
mOnReceivedErrorHelper.notifyCalled(errorCode, description, failingUrl);
|
||||
}
|
||||
|
||||
|
@ -178,7 +178,6 @@ def JavaParamToJni(param):
|
||||
'Lorg/chromium/chrome/browser/ProcessUtils',
|
||||
'Lorg/chromium/chrome/browser/component/web_contents_delegate_android/WebContentsDelegateAndroid',
|
||||
'Lorg/chromium/content/browser/ContentVideoView',
|
||||
'Lorg/chromium/content/browser/ContentViewClient',
|
||||
'Lorg/chromium/content/browser/ContentViewCore',
|
||||
'Lorg/chromium/content/browser/DeviceOrientation',
|
||||
'Lorg/chromium/content/browser/FindNotificationDetails',
|
||||
|
@ -39,6 +39,7 @@
|
||||
'variables': {
|
||||
'input_jars_paths': [],
|
||||
'additional_src_dirs': [],
|
||||
'additional_input_paths': [],
|
||||
},
|
||||
'actions': [
|
||||
{
|
||||
@ -49,6 +50,7 @@
|
||||
'android/ant/chromium-jars.xml',
|
||||
'<!@(find <(java_in_dir) -name "*.java")',
|
||||
'>@(input_jars_paths)',
|
||||
'>@(additional_input_paths)',
|
||||
],
|
||||
'outputs': [
|
||||
'<(PRODUCT_DIR)/lib.java/chromium_<(package_name).jar',
|
||||
|
@ -9,7 +9,6 @@
|
||||
#include "content/browser/android/android_browser_process.h"
|
||||
#include "content/browser/android/content_settings.h"
|
||||
#include "content/browser/android/content_video_view.h"
|
||||
#include "content/browser/android/content_view_client.h"
|
||||
#include "content/browser/android/content_view_core_impl.h"
|
||||
#include "content/browser/android/content_view_statics.h"
|
||||
#include "content/browser/android/download_controller.h"
|
||||
@ -33,7 +32,6 @@ base::android::RegistrationMethod kContentRegisteredMethods[] = {
|
||||
SurfaceTexturePeerBrowserImpl::RegisterBrowserProcessSurfaceTexture },
|
||||
{ "ContentSettings", content::ContentSettings::RegisterContentSettings },
|
||||
{ "ContentVideoView", content::ContentVideoView::RegisterContentVideoView },
|
||||
{ "ContentViewClient", content::RegisterContentViewClient },
|
||||
{ "ContentViewCore", content::RegisterContentViewCore },
|
||||
{ "DownloadController",
|
||||
content::DownloadController::RegisterDownloadController },
|
||||
|
@ -1,240 +0,0 @@
|
||||
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "content/browser/android/content_view_client.h"
|
||||
|
||||
#include <android/keycodes.h>
|
||||
|
||||
#include "base/android/jni_android.h"
|
||||
#include "base/android/jni_string.h"
|
||||
#include "content/browser/android/content_view_core_impl.h"
|
||||
#include "content/browser/android/download_controller.h"
|
||||
#include "content/browser/renderer_host/render_view_host_impl.h"
|
||||
#include "content/public/browser/render_widget_host_view.h"
|
||||
#include "content/public/browser/download_item.h"
|
||||
#include "content/public/browser/invalidate_type.h"
|
||||
#include "content/public/browser/page_navigator.h"
|
||||
#include "content/public/browser/navigation_controller.h"
|
||||
#include "content/public/browser/navigation_entry.h"
|
||||
#include "content/public/browser/web_contents.h"
|
||||
#include "content/public/common/page_transition_types.h"
|
||||
#include "content/public/common/referrer.h"
|
||||
#include "jni/ContentViewClient_jni.h"
|
||||
#include "net/http/http_request_headers.h"
|
||||
|
||||
using base::android::AttachCurrentThread;
|
||||
using base::android::CheckException;
|
||||
using base::android::ConvertUTF8ToJavaString;
|
||||
using base::android::ConvertUTF16ToJavaString;
|
||||
using base::android::GetClass;
|
||||
using base::android::GetMethodID;
|
||||
using base::android::HasClass;
|
||||
using base::android::ScopedJavaLocalRef;
|
||||
|
||||
namespace content {
|
||||
|
||||
ContentViewClient::ContentViewClient(JNIEnv* env, jobject obj)
|
||||
: weak_java_client_(env, obj) {
|
||||
}
|
||||
|
||||
ContentViewClient::~ContentViewClient() {
|
||||
}
|
||||
|
||||
// static
|
||||
ContentViewClient* ContentViewClient::CreateNativeContentViewClient(
|
||||
JNIEnv* env, jobject obj) {
|
||||
DCHECK(obj);
|
||||
return new ContentViewClient(env, obj);
|
||||
}
|
||||
|
||||
void ContentViewClient::OnPageStarted(const GURL& url) {
|
||||
JNIEnv* env = AttachCurrentThread();
|
||||
ScopedJavaLocalRef<jobject> obj = weak_java_client_.get(env);
|
||||
if (obj.is_null())
|
||||
return;
|
||||
ScopedJavaLocalRef<jstring> jstring_url =
|
||||
ConvertUTF8ToJavaString(env, url.spec());
|
||||
Java_ContentViewClient_onPageStarted(env, obj.obj(), jstring_url.obj());
|
||||
}
|
||||
|
||||
void ContentViewClient::OnPageFinished(const GURL& url) {
|
||||
JNIEnv* env = AttachCurrentThread();
|
||||
ScopedJavaLocalRef<jobject> obj = weak_java_client_.get(env);
|
||||
if (obj.is_null())
|
||||
return;
|
||||
ScopedJavaLocalRef<jstring> jstring_url =
|
||||
ConvertUTF8ToJavaString(env, url.spec());
|
||||
|
||||
Java_ContentViewClient_onPageFinished(env, obj.obj(), jstring_url.obj());
|
||||
CheckException(env);
|
||||
}
|
||||
|
||||
void ContentViewClient::OnReceivedError(int error_code,
|
||||
const string16& description,
|
||||
const GURL& url) {
|
||||
JNIEnv* env = AttachCurrentThread();
|
||||
ScopedJavaLocalRef<jobject> obj = weak_java_client_.get(env);
|
||||
if (obj.is_null())
|
||||
return;
|
||||
ScopedJavaLocalRef<jstring> jstring_error_description =
|
||||
ConvertUTF8ToJavaString(env, url.spec());
|
||||
ScopedJavaLocalRef<jstring> jstring_url =
|
||||
ConvertUTF8ToJavaString(env, url.spec());
|
||||
|
||||
Java_ContentViewClient_onReceivedError(
|
||||
env, obj.obj(),
|
||||
ToContentViewClientError(error_code),
|
||||
jstring_error_description.obj(), jstring_url.obj());
|
||||
}
|
||||
|
||||
void ContentViewClient::OnDidCommitMainFrame(const GURL& url,
|
||||
const GURL& base_url) {
|
||||
JNIEnv* env = AttachCurrentThread();
|
||||
ScopedJavaLocalRef<jobject> obj = weak_java_client_.get(env);
|
||||
if (obj.is_null())
|
||||
return;
|
||||
ScopedJavaLocalRef<jstring> jstring_url =
|
||||
ConvertUTF8ToJavaString(env, url.spec());
|
||||
ScopedJavaLocalRef<jstring> jstring_base_url =
|
||||
ConvertUTF8ToJavaString(env, base_url.spec());
|
||||
|
||||
Java_ContentViewClient_onMainFrameCommitted(
|
||||
env, obj.obj(),
|
||||
jstring_url.obj(), jstring_base_url.obj());
|
||||
}
|
||||
|
||||
void ContentViewClient::OnInterstitialShown() {
|
||||
JNIEnv* env = AttachCurrentThread();
|
||||
ScopedJavaLocalRef<jobject> obj = weak_java_client_.get(env);
|
||||
if (obj.is_null())
|
||||
return;
|
||||
Java_ContentViewClient_onInterstitialShown(env, obj.obj());
|
||||
}
|
||||
|
||||
void ContentViewClient::OnInterstitialHidden() {
|
||||
JNIEnv* env = AttachCurrentThread();
|
||||
ScopedJavaLocalRef<jobject> obj = weak_java_client_.get(env);
|
||||
if (obj.is_null())
|
||||
return;
|
||||
Java_ContentViewClient_onInterstitialHidden(env, obj.obj());
|
||||
}
|
||||
|
||||
ContentViewClientError ContentViewClient::ToContentViewClientError(
|
||||
int net_error) {
|
||||
// Note: many net::Error constants don't have an obvious mapping.
|
||||
// These will be handled by the default case, ERROR_UNKNOWN.
|
||||
switch(net_error) {
|
||||
case net::ERR_UNSUPPORTED_AUTH_SCHEME:
|
||||
return CONTENT_VIEW_CLIENT_ERROR_UNSUPPORTED_AUTH_SCHEME;
|
||||
|
||||
case net::ERR_INVALID_AUTH_CREDENTIALS:
|
||||
case net::ERR_MISSING_AUTH_CREDENTIALS:
|
||||
case net::ERR_MISCONFIGURED_AUTH_ENVIRONMENT:
|
||||
return CONTENT_VIEW_CLIENT_ERROR_AUTHENTICATION;
|
||||
|
||||
case net::ERR_TOO_MANY_REDIRECTS:
|
||||
return CONTENT_VIEW_CLIENT_ERROR_REDIRECT_LOOP;
|
||||
|
||||
case net::ERR_UPLOAD_FILE_CHANGED:
|
||||
return CONTENT_VIEW_CLIENT_ERROR_FILE_NOT_FOUND;
|
||||
|
||||
case net::ERR_INVALID_URL:
|
||||
return CONTENT_VIEW_CLIENT_ERROR_BAD_URL;
|
||||
|
||||
case net::ERR_DISALLOWED_URL_SCHEME:
|
||||
case net::ERR_UNKNOWN_URL_SCHEME:
|
||||
return CONTENT_VIEW_CLIENT_ERROR_UNSUPPORTED_SCHEME;
|
||||
|
||||
case net::ERR_IO_PENDING:
|
||||
case net::ERR_NETWORK_IO_SUSPENDED:
|
||||
return CONTENT_VIEW_CLIENT_ERROR_IO;
|
||||
|
||||
case net::ERR_CONNECTION_TIMED_OUT:
|
||||
case net::ERR_TIMED_OUT:
|
||||
return CONTENT_VIEW_CLIENT_ERROR_TIMEOUT;
|
||||
|
||||
case net::ERR_FILE_TOO_BIG:
|
||||
return CONTENT_VIEW_CLIENT_ERROR_FILE;
|
||||
|
||||
case net::ERR_HOST_RESOLVER_QUEUE_TOO_LARGE:
|
||||
case net::ERR_INSUFFICIENT_RESOURCES:
|
||||
case net::ERR_OUT_OF_MEMORY:
|
||||
return CONTENT_VIEW_CLIENT_ERROR_TOO_MANY_REQUESTS;
|
||||
|
||||
case net::ERR_CONNECTION_CLOSED:
|
||||
case net::ERR_CONNECTION_RESET:
|
||||
case net::ERR_CONNECTION_REFUSED:
|
||||
case net::ERR_CONNECTION_ABORTED:
|
||||
case net::ERR_CONNECTION_FAILED:
|
||||
case net::ERR_SOCKET_NOT_CONNECTED:
|
||||
return CONTENT_VIEW_CLIENT_ERROR_CONNECT;
|
||||
|
||||
case net::ERR_INTERNET_DISCONNECTED:
|
||||
case net::ERR_ADDRESS_INVALID:
|
||||
case net::ERR_ADDRESS_UNREACHABLE:
|
||||
case net::ERR_NAME_NOT_RESOLVED:
|
||||
case net::ERR_NAME_RESOLUTION_FAILED:
|
||||
return CONTENT_VIEW_CLIENT_ERROR_HOST_LOOKUP;
|
||||
|
||||
case net::ERR_SSL_PROTOCOL_ERROR:
|
||||
case net::ERR_SSL_CLIENT_AUTH_CERT_NEEDED:
|
||||
case net::ERR_TUNNEL_CONNECTION_FAILED:
|
||||
case net::ERR_NO_SSL_VERSIONS_ENABLED:
|
||||
case net::ERR_SSL_VERSION_OR_CIPHER_MISMATCH:
|
||||
case net::ERR_SSL_RENEGOTIATION_REQUESTED:
|
||||
case net::ERR_CERT_ERROR_IN_SSL_RENEGOTIATION:
|
||||
case net::ERR_BAD_SSL_CLIENT_AUTH_CERT:
|
||||
case net::ERR_SSL_NO_RENEGOTIATION:
|
||||
case net::ERR_SSL_DECOMPRESSION_FAILURE_ALERT:
|
||||
case net::ERR_SSL_BAD_RECORD_MAC_ALERT:
|
||||
case net::ERR_SSL_UNSAFE_NEGOTIATION:
|
||||
case net::ERR_SSL_WEAK_SERVER_EPHEMERAL_DH_KEY:
|
||||
case net::ERR_SSL_CLIENT_AUTH_PRIVATE_KEY_ACCESS_DENIED:
|
||||
case net::ERR_SSL_CLIENT_AUTH_CERT_NO_PRIVATE_KEY:
|
||||
return CONTENT_VIEW_CLIENT_ERROR_FAILED_SSL_HANDSHAKE;
|
||||
|
||||
case net::ERR_PROXY_AUTH_UNSUPPORTED:
|
||||
case net::ERR_PROXY_AUTH_REQUESTED:
|
||||
case net::ERR_PROXY_CONNECTION_FAILED:
|
||||
case net::ERR_UNEXPECTED_PROXY_AUTH:
|
||||
return CONTENT_VIEW_CLIENT_ERROR_PROXY_AUTHENTICATION;
|
||||
|
||||
/* The certificate errors are handled by onReceivedSslError
|
||||
* and don't need to be reported here.
|
||||
*/
|
||||
case net::ERR_CERT_COMMON_NAME_INVALID:
|
||||
case net::ERR_CERT_DATE_INVALID:
|
||||
case net::ERR_CERT_AUTHORITY_INVALID:
|
||||
case net::ERR_CERT_CONTAINS_ERRORS:
|
||||
case net::ERR_CERT_NO_REVOCATION_MECHANISM:
|
||||
case net::ERR_CERT_UNABLE_TO_CHECK_REVOCATION:
|
||||
case net::ERR_CERT_REVOKED:
|
||||
case net::ERR_CERT_INVALID:
|
||||
case net::ERR_CERT_WEAK_SIGNATURE_ALGORITHM:
|
||||
case net::ERR_CERT_NON_UNIQUE_NAME:
|
||||
return CONTENT_VIEW_CLIENT_ERROR_OK;
|
||||
|
||||
default:
|
||||
VLOG(1) << "ContentViewClient::ToContentViewClientError: Unknown "
|
||||
<< "chromium error: "
|
||||
<< net_error;
|
||||
return CONTENT_VIEW_CLIENT_ERROR_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Native JNI methods
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// Register native methods
|
||||
|
||||
bool RegisterContentViewClient(JNIEnv* env) {
|
||||
if (!HasClass(env, kContentViewClientClassPath)) {
|
||||
DLOG(ERROR) << "Unable to find class ContentViewClient!";
|
||||
return false;
|
||||
}
|
||||
return RegisterNativesImpl(env);
|
||||
}
|
||||
|
||||
} // namespace content
|
@ -1,101 +0,0 @@
|
||||
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef CONTENT_BROWSER_ANDROID_CONTENT_VIEW_CLIENT_H_
|
||||
#define CONTENT_BROWSER_ANDROID_CONTENT_VIEW_CLIENT_H_
|
||||
|
||||
#include "base/android/jni_helper.h"
|
||||
#include "base/compiler_specific.h"
|
||||
#include "content/public/browser/native_web_keyboard_event.h"
|
||||
#include "content/public/common/referrer.h"
|
||||
#include "googleurl/src/gurl.h"
|
||||
#include "net/base/net_errors.h"
|
||||
|
||||
namespace content {
|
||||
|
||||
class DownloadItem;
|
||||
class JavaScriptDialogCreator;
|
||||
struct NativeWebKeyboardEvent;
|
||||
class RenderViewHost;
|
||||
class WebContents;
|
||||
|
||||
// These enums must be kept in sync with ContentViewClient.java
|
||||
enum ContentViewClientError {
|
||||
// Success
|
||||
CONTENT_VIEW_CLIENT_ERROR_OK = 0,
|
||||
// Generic error
|
||||
CONTENT_VIEW_CLIENT_ERROR_UNKNOWN = -1,
|
||||
// Server or proxy hostname lookup failed
|
||||
CONTENT_VIEW_CLIENT_ERROR_HOST_LOOKUP = -2,
|
||||
// Unsupported authentication scheme (not basic or digest)
|
||||
CONTENT_VIEW_CLIENT_ERROR_UNSUPPORTED_AUTH_SCHEME = -3,
|
||||
// User authentication failed on server
|
||||
CONTENT_VIEW_CLIENT_ERROR_AUTHENTICATION = -4,
|
||||
// User authentication failed on proxy
|
||||
CONTENT_VIEW_CLIENT_ERROR_PROXY_AUTHENTICATION = -5,
|
||||
// Failed to connect to the server
|
||||
CONTENT_VIEW_CLIENT_ERROR_CONNECT = -6,
|
||||
// Failed to read or write to the server
|
||||
CONTENT_VIEW_CLIENT_ERROR_IO = -7,
|
||||
// Connection timed out
|
||||
CONTENT_VIEW_CLIENT_ERROR_TIMEOUT = -8,
|
||||
// Too many redirects
|
||||
CONTENT_VIEW_CLIENT_ERROR_REDIRECT_LOOP = -9,
|
||||
// Unsupported URI scheme
|
||||
CONTENT_VIEW_CLIENT_ERROR_UNSUPPORTED_SCHEME = -10,
|
||||
// Failed to perform SSL handshake
|
||||
CONTENT_VIEW_CLIENT_ERROR_FAILED_SSL_HANDSHAKE = -11,
|
||||
// Malformed URL
|
||||
CONTENT_VIEW_CLIENT_ERROR_BAD_URL = -12,
|
||||
// Generic file error
|
||||
CONTENT_VIEW_CLIENT_ERROR_FILE = -13,
|
||||
// File not found
|
||||
CONTENT_VIEW_CLIENT_ERROR_FILE_NOT_FOUND = -14,
|
||||
// Too many requests during this load
|
||||
CONTENT_VIEW_CLIENT_ERROR_TOO_MANY_REQUESTS = -15,
|
||||
};
|
||||
|
||||
// Native mirror of ContentViewClient.java. Used as a client of
|
||||
// ContentView, the main FrameLayout on Android.
|
||||
// TODO(joth): Delete this C++ class, to make it Java-only. All the callbacks
|
||||
// defined here originate in WebContentsObserver; we should have a dedicated
|
||||
// bridge class for that rather than overloading ContentViewClient with this.
|
||||
// See http://crbug.com/137967
|
||||
class ContentViewClient {
|
||||
public:
|
||||
ContentViewClient(JNIEnv* env, jobject obj);
|
||||
~ContentViewClient();
|
||||
|
||||
static ContentViewClient* CreateNativeContentViewClient(JNIEnv* env,
|
||||
jobject obj);
|
||||
|
||||
// Called by ContentView:
|
||||
void OnPageStarted(const GURL& url);
|
||||
void OnPageFinished(const GURL& url);
|
||||
void OnLoadStarted();
|
||||
void OnLoadStopped();
|
||||
void OnReceivedError(int error_code,
|
||||
const string16& description,
|
||||
const GURL& url);
|
||||
void OnDidCommitMainFrame(const GURL& url,
|
||||
const GURL& base_url);
|
||||
void OnInterstitialShown();
|
||||
void OnInterstitialHidden();
|
||||
|
||||
private:
|
||||
// Get the closest ContentViewClient match to the given Chrome error code.
|
||||
static ContentViewClientError ToContentViewClientError(int net_error);
|
||||
|
||||
// We depend on ContentView.java to hold a ref to the client object. If we
|
||||
// were to hold a hard ref from native we could end up with a cyclic
|
||||
// ownership leak (the GC can't collect cycles if part of the cycle is caused
|
||||
// by native).
|
||||
JavaObjectWeakGlobalRef weak_java_client_;
|
||||
};
|
||||
|
||||
bool RegisterContentViewClient(JNIEnv* env);
|
||||
|
||||
} // namespace content
|
||||
|
||||
#endif // CONTENT_BROWSER_ANDROID_CONTENT_VIEW_CLIENT_H_
|
@ -9,7 +9,6 @@
|
||||
#include "base/android/jni_string.h"
|
||||
#include "base/android/scoped_java_ref.h"
|
||||
#include "base/json/json_writer.h"
|
||||
#include "content/browser/android/content_view_client.h"
|
||||
#include "content/browser/android/load_url_params.h"
|
||||
#include "content/browser/android/touch_point.h"
|
||||
#include "content/browser/renderer_host/java/java_bound_object.h"
|
||||
@ -464,13 +463,6 @@ jboolean ContentViewCoreImpl::NeedsReload(JNIEnv* env, jobject obj) {
|
||||
return web_contents_->GetController().NeedsReload();
|
||||
}
|
||||
|
||||
void ContentViewCoreImpl::SetClient(JNIEnv* env, jobject obj, jobject jclient) {
|
||||
scoped_ptr<ContentViewClient> client(
|
||||
ContentViewClient::CreateNativeContentViewClient(env, jclient));
|
||||
|
||||
content_view_client_.swap(client);
|
||||
}
|
||||
|
||||
void ContentViewCoreImpl::AddJavascriptInterface(
|
||||
JNIEnv* env,
|
||||
jobject /* obj */,
|
||||
|
@ -29,7 +29,6 @@ class WindowAndroid;
|
||||
}
|
||||
|
||||
namespace content {
|
||||
class ContentViewClient;
|
||||
class RenderWidgetHostViewAndroid;
|
||||
|
||||
// TODO(jrg): this is a shell. Upstream the rest.
|
||||
@ -124,7 +123,6 @@ class ContentViewCoreImpl : public ContentViewCore,
|
||||
void Reload(JNIEnv* env, jobject obj);
|
||||
jboolean NeedsReload(JNIEnv* env, jobject obj);
|
||||
void ClearHistory(JNIEnv* env, jobject obj);
|
||||
void SetClient(JNIEnv* env, jobject obj, jobject jclient);
|
||||
jint EvaluateJavaScript(JNIEnv* env, jobject obj, jstring script);
|
||||
int GetNativeImeAdapter(JNIEnv* env, jobject obj);
|
||||
void AddJavascriptInterface(JNIEnv* env,
|
||||
@ -214,9 +212,6 @@ class ContentViewCoreImpl : public ContentViewCore,
|
||||
// display in the ContentViewCore.
|
||||
WebContentsImpl* web_contents_;
|
||||
|
||||
// We only set this to be the delegate of the web_contents if we own it.
|
||||
scoped_ptr<ContentViewClient> content_view_client_;
|
||||
|
||||
// Whether the renderer backing this ContentViewCore has crashed.
|
||||
bool tab_crashed_;
|
||||
|
||||
|
@ -35,11 +35,11 @@ WebContentsObserverAndroid::WebContentsObserverAndroid(
|
||||
WebContentsObserverAndroid::~WebContentsObserverAndroid() {
|
||||
}
|
||||
|
||||
jint Init(JNIEnv* env, jobject obj, jint native_web_contents) {
|
||||
WebContents* web_contents =
|
||||
reinterpret_cast<WebContents*>(native_web_contents);
|
||||
jint Init(JNIEnv* env, jobject obj, jint native_content_view_core) {
|
||||
ContentViewCore* content_view_core =
|
||||
reinterpret_cast<ContentViewCore*>(native_content_view_core);
|
||||
WebContentsObserverAndroid* native_observer = new WebContentsObserverAndroid(
|
||||
env, obj, web_contents);
|
||||
env, obj, content_view_core->GetWebContents());
|
||||
return reinterpret_cast<jint>(native_observer);
|
||||
}
|
||||
|
||||
@ -105,6 +105,21 @@ void WebContentsObserverAndroid::DidFailLoad(
|
||||
false, is_main_frame, error_code, error_description, validated_url);
|
||||
}
|
||||
|
||||
void WebContentsObserverAndroid::DidNavigateMainFrame(
|
||||
const LoadCommittedDetails& details,
|
||||
const FrameNavigateParams& params) {
|
||||
JNIEnv* env = AttachCurrentThread();
|
||||
ScopedJavaLocalRef<jobject> obj = weak_java_observer_.get(env);
|
||||
if (obj.is_null())
|
||||
return;
|
||||
ScopedJavaLocalRef<jstring> jstring_url =
|
||||
ConvertUTF8ToJavaString(env, params.url.spec());
|
||||
ScopedJavaLocalRef<jstring> jstring_base_url =
|
||||
ConvertUTF8ToJavaString(env, params.base_url.spec());
|
||||
Java_WebContentsObserverAndroid_didNavigateMainFrame(
|
||||
env, obj.obj(), jstring_url.obj(), jstring_base_url.obj());
|
||||
}
|
||||
|
||||
void WebContentsObserverAndroid::DidFailLoadInternal(
|
||||
bool is_provisional_load,
|
||||
bool is_main_frame,
|
||||
|
@ -45,6 +45,8 @@ class WebContentsObserverAndroid : public WebContentsObserver {
|
||||
int error_code,
|
||||
const string16& error_description,
|
||||
RenderViewHost* render_view_host) OVERRIDE;
|
||||
virtual void DidNavigateMainFrame(const LoadCommittedDetails& details,
|
||||
const FrameNavigateParams& params) OVERRIDE;
|
||||
virtual void WebContentsDestroyed(WebContents* web_contents) OVERRIDE;
|
||||
|
||||
void DidFailLoadInternal(bool is_provisional_load,
|
||||
|
@ -197,8 +197,6 @@
|
||||
'browser/android/content_startup_flags.h',
|
||||
'browser/android/content_video_view.cc',
|
||||
'browser/android/content_video_view.h',
|
||||
'browser/android/content_view_client.cc',
|
||||
'browser/android/content_view_client.h',
|
||||
'browser/android/content_view_core_impl.cc',
|
||||
'browser/android/content_view_core_impl.h',
|
||||
'browser/android/content_view_statics.cc',
|
||||
|
@ -15,7 +15,6 @@
|
||||
'public/android/java/src/org/chromium/content/browser/BrowserProcessSurfaceTexture.java',
|
||||
'public/android/java/src/org/chromium/content/browser/ContentSettings.java',
|
||||
'public/android/java/src/org/chromium/content/browser/ContentVideoView.java',
|
||||
'public/android/java/src/org/chromium/content/browser/ContentViewClient.java',
|
||||
'public/android/java/src/org/chromium/content/browser/ContentViewCore.java',
|
||||
'public/android/java/src/org/chromium/content/browser/ContentViewStatics.java',
|
||||
'public/android/java/src/org/chromium/content/browser/DeviceOrientation.java',
|
||||
|
@ -40,65 +40,9 @@ public class ContentViewClient {
|
||||
@AccessedByNative
|
||||
private int mNativeClazz = 0;
|
||||
|
||||
// These ints must match up to the native values in content_view_client.h.
|
||||
// Generic error
|
||||
public static final int ERROR_UNKNOWN = -1;
|
||||
// Server or proxy hostname lookup failed
|
||||
public static final int ERROR_HOST_LOOKUP = -2;
|
||||
// Unsupported authentication scheme (not basic or digest)
|
||||
public static final int ERROR_UNSUPPORTED_AUTH_SCHEME = -3;
|
||||
// User authentication failed on server
|
||||
public static final int ERROR_AUTHENTICATION = -4;
|
||||
// User authentication failed on proxy
|
||||
public static final int ERROR_PROXY_AUTHENTICATION = -5;
|
||||
// Failed to connect to the server
|
||||
public static final int ERROR_CONNECT = -6;
|
||||
// Failed to read or write to the server
|
||||
public static final int ERROR_IO = -7;
|
||||
// Connection timed out
|
||||
public static final int ERROR_TIMEOUT = -8;
|
||||
// Too many redirects
|
||||
public static final int ERROR_REDIRECT_LOOP = -9;
|
||||
// Unsupported URI scheme
|
||||
public static final int ERROR_UNSUPPORTED_SCHEME = -10;
|
||||
// Failed to perform SSL handshake
|
||||
public static final int ERROR_FAILED_SSL_HANDSHAKE = -11;
|
||||
// Malformed URL
|
||||
public static final int ERROR_BAD_URL = -12;
|
||||
// Generic file error
|
||||
public static final int ERROR_FILE = -13;
|
||||
// File not found
|
||||
public static final int ERROR_FILE_NOT_FOUND = -14;
|
||||
// Too many requests during this load
|
||||
public static final int ERROR_TOO_MANY_REQUESTS = -15;
|
||||
|
||||
@CalledByNative
|
||||
public void onPageStarted(String url) {
|
||||
}
|
||||
|
||||
@CalledByNative
|
||||
public void onPageFinished(String url) {
|
||||
}
|
||||
|
||||
@CalledByNative
|
||||
public void onReceivedError(int errorCode, String description, String failingUrl) {
|
||||
}
|
||||
|
||||
@CalledByNative
|
||||
public void onMainFrameCommitted(String url, String baseUrl) {
|
||||
}
|
||||
|
||||
public void onUpdateTitle(String title) {
|
||||
}
|
||||
|
||||
@CalledByNative
|
||||
public void onInterstitialShown() {
|
||||
}
|
||||
|
||||
@CalledByNative
|
||||
public void onInterstitialHidden() {
|
||||
}
|
||||
|
||||
public void onTabCrash(int pid) {
|
||||
}
|
||||
|
||||
|
@ -32,6 +32,7 @@ import org.chromium.content.browser.accessibility.AccessibilityInjector;
|
||||
import org.chromium.content.browser.ContentViewGestureHandler;
|
||||
import org.chromium.content.browser.ContentViewGestureHandler.MotionEventDelegate;
|
||||
import org.chromium.content.browser.TouchPoint;
|
||||
import org.chromium.content.browser.WebContentsObserverAndroid;
|
||||
import org.chromium.content.browser.ZoomManager;
|
||||
import org.chromium.content.common.CleanupReference;
|
||||
import org.chromium.content.common.TraceEvent;
|
||||
@ -141,11 +142,8 @@ public class ContentViewCore implements MotionEventDelegate {
|
||||
private final Context mContext;
|
||||
private ViewGroup mContainerView;
|
||||
private InternalAccessDelegate mContainerViewInternals;
|
||||
private WebContentsObserverAndroid mWebContentsObserver;
|
||||
|
||||
// content_view_client.cc depends on ContentViewCore.java holding a ref to the current client
|
||||
// instance since the native side only holds a weak pointer to the client. We chose this
|
||||
// solution over the managed object owning the C++ object's memory since it's a lot simpler
|
||||
// in terms of clean up.
|
||||
private ContentViewClient mContentViewClient;
|
||||
|
||||
private ContentSettings mContentSettings;
|
||||
@ -193,7 +191,7 @@ public class ContentViewCore implements MotionEventDelegate {
|
||||
private boolean mKeyboardConnected;
|
||||
|
||||
// The AccessibilityInjector that handles loading Accessibility scripts into the web page.
|
||||
private final AccessibilityInjector mAccessibilityInjector;
|
||||
private AccessibilityInjector mAccessibilityInjector;
|
||||
|
||||
private boolean mNeedUpdateOrientationChanged;
|
||||
|
||||
@ -249,9 +247,6 @@ public class ContentViewCore implements MotionEventDelegate {
|
||||
AndroidBrowserProcess.initContentViewProcess(
|
||||
context, AndroidBrowserProcess.MAX_RENDERERS_SINGLE_PROCESS);
|
||||
|
||||
mAccessibilityInjector = AccessibilityInjector.newInstance(this);
|
||||
mAccessibilityInjector.addOrRemoveAccessibilityApisIfNecessary();
|
||||
|
||||
mPersonality = personality;
|
||||
HeapStatsLogger.init(mContext.getApplicationContext());
|
||||
}
|
||||
@ -337,6 +332,10 @@ public class ContentViewCore implements MotionEventDelegate {
|
||||
setAllUserAgentOverridesInHistory();
|
||||
}
|
||||
|
||||
|
||||
mAccessibilityInjector = AccessibilityInjector.newInstance(this);
|
||||
mAccessibilityInjector.addOrRemoveAccessibilityApisIfNecessary();
|
||||
|
||||
String contentDescription = "Web View";
|
||||
if (AppResource.STRING_CONTENT_VIEW_CONTENT_DESCRIPTION == 0) {
|
||||
Log.w(TAG, "Setting contentDescription to 'Web View' as no value was specified.");
|
||||
@ -345,6 +344,12 @@ public class ContentViewCore implements MotionEventDelegate {
|
||||
AppResource.STRING_CONTENT_VIEW_CONTENT_DESCRIPTION);
|
||||
}
|
||||
mContainerView.setContentDescription(contentDescription);
|
||||
mWebContentsObserver = new WebContentsObserverAndroid(this) {
|
||||
@Override
|
||||
public void didStartLoading(String url) {
|
||||
hidePopupDialog();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
@ -471,9 +476,6 @@ public class ContentViewCore implements MotionEventDelegate {
|
||||
throw new IllegalArgumentException("The client can't be null.");
|
||||
}
|
||||
mContentViewClient = client;
|
||||
if (mNativeContentViewCore != 0) {
|
||||
nativeSetClient(mNativeContentViewCore, mContentViewClient);
|
||||
}
|
||||
}
|
||||
|
||||
ContentViewClient getContentViewClient() {
|
||||
@ -1411,8 +1413,6 @@ public class ContentViewCore implements MotionEventDelegate {
|
||||
|
||||
private native void nativeSelectPopupMenuItems(int nativeContentViewCoreImpl, int[] indices);
|
||||
|
||||
private native void nativeSetClient(int nativeContentViewCoreImpl, ContentViewClient client);
|
||||
|
||||
private native boolean nativeNeedsReload(int nativeContentViewCoreImpl);
|
||||
|
||||
private native void nativeClearHistory(int nativeContentViewCoreImpl);
|
||||
|
@ -15,8 +15,8 @@ import org.chromium.base.JNINamespace;
|
||||
public abstract class WebContentsObserverAndroid {
|
||||
private int mNativeWebContentsObserverAndroid;
|
||||
|
||||
public WebContentsObserverAndroid(int webContentsPtr) {
|
||||
mNativeWebContentsObserverAndroid = nativeInit(webContentsPtr);
|
||||
public WebContentsObserverAndroid(ContentViewCore contentViewCore) {
|
||||
mNativeWebContentsObserverAndroid = nativeInit(contentViewCore.getNativeContentViewCore());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -46,6 +46,15 @@ public abstract class WebContentsObserverAndroid {
|
||||
boolean isMainFrame, int errorCode, String description, String failingUrl) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the main frame of the page has committed.
|
||||
* @param url The validated url for the page.
|
||||
* @param baseUrl The validated base url for the page.
|
||||
*/
|
||||
@CalledByNative
|
||||
public void didNavigateMainFrame(String url, String baseUrl) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroy the corresponding native object.
|
||||
*/
|
||||
@ -57,6 +66,6 @@ public abstract class WebContentsObserverAndroid {
|
||||
}
|
||||
}
|
||||
|
||||
private native int nativeInit(int webContentsPtr);
|
||||
private native int nativeInit(int contentViewCorePtr);
|
||||
private native void nativeDestroy(int nativeWebContentsObserverAndroid);
|
||||
}
|
||||
|
@ -19,6 +19,7 @@ import org.apache.http.NameValuePair;
|
||||
import org.apache.http.client.utils.URLEncodedUtils;
|
||||
import org.chromium.content.browser.ContentViewCore;
|
||||
import org.chromium.content.browser.JavascriptInterface;
|
||||
import org.chromium.content.browser.WebContentsObserverAndroid;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
@ -33,7 +34,7 @@ import java.util.concurrent.atomic.AtomicInteger;
|
||||
/**
|
||||
* Responsible for accessibility injection and management of a {@link ContentViewCore}.
|
||||
*/
|
||||
public class AccessibilityInjector {
|
||||
public class AccessibilityInjector extends WebContentsObserverAndroid {
|
||||
// The ContentView this injector is responsible for managing.
|
||||
protected ContentViewCore mContentViewCore;
|
||||
|
||||
@ -93,6 +94,7 @@ public class AccessibilityInjector {
|
||||
* @param view The ContentViewCore that this AccessibilityInjector manages.
|
||||
*/
|
||||
protected AccessibilityInjector(ContentViewCore view) {
|
||||
super(view);
|
||||
mContentViewCore = view;
|
||||
}
|
||||
|
||||
@ -185,10 +187,16 @@ public class AccessibilityInjector {
|
||||
* accessibility script as not being injected. This way we can properly ignore incoming
|
||||
* accessibility gesture events.
|
||||
*/
|
||||
public void onPageLoadStarted() {
|
||||
@Override
|
||||
public void didStartLoading(String url) {
|
||||
mScriptInjected = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void didStopLoading(String url) {
|
||||
injectAccessibilityScriptIntoPage();
|
||||
}
|
||||
|
||||
/**
|
||||
* Stop any notifications that are currently going on (e.g. Text-to-Speech).
|
||||
*/
|
||||
|
@ -12,10 +12,12 @@ import org.chromium.content.browser.ContentView;
|
||||
*/
|
||||
public class TestCallbackHelperContainer{
|
||||
private TestContentViewClient mTestContentViewClient;
|
||||
private TestWebContentsObserver mTestWebContentsObserver;
|
||||
|
||||
public TestCallbackHelperContainer(ContentView contentView) {
|
||||
mTestContentViewClient = new TestContentViewClient();
|
||||
contentView.getContentViewCore().setContentViewClient(mTestContentViewClient);
|
||||
mTestWebContentsObserver = new TestWebContentsObserver(contentView.getContentViewCore());
|
||||
}
|
||||
|
||||
public static class OnPageFinishedHelper extends CallbackHelper {
|
||||
@ -85,15 +87,15 @@ public class TestCallbackHelperContainer{
|
||||
}
|
||||
|
||||
public OnPageStartedHelper getOnPageStartedHelper() {
|
||||
return mTestContentViewClient.getOnPageStartedHelper();
|
||||
return mTestWebContentsObserver.getOnPageStartedHelper();
|
||||
}
|
||||
|
||||
public OnPageFinishedHelper getOnPageFinishedHelper() {
|
||||
return mTestContentViewClient.getOnPageFinishedHelper();
|
||||
return mTestWebContentsObserver.getOnPageFinishedHelper();
|
||||
}
|
||||
|
||||
public OnReceivedErrorHelper getOnReceivedErrorHelper() {
|
||||
return mTestContentViewClient.getOnReceivedErrorHelper();
|
||||
return mTestWebContentsObserver.getOnReceivedErrorHelper();
|
||||
}
|
||||
|
||||
public OnEvaluateJavaScriptResultHelper getOnEvaluateJavaScriptResultHelper() {
|
||||
|
36
content/public/android/javatests/src/org/chromium/content/browser/util/TestContentViewClient.java
36
content/public/android/javatests/src/org/chromium/content/browser/util/TestContentViewClient.java
@ -19,30 +19,12 @@ import org.chromium.content.browser.util.TestCallbackHelperContainer.OnReceivedE
|
||||
*/
|
||||
public class TestContentViewClient extends ContentViewClient {
|
||||
|
||||
private OnPageStartedHelper mOnPageStartedHelper;
|
||||
private OnPageFinishedHelper mOnPageFinishedHelper;
|
||||
private OnReceivedErrorHelper mOnReceivedErrorHelper;
|
||||
private OnEvaluateJavaScriptResultHelper mOnEvaluateJavaScriptResultHelper;
|
||||
|
||||
public TestContentViewClient() {
|
||||
mOnPageStartedHelper = new OnPageStartedHelper();
|
||||
mOnPageFinishedHelper = new OnPageFinishedHelper();
|
||||
mOnReceivedErrorHelper = new OnReceivedErrorHelper();
|
||||
mOnEvaluateJavaScriptResultHelper = new OnEvaluateJavaScriptResultHelper();
|
||||
}
|
||||
|
||||
public OnPageStartedHelper getOnPageStartedHelper() {
|
||||
return mOnPageStartedHelper;
|
||||
}
|
||||
|
||||
public OnPageFinishedHelper getOnPageFinishedHelper() {
|
||||
return mOnPageFinishedHelper;
|
||||
}
|
||||
|
||||
public OnReceivedErrorHelper getOnReceivedErrorHelper() {
|
||||
return mOnReceivedErrorHelper;
|
||||
}
|
||||
|
||||
public OnEvaluateJavaScriptResultHelper getOnEvaluateJavaScriptResultHelper() {
|
||||
return mOnEvaluateJavaScriptResultHelper;
|
||||
}
|
||||
@ -53,24 +35,6 @@ public class TestContentViewClient extends ContentViewClient {
|
||||
* {@link CallbackHelper#waitForCallback()} methods will
|
||||
* stop working!
|
||||
*/
|
||||
@Override
|
||||
public void onPageStarted(String url) {
|
||||
super.onPageStarted(url);
|
||||
mOnPageStartedHelper.notifyCalled(url);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPageFinished(String url) {
|
||||
super.onPageFinished(url);
|
||||
mOnPageFinishedHelper.notifyCalled(url);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReceivedError(int errorCode, String description, String failingUrl) {
|
||||
super.onReceivedError(errorCode, description, failingUrl);
|
||||
mOnReceivedErrorHelper.notifyCalled(errorCode, description, failingUrl);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEvaluateJavaScriptResult(int id, String jsonResult) {
|
||||
super.onEvaluateJavaScriptResult(id, jsonResult);
|
||||
|
66
content/public/android/javatests/src/org/chromium/content/browser/util/TestWebContentsObserver.java
Normal file
66
content/public/android/javatests/src/org/chromium/content/browser/util/TestWebContentsObserver.java
Normal file
@ -0,0 +1,66 @@
|
||||
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
package org.chromium.content.browser.util;
|
||||
|
||||
import org.chromium.content.browser.ContentViewCore;
|
||||
import org.chromium.content.browser.WebContentsObserverAndroid;
|
||||
import org.chromium.content.browser.util.TestCallbackHelperContainer.OnPageFinishedHelper;
|
||||
import org.chromium.content.browser.util.TestCallbackHelperContainer.OnPageStartedHelper;
|
||||
import org.chromium.content.browser.util.TestCallbackHelperContainer.OnReceivedErrorHelper;
|
||||
|
||||
/**
|
||||
* The default WebContentsObserverAndroid used by ContentView tests. The below callbacks can be
|
||||
* accessed by using {@link TestCallbackHelperContainer} or extending this class.
|
||||
*/
|
||||
public class TestWebContentsObserver extends WebContentsObserverAndroid {
|
||||
|
||||
private OnPageStartedHelper mOnPageStartedHelper;
|
||||
private OnPageFinishedHelper mOnPageFinishedHelper;
|
||||
private OnReceivedErrorHelper mOnReceivedErrorHelper;
|
||||
|
||||
public TestWebContentsObserver(ContentViewCore contentViewCore) {
|
||||
super(contentViewCore);
|
||||
mOnPageStartedHelper = new OnPageStartedHelper();
|
||||
mOnPageFinishedHelper = new OnPageFinishedHelper();
|
||||
mOnReceivedErrorHelper = new OnReceivedErrorHelper();
|
||||
}
|
||||
|
||||
public OnPageStartedHelper getOnPageStartedHelper() {
|
||||
return mOnPageStartedHelper;
|
||||
}
|
||||
|
||||
public OnPageFinishedHelper getOnPageFinishedHelper() {
|
||||
return mOnPageFinishedHelper;
|
||||
}
|
||||
|
||||
public OnReceivedErrorHelper getOnReceivedErrorHelper() {
|
||||
return mOnReceivedErrorHelper;
|
||||
}
|
||||
|
||||
/**
|
||||
* ATTENTION!: When overriding the following methods, be sure to call
|
||||
* the corresponding methods in the super class. Otherwise
|
||||
* {@link CallbackHelper#waitForCallback()} methods will
|
||||
* stop working!
|
||||
*/
|
||||
@Override
|
||||
public void didStartLoading(String url) {
|
||||
super.didStartLoading(url);
|
||||
mOnPageStartedHelper.notifyCalled(url);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void didStopLoading(String url) {
|
||||
super.didStopLoading(url);
|
||||
mOnPageFinishedHelper.notifyCalled(url);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void didFailLoad(boolean isProvisionalLoad, boolean isMainFrame,
|
||||
int errorCode, String description, String failingUrl) {
|
||||
super.didFailLoad(isProvisionalLoad, isMainFrame, errorCode, description, failingUrl);
|
||||
mOnReceivedErrorHelper.notifyCalled(errorCode, description, failingUrl);
|
||||
}
|
||||
}
|
@ -5,7 +5,7 @@
|
||||
package org.chromium.net;
|
||||
|
||||
public class NetError {
|
||||
#define NET_ERROR(name, value) public static int ERR_##name = value;
|
||||
#define NET_ERROR(name, value) public static final int ERR_##name = value;
|
||||
#include "net/base/net_error_list.h"
|
||||
}
|
||||
|
||||
|
@ -2206,6 +2206,7 @@
|
||||
'direct_dependent_settings': {
|
||||
'variables': {
|
||||
'additional_src_dirs': ['<(SHARED_INTERMEDIATE_DIR)/net/template/'],
|
||||
'additional_input_paths': ['<(SHARED_INTERMEDIATE_DIR)/net/template/NetError.java'],
|
||||
},
|
||||
},
|
||||
'actions': [
|
||||
|
Reference in New Issue
Block a user