summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortedchoc@chromium.org <tedchoc@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-07-11 17:50:18 +0000
committertedchoc@chromium.org <tedchoc@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-07-11 17:50:18 +0000
commite9fbb9350248394b584934cb735b5506e4f164d6 (patch)
tree7b0cb8669e8305a179333379a114928815dd421f
parent583eb026cd10f3e42db09893ea24c43c80ced8ac (diff)
downloadchromium_src-e9fbb9350248394b584934cb735b5506e4f164d6.zip
chromium_src-e9fbb9350248394b584934cb735b5506e4f164d6.tar.gz
chromium_src-e9fbb9350248394b584934cb735b5506e4f164d6.tar.bz2
Revert "Revert 146000 - Split out ContentViewCore from ContentView for embedders."
This reverts commit 331b803f65e8f994f9148024e8c2be6b465c6a6e. TBR=ericu@chromium.org BUG= TEST= Review URL: https://chromiumcodereview.appspot.com/10696173 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@146141 0039d316-1c4b-4281-b951-d872f2087c98
-rwxr-xr-xbase/android/jni_generator/jni_generator.py7
-rwxr-xr-xbase/android/jni_generator/jni_generator_tests.py13
-rw-r--r--content/browser/android/browser_jni_registrar.cc4
-rw-r--r--content/browser/android/content_settings.cc6
-rw-r--r--content/browser/android/content_view_client.cc2
-rw-r--r--content/browser/android/content_view_core_impl.cc (renamed from content/browser/android/content_view_impl.cc)127
-rw-r--r--content/browser/android/content_view_core_impl.h (renamed from content/browser/android/content_view_impl.h)28
-rw-r--r--content/browser/android/download_controller.cc13
-rw-r--r--content/browser/android/download_controller.h2
-rw-r--r--content/browser/renderer_host/render_widget_host_view_android.cc51
-rw-r--r--content/browser/renderer_host/render_widget_host_view_android.h10
-rw-r--r--content/browser/web_contents/web_contents_view_android.cc30
-rw-r--r--content/browser/web_contents/web_contents_view_android.h12
-rw-r--r--content/content_browser.gypi6
-rw-r--r--content/content_jni.gypi4
-rw-r--r--content/public/android/java/src/org/chromium/content/browser/ContentSettings.java18
-rw-r--r--content/public/android/java/src/org/chromium/content/browser/ContentView.java417
-rw-r--r--content/public/android/java/src/org/chromium/content/browser/ContentViewClient.java5
-rw-r--r--content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java750
-rw-r--r--content/public/android/java/src/org/chromium/content/browser/DownloadController.java10
-rw-r--r--content/public/android/java/src/org/chromium/content/browser/ZoomManager.java33
-rw-r--r--content/public/browser/android/content_view_core.h (renamed from content/public/browser/android/content_view.h)27
-rw-r--r--ui/gfx/native_widget_types.h6
23 files changed, 1119 insertions, 462 deletions
diff --git a/base/android/jni_generator/jni_generator.py b/base/android/jni_generator/jni_generator.py
index 9a095bf..9d132fa 100755
--- a/base/android/jni_generator/jni_generator.py
+++ b/base/android/jni_generator/jni_generator.py
@@ -161,14 +161,13 @@ def JavaParamToJni(param):
'Lorg/chromium/base/SystemMessageHandler',
'Lorg/chromium/chrome/browser/JSModalDialog',
'Lorg/chromium/chrome/browser/SelectFileDialog',
- 'Lorg/chromium/content/browser/ChromeVideoView',
- 'Lorg/chromium/content/browser/ContentView',
- ('Lorg/chromium/content/browser/ContentView$'
- 'FindResultReceivedListener$FindNotificationDetails'),
+ 'Lorg/chromium/content/browser/ContentVideoView',
'Lorg/chromium/content/browser/ContentViewClient',
+ 'Lorg/chromium/content/browser/ContentViewCore',
'Lorg/chromium/content/browser/ContentHttpAuthHandler',
'Lorg/chromium/content/browser/DeviceOrientation',
'Lorg/chromium/content/browser/FileChooserParams',
+ 'Lorg/chromium/content/browser/FindNotificationDetails',
'Lorg/chromium/content/browser/InterceptedRequestData',
'Lorg/chromium/content/browser/JavaInputStream',
'Lorg/chromium/content/browser/LocationProvider',
diff --git a/base/android/jni_generator/jni_generator_tests.py b/base/android/jni_generator/jni_generator_tests.py
index f0f68f9..1ce7a37 100755
--- a/base/android/jni_generator/jni_generator_tests.py
+++ b/base/android/jni_generator/jni_generator_tests.py
@@ -54,6 +54,7 @@ class TestGenerator(unittest.TestCase):
print '=' * 80
self.fail('Golden text mismatch')
+ # TODO(bulach): Detangle these tests from knowing about classes from Content.
def testNatives(self):
test_data = """"
private native int nativeInit();
@@ -64,7 +65,7 @@ class TestGenerator(unittest.TestCase):
private static native String nativeGetDomainAndRegistry(String url);
private static native void nativeCreateHistoricalTabFromState(
byte[] state, int tab_index);
- private native byte[] nativeGetStateAsByteArray(ContentView view);
+ private native byte[] nativeGetStateAsByteArray(ContentViewCore view);
private static native String[] nativeGetAutofillProfileGUIDs();
private native void nativeSetRecognitionResults(
int sessionId, String[] results);
@@ -125,7 +126,7 @@ class TestGenerator(unittest.TestCase):
type='function'),
NativeMethod(return_type='byte[]', static=False,
name='GetStateAsByteArray',
- params=[Param(datatype='ContentView', name='view')],
+ params=[Param(datatype='ContentViewCore', name='view')],
java_class_name=None,
type='function'),
NativeMethod(return_type='String[]', static=True,
@@ -359,7 +360,7 @@ static bool RegisterNativesImpl(JNIEnv* env) {
"V", reinterpret_cast<void*>(CreateHistoricalTabFromState) },
{ "nativeGetStateAsByteArray",
"("
-"Lorg/chromium/content/browser/ContentView;"
+"Lorg/chromium/content/browser/ContentViewCore;"
")"
"[B", reinterpret_cast<void*>(GetStateAsByteArray) },
{ "nativeGetAutofillProfileGUIDs",
@@ -754,7 +755,7 @@ static bool RegisterNativesImpl(JNIEnv* env) {
void dismiss();
@SuppressWarnings("unused")
@CalledByNative
- private static boolean shouldShowAutoLogin(ContentView contentView,
+ private static boolean shouldShowAutoLogin(ContentViewCore contentView,
String realm, String account, String args) {
AccountManagerContainer accountManagerContainer =
new AccountManagerContainer((Activity)contentView.getContext(),
@@ -826,7 +827,7 @@ static bool RegisterNativesImpl(JNIEnv* env) {
name='shouldShowAutoLogin',
method_id_var_name='shouldShowAutoLogin',
java_class_name='',
- params=[Param(datatype='ContentView', name='contentView'),
+ params=[Param(datatype='ContentViewCore', name='contentView'),
Param(datatype='String', name='realm'),
Param(datatype='String', name='account'),
Param(datatype='String', name='args')],
@@ -1061,7 +1062,7 @@ static void GetMethodIDsImpl(JNIEnv* env) {
"shouldShowAutoLogin",
"("
-"Lorg/chromium/content/browser/ContentView;"
+"Lorg/chromium/content/browser/ContentViewCore;"
"Ljava/lang/String;"
"Ljava/lang/String;"
"Ljava/lang/String;"
diff --git a/content/browser/android/browser_jni_registrar.cc b/content/browser/android/browser_jni_registrar.cc
index 008ae86..4699bbe 100644
--- a/content/browser/android/browser_jni_registrar.cc
+++ b/content/browser/android/browser_jni_registrar.cc
@@ -9,7 +9,7 @@
#include "content/browser/android/android_browser_process.h"
#include "content/browser/android/content_settings.h"
#include "content/browser/android/content_view_client.h"
-#include "content/browser/android/content_view_impl.h"
+#include "content/browser/android/content_view_core_impl.h"
#include "content/browser/android/download_controller.h"
#include "content/browser/android/sandboxed_process_launcher.h"
#include "content/browser/android/touch_point.h"
@@ -22,8 +22,8 @@ base::android::RegistrationMethod kContentRegisteredMethods[] = {
AndroidLocationApiAdapter::RegisterGeolocationService },
{ "AndroidBrowserProcess", content::RegisterAndroidBrowserProcess },
{ "ContentSettings", content::ContentSettings::RegisterContentSettings },
- { "ContentView", content::RegisterContentView },
{ "ContentViewClient", content::RegisterContentViewClient },
+ { "ContentViewCore", content::RegisterContentViewCore },
{ "DeviceInfo", content::RegisterDeviceInfo },
{ "DownloadController",
content::DownloadController::RegisterDownloadController },
diff --git a/content/browser/android/content_settings.cc b/content/browser/android/content_settings.cc
index 9ba1ad4..1080658 100644
--- a/content/browser/android/content_settings.cc
+++ b/content/browser/android/content_settings.cc
@@ -6,7 +6,7 @@
#include "base/android/jni_android.h"
#include "base/android/jni_string.h"
-#include "content/browser/android/content_view_impl.h"
+#include "content/browser/android/content_view_core_impl.h"
#include "content/browser/renderer_host/render_view_host_delegate.h"
#include "content/browser/renderer_host/render_view_host_impl.h"
#include "content/public/browser/web_contents.h"
@@ -285,10 +285,10 @@ void ContentSettings::RenderViewCreated(RenderViewHost* render_view_host) {
}
jint Init(
- JNIEnv* env, jobject obj, jint nativeContentView,
+ JNIEnv* env, jobject obj, jint nativeContentViewCore,
jboolean is_master_mode) {
WebContents* web_contents =
- reinterpret_cast<ContentViewImpl*>(nativeContentView)
+ reinterpret_cast<ContentViewCoreImpl*>(nativeContentViewCore)
->web_contents();
ContentSettings* content_settings =
new ContentSettings(env, obj, web_contents, is_master_mode);
diff --git a/content/browser/android/content_view_client.cc b/content/browser/android/content_view_client.cc
index 2b4408f..908ce5c 100644
--- a/content/browser/android/content_view_client.cc
+++ b/content/browser/android/content_view_client.cc
@@ -9,7 +9,7 @@
#include "base/android/jni_android.h"
#include "base/android/jni_string.h"
#include "content/browser/android/content_util.h"
-#include "content/browser/android/content_view_impl.h"
+#include "content/browser/android/content_view_core_impl.h"
#include "content/browser/android/download_controller.h"
#include "content/browser/android/ime_utils.h"
#include "content/browser/renderer_host/render_view_host_impl.h"
diff --git a/content/browser/android/content_view_impl.cc b/content/browser/android/content_view_core_impl.cc
index ea5a913..1a90629 100644
--- a/content/browser/android/content_view_impl.cc
+++ b/content/browser/android/content_view_core_impl.cc
@@ -2,7 +2,7 @@
// 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_impl.h"
+#include "content/browser/android/content_view_core_impl.h"
#include "base/android/jni_android.h"
#include "base/android/jni_string.h"
@@ -11,7 +11,7 @@
#include "content/browser/web_contents/navigation_controller_impl.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/web_contents.h"
-#include "jni/content_view_jni.h"
+#include "jni/content_view_core_jni.h"
using base::android::AttachCurrentThread;
using base::android::ConvertUTF16ToJavaString;
@@ -26,7 +26,7 @@ jfieldID g_native_content_view;
namespace content {
-struct ContentViewImpl::JavaObject {
+struct ContentViewCoreImpl::JavaObject {
jweak obj;
ScopedJavaLocalRef<jobject> View(JNIEnv* env) {
@@ -35,31 +35,32 @@ struct ContentViewImpl::JavaObject {
};
// ----------------------------------------------------------------------------
-// Implementation of static ContentView public interfaces
+// Implementation of static ContentViewCore public interfaces
-ContentView* ContentView::Create(JNIEnv* env, jobject obj,
- WebContents* web_contents) {
- return new ContentViewImpl(env, obj, web_contents);
+ContentViewCore* ContentViewCore::Create(JNIEnv* env, jobject obj,
+ WebContents* web_contents) {
+ return new ContentViewCoreImpl(env, obj, web_contents);
}
-ContentView* ContentView::GetNativeContentView(JNIEnv* env, jobject obj) {
- return reinterpret_cast<ContentView*>(
+ContentViewCore* ContentViewCore::GetNativeContentViewCore(JNIEnv* env,
+ jobject obj) {
+ return reinterpret_cast<ContentViewCore*>(
env->GetIntField(obj, g_native_content_view));
}
// ----------------------------------------------------------------------------
-ContentViewImpl::ContentViewImpl(JNIEnv* env, jobject obj,
- WebContents* web_contents)
+ContentViewCoreImpl::ContentViewCoreImpl(JNIEnv* env, jobject obj,
+ WebContents* web_contents)
: web_contents_(web_contents),
tab_crashed_(false) {
DCHECK(web_contents) <<
- "A ContentViewImpl should be created with a valid WebContents.";
+ "A ContentViewCoreImpl should be created with a valid WebContents.";
InitJNI(env, obj);
}
-ContentViewImpl::~ContentViewImpl() {
+ContentViewCoreImpl::~ContentViewCoreImpl() {
if (java_object_) {
JNIEnv* env = AttachCurrentThread();
env->DeleteWeakGlobalRef(java_object_->obj);
@@ -68,17 +69,17 @@ ContentViewImpl::~ContentViewImpl() {
}
}
-void ContentViewImpl::Destroy(JNIEnv* env, jobject obj) {
+void ContentViewCoreImpl::Destroy(JNIEnv* env, jobject obj) {
delete this;
}
-void ContentViewImpl::Observe(int type,
- const NotificationSource& source,
- const NotificationDetails& details) {
+void ContentViewCoreImpl::Observe(int type,
+ const NotificationSource& source,
+ const NotificationDetails& details) {
// TODO(jrg)
}
-void ContentViewImpl::InitJNI(JNIEnv* env, jobject obj) {
+void ContentViewCoreImpl::InitJNI(JNIEnv* env, jobject obj) {
java_object_ = new JavaObject;
java_object_->obj = env->NewWeakGlobalRef(obj);
}
@@ -87,16 +88,16 @@ void ContentViewImpl::InitJNI(JNIEnv* env, jobject obj) {
// Methods called from Java via JNI
// ----------------------------------------------------------------------------
-void ContentViewImpl::LoadUrlWithoutUrlSanitization(JNIEnv* env,
- jobject,
- jstring jurl,
- int page_transition) {
+void ContentViewCoreImpl::LoadUrlWithoutUrlSanitization(JNIEnv* env,
+ jobject,
+ jstring jurl,
+ int page_transition) {
GURL url(base::android::ConvertJavaStringToUTF8(env, jurl));
LoadUrl(url, page_transition);
}
-void ContentViewImpl::LoadUrlWithoutUrlSanitizationWithUserAgentOverride(
+void ContentViewCoreImpl::LoadUrlWithoutUrlSanitizationWithUserAgentOverride(
JNIEnv* env,
jobject,
jstring jurl,
@@ -110,17 +111,17 @@ void ContentViewImpl::LoadUrlWithoutUrlSanitizationWithUserAgentOverride(
base::android::ConvertJavaStringToUTF8(env, user_agent_override));
}
-ScopedJavaLocalRef<jstring> ContentViewImpl::GetURL(
+ScopedJavaLocalRef<jstring> ContentViewCoreImpl::GetURL(
JNIEnv* env, jobject) const {
return ConvertUTF8ToJavaString(env, web_contents()->GetURL().spec());
}
-ScopedJavaLocalRef<jstring> ContentViewImpl::GetTitle(
+ScopedJavaLocalRef<jstring> ContentViewCoreImpl::GetTitle(
JNIEnv* env, jobject obj) const {
return ConvertUTF16ToJavaString(env, web_contents()->GetTitle());
}
-jdouble ContentViewImpl::GetLoadProgress(JNIEnv* env, jobject obj) const {
+jdouble ContentViewCoreImpl::GetLoadProgress(JNIEnv* env, jobject obj) const {
// An empty page never loads anything and always has a progress of 0.
// We report 1 in that case so the UI does not assume the page is loading.
if (web_contents()->GetURL().is_empty() || !content_view_client_.get())
@@ -128,57 +129,57 @@ jdouble ContentViewImpl::GetLoadProgress(JNIEnv* env, jobject obj) const {
return static_cast<jdouble>(content_view_client_->GetLoadProgress());
}
-jboolean ContentViewImpl::IsIncognito(JNIEnv* env, jobject obj) {
+jboolean ContentViewCoreImpl::IsIncognito(JNIEnv* env, jobject obj) {
return web_contents()->GetBrowserContext()->IsOffTheRecord();
}
-jboolean ContentViewImpl::CanGoBack(JNIEnv* env, jobject obj) {
+jboolean ContentViewCoreImpl::CanGoBack(JNIEnv* env, jobject obj) {
return web_contents_->GetController().CanGoBack();
}
-jboolean ContentViewImpl::CanGoForward(JNIEnv* env, jobject obj) {
+jboolean ContentViewCoreImpl::CanGoForward(JNIEnv* env, jobject obj) {
return web_contents_->GetController().CanGoForward();
}
-jboolean ContentViewImpl::CanGoToOffset(
- JNIEnv* env, jobject obj, jint offset) {
+jboolean ContentViewCoreImpl::CanGoToOffset(JNIEnv* env, jobject obj,
+ jint offset) {
return web_contents_->GetController().CanGoToOffset(offset);
}
-void ContentViewImpl::GoBack(JNIEnv* env, jobject obj) {
+void ContentViewCoreImpl::GoBack(JNIEnv* env, jobject obj) {
web_contents_->GetController().GoBack();
tab_crashed_ = false;
}
-void ContentViewImpl::GoForward(JNIEnv* env, jobject obj) {
+void ContentViewCoreImpl::GoForward(JNIEnv* env, jobject obj) {
web_contents_->GetController().GoForward();
tab_crashed_ = false;
}
-void ContentViewImpl::GoToOffset(JNIEnv* env, jobject obj, jint offset) {
+void ContentViewCoreImpl::GoToOffset(JNIEnv* env, jobject obj, jint offset) {
web_contents_->GetController().GoToOffset(offset);
}
-void ContentViewImpl::StopLoading(JNIEnv* env, jobject obj) {
+void ContentViewCoreImpl::StopLoading(JNIEnv* env, jobject obj) {
web_contents_->Stop();
}
-void ContentViewImpl::Reload(JNIEnv* env, jobject obj) {
+void ContentViewCoreImpl::Reload(JNIEnv* env, jobject obj) {
// Set check_for_repost parameter to false as we have no repost confirmation
// dialog ("confirm form resubmission" screen will still appear, however).
web_contents_->GetController().Reload(false);
tab_crashed_ = false;
}
-void ContentViewImpl::ClearHistory(JNIEnv* env, jobject obj) {
+void ContentViewCoreImpl::ClearHistory(JNIEnv* env, jobject obj) {
web_contents_->GetController().PruneAllButActive();
}
-jboolean ContentViewImpl::NeedsReload(JNIEnv* env, jobject obj) {
+jboolean ContentViewCoreImpl::NeedsReload(JNIEnv* env, jobject obj) {
return web_contents_->GetController().NeedsReload();
}
-void ContentViewImpl::SetClient(JNIEnv* env, jobject obj, jobject jclient) {
+void ContentViewCoreImpl::SetClient(JNIEnv* env, jobject obj, jobject jclient) {
scoped_ptr<ContentViewClient> client(
ContentViewClient::CreateNativeContentViewClient(env, jclient));
@@ -191,7 +192,7 @@ void ContentViewImpl::SetClient(JNIEnv* env, jobject obj, jobject jclient) {
// Methods called from native code
// --------------------------------------------------------------------------
-void ContentViewImpl::LoadUrl(const GURL& url, int page_transition) {
+void ContentViewCoreImpl::LoadUrl(const GURL& url, int page_transition) {
content::Referrer referer;
web_contents()->GetController().LoadURL(
@@ -200,7 +201,7 @@ void ContentViewImpl::LoadUrl(const GURL& url, int page_transition) {
PostLoadUrl(url);
}
-void ContentViewImpl::LoadUrlWithUserAgentOverride(
+void ContentViewCoreImpl::LoadUrlWithUserAgentOverride(
const GURL& url,
int page_transition,
const std::string& user_agent_override) {
@@ -213,7 +214,7 @@ void ContentViewImpl::LoadUrlWithUserAgentOverride(
PostLoadUrl(url);
}
-void ContentViewImpl::PostLoadUrl(const GURL& url) {
+void ContentViewCoreImpl::PostLoadUrl(const GURL& url) {
tab_crashed_ = false;
// TODO(tedchoc): Update the content view client of the page load request.
}
@@ -222,9 +223,9 @@ void ContentViewImpl::PostLoadUrl(const GURL& url) {
// Native JNI methods
// ----------------------------------------------------------------------------
-// This is called for each ContentView.
-static jint Init(JNIEnv* env, jobject obj, jint native_web_contents) {
- ContentView* view = ContentView::Create(
+// This is called for each ContentViewCore.
+jint Init(JNIEnv* env, jobject obj, jint native_web_contents) {
+ ContentViewCore* view = ContentViewCore::Create(
env, obj, reinterpret_cast<WebContents*>(native_web_contents));
return reinterpret_cast<jint>(view);
}
@@ -233,24 +234,24 @@ static jint Init(JNIEnv* env, jobject obj, jint native_web_contents) {
// Public methods that call to Java via JNI
// --------------------------------------------------------------------------
-void ContentViewImpl::OnTabCrashed(const base::ProcessHandle handle) {
+void ContentViewCoreImpl::OnTabCrashed(const base::ProcessHandle handle) {
NOTIMPLEMENTED() << "not upstreamed yet";
}
-void ContentViewImpl::SetTitle(const string16& title) {
+void ContentViewCoreImpl::SetTitle(const string16& title) {
NOTIMPLEMENTED() << "not upstreamed yet";
}
-bool ContentViewImpl::HasFocus() {
+bool ContentViewCoreImpl::HasFocus() {
NOTIMPLEMENTED() << "not upstreamed yet";
return false;
}
-void ContentViewImpl::OnSelectionChanged(const std::string& text) {
+void ContentViewCoreImpl::OnSelectionChanged(const std::string& text) {
NOTIMPLEMENTED() << "not upstreamed yet";
}
-void ContentViewImpl::OnSelectionBoundsChanged(
+void ContentViewCoreImpl::OnSelectionBoundsChanged(
int startx,
int starty,
base::i18n::TextDirection start_dir,
@@ -260,18 +261,18 @@ void ContentViewImpl::OnSelectionBoundsChanged(
NOTIMPLEMENTED() << "not upstreamed yet";
}
-void ContentViewImpl::OnAcceleratedCompositingStateChange(
+void ContentViewCoreImpl::OnAcceleratedCompositingStateChange(
RenderWidgetHostViewAndroid* rwhva, bool activated, bool force) {
NOTIMPLEMENTED() << "not upstreamed yet";
}
-void ContentViewImpl::StartContentIntent(const GURL& content_url) {
+void ContentViewCoreImpl::StartContentIntent(const GURL& content_url) {
JNIEnv* env = AttachCurrentThread();
ScopedJavaLocalRef<jstring> jcontent_url =
ConvertUTF8ToJavaString(env, content_url.spec());
- Java_ContentView_startContentIntent(env,
- java_object_->View(env).obj(),
- jcontent_url.obj());
+ Java_ContentViewCore_startContentIntent(env,
+ java_object_->View(env).obj(),
+ jcontent_url.obj());
}
// --------------------------------------------------------------------------
@@ -282,24 +283,24 @@ void ContentViewImpl::StartContentIntent(const GURL& content_url) {
// Methods called from native code
// --------------------------------------------------------------------------
-gfx::Rect ContentViewImpl::GetBounds() const {
+gfx::Rect ContentViewCoreImpl::GetBounds() const {
NOTIMPLEMENTED() << "not upstreamed yet";
return gfx::Rect();
}
// ----------------------------------------------------------------------------
-bool RegisterContentView(JNIEnv* env) {
- if (!base::android::HasClass(env, kContentViewClassPath)) {
- DLOG(ERROR) << "Unable to find class ContentView!";
+bool RegisterContentViewCore(JNIEnv* env) {
+ if (!base::android::HasClass(env, kContentViewCoreClassPath)) {
+ DLOG(ERROR) << "Unable to find class ContentViewCore!";
return false;
}
- ScopedJavaLocalRef<jclass> clazz = GetClass(env, kContentViewClassPath);
- if (!HasField(env, clazz, "mNativeContentView", "I")) {
- DLOG(ERROR) << "Unable to find ContentView.mNativeContentView!";
+ ScopedJavaLocalRef<jclass> clazz = GetClass(env, kContentViewCoreClassPath);
+ if (!HasField(env, clazz, "mNativeContentViewCore", "I")) {
+ DLOG(ERROR) << "Unable to find ContentView.mNativeContentViewCore!";
return false;
}
- g_native_content_view = GetFieldID(env, clazz, "mNativeContentView", "I");
+ g_native_content_view = GetFieldID(env, clazz, "mNativeContentViewCore", "I");
return RegisterNativesImpl(env) >= 0;
}
diff --git a/content/browser/android/content_view_impl.h b/content/browser/android/content_view_core_impl.h
index 858c64e..46c00d4 100644
--- a/content/browser/android/content_view_impl.h
+++ b/content/browser/android/content_view_core_impl.h
@@ -2,8 +2,8 @@
// 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_IMPL_H_
-#define CONTENT_BROWSER_ANDROID_CONTENT_VIEW_IMPL_H_
+#ifndef CONTENT_BROWSER_ANDROID_CONTENT_VIEW_CORE_IMPL_H_
+#define CONTENT_BROWSER_ANDROID_CONTENT_VIEW_CORE_IMPL_H_
#include "base/android/jni_helper.h"
#include "base/basictypes.h"
@@ -11,7 +11,7 @@
#include "base/i18n/rtl.h"
#include "base/memory/scoped_ptr.h"
#include "base/process.h"
-#include "content/public/browser/android/content_view.h"
+#include "content/public/browser/android/content_view_core.h"
#include "content/public/browser/notification_observer.h"
#include "googleurl/src/gurl.h"
#include "ui/gfx/rect.h"
@@ -21,12 +21,12 @@ class ContentViewClient;
class RenderWidgetHostViewAndroid;
// TODO(jrg): this is a shell. Upstream the rest.
-class ContentViewImpl : public ContentView,
- public NotificationObserver {
+class ContentViewCoreImpl : public ContentViewCore,
+ public NotificationObserver {
public:
- ContentViewImpl(JNIEnv* env,
- jobject obj,
- WebContents* web_contents);
+ ContentViewCoreImpl(JNIEnv* env,
+ jobject obj,
+ WebContents* web_contents);
virtual void Destroy(JNIEnv* env, jobject obj);
// --------------------------------------------------------------------------
@@ -102,7 +102,7 @@ class ContentViewImpl : public ContentView,
// --------------------------------------------------------------------------
// Private methods that call to Java via JNI
// --------------------------------------------------------------------------
- virtual ~ContentViewImpl();
+ virtual ~ContentViewCoreImpl();
// --------------------------------------------------------------------------
// Other private methods and data
@@ -116,20 +116,20 @@ class ContentViewImpl : public ContentView,
JavaObject* java_object_;
// Reference to the current WebContents used to determine how and what to
- // display in the ContentView.
+ // display in the ContentViewCore.
WebContents* 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 ContentView has crashed.
+ // Whether the renderer backing this ContentViewCore has crashed.
bool tab_crashed_;
- DISALLOW_COPY_AND_ASSIGN(ContentViewImpl);
+ DISALLOW_COPY_AND_ASSIGN(ContentViewCoreImpl);
};
-bool RegisterContentView(JNIEnv* env);
+bool RegisterContentViewCore(JNIEnv* env);
}; // namespace content
-#endif // CONTENT_BROWSER_ANDROID_CONTENT_VIEW_IMPL_H_
+#endif // CONTENT_BROWSER_ANDROID_CONTENT_VIEW_CORE_IMPL_H_
diff --git a/content/browser/android/download_controller.cc b/content/browser/android/download_controller.cc
index ccd3996..ca6b90a 100644
--- a/content/browser/android/download_controller.cc
+++ b/content/browser/android/download_controller.cc
@@ -9,6 +9,7 @@
#include "base/bind.h"
#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
+#include "content/browser/android/content_view_core_impl.h"
#include "content/browser/download/download_item_impl.h"
#include "content/browser/renderer_host/render_process_host_impl.h"
#include "content/browser/renderer_host/render_view_host_delegate.h"
@@ -218,7 +219,7 @@ void DownloadController::OnPostDownloadStarted(
// Register for updates to the DownloadItem.
download_item->AddObserver(this);
- jobject view = GetContentViewFromWebContents(web_contents);
+ jobject view = GetContentViewCoreFromWebContents(web_contents);
if(!view) {
// The view went away. Can't proceed.
return;
@@ -245,14 +246,14 @@ void DownloadController::OnDownloadUpdated(DownloadItem* item) {
ScopedJavaLocalRef<jstring> jpath =
ConvertUTF8ToJavaString(env, item->GetFullPath().value());
- jobject view = GetContentViewFromWebContents(item->GetWebContents());
- if(!view) {
+ jobject view_core = GetContentViewCoreFromWebContents(item->GetWebContents());
+ if (!view_core) {
// We can get NULL WebContents from the DownloadItem.
return;
}
Java_DownloadController_onHttpPostDownloadCompleted(env,
- GetJavaObject()->Controller(env).obj(), view, jurl.obj(),
+ GetJavaObject()->Controller(env).obj(), view_core, jurl.obj(),
jcontent_disposition.obj(), jmime_type.obj(), jpath.obj(),
item->GetReceivedBytes(), true);
}
@@ -274,10 +275,10 @@ jobject DownloadController::GetContentView(int render_process_id,
if (!web_contents)
return NULL;
- return GetContentViewFromWebContents(web_contents);
+ return GetContentViewCoreFromWebContents(web_contents);
}
-jobject DownloadController::GetContentViewFromWebContents(
+jobject DownloadController::GetContentViewCoreFromWebContents(
WebContents* web_contents) {
NOTIMPLEMENTED();
return NULL;
diff --git a/content/browser/android/download_controller.h b/content/browser/android/download_controller.h
index 431aef9..a11ed17 100644
--- a/content/browser/android/download_controller.h
+++ b/content/browser/android/download_controller.h
@@ -109,7 +109,7 @@ class DownloadController : public DownloadItem::Observer {
int render_process_id,
int render_view_id);
- jobject GetContentViewFromWebContents(WebContents* web_contents);
+ jobject GetContentViewCoreFromWebContents(WebContents* web_contents);
jobject GetContentView(int render_process_id, int render_view_id);
// Creates Java object if it is not created already and returns it.
diff --git a/content/browser/renderer_host/render_widget_host_view_android.cc b/content/browser/renderer_host/render_widget_host_view_android.cc
index 83c702b..d39f6a6 100644
--- a/content/browser/renderer_host/render_widget_host_view_android.cc
+++ b/content/browser/renderer_host/render_widget_host_view_android.cc
@@ -7,7 +7,7 @@
#include "base/logging.h"
#include "base/message_loop.h"
#include "base/utf_string_conversions.h"
-#include "content/browser/android/content_view_impl.h"
+#include "content/browser/android/content_view_core_impl.h"
#include "content/browser/gpu/gpu_surface_tracker.h"
#include "content/browser/renderer_host/render_widget_host_impl.h"
#include "content/common/android/device_info.h"
@@ -17,13 +17,13 @@ namespace content {
RenderWidgetHostViewAndroid::RenderWidgetHostViewAndroid(
RenderWidgetHostImpl* widget_host,
- ContentViewImpl* content_view)
+ ContentViewCoreImpl* content_view_core)
: host_(widget_host),
- // ContentViewImpl represents the native side of the Java ContentView.
- // It being NULL means that it is not attached to the View system yet,
- // so we treat it as hidden.
- is_hidden_(!content_view),
- content_view_(content_view) {
+ // ContentViewCoreImpl represents the native side of the Java
+ // ContentViewCore. It being NULL means that it is not attached to the
+ // View system yet, so we treat it as hidden.
+ is_hidden_(!content_view_core),
+ content_view_core_(content_view_core) {
host_->SetView(this);
// RenderWidgetHost is initialized as visible. If is_hidden_ is true, tell
// RenderWidgetHost to hide.
@@ -92,7 +92,7 @@ void RenderWidgetHostViewAndroid::SetBounds(const gfx::Rect& rect) {
}
gfx::NativeView RenderWidgetHostViewAndroid::GetNativeView() const {
- return content_view_;
+ return content_view_core_;
}
gfx::NativeViewId RenderWidgetHostViewAndroid::GetNativeViewId() const {
@@ -126,10 +126,10 @@ void RenderWidgetHostViewAndroid::Blur() {
}
bool RenderWidgetHostViewAndroid::HasFocus() const {
- if (!content_view_)
- return false; // ContentView not created yet.
+ if (!content_view_core_)
+ return false; // ContentViewCore not created yet.
- return content_view_->HasFocus();
+ return content_view_core_->HasFocus();
}
bool RenderWidgetHostViewAndroid::IsSurfaceAvailableForCopy() const {
@@ -150,10 +150,10 @@ bool RenderWidgetHostViewAndroid::IsShowing() {
}
gfx::Rect RenderWidgetHostViewAndroid::GetViewBounds() const {
- if (content_view_) {
- return content_view_->GetBounds();
+ if (content_view_core_) {
+ return content_view_core_->GetBounds();
} else {
- // The ContentView has not been created yet. This only happens when
+ // The ContentViewCore has not been created yet. This only happens when
// renderer asks for creating new window, for example,
// javascript window.open().
return gfx::Rect(0, 0, 0, 0);
@@ -194,7 +194,7 @@ void RenderWidgetHostViewAndroid::RenderViewGone(
}
void RenderWidgetHostViewAndroid::Destroy() {
- content_view_ = NULL;
+ content_view_core_ = NULL;
// The RenderWidgetHost's destruction led here, so don't call it.
host_ = NULL;
@@ -212,7 +212,7 @@ void RenderWidgetHostViewAndroid::SelectionChanged(const string16& text,
const ui::Range& range) {
RenderWidgetHostViewBase::SelectionChanged(text, offset, range);
- if (text.empty() || range.is_empty() || !content_view_)
+ if (text.empty() || range.is_empty() || !content_view_core_)
return;
size_t pos = range.GetMin() - offset;
size_t n = range.length();
@@ -225,7 +225,7 @@ void RenderWidgetHostViewAndroid::SelectionChanged(const string16& text,
std::string utf8_selection = UTF16ToUTF8(text.substr(pos, n));
- content_view_->OnSelectionChanged(utf8_selection);
+ content_view_core_->OnSelectionChanged(utf8_selection);
}
BackingStore* RenderWidgetHostViewAndroid::AllocBackingStore(
@@ -249,8 +249,9 @@ void RenderWidgetHostViewAndroid::CopyFromCompositingSurface(
void RenderWidgetHostViewAndroid::OnAcceleratedCompositingStateChange() {
const bool activated = host_->is_accelerated_compositing_active();
- if (content_view_)
- content_view_->OnAcceleratedCompositingStateChange(this, activated, false);
+ if (content_view_core_)
+ content_view_core_->OnAcceleratedCompositingStateChange(
+ this, activated, false);
}
void RenderWidgetHostViewAndroid::AcceleratedSurfaceBuffersSwapped(
@@ -277,8 +278,8 @@ bool RenderWidgetHostViewAndroid::HasAcceleratedSurface(
void RenderWidgetHostViewAndroid::StartContentIntent(
const GURL& content_url) {
- if (content_view_)
- content_view_->StartContentIntent(content_url);
+ if (content_view_core_)
+ content_view_core_->StartContentIntent(content_url);
}
gfx::GLSurfaceHandle RenderWidgetHostViewAndroid::GetCompositingSurface() {
@@ -328,12 +329,12 @@ void RenderWidgetHostViewAndroid::UnlockMouse() {
NOTIMPLEMENTED();
}
-void RenderWidgetHostViewAndroid::SetContentView(
- ContentViewImpl* content_view) {
- content_view_ = content_view;
+void RenderWidgetHostViewAndroid::SetContentViewCore(
+ ContentViewCoreImpl* content_view_core) {
+ content_view_core_ = content_view_core;
if (host_) {
GpuSurfaceTracker::Get()->SetSurfaceHandle(
- host_->surface_id(), content_view_ ?
+ host_->surface_id(), content_view_core_ ?
GetCompositingSurface() : gfx::GLSurfaceHandle());
}
}
diff --git a/content/browser/renderer_host/render_widget_host_view_android.h b/content/browser/renderer_host/render_widget_host_view_android.h
index 5c155fa..dd48b8b 100644
--- a/content/browser/renderer_host/render_widget_host_view_android.h
+++ b/content/browser/renderer_host/render_widget_host_view_android.h
@@ -17,7 +17,7 @@ struct GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params;
struct GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params;
namespace content {
-class ContentViewImpl;
+class ContentViewCoreImpl;
class RenderWidgetHost;
class RenderWidgetHostImpl;
struct NativeWebKeyboardEvent;
@@ -28,7 +28,7 @@ struct NativeWebKeyboardEvent;
class RenderWidgetHostViewAndroid : public RenderWidgetHostViewBase {
public:
RenderWidgetHostViewAndroid(RenderWidgetHostImpl* widget,
- ContentViewImpl* content_view);
+ ContentViewCoreImpl* content_view_core);
virtual ~RenderWidgetHostViewAndroid();
// RenderWidgetHostView implementation.
@@ -103,7 +103,7 @@ class RenderWidgetHostViewAndroid : public RenderWidgetHostViewBase {
virtual void StartContentIntent(const GURL& content_url) OVERRIDE;
- void SetContentView(ContentViewImpl* content_view);
+ void SetContentViewCore(ContentViewCoreImpl* content_view_core);
private:
// The model object.
@@ -112,8 +112,8 @@ class RenderWidgetHostViewAndroid : public RenderWidgetHostViewBase {
// Whether or not this widget is hidden.
bool is_hidden_;
- // ContentViewImpl is our interface to the view system.
- ContentViewImpl* content_view_;
+ // ContentViewCoreImpl is our interface to the view system.
+ ContentViewCoreImpl* content_view_core_;
// The size that we want the renderer to be. We keep this in a separate
// variable because resizing is async.
diff --git a/content/browser/web_contents/web_contents_view_android.cc b/content/browser/web_contents/web_contents_view_android.cc
index 62e3bf2..c628183 100644
--- a/content/browser/web_contents/web_contents_view_android.cc
+++ b/content/browser/web_contents/web_contents_view_android.cc
@@ -5,7 +5,7 @@
#include "content/browser/web_contents/web_contents_view_android.h"
#include "base/logging.h"
-#include "content/browser/android/content_view_impl.h"
+#include "content/browser/android/content_view_core_impl.h"
#include "content/browser/renderer_host/render_widget_host_view_android.h"
#include "content/browser/renderer_host/render_view_host_factory.h"
#include "content/browser/renderer_host/render_view_host_impl.h"
@@ -34,13 +34,13 @@ WebContentsViewAndroid::WebContentsViewAndroid(
WebContentsViewAndroid::~WebContentsViewAndroid() {
}
-void WebContentsViewAndroid::SetContentView(
- ContentViewImpl* content_view) {
- content_view_ = content_view;
+void WebContentsViewAndroid::SetContentViewCore(
+ ContentViewCoreImpl* content_view_core) {
+ content_view_core_ = content_view_core;
RenderWidgetHostViewAndroid* rwhv = static_cast<RenderWidgetHostViewAndroid*>(
web_contents_->GetRenderWidgetHostView());
if (rwhv)
- rwhv->SetContentView(content_view_);
+ rwhv->SetContentViewCore(content_view_core_);
if (web_contents_->ShowingInterstitialPage()) {
NOTIMPLEMENTED() << "not upstreamed yet";
}
@@ -66,29 +66,29 @@ RenderWidgetHostView* WebContentsViewAndroid::CreateViewForWidget(
// order to paint it. See ContentView::GetRenderWidgetHostViewAndroid for an
// example of how this is achieved for InterstitialPages.
RenderWidgetHostImpl* rwhi = RenderWidgetHostImpl::From(render_widget_host);
- return new RenderWidgetHostViewAndroid(rwhi, content_view_);
+ return new RenderWidgetHostViewAndroid(rwhi, content_view_core_);
}
gfx::NativeView WebContentsViewAndroid::GetNativeView() const {
- return content_view_;
+ return content_view_core_;
}
gfx::NativeView WebContentsViewAndroid::GetContentNativeView() const {
- return content_view_;
+ return content_view_core_;
}
gfx::NativeWindow WebContentsViewAndroid::GetTopLevelNativeWindow() const {
- return content_view_;
+ return content_view_core_;
}
void WebContentsViewAndroid::GetContainerBounds(gfx::Rect* out) const {
- if (content_view_)
- *out = content_view_->GetBounds();
+ if (content_view_core_)
+ *out = content_view_core_->GetBounds();
}
void WebContentsViewAndroid::SetPageTitle(const string16& title) {
- if (content_view_)
- content_view_->SetTitle(title);
+ if (content_view_core_)
+ content_view_core_->SetTitle(title);
}
void WebContentsViewAndroid::OnTabCrashed(base::TerminationStatus status,
@@ -152,8 +152,8 @@ void WebContentsViewAndroid::CloseTabAfterEventTracking() {
}
gfx::Rect WebContentsViewAndroid::GetViewBounds() const {
- if (content_view_)
- return content_view_->GetBounds();
+ if (content_view_core_)
+ return content_view_core_->GetBounds();
else
return gfx::Rect();
}
diff --git a/content/browser/web_contents/web_contents_view_android.h b/content/browser/web_contents/web_contents_view_android.h
index e7aba5b..c38ec34 100644
--- a/content/browser/web_contents/web_contents_view_android.h
+++ b/content/browser/web_contents/web_contents_view_android.h
@@ -13,7 +13,7 @@
#include "content/public/common/context_menu_params.h"
namespace content {
-class ContentViewImpl;
+class ContentViewCoreImpl;
// Android-specific implementation of the WebContentsView.
class WebContentsViewAndroid : public WebContentsView,
@@ -23,10 +23,10 @@ class WebContentsViewAndroid : public WebContentsView,
WebContentsViewDelegate* delegate);
virtual ~WebContentsViewAndroid();
- // Sets the interface to the view system. ContentViewImpl is owned
- // by its Java ContentView counterpart, whose lifetime is managed
+ // Sets the interface to the view system. ContentViewCoreImpl is owned
+ // by its Java ContentViewCore counterpart, whose lifetime is managed
// by the UI frontend.
- void SetContentView(ContentViewImpl* content_view);
+ void SetContentViewCore(ContentViewCoreImpl* content_view_core);
// WebContentsView implementation --------------------------------------------
@@ -74,8 +74,8 @@ class WebContentsViewAndroid : public WebContentsView,
// The WebContents whose contents we display.
WebContentsImpl* web_contents_;
- // ContentViewImpl is our interface to the view system.
- ContentViewImpl* content_view_;
+ // ContentViewCoreImpl is our interface to the view system.
+ ContentViewCoreImpl* content_view_core_;
// Interface for extensions to WebContentsView. Used to show the context menu.
scoped_ptr<WebContentsViewDelegate> delegate_;
diff --git a/content/content_browser.gypi b/content/content_browser.gypi
index 513a7b0..37ab59f 100644
--- a/content/content_browser.gypi
+++ b/content/content_browser.gypi
@@ -30,6 +30,7 @@
'port/browser/render_view_host_delegate_view.h',
'port/browser/render_widget_host_view_port.h',
'public/browser/access_token_store.h',
+ 'public/browser/android/content_view_core.h',
'public/browser/browser_accessibility_state.h',
'public/browser/browser_child_process_host.h',
'public/browser/browser_child_process_host_delegate.cc',
@@ -53,7 +54,6 @@
'public/browser/content_browser_client.cc',
'public/browser/content_browser_client.h',
'public/browser/content_ipc_logging.h',
- 'public/browser/android/content_view.h',
'public/browser/devtools_agent_host_registry.h',
'public/browser/devtools_client_host.h',
'public/browser/download_danger_type.h',
@@ -198,8 +198,8 @@
'browser/android/content_util.h',
'browser/android/content_view_client.cc',
'browser/android/content_view_client.h',
- 'browser/android/content_view_impl.cc',
- 'browser/android/content_view_impl.h',
+ 'browser/android/content_view_core_impl.cc',
+ 'browser/android/content_view_core_impl.h',
'browser/android/download_controller.cc',
'browser/android/download_controller.h',
'browser/android/ime_utils.cc',
diff --git a/content/content_jni.gypi b/content/content_jni.gypi
index 31acf33..e85a7c0 100644
--- a/content/content_jni.gypi
+++ b/content/content_jni.gypi
@@ -15,8 +15,8 @@
'public/android/java/src/org/chromium/content/app/UserAgent.java',
'public/android/java/src/org/chromium/content/browser/AndroidBrowserProcess.java',
'public/android/java/src/org/chromium/content/browser/ContentSettings.java',
- 'public/android/java/src/org/chromium/content/browser/ContentView.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/DeviceOrientation.java',
'public/android/java/src/org/chromium/content/browser/DownloadController.java',
'public/android/java/src/org/chromium/content/browser/LocationProvider.java',
@@ -35,8 +35,8 @@
'<(SHARED_INTERMEDIATE_DIR)/content/jni/user_agent_jni.h',
'<(SHARED_INTERMEDIATE_DIR)/content/jni/android_browser_process_jni.h',
'<(SHARED_INTERMEDIATE_DIR)/content/jni/content_settings_jni.h',
- '<(SHARED_INTERMEDIATE_DIR)/content/jni/content_view_jni.h',
'<(SHARED_INTERMEDIATE_DIR)/content/jni/content_view_client_jni.h',
+ '<(SHARED_INTERMEDIATE_DIR)/content/jni/content_view_core_jni.h',
'<(SHARED_INTERMEDIATE_DIR)/content/jni/device_orientation_jni.h',
'<(SHARED_INTERMEDIATE_DIR)/content/jni/download_controller_jni.h',
'<(SHARED_INTERMEDIATE_DIR)/content/jni/location_provider_jni.h',
diff --git a/content/public/android/java/src/org/chromium/content/browser/ContentSettings.java b/content/public/android/java/src/org/chromium/content/browser/ContentSettings.java
index 3aa627a..f191230 100644
--- a/content/public/android/java/src/org/chromium/content/browser/ContentSettings.java
+++ b/content/public/android/java/src/org/chromium/content/browser/ContentSettings.java
@@ -29,7 +29,7 @@ public class ContentSettings {
private int mNativeContentSettings = 0;
- private ContentView mContentView;
+ private ContentViewCore mContentViewCore;
// When ContentView is used in PERSONALITY_CHROME mode, settings can't
// be modified through the ContentSettings instance.
@@ -84,7 +84,7 @@ public class ContentSettings {
private Handler mHandler;
EventHandler() {
- mHandler = mContentView.isPersonalityView() ?
+ mHandler = mContentViewCore.isPersonalityView() ?
new Handler() {
@Override
public void handleMessage(Message msg) {
@@ -96,13 +96,13 @@ public class ContentSettings {
}
break;
case UPDATE_UA:
- synchronized (mContentView) {
- mContentView.setAllUserAgentOverridesInHistory();
+ synchronized (mContentViewCore) {
+ mContentViewCore.setAllUserAgentOverridesInHistory();
}
break;
case UPDATE_MULTI_TOUCH:
- synchronized (mContentView) {
- mContentView.updateMultiTouchZoomSupport();
+ synchronized (mContentViewCore) {
+ mContentViewCore.updateMultiTouchZoomSupport();
}
break;
}
@@ -140,10 +140,10 @@ public class ContentSettings {
* Package constructor to prevent clients from creating a new settings
* instance. Must be called on the UI thread.
*/
- ContentSettings(ContentView contentView, int nativeContentView) {
+ ContentSettings(ContentViewCore contentViewCore, int nativeContentView) {
ThreadUtils.assertOnUiThread();
- mContentView = contentView;
- mCanModifySettings = mContentView.isPersonalityView();
+ mContentViewCore = contentViewCore;
+ mCanModifySettings = mContentViewCore.isPersonalityView();
mNativeContentSettings = nativeInit(nativeContentView, mCanModifySettings);
assert mNativeContentSettings != 0;
diff --git a/content/public/android/java/src/org/chromium/content/browser/ContentView.java b/content/public/android/java/src/org/chromium/content/browser/ContentView.java
index 893fdff..e99a348 100644
--- a/content/public/android/java/src/org/chromium/content/browser/ContentView.java
+++ b/content/public/android/java/src/org/chromium/content/browser/ContentView.java
@@ -5,20 +5,23 @@
package org.chromium.content.browser;
import android.content.Context;
+import android.content.res.Configuration;
+import android.graphics.Canvas;
import android.util.AttributeSet;
-import android.util.Log;
+import android.view.KeyEvent;
+import android.view.MotionEvent;
import android.view.View;
import android.webkit.DownloadListener;
import android.widget.FrameLayout;
-import org.chromium.base.CalledByNative;
-import org.chromium.base.JNINamespace;
-import org.chromium.base.WeakContext;
-import org.chromium.content.app.AppResource;
-import org.chromium.content.common.TraceEvent;
-
-@JNINamespace("content")
-public class ContentView extends FrameLayout {
+/**
+ * The containing view for {@link ContentViewCore} that exists in the Android UI hierarchy and
+ * exposes the various {@link View} functionality to it.
+ *
+ * TODO(joth): Remove any methods overrides from this class that were added for WebView
+ * compatibility.
+ */
+public class ContentView extends FrameLayout implements ContentViewCore.InternalAccessDelegate {
// The following constants match the ones in chrome/common/page_transition_types.h.
// Add more if you need them.
@@ -27,14 +30,20 @@ public class ContentView extends FrameLayout {
public static final int PAGE_TRANSITION_AUTO_BOOKMARK = 2;
public static final int PAGE_TRANSITION_START_PAGE = 6;
- private static final String TAG = "ContentView";
+ /** Translate the find selection into a normal selection. */
+ public static final int FIND_SELECTION_ACTION_KEEP_SELECTION =
+ ContentViewCore.FIND_SELECTION_ACTION_KEEP_SELECTION;
+ /** Clear the find selection. */
+ public static final int FIND_SELECTION_ACTION_CLEAR_SELECTION =
+ ContentViewCore.FIND_SELECTION_ACTION_CLEAR_SELECTION;
+ /** Focus and click the selected node (for links). */
+ public static final int FIND_SELECTION_ACTION_ACTIVATE_SELECTION =
+ ContentViewCore.FIND_SELECTION_ACTION_ACTIVATE_SELECTION;
- // Personality of the ContentView.
- private int mPersonality;
// Used when ContentView implements a standalone View.
- public static final int PERSONALITY_VIEW = 0;
+ public static final int PERSONALITY_VIEW = ContentViewCore.PERSONALITY_VIEW;
// Used for Chrome.
- public static final int PERSONALITY_CHROME = 1;
+ public static final int PERSONALITY_CHROME = ContentViewCore.PERSONALITY_CHROME;
/**
* Automatically decide the number of renderer processes to use based on device memory class.
@@ -45,40 +54,10 @@ public class ContentView extends FrameLayout {
*/
public static final int MAX_RENDERERS_SINGLE_PROCESS =
AndroidBrowserProcess.MAX_RENDERERS_SINGLE_PROCESS;
-
- // Used to avoid enabling zooming in / out in WebView zoom controls
- // if resulting zooming will produce little visible difference.
- private static float WEBVIEW_ZOOM_CONTROLS_EPSILON = 0.007f;
-
- // content_view_client.cc depends on ContentView.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;
-
- // Native pointer to C++ ContentView object which will be set by nativeInit()
- private int mNativeContentView = 0;
-
- private ZoomManager mZoomManager;
-
- // Cached page scale factor from native
- private float mNativePageScaleFactor = 1.0f;
- private float mNativeMinimumScale = 1.0f;
- private float mNativeMaximumScale = 1.0f;
-
- // TODO(klobag): this is to avoid a bug in GestureDetector. With multi-touch,
- // mAlwaysInTapRegion is not reset. So when the last finger is up, onSingleTapUp()
- // will be mistakenly fired.
- private boolean mIgnoreSingleTap;
-
- // The legacy webview DownloadListener.
- private DownloadListener mDownloadListener;
- // ContentViewDownloadDelegate adds support for authenticated downloads
- // and POST downloads. Embedders should prefer ContentViewDownloadDelegate
- // over DownloadListener.
- private ContentViewDownloadDelegate mDownloadDelegate;
+ /**
+ * Cap on the maximum number of renderer processes that can be requested.
+ */
+ public static final int MAX_RENDERERS_LIMIT = AndroidBrowserProcess.MAX_RENDERERS_LIMIT;
/**
* Enable multi-process ContentView. This should be called by the application before
@@ -96,69 +75,66 @@ public class ContentView extends FrameLayout {
* maximum number of allowed renderers is capped by MAX_RENDERERS_LIMIT.
*/
public static void enableMultiProcess(Context context, int maxRendererProcesses) {
- AndroidBrowserProcess.initContentViewProcess(context, maxRendererProcesses);
+ ContentViewCore.enableMultiProcess(context, maxRendererProcesses);
}
+ /**
+ * Initialize the process as the platform browser. This must be called before accessing
+ * ContentView in order to treat this as a Chromium browser process.
+ *
+ * @param context Context used to obtain the application context.
+ * @param maxRendererProcesses Same as ContentView.enableMultiProcess()
+ * @hide Only used by the platform browser.
+ */
+ public static void initChromiumBrowserProcess(Context context, int maxRendererProcesses) {
+ ContentViewCore.initChromiumBrowserProcess(context, maxRendererProcesses);
+ }
+
+ private ContentViewCore mContentViewCore;
+
public ContentView(Context context, int nativeWebContents, int personality) {
this(context, nativeWebContents, null, android.R.attr.webViewStyle, personality);
}
+ public ContentView(Context context, int nativeWebContents, AttributeSet attrs) {
+ // TODO(klobag): use the WebViewStyle as the default style for now. It enables scrollbar.
+ // When ContentView is moved to framework, we can define its own style in the res.
+ this(context, nativeWebContents, attrs, android.R.attr.webViewStyle);
+ }
+
+ public ContentView(Context context, int nativeWebContents, AttributeSet attrs, int defStyle) {
+ this(context, nativeWebContents, attrs, defStyle, PERSONALITY_VIEW);
+ }
+
private ContentView(Context context, int nativeWebContents, AttributeSet attrs, int defStyle,
int personality) {
super(context, attrs, defStyle);
- WeakContext.initializeWeakContext(context);
- // By default, ContentView will initialize single process mode. The call to
- // initContentViewProcess below is ignored if either the ContentView host called
- // enableMultiProcess() or the platform browser called initChromiumBrowserProcess().
- AndroidBrowserProcess.initContentViewProcess(context, MAX_RENDERERS_SINGLE_PROCESS);
-
- initialize(context, nativeWebContents, personality);
+ mContentViewCore = new ContentViewCore(context, this, this, nativeWebContents, personality);
}
- // TODO(jrg): incomplete; upstream the rest of this method.
- private void initialize(Context context, int nativeWebContents, int personality) {
- mNativeContentView = nativeInit(nativeWebContents);
-
- mPersonality = personality;
- mContentSettings = new ContentSettings(this, mNativeContentView);
-
- initGestureDetectors(context);
-
- Log.i(TAG, "mNativeContentView=0x"+ Integer.toHexString(mNativeContentView));
+ /**
+ * @return The core component of the ContentView that handles JNI communication. Should only be
+ * used for passing to native.
+ */
+ public ContentViewCore getContentViewCore() {
+ return mContentViewCore;
}
/**
* @return Whether the configured personality of this ContentView is {@link #PERSONALITY_VIEW}.
*/
boolean isPersonalityView() {
- switch (mPersonality) {
- case PERSONALITY_VIEW:
- return true;
- case PERSONALITY_CHROME:
- return false;
- default:
- Log.e(TAG, "Unknown ContentView personality: " + mPersonality);
- return false;
- }
+ return mContentViewCore.isPersonalityView();
}
-
/**
* Destroy the internal state of the WebView. This method may only be called
* after the WebView has been removed from the view system. No other methods
* may be called on this WebView after this method has been called.
*/
- // TODO(jrg): incomplete; upstream the rest of this method.
public void destroy() {
- if (mNativeContentView != 0) {
- nativeDestroy(mNativeContentView);
- mNativeContentView = 0;
- }
- if (mContentSettings != null) {
- mContentSettings.destroy();
- mContentSettings = null;
- }
+ mContentViewCore.destroy();
}
/**
@@ -166,30 +142,24 @@ public class ContentView extends FrameLayout {
* It is illegal to call any other public method after destroy().
*/
public boolean isAlive() {
- return mNativeContentView != 0;
+ return mContentViewCore.isAlive();
+ }
+
+ /**
+ * For internal use. Throws IllegalStateException if mNativeContentView is 0.
+ * Use this to ensure we get a useful Java stack trace, rather than a native
+ * crash dump, from use-after-destroy bugs in Java code.
+ */
+ void checkIsAlive() throws IllegalStateException {
+ mContentViewCore.checkIsAlive();
}
public void setContentViewClient(ContentViewClient client) {
- if (client == null) {
- throw new IllegalArgumentException("The client can't be null.");
- }
- mContentViewClient = client;
- if (mNativeContentView != 0) {
- nativeSetClient(mNativeContentView, mContentViewClient);
- }
+ mContentViewCore.setContentViewClient(client);
}
ContentViewClient getContentViewClient() {
- if (mContentViewClient == null) {
- // We use the Null Object pattern to avoid having to perform a null check in this class.
- // We create it lazily because most of the time a client will be set almost immediately
- // after ContentView is created.
- mContentViewClient = new ContentViewClient();
- // We don't set the native ContentViewClient pointer here on purpose. The native
- // implementation doesn't mind a null delegate and using one is better than passing a
- // Null Object, since we cut down on the number of JNI calls.
- }
- return mContentViewClient;
+ return mContentViewCore.getContentViewClient();
}
/**
@@ -214,33 +184,18 @@ public class ContentView extends FrameLayout {
* omnibox can report suggestions correctly.
*/
public void loadUrlWithoutUrlSanitization(String url, int pageTransition) {
- if (mNativeContentView != 0) {
- if (isPersonalityView()) {
- nativeLoadUrlWithoutUrlSanitizationWithUserAgentOverride(
- mNativeContentView,
- url,
- pageTransition,
- mContentSettings.getUserAgentString());
- } else {
- // Chrome stores overridden UA strings in navigation history
- // items, so they stay the same on going back / forward.
- nativeLoadUrlWithoutUrlSanitization(
- mNativeContentView,
- url,
- pageTransition);
- }
- }
+ mContentViewCore.loadUrlWithoutUrlSanitization(url, pageTransition);
}
void setAllUserAgentOverridesInHistory() {
- // TODO(tedchoc): Pass user agent override down to native.
+ mContentViewCore.setAllUserAgentOverridesInHistory();
}
/**
* Stops loading the current web contents.
*/
public void stopLoading() {
- if (mNativeContentView != 0) nativeStopLoading(mNativeContentView);
+ mContentViewCore.stopLoading();
}
/**
@@ -249,8 +204,7 @@ public class ContentView extends FrameLayout {
* @return The URL of the current page.
*/
public String getUrl() {
- if (mNativeContentView != 0) return nativeGetURL(mNativeContentView);
- return null;
+ return mContentViewCore.getUrl();
}
/**
@@ -259,32 +213,28 @@ public class ContentView extends FrameLayout {
* @return The title of the current page.
*/
public String getTitle() {
- if (mNativeContentView != 0) return nativeGetTitle(mNativeContentView);
- return null;
+ return mContentViewCore.getTitle();
}
/**
* @return The load progress of current web contents (range is 0 - 100).
*/
public int getProgress() {
- if (mNativeContentView != 0) {
- return (int) (100.0 * nativeGetLoadProgress(mNativeContentView));
- }
- return 100;
+ return mContentViewCore.getProgress();
}
/**
* @return Whether the current WebContents has a previous navigation entry.
*/
public boolean canGoBack() {
- return mNativeContentView != 0 && nativeCanGoBack(mNativeContentView);
+ return mContentViewCore.canGoBack();
}
/**
* @return Whether the current WebContents has a navigation entry after the current one.
*/
public boolean canGoForward() {
- return mNativeContentView != 0 && nativeCanGoForward(mNativeContentView);
+ return mContentViewCore.canGoForward();
}
/**
@@ -292,7 +242,7 @@ public class ContentView extends FrameLayout {
* @return Whether we can move in history by given offset
*/
public boolean canGoToOffset(int offset) {
- return mNativeContentView != 0 && nativeCanGoToOffset(mNativeContentView, offset);
+ return mContentViewCore.canGoToOffset(offset);
}
/**
@@ -301,28 +251,28 @@ public class ContentView extends FrameLayout {
* @param offset The offset into the navigation history.
*/
public void goToOffset(int offset) {
- if (mNativeContentView != 0) nativeGoToOffset(mNativeContentView, offset);
+ mContentViewCore.goToOffset(offset);
}
/**
* Goes to the navigation entry before the current one.
*/
public void goBack() {
- if (mNativeContentView != 0) nativeGoBack(mNativeContentView);
+ mContentViewCore.goBack();
}
/**
* Goes to the navigation entry following the current one.
*/
public void goForward() {
- if (mNativeContentView != 0) nativeGoForward(mNativeContentView);
+ mContentViewCore.goForward();
}
/**
* Reload the current page.
*/
public void reload() {
- if (mNativeContentView != 0) nativeReload(mNativeContentView);
+ mContentViewCore.reload();
}
/**
@@ -330,29 +280,25 @@ public class ContentView extends FrameLayout {
* directions.
*/
public void clearHistory() {
- if (mNativeContentView != 0) nativeClearHistory(mNativeContentView);
+ mContentViewCore.clearHistory();
}
/**
* Start pinch zoom. You must call {@link #pinchEnd} to stop.
*/
void pinchBegin(long timeMs, int x, int y) {
- if (mNativeContentView != 0) {
- // TODO(tedchoc): Pass pinch begin to native.
- }
+ mContentViewCore.pinchBegin(timeMs, x, y);
}
/**
* Stop pinch zoom.
*/
void pinchEnd(long timeMs) {
- if (mNativeContentView != 0) {
- // TODO(tedchoc): Pass pinch end to native.
- }
+ mContentViewCore.pinchEnd(timeMs);
}
void setIgnoreSingleTap(boolean value) {
- mIgnoreSingleTap = value;
+ mContentViewCore.setIgnoreSingleTap(value);
}
/**
@@ -368,9 +314,7 @@ public class ContentView extends FrameLayout {
* coordinate.
*/
void pinchBy(long timeMs, int anchorX, int anchorY, float delta) {
- if (mNativeContentView != 0) {
- // TODO(tedchoc): Pass pinch by to native.
- }
+ mContentViewCore.pinchBy(timeMs, anchorX, anchorY, delta);
}
/**
@@ -384,26 +328,41 @@ public class ContentView extends FrameLayout {
* settings.
*/
public ContentSettings getContentSettings() {
- return mContentSettings;
+ return mContentViewCore.getContentSettings();
+ }
+
+ // FrameLayout overrides.
+
+ // Needed by ContentViewCore.InternalAccessDelegate
+ @Override
+ public boolean drawChild(Canvas canvas, View child, long drawingTime) {
+ return super.drawChild(canvas, child, drawingTime);
}
- private void initGestureDetectors(final Context context) {
- try {
- TraceEvent.begin();
- // TODO(tedchoc): Upstream the rest of the initialization.
- mZoomManager = new ZoomManager(context, this);
- mZoomManager.updateMultiTouchSupport();
- } finally {
- TraceEvent.end();
- }
+ // Needed by ContentViewCore.InternalAccessDelegate
+ @Override
+ public void onScrollChanged(int l, int t, int oldl, int oldt) {
+ super.onScrollChanged(l, t, oldl, oldt);
+ }
+
+ // End FrameLayout overrides.
+
+ @Override
+ public boolean awakenScrollBars(int startDelay, boolean invalidate) {
+ return mContentViewCore.awakenScrollBars(startDelay, invalidate);
+ }
+
+ @Override
+ public boolean awakenScrollBars() {
+ return super.awakenScrollBars();
}
void updateMultiTouchZoomSupport() {
- mZoomManager.updateMultiTouchSupport();
+ mContentViewCore.updateMultiTouchZoomSupport();
}
public boolean isMultiTouchZoomSupported() {
- return mZoomManager.isMultiTouchZoomSupported();
+ return mContentViewCore.isMultiTouchZoomSupported();
}
/**
@@ -417,12 +376,12 @@ public class ContentView extends FrameLayout {
// fact that a ContentViewDownloadDelegate will be used in preference to a
// DownloadListener.
public void setDownloadListener(DownloadListener listener) {
- mDownloadListener = listener;
+ mContentViewCore.setDownloadListener(listener);
}
// Called by DownloadController.
DownloadListener downloadListener() {
- return mDownloadListener;
+ return mContentViewCore.downloadListener();
}
/**
@@ -433,27 +392,26 @@ public class ContentView extends FrameLayout {
* @param listener An implementation of ContentViewDownloadDelegate.
*/
public void setDownloadDelegate(ContentViewDownloadDelegate delegate) {
- mDownloadDelegate = delegate;
+ mContentViewCore.setDownloadDelegate(delegate);
}
// Called by DownloadController.
ContentViewDownloadDelegate getDownloadDelegate() {
- return mDownloadDelegate;
+ return mContentViewCore.getDownloadDelegate();
}
/**
* @return Whether the native ContentView has crashed.
*/
public boolean isCrashed() {
- if (mNativeContentView == 0) return false;
- return nativeCrashed(mNativeContentView);
+ return mContentViewCore.isCrashed();
}
/**
* @return Whether a reload happens when this ContentView is activated.
*/
public boolean needsReload() {
- return mNativeContentView != 0 && nativeNeedsReload(mNativeContentView);
+ return mContentViewCore.needsReload();
}
/**
@@ -464,7 +422,7 @@ public class ContentView extends FrameLayout {
// This method uses the term 'zoom' for legacy reasons, but relates
// to what chrome calls the 'page scale factor'.
public boolean canZoomIn() {
- return mNativeMaximumScale - mNativePageScaleFactor > WEBVIEW_ZOOM_CONTROLS_EPSILON;
+ return mContentViewCore.canZoomIn();
}
/**
@@ -475,7 +433,7 @@ public class ContentView extends FrameLayout {
// This method uses the term 'zoom' for legacy reasons, but relates
// to what chrome calls the 'page scale factor'.
public boolean canZoomOut() {
- return mNativePageScaleFactor - mNativeMinimumScale > WEBVIEW_ZOOM_CONTROLS_EPSILON;
+ return mContentViewCore.canZoomOut();
}
/**
@@ -487,24 +445,7 @@ public class ContentView extends FrameLayout {
// This method uses the term 'zoom' for legacy reasons, but relates
// to what chrome calls the 'page scale factor'.
public boolean zoomIn() {
- if (!canZoomIn()) {
- return false;
- }
-
- if (mNativeContentView == 0) {
- return false;
- }
-
- long timeMs = System.currentTimeMillis();
- int x = getWidth() / 2;
- int y = getHeight() / 2;
- float delta = 1.25f;
-
- pinchBegin(timeMs, x, y);
- pinchBy(timeMs, x, y, delta);
- pinchEnd(timeMs);
-
- return true;
+ return mContentViewCore.zoomIn();
}
/**
@@ -516,93 +457,55 @@ public class ContentView extends FrameLayout {
// This method uses the term 'zoom' for legacy reasons, but relates
// to what chrome calls the 'page scale factor'.
public boolean zoomOut() {
- if (!canZoomOut()) {
- return false;
- }
-
- if (mNativeContentView == 0) {
- return false;
- }
-
- long timeMs = System.currentTimeMillis();
- int x = getWidth() / 2;
- int y = getHeight() / 2;
- float delta = 0.8f;
-
- pinchBegin(timeMs, x, y);
- pinchBy(timeMs, x, y, delta);
- pinchEnd(timeMs);
-
- return true;
+ return mContentViewCore.zoomOut();
}
// Invokes the graphical zoom picker widget for this ContentView.
public void invokeZoomPicker() {
- if (mContentSettings.supportZoom()) {
- mZoomManager.invokeZoomPicker();
- }
+ mContentViewCore.invokeZoomPicker();
}
// Unlike legacy WebView getZoomControls which returns external zoom controls,
// this method returns built-in zoom controls. This method is used in tests.
public View getZoomControlsForTest() {
- return mZoomManager.getZoomControlsViewForTest();
+ return mContentViewCore.getZoomControlsForTest();
}
- @CalledByNative
- private void startContentIntent(String contentUrl) {
- getContentViewClient().onStartContentIntent(getContext(), contentUrl);
- }
-
-
- /**
- * Initialize the ContentView native side.
- * Should be called with a valid native WebContents.
- * If nativeInitProcess is never called, the first time this method is called, nativeInitProcess
- * will be called implicitly with the default settings.
- * @param webContentsPtr the ContentView does not create a new native WebContents and uses
- * the provided one.
- * @return a native pointer to the native ContentView object.
- */
- private native int nativeInit(int webContentsPtr);
+ ///////////////////////////////////////////////////////////////////////////////////////////////
+ // Start Implementation of ContentViewCore.InternalAccessDelegate //
+ ///////////////////////////////////////////////////////////////////////////////////////////////
- private native void nativeDestroy(int nativeContentViewImpl);
-
- private native void nativeLoadUrlWithoutUrlSanitization(int nativeContentViewImpl,
- String url, int pageTransition);
- private native void nativeLoadUrlWithoutUrlSanitizationWithUserAgentOverride(
- int nativeContentViewImpl, String url, int pageTransition, String userAgentOverride);
-
- private native String nativeGetURL(int nativeContentViewImpl);
-
- private native String nativeGetTitle(int nativeContentViewImpl);
-
- private native double nativeGetLoadProgress(int nativeContentViewImpl);
-
- private native boolean nativeIsIncognito(int nativeContentViewImpl);
-
- // Returns true if the native side crashed so that java side can draw a sad tab.
- private native boolean nativeCrashed(int nativeContentViewImpl);
-
- private native boolean nativeCanGoBack(int nativeContentViewImpl);
-
- private native boolean nativeCanGoForward(int nativeContentViewImpl);
-
- private native boolean nativeCanGoToOffset(int nativeContentViewImpl, int offset);
-
- private native void nativeGoToOffset(int nativeContentViewImpl, int offset);
-
- private native void nativeGoBack(int nativeContentViewImpl);
+ @Override
+ public boolean super_onKeyUp(int keyCode, KeyEvent event) {
+ return super.onKeyUp(keyCode, event);
+ }
- private native void nativeGoForward(int nativeContentViewImpl);
+ @Override
+ public boolean super_dispatchKeyEventPreIme(KeyEvent event) {
+ return super.dispatchKeyEventPreIme(event);
+ }
- private native void nativeStopLoading(int nativeContentViewImpl);
+ @Override
+ public boolean super_dispatchKeyEvent(KeyEvent event) {
+ return super.dispatchKeyEvent(event);
+ }
- private native void nativeReload(int nativeContentViewImpl);
+ @Override
+ public boolean super_onGenericMotionEvent(MotionEvent event) {
+ return super.onGenericMotionEvent(event);
+ }
- private native void nativeSetClient(int nativeContentViewImpl, ContentViewClient client);
+ @Override
+ public void super_onConfigurationChanged(Configuration newConfig) {
+ super.onConfigurationChanged(newConfig);
+ }
- private native boolean nativeNeedsReload(int nativeContentViewImpl);
+ @Override
+ public boolean super_awakenScrollBars(int startDelay, boolean invalidate) {
+ return super.awakenScrollBars(startDelay, invalidate);
+ }
- private native void nativeClearHistory(int nativeContentViewImpl);
+ ///////////////////////////////////////////////////////////////////////////////////////////////
+ // End Implementation of ContentViewCore.InternalAccessDelegate //
+ ///////////////////////////////////////////////////////////////////////////////////////////////
}
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 ed2dbea..3660fac 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
@@ -12,11 +12,10 @@ import android.graphics.RectF;
import android.util.Log;
import android.view.KeyEvent;
-import java.net.URISyntaxException;
-
import org.chromium.base.AccessedByNative;
import org.chromium.base.CalledByNative;
-import org.chromium.content.browser.ContentHttpAuthHandler;
+
+import java.net.URISyntaxException;
/**
* Main callback class used by ContentView.
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
new file mode 100644
index 0000000..00969d8
--- /dev/null
+++ b/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java
@@ -0,0 +1,750 @@
+// 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;
+
+import android.content.Context;
+import android.content.res.Configuration;
+import android.graphics.Canvas;
+import android.util.Log;
+import android.view.KeyEvent;
+import android.view.MotionEvent;
+import android.view.View;
+import android.view.ViewGroup;
+import android.webkit.DownloadListener;
+
+import org.chromium.base.CalledByNative;
+import org.chromium.base.JNINamespace;
+import org.chromium.base.WeakContext;
+import org.chromium.content.common.TraceEvent;
+
+/**
+ * Contains all the major functionality necessary to manage the lifecycle of a ContentView without
+ * being tied to the view system.
+ */
+@JNINamespace("content")
+public class ContentViewCore {
+ private static final String TAG = ContentViewCore.class.getName();
+
+ // The following constants match the ones in chrome/common/page_transition_types.h.
+ // Add more if you need them.
+ public static final int PAGE_TRANSITION_LINK = 0;
+ public static final int PAGE_TRANSITION_TYPED = 1;
+ public static final int PAGE_TRANSITION_AUTO_BOOKMARK = 2;
+ public static final int PAGE_TRANSITION_START_PAGE = 6;
+
+ /** Translate the find selection into a normal selection. */
+ public static final int FIND_SELECTION_ACTION_KEEP_SELECTION = 0;
+ /** Clear the find selection. */
+ public static final int FIND_SELECTION_ACTION_CLEAR_SELECTION = 1;
+ /** Focus and click the selected node (for links). */
+ public static final int FIND_SELECTION_ACTION_ACTIVATE_SELECTION = 2;
+
+ // Personality of the ContentView.
+ private int mPersonality;
+ // Used when ContentView implements a standalone View.
+ public static final int PERSONALITY_VIEW = 0;
+ // Used for Chrome.
+ public static final int PERSONALITY_CHROME = 1;
+
+ // Used to avoid enabling zooming in / out in WebView zoom controls
+ // if resulting zooming will produce little visible difference.
+ private static float WEBVIEW_ZOOM_CONTROLS_EPSILON = 0.007f;
+
+ /**
+ * Interface that consumers of {@link ContentViewCore} must implement to allow the proper
+ * dispatching of view methods through the containing view.
+ *
+ * <p>
+ * All methods with the "super_" prefix should be routed to the parent of the
+ * implementing container view.
+ */
+ @SuppressWarnings("javadoc")
+ public static interface InternalAccessDelegate {
+ /**
+ * @see View#drawChild(Canvas, View, long)
+ */
+ boolean drawChild(Canvas canvas, View child, long drawingTime);
+
+ /**
+ * @see View#onKeyUp(keyCode, KeyEvent)
+ */
+ boolean super_onKeyUp(int keyCode, KeyEvent event);
+
+ /**
+ * @see View#dispatchKeyEventPreIme(KeyEvent)
+ */
+ boolean super_dispatchKeyEventPreIme(KeyEvent event);
+
+ /**
+ * @see View#dispatchKeyEvent(KeyEvent)
+ */
+ boolean super_dispatchKeyEvent(KeyEvent event);
+
+ /**
+ * @see View#onGenericMotionEvent(MotionEvent)
+ */
+ boolean super_onGenericMotionEvent(MotionEvent event);
+
+ /**
+ * @see View#onConfigurationChanged(Configuration)
+ */
+ void super_onConfigurationChanged(Configuration newConfig);
+
+ /**
+ * @see View#onScrollChanged(int, int, int, int)
+ */
+ void onScrollChanged(int l, int t, int oldl, int oldt);
+
+ /**
+ * @see View#awakenScrollBars()
+ */
+ boolean awakenScrollBars();
+
+ /**
+ * @see View#awakenScrollBars(int, boolean)
+ */
+ boolean super_awakenScrollBars(int startDelay, boolean invalidate);
+ }
+
+ private Context mContext;
+ private ViewGroup mContainerView;
+ private InternalAccessDelegate mContainerViewInternals;
+
+ // 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;
+
+ // Native pointer to C++ ContentView object which will be set by nativeInit()
+ private int mNativeContentViewCore = 0;
+
+ private ZoomManager mZoomManager;
+
+ // Cached page scale factor from native
+ private float mNativePageScaleFactor = 1.0f;
+ private float mNativeMinimumScale = 1.0f;
+ private float mNativeMaximumScale = 1.0f;
+
+ // TODO(klobag): this is to avoid a bug in GestureDetector. With multi-touch,
+ // mAlwaysInTapRegion is not reset. So when the last finger is up, onSingleTapUp()
+ // will be mistakenly fired.
+ private boolean mIgnoreSingleTap;
+
+ // The legacy webview DownloadListener.
+ private DownloadListener mDownloadListener;
+ // ContentViewDownloadDelegate adds support for authenticated downloads
+ // and POST downloads. Embedders should prefer ContentViewDownloadDelegate
+ // over DownloadListener.
+ private ContentViewDownloadDelegate mDownloadDelegate;
+
+ /**
+ * Enable multi-process ContentView. This should be called by the application before
+ * constructing any ContentView instances. If enabled, ContentView will run renderers in
+ * separate processes up to the number of processes specified by maxRenderProcesses. If this is
+ * not called then the default is to run the renderer in the main application on a separate
+ * thread.
+ *
+ * @param context Context used to obtain the application context.
+ * @param maxRendererProcesses Limit on the number of renderers to use. Each tab runs in its own
+ * process until the maximum number of processes is reached. The special value of
+ * MAX_RENDERERS_SINGLE_PROCESS requests single-process mode where the renderer will run in the
+ * application process in a separate thread. If the special value MAX_RENDERERS_AUTOMATIC is
+ * used then the number of renderers will be determined based on the device memory class. The
+ * maximum number of allowed renderers is capped by MAX_RENDERERS_LIMIT.
+ */
+ public static void enableMultiProcess(Context context, int maxRendererProcesses) {
+ AndroidBrowserProcess.initContentViewProcess(context, maxRendererProcesses);
+ }
+
+ /**
+ * Initialize the process as the platform browser. This must be called before accessing
+ * ContentView in order to treat this as a Chromium browser process.
+ *
+ * @param context Context used to obtain the application context.
+ * @param maxRendererProcesses Same as ContentView.enableMultiProcess()
+ * @hide Only used by the platform browser.
+ */
+ public static void initChromiumBrowserProcess(Context context, int maxRendererProcesses) {
+ AndroidBrowserProcess.initChromiumBrowserProcess(context, maxRendererProcesses);
+ }
+
+ /**
+ * Constructs a new ContentViewCore.
+ *
+ * @param context The context used to create this.
+ * @param containerView The view that will act as a container for all views created by this.
+ * @param internalDispatcher Handles dispatching all hidden or super methods to the
+ * containerView.
+ * @param nativeWebContents A pointer to the native web contents.
+ * @param personality The type of ContentViewCore being created.
+ */
+ public ContentViewCore(
+ Context context, ViewGroup containerView,
+ InternalAccessDelegate internalDispatcher,
+ int nativeWebContents, int personality) {
+ mContext = context;
+ mContainerView = containerView;
+ mContainerViewInternals = internalDispatcher;
+
+ WeakContext.initializeWeakContext(context);
+ // By default, ContentView will initialize single process mode. The call to
+ // initContentViewProcess below is ignored if either the ContentView host called
+ // enableMultiProcess() or the platform browser called initChromiumBrowserProcess().
+ AndroidBrowserProcess.initContentViewProcess(
+ context, AndroidBrowserProcess.MAX_RENDERERS_SINGLE_PROCESS);
+
+ initialize(context, nativeWebContents, personality);
+ }
+
+ /**
+ * @return The context used for creating this ContentViewCore.
+ */
+ public Context getContext() {
+ return mContext;
+ }
+
+ /**
+ * @return The ViewGroup that all view actions of this ContentViewCore should interact with.
+ */
+ protected ViewGroup getContainerView() {
+ return mContainerView;
+ }
+
+ // TODO(jrg): incomplete; upstream the rest of this method.
+ private void initialize(Context context, int nativeWebContents, int personality) {
+ mNativeContentViewCore = nativeInit(nativeWebContents);
+
+ mPersonality = personality;
+ mContentSettings = new ContentSettings(this, mNativeContentViewCore);
+ mContainerView.setWillNotDraw(false);
+ mContainerView.setFocusable(true);
+ mContainerView.setFocusableInTouchMode(true);
+ if (mContainerView.getScrollBarStyle() == View.SCROLLBARS_INSIDE_OVERLAY) {
+ mContainerView.setHorizontalScrollBarEnabled(false);
+ mContainerView.setVerticalScrollBarEnabled(false);
+ }
+ mContainerView.setClickable(true);
+ initGestureDetectors(context);
+
+ Log.i(TAG, "mNativeContentView=0x"+ Integer.toHexString(mNativeContentViewCore));
+ }
+
+ /**
+ * @return Whether the configured personality of this ContentView is {@link #PERSONALITY_VIEW}.
+ */
+ boolean isPersonalityView() {
+ switch (mPersonality) {
+ case PERSONALITY_VIEW:
+ return true;
+ case PERSONALITY_CHROME:
+ return false;
+ default:
+ Log.e(TAG, "Unknown ContentView personality: " + mPersonality);
+ return false;
+ }
+ }
+
+ /**
+ * Destroy the internal state of the WebView. This method may only be called
+ * after the WebView has been removed from the view system. No other methods
+ * may be called on this WebView after this method has been called.
+ */
+ public void destroy() {
+ if (mNativeContentViewCore != 0) {
+ nativeDestroy(mNativeContentViewCore);
+ mNativeContentViewCore = 0;
+ }
+ if (mContentSettings != null) {
+ mContentSettings.destroy();
+ mContentSettings = null;
+ }
+ }
+
+ /**
+ * Returns true initially, false after destroy() has been called.
+ * It is illegal to call any other public method after destroy().
+ */
+ public boolean isAlive() {
+ return mNativeContentViewCore != 0;
+ }
+
+ /**
+ * For internal use. Throws IllegalStateException if mNativeContentView is 0.
+ * Use this to ensure we get a useful Java stack trace, rather than a native
+ * crash dump, from use-after-destroy bugs in Java code.
+ */
+ void checkIsAlive() throws IllegalStateException {
+ if (!isAlive()) {
+ throw new IllegalStateException("ContentView used after destroy() was called");
+ }
+ }
+
+ public void setContentViewClient(ContentViewClient client) {
+ if (client == null) {
+ throw new IllegalArgumentException("The client can't be null.");
+ }
+ mContentViewClient = client;
+ if (mNativeContentViewCore != 0) {
+ nativeSetClient(mNativeContentViewCore, mContentViewClient);
+ }
+ }
+
+ ContentViewClient getContentViewClient() {
+ if (mContentViewClient == null) {
+ // We use the Null Object pattern to avoid having to perform a null check in this class.
+ // We create it lazily because most of the time a client will be set almost immediately
+ // after ContentView is created.
+ mContentViewClient = new ContentViewClient();
+ // We don't set the native ContentViewClient pointer here on purpose. The native
+ // implementation doesn't mind a null delegate and using one is better than passing a
+ // Null Object, since we cut down on the number of JNI calls.
+ }
+ return mContentViewClient;
+ }
+
+ /**
+ * Load url without fixing up the url string. Consumers of ContentView are responsible for
+ * ensuring the URL passed in is properly formatted (i.e. the scheme has been added if left
+ * off during user input).
+ *
+ * @param url The url to load.
+ */
+ public void loadUrlWithoutUrlSanitization(String url) {
+ loadUrlWithoutUrlSanitization(url, PAGE_TRANSITION_TYPED);
+ }
+
+ /**
+ * Load url without fixing up the url string. Consumers of ContentView are responsible for
+ * ensuring the URL passed in is properly formatted (i.e. the scheme has been added if left
+ * off during user input).
+ *
+ * @param url The url to load.
+ * @param pageTransition Page transition id that describes the action that led to this
+ * navigation. It is important for ranking URLs in the history so the
+ * omnibox can report suggestions correctly.
+ */
+ public void loadUrlWithoutUrlSanitization(String url, int pageTransition) {
+ if (mNativeContentViewCore != 0) {
+ if (isPersonalityView()) {
+ nativeLoadUrlWithoutUrlSanitizationWithUserAgentOverride(
+ mNativeContentViewCore,
+ url,
+ pageTransition,
+ mContentSettings.getUserAgentString());
+ } else {
+ // Chrome stores overridden UA strings in navigation history
+ // items, so they stay the same on going back / forward.
+ nativeLoadUrlWithoutUrlSanitization(
+ mNativeContentViewCore,
+ url,
+ pageTransition);
+ }
+ }
+ }
+
+ void setAllUserAgentOverridesInHistory() {
+ // TODO(tedchoc): Pass user agent override down to native.
+ }
+
+ /**
+ * Stops loading the current web contents.
+ */
+ public void stopLoading() {
+ if (mNativeContentViewCore != 0) nativeStopLoading(mNativeContentViewCore);
+ }
+
+ /**
+ * Get the URL of the current page.
+ *
+ * @return The URL of the current page.
+ */
+ public String getUrl() {
+ if (mNativeContentViewCore != 0) return nativeGetURL(mNativeContentViewCore);
+ return null;
+ }
+
+ /**
+ * Get the title of the current page.
+ *
+ * @return The title of the current page.
+ */
+ public String getTitle() {
+ if (mNativeContentViewCore != 0) return nativeGetTitle(mNativeContentViewCore);
+ return null;
+ }
+
+ /**
+ * @return The load progress of current web contents (range is 0 - 100).
+ */
+ public int getProgress() {
+ if (mNativeContentViewCore != 0) {
+ return (int) (100.0 * nativeGetLoadProgress(mNativeContentViewCore));
+ }
+ return 100;
+ }
+
+ public int getWidth() {
+ return mContainerView.getWidth();
+ }
+
+ public int getHeight() {
+ return mContainerView.getHeight();
+ }
+
+ /**
+ * @return Whether the current WebContents has a previous navigation entry.
+ */
+ public boolean canGoBack() {
+ return mNativeContentViewCore != 0 && nativeCanGoBack(mNativeContentViewCore);
+ }
+
+ /**
+ * @return Whether the current WebContents has a navigation entry after the current one.
+ */
+ public boolean canGoForward() {
+ return mNativeContentViewCore != 0 && nativeCanGoForward(mNativeContentViewCore);
+ }
+
+ /**
+ * @param offset The offset into the navigation history.
+ * @return Whether we can move in history by given offset
+ */
+ public boolean canGoToOffset(int offset) {
+ return mNativeContentViewCore != 0 && nativeCanGoToOffset(mNativeContentViewCore, offset);
+ }
+
+ /**
+ * Navigates to the specified offset from the "current entry". Does nothing if the offset is out
+ * of bounds.
+ * @param offset The offset into the navigation history.
+ */
+ public void goToOffset(int offset) {
+ if (mNativeContentViewCore != 0) nativeGoToOffset(mNativeContentViewCore, offset);
+ }
+
+ /**
+ * Goes to the navigation entry before the current one.
+ */
+ public void goBack() {
+ if (mNativeContentViewCore != 0) nativeGoBack(mNativeContentViewCore);
+ }
+
+ /**
+ * Goes to the navigation entry following the current one.
+ */
+ public void goForward() {
+ if (mNativeContentViewCore != 0) nativeGoForward(mNativeContentViewCore);
+ }
+
+ /**
+ * Reload the current page.
+ */
+ public void reload() {
+ if (mNativeContentViewCore != 0) nativeReload(mNativeContentViewCore);
+ }
+
+ /**
+ * Clears the WebView's page history in both the backwards and forwards
+ * directions.
+ */
+ public void clearHistory() {
+ if (mNativeContentViewCore != 0) nativeClearHistory(mNativeContentViewCore);
+ }
+
+ /**
+ * Start pinch zoom. You must call {@link #pinchEnd} to stop.
+ */
+ void pinchBegin(long timeMs, int x, int y) {
+ if (mNativeContentViewCore != 0) {
+ // TODO(tedchoc): Pass pinch begin to native.
+ }
+ }
+
+ /**
+ * Stop pinch zoom.
+ */
+ void pinchEnd(long timeMs) {
+ if (mNativeContentViewCore != 0) {
+ // TODO(tedchoc): Pass pinch end to native.
+ }
+ }
+
+ void setIgnoreSingleTap(boolean value) {
+ mIgnoreSingleTap = value;
+ }
+
+ /**
+ * Modify the ContentView magnification level. The effect of calling this
+ * method is exactly as after "pinch zoom".
+ *
+ * @param timeMs The event time in milliseconds.
+ * @param delta The ratio of the new magnification level over the current
+ * magnification level.
+ * @param anchorX The magnification anchor (X) in the current view
+ * coordinate.
+ * @param anchorY The magnification anchor (Y) in the current view
+ * coordinate.
+ */
+ void pinchBy(long timeMs, int anchorX, int anchorY, float delta) {
+ if (mNativeContentViewCore != 0) {
+ // TODO(tedchoc): Pass pinch by to native.
+ }
+ }
+
+ /**
+ * Return the ContentSettings object used to control the settings for this
+ * WebView.
+ *
+ * Note that when ContentView is used in the PERSONALITY_CHROME role,
+ * ContentSettings can only be used for retrieving settings values. For
+ * modifications, ChromeNativePreferences is to be used.
+ * @return A ContentSettings object that can be used to control this WebView's
+ * settings.
+ */
+ public ContentSettings getContentSettings() {
+ return mContentSettings;
+ }
+
+ // End FrameLayout overrides.
+
+ /**
+ * @see View#awakenScrollBars(int, boolean)
+ */
+ @SuppressWarnings("javadoc")
+ protected boolean awakenScrollBars(int startDelay, boolean invalidate) {
+ // For the default implementation of ContentView which draws the scrollBars on the native
+ // side, calling this function may get us into a bad state where we keep drawing the
+ // scrollBars, so disable it by always returning false.
+ if (mContainerView.getScrollBarStyle() == View.SCROLLBARS_INSIDE_OVERLAY) {
+ return false;
+ } else {
+ return mContainerViewInternals.super_awakenScrollBars(startDelay, invalidate);
+ }
+ }
+
+ private void initGestureDetectors(final Context context) {
+ try {
+ TraceEvent.begin();
+ // TODO(tedchoc): Upstream the rest of the initialization.
+ mZoomManager = new ZoomManager(context, this);
+ mZoomManager.updateMultiTouchSupport();
+ } finally {
+ TraceEvent.end();
+ }
+ }
+
+ void updateMultiTouchZoomSupport() {
+ mZoomManager.updateMultiTouchSupport();
+ }
+
+ public boolean isMultiTouchZoomSupported() {
+ return mZoomManager.isMultiTouchZoomSupported();
+ }
+
+ /**
+ * Register the listener to be used when content can not be handled by the
+ * rendering engine, and should be downloaded instead. This will replace the
+ * current listener.
+ * @param listener An implementation of DownloadListener.
+ */
+ // TODO(nileshagrawal): decide if setDownloadDelegate will be public API. If so,
+ // this method should be deprecated and the javadoc should make reference to the
+ // fact that a ContentViewDownloadDelegate will be used in preference to a
+ // DownloadListener.
+ public void setDownloadListener(DownloadListener listener) {
+ mDownloadListener = listener;
+ }
+
+ // Called by DownloadController.
+ DownloadListener downloadListener() {
+ return mDownloadListener;
+ }
+
+ /**
+ * Register the delegate to be used when content can not be handled by
+ * the rendering engine, and should be downloaded instead. This will replace
+ * the current delegate or existing DownloadListner.
+ * Embedders should prefer this over the legacy DownloadListener.
+ * @param listener An implementation of ContentViewDownloadDelegate.
+ */
+ public void setDownloadDelegate(ContentViewDownloadDelegate delegate) {
+ mDownloadDelegate = delegate;
+ }
+
+ // Called by DownloadController.
+ ContentViewDownloadDelegate getDownloadDelegate() {
+ return mDownloadDelegate;
+ }
+
+ /**
+ * @return Whether the native ContentView has crashed.
+ */
+ public boolean isCrashed() {
+ if (mNativeContentViewCore == 0) return false;
+ return nativeCrashed(mNativeContentViewCore);
+ }
+
+ /**
+ * @return Whether a reload happens when this ContentView is activated.
+ */
+ public boolean needsReload() {
+ return mNativeContentViewCore != 0 && nativeNeedsReload(mNativeContentViewCore);
+ }
+
+ /**
+ * Checks whether the WebView can be zoomed in.
+ *
+ * @return True if the WebView can be zoomed in.
+ */
+ // This method uses the term 'zoom' for legacy reasons, but relates
+ // to what chrome calls the 'page scale factor'.
+ public boolean canZoomIn() {
+ return mNativeMaximumScale - mNativePageScaleFactor > WEBVIEW_ZOOM_CONTROLS_EPSILON;
+ }
+
+ /**
+ * Checks whether the WebView can be zoomed out.
+ *
+ * @return True if the WebView can be zoomed out.
+ */
+ // This method uses the term 'zoom' for legacy reasons, but relates
+ // to what chrome calls the 'page scale factor'.
+ public boolean canZoomOut() {
+ return mNativePageScaleFactor - mNativeMinimumScale > WEBVIEW_ZOOM_CONTROLS_EPSILON;
+ }
+
+ /**
+ * Zooms in the WebView by 25% (or less if that would result in zooming in
+ * more than possible).
+ *
+ * @return True if there was a zoom change, false otherwise.
+ */
+ // This method uses the term 'zoom' for legacy reasons, but relates
+ // to what chrome calls the 'page scale factor'.
+ public boolean zoomIn() {
+ if (!canZoomIn()) {
+ return false;
+ }
+
+ if (mNativeContentViewCore == 0) {
+ return false;
+ }
+
+ long timeMs = System.currentTimeMillis();
+ int x = getWidth() / 2;
+ int y = getHeight() / 2;
+ float delta = 1.25f;
+
+ pinchBegin(timeMs, x, y);
+ pinchBy(timeMs, x, y, delta);
+ pinchEnd(timeMs);
+
+ return true;
+ }
+
+ /**
+ * Zooms out the WebView by 20% (or less if that would result in zooming out
+ * more than possible).
+ *
+ * @return True if there was a zoom change, false otherwise.
+ */
+ // This method uses the term 'zoom' for legacy reasons, but relates
+ // to what chrome calls the 'page scale factor'.
+ public boolean zoomOut() {
+ if (!canZoomOut()) {
+ return false;
+ }
+
+ if (mNativeContentViewCore == 0) {
+ return false;
+ }
+
+ long timeMs = System.currentTimeMillis();
+ int x = getWidth() / 2;
+ int y = getHeight() / 2;
+ float delta = 0.8f;
+
+ pinchBegin(timeMs, x, y);
+ pinchBy(timeMs, x, y, delta);
+ pinchEnd(timeMs);
+
+ return true;
+ }
+
+ // Invokes the graphical zoom picker widget for this ContentView.
+ public void invokeZoomPicker() {
+ if (mContentSettings.supportZoom()) {
+ mZoomManager.invokeZoomPicker();
+ }
+ }
+
+ // Unlike legacy WebView getZoomControls which returns external zoom controls,
+ // this method returns built-in zoom controls. This method is used in tests.
+ public View getZoomControlsForTest() {
+ return mZoomManager.getZoomControlsViewForTest();
+ }
+
+ @CalledByNative
+ private void startContentIntent(String contentUrl) {
+ getContentViewClient().onStartContentIntent(getContext(), contentUrl);
+ }
+
+ // The following methods are implemented at native side.
+
+ /**
+ * Initialize the ContentView native side.
+ * Should be called with a valid native WebContents.
+ * If nativeInitProcess is never called, the first time this method is called,
+ * nativeInitProcess will be called implicitly with the default settings.
+ * @param webContentsPtr the ContentView does not create a new native WebContents and uses
+ * the provided one.
+ * @return a native pointer to the native ContentView object.
+ */
+ private native int nativeInit(int webContentsPtr);
+
+ private native void nativeDestroy(int nativeContentViewCoreImpl);
+
+ private native void nativeLoadUrlWithoutUrlSanitization(int nativeContentViewCoreImpl,
+ String url, int pageTransition);
+ private native void nativeLoadUrlWithoutUrlSanitizationWithUserAgentOverride(
+ int nativeContentViewCoreImpl, String url, int pageTransition,
+ String userAgentOverride);
+
+ private native String nativeGetURL(int nativeContentViewCoreImpl);
+
+ private native String nativeGetTitle(int nativeContentViewCoreImpl);
+
+ private native double nativeGetLoadProgress(int nativeContentViewCoreImpl);
+
+ private native boolean nativeIsIncognito(int nativeContentViewCoreImpl);
+
+ // Returns true if the native side crashed so that java side can draw a sad tab.
+ private native boolean nativeCrashed(int nativeContentViewCoreImpl);
+
+ private native boolean nativeCanGoBack(int nativeContentViewCoreImpl);
+
+ private native boolean nativeCanGoForward(int nativeContentViewCoreImpl);
+
+ private native boolean nativeCanGoToOffset(int nativeContentViewCoreImpl, int offset);
+
+ private native void nativeGoToOffset(int nativeContentViewCoreImpl, int offset);
+
+ private native void nativeGoBack(int nativeContentViewCoreImpl);
+
+ private native void nativeGoForward(int nativeContentViewCoreImpl);
+
+ private native void nativeStopLoading(int nativeContentViewCoreImpl);
+
+ private native void nativeReload(int nativeContentViewCoreImpl);
+
+ 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/DownloadController.java b/content/public/android/java/src/org/chromium/content/browser/DownloadController.java
index 496e1c9..496ea65 100644
--- a/content/public/android/java/src/org/chromium/content/browser/DownloadController.java
+++ b/content/public/android/java/src/org/chromium/content/browser/DownloadController.java
@@ -31,11 +31,11 @@ class DownloadController {
nativeInit();
}
- private static DownloadListener listenerFromView(ContentView view) {
+ private static DownloadListener listenerFromView(ContentViewCore view) {
return view.downloadListener();
}
- private static ContentViewDownloadDelegate downloadDelegateFromView(ContentView view) {
+ private static ContentViewDownloadDelegate downloadDelegateFromView(ContentViewCore view) {
return view.getDownloadDelegate();
}
@@ -50,7 +50,7 @@ class DownloadController {
* The DownloadListener is expected to handle the download.
*/
@CalledByNative
- public void newHttpGetDownload(ContentView view, String url,
+ public void newHttpGetDownload(ContentViewCore view, String url,
String userAgent, String contentDisposition, String mimetype,
String cookie, long contentLength) {
ContentViewDownloadDelegate downloadDelagate = downloadDelegateFromView(view);
@@ -72,7 +72,7 @@ class DownloadController {
* Notifies the DownloadListener that a new POST download has started.
*/
@CalledByNative
- public void onHttpPostDownloadStarted(ContentView view) {
+ public void onHttpPostDownloadStarted(ContentViewCore view) {
ContentViewDownloadDelegate downloadDelagate = downloadDelegateFromView(view);
if (downloadDelagate != null) {
@@ -85,7 +85,7 @@ class DownloadController {
* download.
*/
@CalledByNative
- public void onHttpPostDownloadCompleted(ContentView view, String url,
+ public void onHttpPostDownloadCompleted(ContentViewCore view, String url,
String contentDisposition, String mimetype, String path,
long contentLength, boolean successful) {
ContentViewDownloadDelegate downloadDelagate = downloadDelegateFromView(view);
diff --git a/content/public/android/java/src/org/chromium/content/browser/ZoomManager.java b/content/public/android/java/src/org/chromium/content/browser/ZoomManager.java
index 8ee98ea..adb5cbb 100644
--- a/content/public/android/java/src/org/chromium/content/browser/ZoomManager.java
+++ b/content/public/android/java/src/org/chromium/content/browser/ZoomManager.java
@@ -21,7 +21,7 @@ import android.widget.ZoomButtonsController;
class ZoomManager {
private static final String TAG = "ContentViewZoom";
- private ContentView mContentView;
+ private ContentViewCore mContentViewCore;
private ZoomButtonsController mZoomButtonsController;
private class ScaleGestureListener implements ScaleGestureDetector.OnScaleGestureListener {
@@ -55,14 +55,14 @@ class ZoomManager {
public boolean onScaleBegin(ScaleGestureDetector detector) {
if (ignoreDetectorEvents()) return false;
mPinchEventSent = false;
- mContentView.setIgnoreSingleTap(true);
+ mContentViewCore.setIgnoreSingleTap(true);
return true;
}
@Override
public void onScaleEnd(ScaleGestureDetector detector) {
- if (!mPinchEventSent || !mContentView.isAlive()) return;
- mContentView.pinchEnd(detector.getEventTime());
+ if (!mPinchEventSent || !mContentViewCore.isAlive()) return;
+ mContentViewCore.pinchEnd(detector.getEventTime());
mPinchEventSent = false;
}
@@ -76,11 +76,11 @@ class ZoomManager {
// that pinchBy() is called without any pinchBegin().
// To solve this problem, we call pinchBegin() here if it is never called.
if (!mPinchEventSent) {
- mContentView.pinchBegin(detector.getEventTime(),
+ mContentViewCore.pinchBegin(detector.getEventTime(),
(int) detector.getFocusX(), (int) detector.getFocusY());
mPinchEventSent = true;
}
- mContentView.pinchBy(
+ mContentViewCore.pinchBy(
detector.getEventTime(), (int) detector.getFocusX(), (int) detector.getFocusY(),
detector.getScaleFactor());
return true;
@@ -89,15 +89,15 @@ class ZoomManager {
private boolean ignoreDetectorEvents() {
return mPermanentlyIgnoreDetectorEvents ||
mTemporarilyIgnoreDetectorEvents ||
- !mContentView.isAlive();
+ !mContentViewCore.isAlive();
}
}
private ScaleGestureDetector mMultiTouchDetector;
private ScaleGestureListener mMultiTouchListener;
- ZoomManager(final Context context, ContentView contentView) {
- mContentView = contentView;
+ ZoomManager(final Context context, ContentViewCore contentViewCore) {
+ mContentViewCore = contentViewCore;
mMultiTouchListener = new ScaleGestureListener();
mMultiTouchDetector = new ScaleGestureDetector(context, mMultiTouchListener);
}
@@ -148,13 +148,14 @@ class ZoomManager {
void updateMultiTouchSupport() {
mMultiTouchListener.setPermanentlyIgnoreDetectorEvents(
- !mContentView.getContentSettings().supportsMultiTouchZoom());
+ !mContentViewCore.getContentSettings().supportsMultiTouchZoom());
}
private ZoomButtonsController getZoomControls() {
if (mZoomButtonsController == null &&
- mContentView.getContentSettings().shouldDisplayZoomControls()) {
- mZoomButtonsController = new ZoomButtonsController(mContentView);
+ mContentViewCore.getContentSettings().shouldDisplayZoomControls()) {
+ mZoomButtonsController = new ZoomButtonsController(
+ mContentViewCore.getContainerView());
mZoomButtonsController.setOnZoomListener(new ZoomListener());
// ZoomButtonsController positions the buttons at the bottom, but in
// the middle. Change their layout parameters so they appear on the
@@ -175,8 +176,8 @@ class ZoomManager {
void updateZoomControls() {
if (mZoomButtonsController == null) return;
- boolean canZoomIn = mContentView.canZoomIn();
- boolean canZoomOut = mContentView.canZoomOut();
+ boolean canZoomIn = mContentViewCore.canZoomIn();
+ boolean canZoomOut = mContentViewCore.canZoomOut();
if (!canZoomIn && !canZoomOut) {
// Hide the zoom in and out buttons if the page cannot zoom
mZoomButtonsController.getZoomControls().setVisibility(View.GONE);
@@ -200,9 +201,9 @@ class ZoomManager {
@Override
public void onZoom(boolean zoomIn) {
if (zoomIn) {
- mContentView.zoomIn();
+ mContentViewCore.zoomIn();
} else {
- mContentView.zoomOut();
+ mContentViewCore.zoomOut();
}
// ContentView will call updateZoomControls after its current page scale
// is got updated from the native code.
diff --git a/content/public/browser/android/content_view.h b/content/public/browser/android/content_view_core.h
index 95d1fbf..d15c169 100644
--- a/content/public/browser/android/content_view.h
+++ b/content/public/browser/android/content_view_core.h
@@ -2,8 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CONTENT_PUBLIC_BROWSER_CONTENT_VIEW_H_
-#define CONTENT_PUBLIC_BROWSER_CONTENT_VIEW_H_
+#ifndef CONTENT_PUBLIC_BROWSER_ANDROID_CONTENT_VIEW_CORE_H_
+#define CONTENT_PUBLIC_BROWSER_ANDROID_CONTENT_VIEW_CORE_H_
+#pragma once
#include <jni.h>
@@ -13,27 +14,27 @@ namespace content {
class WebContents;
-// Native side of the ContentView.java, the primary FrameLayout of
-// Chromium on Android. This is a public interface used by native
-// code outside of the content module.
+// Native side of the ContentViewCore.java, which is the primary way of
+// communicating with the native Chromium code on Android. This is a
+// public interface used by native code outside of the content module.
//
// TODO(jrg): this is a shell. Upstream the rest.
//
// TODO(jrg): downstream, this class derives from
-// base::SupportsWeakPtr<ContentView>. Issues raised in
+// base::SupportsWeakPtr<ContentViewCore>. Issues raised in
// http://codereview.chromium.org/10536066/ make us want to rethink
// ownership issues.
// FOR THE MERGE (downstream), re-add derivation from
-// base::SupportsWeakPtr<ContentView> to keep everything else working
+// base::SupportsWeakPtr<ContentViewCore> to keep everything else working
// until this issue is resolved.
// http://b/6666045
-class ContentView {
+class ContentViewCore {
public:
virtual void Destroy(JNIEnv* env, jobject obj) = 0;
- static ContentView* Create(JNIEnv* env, jobject obj,
- WebContents* web_contents);
- static ContentView* GetNativeContentView(JNIEnv* env, jobject obj);
+ static ContentViewCore* Create(JNIEnv* env, jobject obj,
+ WebContents* web_contents);
+ static ContentViewCore* GetNativeContentViewCore(JNIEnv* env, jobject obj);
// --------------------------------------------------------------------------
// Public methods that call to Java via JNI
@@ -42,9 +43,9 @@ class ContentView {
virtual void StartContentIntent(const GURL& content_url) = 0;
protected:
- virtual ~ContentView() {};
+ virtual ~ContentViewCore() {};
};
}; // namespace content
-#endif // CONTENT_PUBLIC_BROWSER_CONTENT_VIEW_H_
+#endif // CONTENT_PUBLIC_BROWSER_CONTENT_VIEW_CORE_H_
diff --git a/ui/gfx/native_widget_types.h b/ui/gfx/native_widget_types.h
index d9eeebc..6fc848d 100644
--- a/ui/gfx/native_widget_types.h
+++ b/ui/gfx/native_widget_types.h
@@ -89,7 +89,7 @@ typedef struct _GtkWidget GtkWidget;
typedef struct _GtkWindow GtkWindow;
#elif defined(OS_ANDROID)
namespace content {
-class ContentView;
+class ContentViewCore;
}
#endif
class SkBitmap;
@@ -121,8 +121,8 @@ typedef GdkRegion* NativeRegion;
typedef GdkEvent* NativeEvent;
#elif defined(OS_ANDROID)
typedef void* NativeCursor;
-typedef content::ContentView* NativeView;
-typedef content::ContentView* NativeWindow;
+typedef content::ContentViewCore* NativeView;
+typedef content::ContentViewCore* NativeWindow;
typedef void* NativeRegion;
typedef jobject NativeEvent;
#endif