summaryrefslogtreecommitdiffstats
path: root/content
diff options
context:
space:
mode:
Diffstat (limited to 'content')
-rw-r--r--content/browser/android/browser_jni_registrar.cc2
-rw-r--r--content/browser/android/content_view_client.cc240
-rw-r--r--content/browser/android/content_view_client.h101
-rw-r--r--content/browser/android/content_view_core_impl.cc8
-rw-r--r--content/browser/android/content_view_core_impl.h5
-rw-r--r--content/browser/android/web_contents_observer_android.cc23
-rw-r--r--content/browser/android/web_contents_observer_android.h2
-rw-r--r--content/content_browser.gypi2
-rw-r--r--content/content_jni.gypi1
-rw-r--r--content/public/android/java/src/org/chromium/content/browser/ContentViewClient.java56
-rw-r--r--content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java26
-rw-r--r--content/public/android/java/src/org/chromium/content/browser/WebContentsObserverAndroid.java15
-rw-r--r--content/public/android/java/src/org/chromium/content/browser/accessibility/AccessibilityInjector.java12
-rw-r--r--content/public/android/javatests/src/org/chromium/content/browser/util/TestCallbackHelperContainer.java8
-rw-r--r--content/public/android/javatests/src/org/chromium/content/browser/util/TestContentViewClient.java36
-rw-r--r--content/public/android/javatests/src/org/chromium/content/browser/util/TestWebContentsObserver.java66
16 files changed, 127 insertions, 476 deletions
diff --git a/content/browser/android/browser_jni_registrar.cc b/content/browser/android/browser_jni_registrar.cc
index 1fb0334..7394a25 100644
--- a/content/browser/android/browser_jni_registrar.cc
+++ b/content/browser/android/browser_jni_registrar.cc
@@ -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 },
diff --git a/content/browser/android/content_view_client.cc b/content/browser/android/content_view_client.cc
deleted file mode 100644
index c77252f..0000000
--- a/content/browser/android/content_view_client.cc
+++ /dev/null
@@ -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
diff --git a/content/browser/android/content_view_client.h b/content/browser/android/content_view_client.h
deleted file mode 100644
index b28915e..0000000
--- a/content/browser/android/content_view_client.h
+++ /dev/null
@@ -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_
diff --git a/content/browser/android/content_view_core_impl.cc b/content/browser/android/content_view_core_impl.cc
index b593c19..6fb4b42 100644
--- a/content/browser/android/content_view_core_impl.cc
+++ b/content/browser/android/content_view_core_impl.cc
@@ -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 */,
diff --git a/content/browser/android/content_view_core_impl.h b/content/browser/android/content_view_core_impl.h
index 12556a8..96a9a92 100644
--- a/content/browser/android/content_view_core_impl.h
+++ b/content/browser/android/content_view_core_impl.h
@@ -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_;
diff --git a/content/browser/android/web_contents_observer_android.cc b/content/browser/android/web_contents_observer_android.cc
index 3fa212d..e57c2a5 100644
--- a/content/browser/android/web_contents_observer_android.cc
+++ b/content/browser/android/web_contents_observer_android.cc
@@ -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,
diff --git a/content/browser/android/web_contents_observer_android.h b/content/browser/android/web_contents_observer_android.h
index 96fecff..32dd5c6 100644
--- a/content/browser/android/web_contents_observer_android.h
+++ b/content/browser/android/web_contents_observer_android.h
@@ -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,
diff --git a/content/content_browser.gypi b/content/content_browser.gypi
index 42f26fa..99f029c 100644
--- a/content/content_browser.gypi
+++ b/content/content_browser.gypi
@@ -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',
diff --git a/content/content_jni.gypi b/content/content_jni.gypi
index f7cda06..951efa8 100644
--- a/content/content_jni.gypi
+++ b/content/content_jni.gypi
@@ -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',
diff --git a/content/public/android/java/src/org/chromium/content/browser/ContentViewClient.java b/content/public/android/java/src/org/chromium/content/browser/ContentViewClient.java
index 23ede97..411738b 100644
--- a/content/public/android/java/src/org/chromium/content/browser/ContentViewClient.java
+++ b/content/public/android/java/src/org/chromium/content/browser/ContentViewClient.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) {
}
diff --git a/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java b/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java
index 9aa145f..afc3583 100644
--- a/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java
+++ b/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java
@@ -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);
diff --git a/content/public/android/java/src/org/chromium/content/browser/WebContentsObserverAndroid.java b/content/public/android/java/src/org/chromium/content/browser/WebContentsObserverAndroid.java
index af16d0a..c8822911 100644
--- a/content/public/android/java/src/org/chromium/content/browser/WebContentsObserverAndroid.java
+++ b/content/public/android/java/src/org/chromium/content/browser/WebContentsObserverAndroid.java
@@ -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());
}
/**
@@ -47,6 +47,15 @@ public abstract class WebContentsObserverAndroid {
}
/**
+ * 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.
*/
@CalledByNative
@@ -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);
}
diff --git a/content/public/android/java/src/org/chromium/content/browser/accessibility/AccessibilityInjector.java b/content/public/android/java/src/org/chromium/content/browser/accessibility/AccessibilityInjector.java
index 9d9784d..457492a 100644
--- a/content/public/android/java/src/org/chromium/content/browser/accessibility/AccessibilityInjector.java
+++ b/content/public/android/java/src/org/chromium/content/browser/accessibility/AccessibilityInjector.java
@@ -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).
*/
diff --git a/content/public/android/javatests/src/org/chromium/content/browser/util/TestCallbackHelperContainer.java b/content/public/android/javatests/src/org/chromium/content/browser/util/TestCallbackHelperContainer.java
index 250a097..43d2193 100644
--- a/content/public/android/javatests/src/org/chromium/content/browser/util/TestCallbackHelperContainer.java
+++ b/content/public/android/javatests/src/org/chromium/content/browser/util/TestCallbackHelperContainer.java
@@ -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() {
diff --git a/content/public/android/javatests/src/org/chromium/content/browser/util/TestContentViewClient.java b/content/public/android/javatests/src/org/chromium/content/browser/util/TestContentViewClient.java
index d33c8c3..4bfec42 100644
--- a/content/public/android/javatests/src/org/chromium/content/browser/util/TestContentViewClient.java
+++ b/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;
}
@@ -54,24 +36,6 @@ public class TestContentViewClient extends ContentViewClient {
* 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);
mOnEvaluateJavaScriptResultHelper.notifyCalled(id, jsonResult);
diff --git a/content/public/android/javatests/src/org/chromium/content/browser/util/TestWebContentsObserver.java b/content/public/android/javatests/src/org/chromium/content/browser/util/TestWebContentsObserver.java
new file mode 100644
index 0000000..503ab4e
--- /dev/null
+++ b/content/public/android/javatests/src/org/chromium/content/browser/util/TestWebContentsObserver.java
@@ -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);
+ }
+}