diff options
author | aurimas@chromium.org <aurimas@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-04-23 07:36:40 +0000 |
---|---|---|
committer | aurimas@chromium.org <aurimas@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-04-23 07:36:40 +0000 |
commit | 74d969838ae9091cbfe0caafe18d979bcc181f5e (patch) | |
tree | 55584d6633cb1627b5ecb3153235b4069c256c84 /content/browser/android | |
parent | 5b881abc43e42ea82bd64f974fcd35abff455cfc (diff) | |
download | chromium_src-74d969838ae9091cbfe0caafe18d979bcc181f5e.zip chromium_src-74d969838ae9091cbfe0caafe18d979bcc181f5e.tar.gz chromium_src-74d969838ae9091cbfe0caafe18d979bcc181f5e.tar.bz2 |
[Android] Refactor NativeView to be able to use it for AutofillDialog.
Create a new class WindowAndroid that serves the purpose of representing a native (platform specific) view where Chromium code expects to have a cross platform handle to the system view type. As Views are Java objects on Android, ViewAndroid.java and view_android.* will provide the expected abstractions on the C++ side and allow it to be flexibly glued to an actual Android Java View at runtime. It should only be used where access to Android Views is needed from the C++ code as there are easier/better ways to access Views from Java.
This new abstraction will allow to reuse AutofillPopup for regular use in a webpage (using ContentView) as well as for AutofillDialog.
BUG=229199
Review URL: https://chromiumcodereview.appspot.com/14018004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@195750 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/browser/android')
-rw-r--r-- | content/browser/android/content_view_core_impl.cc | 23 | ||||
-rw-r--r-- | content/browser/android/content_view_core_impl.h | 9 |
2 files changed, 20 insertions, 12 deletions
diff --git a/content/browser/android/content_view_core_impl.cc b/content/browser/android/content_view_core_impl.cc index e459afe..0618ea0 100644 --- a/content/browser/android/content_view_core_impl.cc +++ b/content/browser/android/content_view_core_impl.cc @@ -45,6 +45,7 @@ #include "third_party/WebKit/Source/WebKit/chromium/public/WebBindings.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" #include "third_party/WebKit/Source/WebKit/chromium/public/android/WebInputEventFactory.h" +#include "ui/android/view_android.h" #include "ui/android/window_android.h" #include "ui/gfx/android/java_bitmap.h" #include "ui/gfx/screen.h" @@ -152,12 +153,14 @@ ContentViewCoreImpl::ContentViewCoreImpl(JNIEnv* env, jobject obj, bool hardware_accelerated, bool input_events_delivered_at_vsync, WebContents* web_contents, + ui::ViewAndroid* view_android, ui::WindowAndroid* window_android) : java_ref_(env, obj), web_contents_(static_cast<WebContentsImpl*>(web_contents)), root_layer_(cc::Layer::Create()), tab_crashed_(false), input_events_delivered_at_vsync_(input_events_delivered_at_vsync), + view_android_(view_android), window_android_(window_android) { CHECK(web_contents) << "A ContentViewCoreImpl should be created with a valid WebContents."; @@ -309,14 +312,6 @@ ScopedJavaLocalRef<jobject> ContentViewCoreImpl::GetJavaObject() { return java_ref_.get(env); } -ScopedJavaLocalRef<jobject> ContentViewCoreImpl::GetContainerViewDelegate() { - JNIEnv* env = AttachCurrentThread(); - ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); - if (obj.is_null()) - return ScopedJavaLocalRef<jobject>(); - return Java_ContentViewCore_getContainerViewDelegate(env, obj.obj()); -} - void ContentViewCoreImpl::OnWebPreferencesUpdated() { JNIEnv* env = AttachCurrentThread(); ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); @@ -710,6 +705,12 @@ void ContentViewCoreImpl::SetVSyncNotificationEnabled(bool enabled) { env, obj.obj(), static_cast<jboolean>(enabled)); } +ui::ViewAndroid* ContentViewCoreImpl::GetViewAndroid() const { + // view_android_ should never be null for Chrome. + DCHECK(view_android_); + return view_android_; +} + ui::WindowAndroid* ContentViewCoreImpl::GetWindowAndroid() const { // This should never be NULL for Chrome, but will be NULL for WebView. DCHECK(window_android_); @@ -1528,11 +1529,13 @@ jint Init(JNIEnv* env, jobject obj, jboolean input_events_delivered_at_vsync, jboolean hardware_accelerated, jint native_web_contents, - jint native_window) { + jint view_android, + jint window_android) { ContentViewCoreImpl* view = new ContentViewCoreImpl( env, obj, input_events_delivered_at_vsync, hardware_accelerated, reinterpret_cast<WebContents*>(native_web_contents), - reinterpret_cast<ui::WindowAndroid*>(native_window)); + reinterpret_cast<ui::ViewAndroid*>(view_android), + reinterpret_cast<ui::WindowAndroid*>(window_android)); return reinterpret_cast<jint>(view); } diff --git a/content/browser/android/content_view_core_impl.h b/content/browser/android/content_view_core_impl.h index ed93833..146f836 100644 --- a/content/browser/android/content_view_core_impl.h +++ b/content/browser/android/content_view_core_impl.h @@ -26,6 +26,7 @@ struct WebMenuItem; namespace ui { +class ViewAndroid; class WindowAndroid; } @@ -43,13 +44,13 @@ class ContentViewCoreImpl : public ContentViewCore, bool hardware_accelerated, bool input_events_delivered_at_vsync, WebContents* web_contents, + ui::ViewAndroid* view_android, ui::WindowAndroid* window_android); // ContentViewCore implementation. virtual base::android::ScopedJavaLocalRef<jobject> GetJavaObject() OVERRIDE; - virtual base::android::ScopedJavaLocalRef<jobject> GetContainerViewDelegate() - OVERRIDE; virtual WebContents* GetWebContents() const OVERRIDE; + virtual ui::ViewAndroid* GetViewAndroid() const OVERRIDE; virtual ui::WindowAndroid* GetWindowAndroid() const OVERRIDE; virtual scoped_refptr<cc::Layer> GetLayer() const OVERRIDE; virtual void LoadUrl(NavigationController::LoadURLParams& params) OVERRIDE; @@ -344,6 +345,10 @@ class ContentViewCoreImpl : public ContentViewCore, // Device scale factor. float dpi_scale_; + // The Android view that can be used to add and remove decoration layers + // like AutofillPopup. + ui::ViewAndroid* view_android_; + // The owning window that has a hold of main application activity. ui::WindowAndroid* window_android_; |