summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/android/testshell/chrome_main_delegate_testshell_android.cc13
-rw-r--r--chrome/android/testshell/java/src/org/chromium/chrome/testshell/ChromiumTestShellActivity.java1
-rw-r--r--chrome/android/testshell/java/src/org/chromium/chrome/testshell/TabManager.java22
-rw-r--r--chrome/android/testshell/tab_manager.cc49
-rw-r--r--chrome/android/testshell/tab_manager.h16
-rw-r--r--chrome/browser/android/tab_base_android_impl.cc39
-rw-r--r--chrome/browser/android/tab_base_android_impl.h7
-rw-r--r--chrome/chrome_android.gypi14
-rw-r--r--content/browser/android/browser_jni_registrar.cc3
-rw-r--r--content/browser/android/content_view_core_impl.cc21
-rw-r--r--content/browser/android/content_view_core_impl.h11
-rw-r--r--content/browser/android/content_view_render_view.cc150
-rw-r--r--content/browser/android/content_view_render_view.h45
-rw-r--r--content/browser/renderer_host/render_view_host_delegate.h9
-rw-r--r--content/browser/renderer_host/render_view_host_impl.cc7
-rw-r--r--content/browser/renderer_host/render_view_host_impl.h5
-rw-r--r--content/browser/renderer_host/render_widget_host_impl.h5
-rw-r--r--content/browser/renderer_host/render_widget_host_view_android.cc24
-rw-r--r--content/browser/renderer_host/render_widget_host_view_android.h1
-rw-r--r--content/browser/web_contents/interstitial_page_impl.cc10
-rw-r--r--content/browser/web_contents/interstitial_page_impl.h5
-rw-r--r--content/browser/web_contents/web_contents_impl.cc12
-rw-r--r--content/browser/web_contents/web_contents_impl.h5
-rw-r--r--content/public/android/java/src/org/chromium/content/browser/ContentViewRenderView.java47
-rw-r--r--content/public/browser/android/content_view_core.h5
-rw-r--r--content/public/browser/web_contents_delegate.h12
-rw-r--r--content/shell/android/java/src/org/chromium/content_shell/Shell.java6
-rw-r--r--content/shell/android/java/src/org/chromium/content_shell/ShellManager.java18
-rw-r--r--content/shell/android/shell_manager.cc6
-rw-r--r--content/shell/shell.cc2
-rw-r--r--content/shell/shell.h15
-rw-r--r--content/shell/shell_android.cc14
32 files changed, 195 insertions, 404 deletions
diff --git a/chrome/android/testshell/chrome_main_delegate_testshell_android.cc b/chrome/android/testshell/chrome_main_delegate_testshell_android.cc
index 0e1b656..bba5d4c 100644
--- a/chrome/android/testshell/chrome_main_delegate_testshell_android.cc
+++ b/chrome/android/testshell/chrome_main_delegate_testshell_android.cc
@@ -5,16 +5,10 @@
#include "chrome/android/testshell/chrome_main_delegate_testshell_android.h"
#include "base/android/jni_android.h"
-#include "base/android/jni_registrar.h"
-#include "chrome/android/testshell/tab_manager.h"
#include "chrome/browser/search_engines/template_url_prepopulate_data.h"
static const char kDefaultCountryCode[] = "US";
-static base::android::RegistrationMethod kRegistrationMethods[] = {
- { "TabManager", chrome::RegisterTabManager },
-};
-
ChromeMainDelegateTestShellAndroid::ChromeMainDelegateTestShellAndroid() {
}
@@ -28,10 +22,5 @@ bool ChromeMainDelegateTestShellAndroid::BasicStartupComplete(int* exit_code) {
bool ChromeMainDelegateTestShellAndroid::RegisterApplicationNativeMethods(
JNIEnv* env) {
- if (!ChromeMainDelegateAndroid::RegisterApplicationNativeMethods(env))
- return false;
-
- return base::android::RegisterNativeMethods(env,
- kRegistrationMethods,
- arraysize(kRegistrationMethods));
+ return ChromeMainDelegateAndroid::RegisterApplicationNativeMethods(env);
}
diff --git a/chrome/android/testshell/java/src/org/chromium/chrome/testshell/ChromiumTestShellActivity.java b/chrome/android/testshell/java/src/org/chromium/chrome/testshell/ChromiumTestShellActivity.java
index ede99c1..081aba6 100644
--- a/chrome/android/testshell/java/src/org/chromium/chrome/testshell/ChromiumTestShellActivity.java
+++ b/chrome/android/testshell/java/src/org/chromium/chrome/testshell/ChromiumTestShellActivity.java
@@ -62,6 +62,7 @@ public class ChromiumTestShellActivity extends Activity {
@Override
protected void onDestroy() {
super.onDestroy();
+
mDevToolsServer.destroy();
mDevToolsServer = null;
}
diff --git a/chrome/android/testshell/java/src/org/chromium/chrome/testshell/TabManager.java b/chrome/android/testshell/java/src/org/chromium/chrome/testshell/TabManager.java
index b5f64c7..2f6a51b 100644
--- a/chrome/android/testshell/java/src/org/chromium/chrome/testshell/TabManager.java
+++ b/chrome/android/testshell/java/src/org/chromium/chrome/testshell/TabManager.java
@@ -10,8 +10,6 @@ import android.content.Context;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
-import org.chromium.base.JNINamespace;
-
import org.chromium.chrome.browser.TabBase;
import org.chromium.content.browser.ContentViewRenderView;
import org.chromium.ui.gfx.NativeWindow;
@@ -21,13 +19,12 @@ import org.chromium.ui.gfx.NativeWindow;
* a {@link TabBase}. It properly builds a {@link TabBase} and makes sure that the {@link Toolbar}
* and {@link ContentViewRenderView} show the proper content.
*/
-@JNINamespace("chrome")
public class TabManager extends LinearLayout {
private static final String DEFAULT_URL = "http://www.google.com";
private NativeWindow mWindow;
private ViewGroup mContentViewHolder;
- private ContentViewRenderView mRenderTarget;
+ private ContentViewRenderView mContentViewRenderView;
private TestShellToolbar mToolbar;
private TabBase mCurrentTab;
@@ -48,13 +45,13 @@ public class TabManager extends LinearLayout {
mContentViewHolder = (ViewGroup) findViewById(R.id.content_container);
mToolbar = (TestShellToolbar) findViewById(R.id.toolbar);
- mRenderTarget = new ContentViewRenderView(getContext()) {
+ mContentViewRenderView = new ContentViewRenderView(getContext()) {
@Override
protected void onReadyToRender() {
if (mCurrentTab == null) createTab(mStartupUrl);
}
};
- mContentViewHolder.addView(mRenderTarget,
+ mContentViewHolder.addView(mContentViewRenderView,
new FrameLayout.LayoutParams(
FrameLayout.LayoutParams.MATCH_PARENT,
FrameLayout.LayoutParams.MATCH_PARENT));
@@ -86,21 +83,19 @@ public class TabManager extends LinearLayout {
* @param url The URL the new {@link TabBase} should start with.
*/
public void createTab(String url) {
- if (!isRenderTargetInitialized()) return;
+ if (!isContentViewRenderViewInitialized()) return;
TabBase tab = new TabBase(getContext(), url, mWindow);
setCurrentTab(tab);
}
- private boolean isRenderTargetInitialized() {
- return mRenderTarget != null && mRenderTarget.isInitialized();
+ private boolean isContentViewRenderViewInitialized() {
+ return mContentViewRenderView != null && mContentViewRenderView.isInitialized();
}
private void setCurrentTab(TabBase tab) {
- int nativeContentViewLayerRenderer = mRenderTarget.getNativeContentViewLayerRenderer();
if (mCurrentTab != null) {
mContentViewHolder.removeView(mCurrentTab.getContentView());
- nativeHideTab(mCurrentTab.getNativeTab(), nativeContentViewLayerRenderer);
mCurrentTab.destroy();
}
@@ -108,10 +103,7 @@ public class TabManager extends LinearLayout {
mToolbar.showTab(mCurrentTab);
mContentViewHolder.addView(mCurrentTab.getContentView());
+ mContentViewRenderView.setCurrentContentView(mCurrentTab.getContentView());
mCurrentTab.getContentView().requestFocus();
- nativeShowTab(mCurrentTab.getNativeTab(), nativeContentViewLayerRenderer);
}
-
- private static native void nativeShowTab(int jtab, int contentViewLayerRenderer);
- private static native void nativeHideTab(int jtab, int contentViewLayerRenderer);
} \ No newline at end of file
diff --git a/chrome/android/testshell/tab_manager.cc b/chrome/android/testshell/tab_manager.cc
deleted file mode 100644
index 0a9da47..0000000
--- a/chrome/android/testshell/tab_manager.cc
+++ /dev/null
@@ -1,49 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/android/testshell/tab_manager.h"
-
-#include "base/logging.h"
-#include "base/android/jni_android.h"
-#include "base/android/jni_string.h"
-#include "base/android/scoped_java_ref.h"
-#include "base/bind.h"
-#include "base/lazy_instance.h"
-#include "base/message_loop.h"
-#include "chrome/browser/android/tab_base_android_impl.h"
-#include "content/public/browser/android/content_view_layer_renderer.h"
-#include "jni/TabManager_jni.h"
-#include "third_party/WebKit/Source/Platform/chromium/public/WebLayer.h"
-
-#include <android/native_window_jni.h>
-
-using base::android::ScopedJavaLocalRef;
-using content::ContentViewLayerRenderer;
-
-namespace chrome {
-
-// Register native methods
-bool RegisterTabManager(JNIEnv* env) {
- return RegisterNativesImpl(env);
-}
-
-static void ShowTab(JNIEnv* env, jclass clazz, jint jtab,
- jint j_content_view_layer_renderer) {
- TabBaseAndroidImpl* tab = reinterpret_cast<TabBaseAndroidImpl*>(jtab);
- ContentViewLayerRenderer* content_view_layer_renderer =
- reinterpret_cast<ContentViewLayerRenderer*>(
- j_content_view_layer_renderer);
- content_view_layer_renderer->AttachLayer(tab->tab_layer());
-}
-
-static void HideTab(JNIEnv* env, jclass clazz, jint jtab,
- jint j_content_view_layer_renderer) {
- TabBaseAndroidImpl* tab = reinterpret_cast<TabBaseAndroidImpl*>(jtab);
- ContentViewLayerRenderer* content_view_layer_renderer =
- reinterpret_cast<ContentViewLayerRenderer*>(
- j_content_view_layer_renderer);
- content_view_layer_renderer->DetachLayer(tab->tab_layer());
-}
-
-} // namespace chrome
diff --git a/chrome/android/testshell/tab_manager.h b/chrome/android/testshell/tab_manager.h
deleted file mode 100644
index c576768..0000000
--- a/chrome/android/testshell/tab_manager.h
+++ /dev/null
@@ -1,16 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_ANDROID_TESTSHELL_TAB_MANAGER_H_
-#define CHROME_ANDROID_TESTSHELL_TAB_MANAGER_H_
-
-#include <jni.h>
-
-namespace chrome {
-
-bool RegisterTabManager(JNIEnv* env);
-
-}
-
-#endif // CHROME_ANDROID_TESTSHELL_TAB_MANAGER_H_
diff --git a/chrome/browser/android/tab_base_android_impl.cc b/chrome/browser/android/tab_base_android_impl.cc
index b2f639d..bde238b 100644
--- a/chrome/browser/android/tab_base_android_impl.cc
+++ b/chrome/browser/android/tab_base_android_impl.cc
@@ -13,7 +13,6 @@
#include "content/public/browser/web_contents.h"
#include "googleurl/src/gurl.h"
#include "jni/TabBase_jni.h"
-#include "third_party/WebKit/Source/Platform/chromium/public/WebLayer.h"
#include "ui/gfx/android/window_android.h"
using base::android::ConvertJavaStringToUTF8;
@@ -23,43 +22,11 @@ using chrome::android::ChromeWebContentsDelegateAndroid;
using content::WebContents;
using ui::WindowAndroid;
-namespace {
-class ChromeWebContentsDelegateRenderAndroid
- : public ChromeWebContentsDelegateAndroid {
- public:
- ChromeWebContentsDelegateRenderAndroid(TabBaseAndroidImpl* tab_android_impl,
- JNIEnv* env,
- jobject obj)
- : ChromeWebContentsDelegateAndroid(env, obj),
- tab_android_impl_(tab_android_impl) {
- }
-
- virtual ~ChromeWebContentsDelegateRenderAndroid() {
- }
-
- virtual void AttachLayer(WebContents* web_contents,
- WebKit::WebLayer* layer) OVERRIDE {
- tab_android_impl_->tab_layer()->addChild(layer);
- }
-
- virtual void RemoveLayer(WebContents* web_contents,
- WebKit::WebLayer* layer) OVERRIDE {
- layer->removeFromParent();
- }
-
- private:
- TabBaseAndroidImpl* tab_android_impl_;
-
- DISALLOW_COPY_AND_ASSIGN(ChromeWebContentsDelegateRenderAndroid);
-};
-} // namespace
-
TabBaseAndroidImpl::TabBaseAndroidImpl(JNIEnv* env,
jobject obj,
WebContents* web_contents,
WindowAndroid* window_android)
- : web_contents_(web_contents),
- tab_layer_(WebKit::WebLayer::create()) {
+ : web_contents_(web_contents) {
InitTabHelpers(web_contents);
WindowAndroidHelper::FromWebContents(web_contents)->
SetWindowAndroid(window_android);
@@ -113,9 +80,7 @@ void TabBaseAndroidImpl::InitWebContentsDelegate(
jobject obj,
jobject web_contents_delegate) {
web_contents_delegate_.reset(
- new ChromeWebContentsDelegateRenderAndroid(this,
- env,
- web_contents_delegate));
+ new ChromeWebContentsDelegateAndroid(env, web_contents_delegate));
web_contents_->SetDelegate(web_contents_delegate_.get());
}
diff --git a/chrome/browser/android/tab_base_android_impl.h b/chrome/browser/android/tab_base_android_impl.h
index a04b588..a5a2907 100644
--- a/chrome/browser/android/tab_base_android_impl.h
+++ b/chrome/browser/android/tab_base_android_impl.h
@@ -29,10 +29,6 @@ namespace ui {
class WindowAndroid;
}
-namespace WebKit {
-class WebLayer;
-}
-
class TabBaseAndroidImpl : public TabAndroid {
public:
TabBaseAndroidImpl(JNIEnv* env,
@@ -41,8 +37,6 @@ class TabBaseAndroidImpl : public TabAndroid {
ui::WindowAndroid* window_android);
void Destroy(JNIEnv* env, jobject obj);
- WebKit::WebLayer* tab_layer() const { return tab_layer_.get(); }
-
// --------------------------------------------------------------------------
// TabAndroid Methods
// --------------------------------------------------------------------------
@@ -86,7 +80,6 @@ class TabBaseAndroidImpl : public TabAndroid {
private:
scoped_ptr<content::WebContents> web_contents_;
- scoped_ptr<WebKit::WebLayer> tab_layer_;
scoped_ptr<chrome::android::ChromeWebContentsDelegateAndroid>
web_contents_delegate_;
diff --git a/chrome/chrome_android.gypi b/chrome/chrome_android.gypi
index 9748bda..d99e143 100644
--- a/chrome/chrome_android.gypi
+++ b/chrome/chrome_android.gypi
@@ -14,13 +14,10 @@
'type': 'shared_library',
'dependencies': [
'chrome_android_core',
- 'chromium_testshell_jni_headers',
],
'sources': [
'android/testshell/chrome_main_delegate_testshell_android.cc',
'android/testshell/chrome_main_delegate_testshell_android.h',
- 'android/testshell/tab_manager.cc',
- 'android/testshell/tab_manager.h',
'android/testshell/testshell_entry_point.cc',
"android/testshell/testshell_google_location_settings_helper.cc",
"android/testshell/testshell_google_location_settings_helper.h",
@@ -63,17 +60,6 @@
'includes': [ '../build/java_apk.gypi', ],
},
{
- 'target_name': 'chromium_testshell_jni_headers',
- 'type': 'none',
- 'sources': [
- 'android/testshell/java/src/org/chromium/chrome/testshell/TabManager.java',
- ],
- 'variables': {
- 'jni_gen_dir': 'chromium_testshell',
- },
- 'includes': [ '../build/jni_generator.gypi' ],
- },
- {
# chromium_testshell creates a .jar as a side effect. Any java targets
# that need that .jar in their classpath should depend on this target,
# chromium_testshell_java. Dependents of chromium_testshell receive its
diff --git a/content/browser/android/browser_jni_registrar.cc b/content/browser/android/browser_jni_registrar.cc
index 77ef26d..44ea562 100644
--- a/content/browser/android/browser_jni_registrar.cc
+++ b/content/browser/android/browser_jni_registrar.cc
@@ -32,7 +32,8 @@ base::android::RegistrationMethod kContentRegisteredMethods[] = {
{ "BrowserProcessSurfaceTexture",
SurfaceTexturePeerBrowserImpl::RegisterBrowserProcessSurfaceTexture },
{ "ContentSettings", content::ContentSettings::RegisterContentSettings },
- { "ContentViewRenderView", content::RegisterContentViewRenderView },
+ { "ContentViewRenderView",
+ content::ContentViewRenderView::RegisterContentViewRenderView },
{ "ContentVideoView", content::ContentVideoView::RegisterContentVideoView },
{ "ContentViewCore", content::RegisterContentViewCore },
{ "DownloadControllerAndroidImpl",
diff --git a/content/browser/android/content_view_core_impl.cc b/content/browser/android/content_view_core_impl.cc
index 95c5180..02e4c2b 100644
--- a/content/browser/android/content_view_core_impl.cc
+++ b/content/browser/android/content_view_core_impl.cc
@@ -59,6 +59,7 @@ using base::android::ScopedJavaLocalRef;
using WebKit::WebGestureEvent;
using WebKit::WebInputEvent;
using WebKit::WebInputEventFactory;
+using WebKit::WebLayer;
// Describes the type and enabled state of a select popup item.
// Keep in sync with the value defined in SelectPopupDialog.java
@@ -145,6 +146,7 @@ ContentViewCoreImpl::ContentViewCoreImpl(JNIEnv* env, jobject obj,
ui::WindowAndroid* window_android)
: java_ref_(env, obj),
web_contents_(static_cast<WebContentsImpl*>(web_contents)),
+ root_layer_(WebLayer::create()),
tab_crashed_(false),
window_android_(window_android) {
DCHECK(web_contents) <<
@@ -548,11 +550,6 @@ unsigned int ContentViewCoreImpl::GetScaledContentTexture(
return view->GetScaledContentTexture(size);
}
-WebKit::WebLayer* ContentViewCoreImpl::GetWebLayer() {
- RenderWidgetHostViewAndroid* view = GetRenderWidgetHostViewAndroid();
- return view ? view->GetWebLayer() : NULL;
-}
-
void ContentViewCoreImpl::StartContentIntent(const GURL& content_url) {
JNIEnv* env = AttachCurrentThread();
ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env);
@@ -602,16 +599,28 @@ gfx::Rect ContentViewCoreImpl::GetBounds() const {
Java_ContentViewCore_getHeight(env, j_obj.obj()));
}
+void ContentViewCoreImpl::AttachWebLayer(WebLayer* layer) {
+ root_layer_->addChild(layer);
+}
+
+void ContentViewCoreImpl::RemoveWebLayer(WebLayer* layer) {
+ layer->removeFromParent();
+}
+
void ContentViewCoreImpl::LoadUrl(
NavigationController::LoadURLParams& params) {
GetWebContents()->GetController().LoadURLWithParams(params);
tab_crashed_ = false;
}
-ui::WindowAndroid* ContentViewCoreImpl::GetWindowAndroid() {
+ui::WindowAndroid* ContentViewCoreImpl::GetWindowAndroid() const {
return window_android_;
}
+WebLayer* ContentViewCoreImpl::GetWebLayer() const {
+ return root_layer_.get();
+}
+
// ----------------------------------------------------------------------------
// Methods called from Java via JNI
// ----------------------------------------------------------------------------
diff --git a/content/browser/android/content_view_core_impl.h b/content/browser/android/content_view_core_impl.h
index 6157f70..4078f38 100644
--- a/content/browser/android/content_view_core_impl.h
+++ b/content/browser/android/content_view_core_impl.h
@@ -47,13 +47,13 @@ class ContentViewCoreImpl : public ContentViewCore,
virtual base::android::ScopedJavaLocalRef<jobject> GetContainerViewDelegate()
OVERRIDE;
virtual WebContents* GetWebContents() const OVERRIDE;
- virtual ui::WindowAndroid* GetWindowAndroid() OVERRIDE;
+ virtual ui::WindowAndroid* GetWindowAndroid() const OVERRIDE;
+ virtual WebKit::WebLayer* GetWebLayer() const OVERRIDE;
virtual void LoadUrl(NavigationController::LoadURLParams& params) OVERRIDE;
virtual void OnWebPreferencesUpdated() OVERRIDE;
virtual jint GetCurrentRenderProcessId(JNIEnv* env, jobject obj) OVERRIDE;
virtual void ShowPastePopup(int x, int y) OVERRIDE;
virtual unsigned int GetScaledContentTexture(const gfx::Size& size) OVERRIDE;
- virtual WebKit::WebLayer* GetWebLayer() OVERRIDE;
// --------------------------------------------------------------------------
// Methods called from Java via JNI
@@ -229,8 +229,12 @@ class ContentViewCoreImpl : public ContentViewCore,
gfx::Rect GetBounds() const;
+ void AttachWebLayer(WebKit::WebLayer* layer);
+ void RemoveWebLayer(WebKit::WebLayer* layer);
+
private:
class ContentViewUserData;
+
friend class ContentViewUserData;
virtual ~ContentViewCoreImpl();
@@ -269,6 +273,9 @@ class ContentViewCoreImpl : public ContentViewCore,
// display in the ContentViewCore.
WebContentsImpl* web_contents_;
+ // A WebLayer containing any WebLayer that should be shown.
+ scoped_ptr<WebKit::WebLayer> root_layer_;
+
// Whether the renderer backing this ContentViewCore has crashed.
bool tab_crashed_;
diff --git a/content/browser/android/content_view_render_view.cc b/content/browser/android/content_view_render_view.cc
index 1db4e61..2e040c5 100644
--- a/content/browser/android/content_view_render_view.cc
+++ b/content/browser/android/content_view_render_view.cc
@@ -11,9 +11,9 @@
#include "base/lazy_instance.h"
#include "base/memory/scoped_ptr.h"
#include "base/message_loop.h"
+#include "content/browser/android/content_view_core_impl.h"
#include "content/public/browser/android/compositor.h"
#include "content/public/browser/android/content_view_layer_renderer.h"
-#include "content/public/browser/android/draw_delegate.h"
#include "jni/ContentViewRenderView_jni.h"
#include "third_party/WebKit/Source/Platform/chromium/public/WebLayer.h"
#include "ui/gfx/size.h"
@@ -21,121 +21,87 @@
#include <android/native_window_jni.h>
using base::android::ScopedJavaLocalRef;
-using base::android::ScopedJavaGlobalRef;
-using content::Compositor;
-using content::DrawDelegate;
-namespace {
-
-class CompositorClient : public Compositor::Client {
- public:
- virtual void ScheduleComposite() OVERRIDE;
-};
+namespace content {
-class ContentViewLayerRendererImpl;
+// static
+bool ContentViewRenderView::RegisterContentViewRenderView(JNIEnv* env) {
+ return RegisterNativesImpl(env);
+}
-struct GlobalState {
- GlobalState() : g_scheduled_composite(false) {}
- ScopedJavaGlobalRef<jobject> j_obj;
- CompositorClient client;
- scoped_ptr<content::Compositor> compositor;
- scoped_ptr<WebKit::WebLayer> root_layer;
- scoped_ptr<ContentViewLayerRendererImpl> layer_renderer;
- bool g_scheduled_composite;
-};
+ContentViewRenderView::ContentViewRenderView()
+ : scheduled_composite_(false),
+ weak_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) {
+}
-base::LazyInstance<GlobalState> g_global_state = LAZY_INSTANCE_INITIALIZER;
+ContentViewRenderView::~ContentViewRenderView() {
+}
-content::Compositor* GetCompositor() {
- return g_global_state.Get().compositor.get();
+// static
+jint Init(JNIEnv* env, jclass clazz) {
+ ContentViewRenderView* content_view_render_view =
+ new ContentViewRenderView();
+ return reinterpret_cast<jint>(content_view_render_view);
}
-class ContentViewLayerRendererImpl : public content::ContentViewLayerRenderer {
- public:
- ContentViewLayerRendererImpl() {}
- virtual ~ContentViewLayerRendererImpl() {}
-
- private:
- virtual void AttachLayer(WebKit::WebLayer* layer) OVERRIDE {
- if (GetCompositor())
- g_global_state.Get().root_layer->addChild(layer);
- }
-
- virtual void DetachLayer(WebKit::WebLayer* layer) OVERRIDE {
- if (GetCompositor())
- layer->removeFromParent();
- }
-
- DISALLOW_COPY_AND_ASSIGN(ContentViewLayerRendererImpl);
-};
-
-void Composite() {
- g_global_state.Get().g_scheduled_composite = false;
- if (GetCompositor())
- GetCompositor()->Composite();
+void ContentViewRenderView::Destroy(JNIEnv* env, jobject obj) {
+ delete this;
}
-void CompositorClient::ScheduleComposite() {
- if (!g_global_state.Get().g_scheduled_composite) {
- g_global_state.Get().g_scheduled_composite = true;
- MessageLoop::current()->PostTask(FROM_HERE, base::Bind(&Composite));
- }
+void ContentViewRenderView::SetCurrentContentView(
+ JNIEnv* env, jobject obj, int native_content_view) {
+ InitCompositor();
+ ContentViewCoreImpl* content_view =
+ reinterpret_cast<ContentViewCoreImpl*>(native_content_view);
+ if (content_view)
+ compositor_->SetRootLayer(content_view->GetWebLayer());
}
-void InitCompositor() {
- if (GetCompositor())
+void ContentViewRenderView::SurfaceCreated(
+ JNIEnv* env, jobject obj, jobject jsurface) {
+ InitCompositor();
+ ANativeWindow* native_window = ANativeWindow_fromSurface(env, jsurface);
+ if (!native_window)
return;
- Compositor::Initialize();
- g_global_state.Get().compositor.reset(
- Compositor::Create(&g_global_state.Get().client));
- DCHECK(!g_global_state.Get().root_layer.get());
- g_global_state.Get().root_layer.reset(WebKit::WebLayer::create());
- g_global_state.Get().layer_renderer.reset(new ContentViewLayerRendererImpl());
+ compositor_->SetWindowSurface(native_window);
+ ANativeWindow_release(native_window);
}
-} // anonymous namespace
-
-namespace content {
-
-// Register native methods
-bool RegisterContentViewRenderView(JNIEnv* env) {
- return RegisterNativesImpl(env);
+void ContentViewRenderView::SurfaceDestroyed(JNIEnv* env, jobject obj) {
+ compositor_->SetWindowSurface(NULL);
}
-static void Init(JNIEnv* env, jobject obj) {
- g_global_state.Get().j_obj.Reset(ScopedJavaLocalRef<jobject>(env, obj));
+void ContentViewRenderView::SurfaceSetSize(
+ JNIEnv* env, jobject obj, jint width, jint height) {
+ compositor_->SetWindowBounds(gfx::Size(width, height));
}
-static jint GetNativeContentViewLayerRenderer(JNIEnv* env, jclass clazz) {
- // The compositor might not have been initialized yet.
- InitCompositor();
- // Note it's important to static cast to the interface here as we'll
- // reinterpret cast the jint back to the interace later on.
- return reinterpret_cast<jint>(static_cast<content::ContentViewLayerRenderer*>(
- g_global_state.Get().layer_renderer.get()));
-}
+void ContentViewRenderView::ScheduleComposite() {
+ if (scheduled_composite_)
+ return;
-static void SurfaceCreated(
- JNIEnv* env, jclass clazz, jobject jsurface) {
- InitCompositor();
- ANativeWindow* native_window = ANativeWindow_fromSurface(env, jsurface);
- if (native_window) {
- GetCompositor()->SetWindowSurface(native_window);
- ANativeWindow_release(native_window);
- GetCompositor()->SetRootLayer(g_global_state.Get().root_layer.get());
- }
+ scheduled_composite_ = true;
+ MessageLoop::current()->PostTask(
+ FROM_HERE,
+ base::Bind(&ContentViewRenderView::Composite,
+ weak_factory_.GetWeakPtr()));
}
-static void SurfaceDestroyed(JNIEnv* env, jclass clazz) {
- GetCompositor()->SetWindowSurface(NULL);
+void ContentViewRenderView::InitCompositor() {
+ if (compositor_.get())
+ return;
+
+ Compositor::Initialize();
+ compositor_.reset(Compositor::Create(this));
}
-static void SurfaceSetSize(
- JNIEnv* env, jclass clazz, jint width, jint height) {
- gfx::Size size = gfx::Size(width, height);
- DrawDelegate::GetInstance()->SetBounds(size);
- GetCompositor()->SetWindowBounds(size);
+void ContentViewRenderView::Composite() {
+ if (!compositor_.get())
+ return;
+
+ scheduled_composite_ = false;
+ compositor_->Composite();
}
} // namespace content
diff --git a/content/browser/android/content_view_render_view.h b/content/browser/android/content_view_render_view.h
index 2770a5e..da371c55 100644
--- a/content/browser/android/content_view_render_view.h
+++ b/content/browser/android/content_view_render_view.h
@@ -7,10 +7,51 @@
#include <jni.h>
+#include "base/logging.h"
+#include "base/memory/weak_ptr.h"
+#include "content/public/browser/android/compositor.h"
+
namespace content {
-// Registers the JNI methods for ContentViewRender.
-bool RegisterContentViewRenderView(JNIEnv* env);
+class ContentViewRenderView : public Compositor::Client {
+ public:
+ // Registers the JNI methods for ContentViewRender.
+ static bool RegisterContentViewRenderView(JNIEnv* env);
+
+ ContentViewRenderView();
+
+ // --------------------------------------------------------------------------
+ // Methods called from Java via JNI
+ // --------------------------------------------------------------------------
+ static jint Init(JNIEnv* env, jclass clazz);
+ void Destroy(JNIEnv* env, jobject obj);
+ void SetCurrentContentView(JNIEnv* env, jobject obj, int native_content_view);
+ void SurfaceCreated(JNIEnv* env, jobject obj, jobject jsurface);
+ void SurfaceDestroyed(JNIEnv* env, jobject obj);
+ void SurfaceSetSize(JNIEnv* env, jobject obj, jint width, jint height);
+
+ private:
+ friend class base::RefCounted<ContentViewRenderView>;
+ virtual ~ContentViewRenderView();
+
+ // Compositor::Client implementation.
+ virtual void ScheduleComposite() OVERRIDE;
+
+ void InitCompositor();
+ void Composite();
+
+ scoped_ptr<content::Compositor> compositor_;
+ bool scheduled_composite_;
+
+ base::WeakPtrFactory<ContentViewRenderView> weak_factory_;
+
+ // Note that this class does not call back to Java and as a result does not
+ // have a reference to its Java object.
+
+ DISALLOW_COPY_AND_ASSIGN(ContentViewRenderView);
+};
+
+
}
diff --git a/content/browser/renderer_host/render_view_host_delegate.h b/content/browser/renderer_host/render_view_host_delegate.h
index c424f1a..70bd895 100644
--- a/content/browser/renderer_host/render_view_host_delegate.h
+++ b/content/browser/renderer_host/render_view_host_delegate.h
@@ -47,10 +47,6 @@ class Rect;
class Size;
}
-namespace WebKit {
-class WebLayer;
-}
-
namespace content {
class BrowserContext;
@@ -418,11 +414,6 @@ class CONTENT_EXPORT RenderViewHostDelegate {
const MediaStreamRequest* request,
const MediaResponseCallback& callback) {}
-#if defined(OS_ANDROID)
- virtual void AttachLayer(WebKit::WebLayer* layer) {}
- virtual void RemoveLayer(WebKit::WebLayer* layer) {}
-#endif
-
protected:
virtual ~RenderViewHostDelegate() {}
};
diff --git a/content/browser/renderer_host/render_view_host_impl.cc b/content/browser/renderer_host/render_view_host_impl.cc
index 569001c..a1a889c 100644
--- a/content/browser/renderer_host/render_view_host_impl.cc
+++ b/content/browser/renderer_host/render_view_host_impl.cc
@@ -1677,13 +1677,6 @@ void RenderViewHostImpl::ForwardKeyboardEvent(
}
#if defined(OS_ANDROID)
-void RenderViewHostImpl::AttachLayer(WebKit::WebLayer* layer) {
- delegate_->AttachLayer(layer);
-}
-
-void RenderViewHostImpl::RemoveLayer(WebKit::WebLayer* layer) {
- delegate_->RemoveLayer(layer);
-}
void RenderViewHostImpl::DidSelectPopupMenuItems(
const std::vector<int>& selected_indices) {
Send(new ViewMsg_SelectPopupMenuItems(GetRoutingID(), false,
diff --git a/content/browser/renderer_host/render_view_host_impl.h b/content/browser/renderer_host/render_view_host_impl.h
index 26c2777..f6710a4 100644
--- a/content/browser/renderer_host/render_view_host_impl.h
+++ b/content/browser/renderer_host/render_view_host_impl.h
@@ -382,11 +382,6 @@ class CONTENT_EXPORT RenderViewHostImpl
const NativeWebKeyboardEvent& key_event) OVERRIDE;
virtual gfx::Rect GetRootWindowResizerRect() const OVERRIDE;
-#if defined(OS_ANDROID)
- virtual void AttachLayer(WebKit::WebLayer* layer) OVERRIDE;
- virtual void RemoveLayer(WebKit::WebLayer* layer) OVERRIDE;
-#endif
-
// Creates a new RenderView with the given route id.
void CreateNewWindow(
int route_id,
diff --git a/content/browser/renderer_host/render_widget_host_impl.h b/content/browser/renderer_host/render_widget_host_impl.h
index 06dd7d2..c3f2ff8 100644
--- a/content/browser/renderer_host/render_widget_host_impl.h
+++ b/content/browser/renderer_host/render_widget_host_impl.h
@@ -428,11 +428,6 @@ class CONTENT_EXPORT RenderWidgetHostImpl : virtual public RenderWidgetHost,
allow_privileged_mouse_lock_ = allow;
}
-#if defined(OS_ANDROID)
- virtual void AttachLayer(WebKit::WebLayer* layer) {}
- virtual void RemoveLayer(WebKit::WebLayer* layer) {}
-#endif
-
// Resets state variables related to tracking pending size and painting.
//
// We need to reset these flags when we want to repaint the contents of
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 53ca77c..5a13d57 100644
--- a/content/browser/renderer_host/render_widget_host_view_android.cc
+++ b/content/browser/renderer_host/render_widget_host_view_android.cc
@@ -52,19 +52,19 @@ RenderWidgetHostViewAndroid::RenderWidgetHostViewAndroid(
// 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),
+ content_view_core_(NULL),
ime_adapter_android_(ALLOW_THIS_IN_INITIALIZER_LIST(this)),
cached_background_color_(SK_ColorWHITE),
texture_layer_(WebKit::WebExternalTextureLayer::create()),
texture_id_in_layer_(0) {
host_->SetView(this);
+ SetContentViewCore(content_view_core);
// RenderWidgetHost is initialized as visible. If is_hidden_ is true, tell
// RenderWidgetHost to hide.
if (is_hidden_)
host_->WasHidden();
texture_layer_->layer()->setOpaque(true);
texture_layer_->layer()->setDrawsContent(!is_hidden_);
- host_->AttachLayer(texture_layer_->layer());
}
RenderWidgetHostViewAndroid::~RenderWidgetHostViewAndroid() {
@@ -178,10 +178,6 @@ bool RenderWidgetHostViewAndroid::PopulateBitmapWithContents(jobject jbitmap) {
return true;
}
-WebKit::WebLayer* RenderWidgetHostViewAndroid::GetWebLayer() {
- return texture_layer_->layer();
-}
-
gfx::NativeView RenderWidgetHostViewAndroid::GetNativeView() const {
return content_view_core_;
}
@@ -230,10 +226,8 @@ bool RenderWidgetHostViewAndroid::IsSurfaceAvailableForCopy() const {
}
void RenderWidgetHostViewAndroid::Show() {
- if (content_view_core_) {
- host_->AttachLayer(texture_layer_->layer());
+ if (content_view_core_)
is_hidden_ = false;
- }
texture_layer_->layer()->setDrawsContent(true);
}
@@ -298,9 +292,10 @@ void RenderWidgetHostViewAndroid::RenderViewGone(
}
void RenderWidgetHostViewAndroid::Destroy() {
- host_->RemoveLayer(texture_layer_->layer());
-
- content_view_core_ = NULL;
+ if (content_view_core_) {
+ content_view_core_->RemoveWebLayer(texture_layer_->layer());
+ content_view_core_ = NULL;
+ }
// The RenderWidgetHost's destruction led here, so don't call it.
host_ = NULL;
@@ -546,12 +541,17 @@ void RenderWidgetHostViewAndroid::UpdateFrameInfo(
void RenderWidgetHostViewAndroid::SetContentViewCore(
ContentViewCoreImpl* content_view_core) {
+ if (content_view_core_)
+ content_view_core_->RemoveWebLayer(texture_layer_->layer());
+
content_view_core_ = content_view_core;
if (host_) {
GpuSurfaceTracker::Get()->SetSurfaceHandle(
host_->surface_id(), content_view_core_ ?
GetCompositingSurface() : gfx::GLSurfaceHandle());
}
+ if (content_view_core_)
+ content_view_core_->AttachWebLayer(texture_layer_->layer());
}
void RenderWidgetHostViewAndroid::HasTouchEventHandlers(
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 3606eb9..0f075cd 100644
--- a/content/browser/renderer_host/render_widget_host_view_android.h
+++ b/content/browser/renderer_host/render_widget_host_view_android.h
@@ -140,7 +140,6 @@ class RenderWidgetHostViewAndroid : public RenderWidgetHostViewBase {
WebKit::WebGLId GetScaledContentTexture(const gfx::Size& size);
bool PopulateBitmapWithContents(jobject jbitmap);
- WebKit::WebLayer* GetWebLayer();
// Select all text between the given coordinates.
void SelectRange(const gfx::Point& start, const gfx::Point& end);
diff --git a/content/browser/web_contents/interstitial_page_impl.cc b/content/browser/web_contents/interstitial_page_impl.cc
index c7738bd..58fa2fa 100644
--- a/content/browser/web_contents/interstitial_page_impl.cc
+++ b/content/browser/web_contents/interstitial_page_impl.cc
@@ -685,16 +685,6 @@ void InterstitialPageImpl::ShowContextMenu(
ContextMenuSourceType type) {
}
-#if defined(OS_ANDROID)
-void InterstitialPageImpl::AttachLayer(WebKit::WebLayer* layer) {
- web_contents_->AttachLayer(layer);
-}
-
-void InterstitialPageImpl::RemoveLayer(WebKit::WebLayer* layer) {
- web_contents_->RemoveLayer(layer);
-}
-#endif
-
void InterstitialPageImpl::Disable() {
enabled_ = false;
}
diff --git a/content/browser/web_contents/interstitial_page_impl.h b/content/browser/web_contents/interstitial_page_impl.h
index e1ebbf5..69f6120 100644
--- a/content/browser/web_contents/interstitial_page_impl.h
+++ b/content/browser/web_contents/interstitial_page_impl.h
@@ -121,11 +121,6 @@ class CONTENT_EXPORT InterstitialPageImpl
const ContextMenuParams& params,
ContextMenuSourceType type) OVERRIDE;
-#if defined(OS_ANDROID)
- virtual void AttachLayer(WebKit::WebLayer* layer) OVERRIDE;
- virtual void RemoveLayer(WebKit::WebLayer* layer) OVERRIDE;
-#endif
-
// RenderWidgetHostDelegate implementation:
virtual void RenderWidgetDeleted(
RenderWidgetHostImpl* render_widget_host) OVERRIDE;
diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc
index 175cd7b..df435f0 100644
--- a/content/browser/web_contents/web_contents_impl.cc
+++ b/content/browser/web_contents/web_contents_impl.cc
@@ -1497,18 +1497,6 @@ void WebContentsImpl::RequestMediaAccessPermission(
callback.Run(MediaStreamDevices());
}
-#if defined(OS_ANDROID)
-void WebContentsImpl::AttachLayer(WebKit::WebLayer* layer) {
- if (delegate_)
- delegate_->AttachLayer(this, layer);
-}
-
-void WebContentsImpl::RemoveLayer(WebKit::WebLayer* layer) {
- if (delegate_)
- delegate_->RemoveLayer(this, layer);
-}
-#endif
-
void WebContentsImpl::UpdatePreferredSize(const gfx::Size& pref_size) {
preferred_size_ = pref_size;
if (delegate_)
diff --git a/content/browser/web_contents/web_contents_impl.h b/content/browser/web_contents/web_contents_impl.h
index 11bff14..85fa28e 100644
--- a/content/browser/web_contents/web_contents_impl.h
+++ b/content/browser/web_contents/web_contents_impl.h
@@ -424,11 +424,6 @@ class CONTENT_EXPORT WebContentsImpl
const MediaStreamRequest* request,
const MediaResponseCallback& callback) OVERRIDE;
-#if defined(OS_ANDROID)
- virtual void AttachLayer(WebKit::WebLayer* layer) OVERRIDE;
- virtual void RemoveLayer(WebKit::WebLayer* layer) OVERRIDE;
-#endif
-
// RenderWidgetHostDelegate --------------------------------------------------
virtual void RenderWidgetDeleted(
diff --git a/content/public/android/java/src/org/chromium/content/browser/ContentViewRenderView.java b/content/public/android/java/src/org/chromium/content/browser/ContentViewRenderView.java
index 719ca57..2c78242 100644
--- a/content/public/android/java/src/org/chromium/content/browser/ContentViewRenderView.java
+++ b/content/public/android/java/src/org/chromium/content/browser/ContentViewRenderView.java
@@ -14,13 +14,15 @@ import org.chromium.base.JNINamespace;
/***
* This view is used by a ContentView to render its content.
- * It renders the layers added to it through the native ContentViewLayerRenderer to its SurfaceView.
- * TODO(jcivelli): the API is confusing and complicated. There should be a way to do all that
- * wihtout native code.
+ * Call {@link #setCurrentContentView(ContentView)} with the contentView that should be displayed.
+ * Note that only one ContentView can be shown at a time.
*/
@JNINamespace("content")
public class ContentViewRenderView extends FrameLayout {
+ // The native side of this object.
+ private int mNativeContentViewRenderView = 0;
+
private SurfaceView mSurfaceView;
/**
@@ -31,24 +33,25 @@ public class ContentViewRenderView extends FrameLayout {
public ContentViewRenderView(Context context) {
super(context);
- nativeInit();
+ mNativeContentViewRenderView = nativeInit();
+ assert mNativeContentViewRenderView != 0;
mSurfaceView = new SurfaceView(getContext());
mSurfaceView.getHolder().addCallback(new SurfaceHolder.Callback() {
@Override
public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
- nativeSurfaceSetSize(width, height);
+ nativeSurfaceSetSize(mNativeContentViewRenderView, width, height);
}
@Override
public void surfaceCreated(SurfaceHolder holder) {
- nativeSurfaceCreated(holder.getSurface());
+ nativeSurfaceCreated(mNativeContentViewRenderView, holder.getSurface());
onReadyToRender();
}
@Override
public void surfaceDestroyed(SurfaceHolder holder) {
- nativeSurfaceDestroyed();
+ nativeSurfaceDestroyed(mNativeContentViewRenderView);
}
});
@@ -59,11 +62,19 @@ public class ContentViewRenderView extends FrameLayout {
}
/**
- * @return pointer to a native ContentViewLayerRenderer on which the layers to be added should
- * be added removed.
+ * Should be called when the ContentViewRenderView is not needed anymore so its associated
+ * native resource can be freed.
+ */
+ public void destroy() {
+ nativeDestroy(mNativeContentViewRenderView);
+ }
+
+ /**
+ * Makes the passed ContentView the one displayed by this ContentViewRenderView.
*/
- public int getNativeContentViewLayerRenderer() {
- return nativeGetNativeContentViewLayerRenderer();
+ public void setCurrentContentView(ContentView contentView) {
+ nativeSetCurrentContentView(mNativeContentViewRenderView,
+ contentView.getContentViewCore().getNativeContentViewCore());
}
/**
@@ -80,10 +91,12 @@ public class ContentViewRenderView extends FrameLayout {
return mSurfaceView.getHolder().getSurface() != null;
}
- private native void nativeInit();
- private static native int nativeGetNativeContentViewLayerRenderer();
- private static native void nativeSurfaceCreated(Surface surface);
- private static native void nativeSurfaceDestroyed();
- private static native void nativeSurfaceSetSize(int width, int height);
+ private static native int nativeInit();
+ private native void nativeDestroy(int nativeContentViewRenderView);
+ private native void nativeSetCurrentContentView(int nativeContentViewRenderView,
+ int nativeContentView);
+ private native void nativeSurfaceCreated(int nativeContentViewRenderView, Surface surface);
+ private native void nativeSurfaceDestroyed(int nativeContentViewRenderView);
+ private native void nativeSurfaceSetSize(int nativeContentViewRenderView,
+ int width, int height);
}
-
diff --git a/content/public/browser/android/content_view_core.h b/content/public/browser/android/content_view_core.h
index 5a97fdf..288cdb5 100644
--- a/content/public/browser/android/content_view_core.h
+++ b/content/public/browser/android/content_view_core.h
@@ -38,13 +38,14 @@ class ContentViewCore {
virtual base::android::ScopedJavaLocalRef<jobject> GetJavaObject() = 0;
virtual base::android::ScopedJavaLocalRef<jobject> GetContainerViewDelegate()
= 0;
- virtual ui::WindowAndroid* GetWindowAndroid() = 0;
+ virtual ui::WindowAndroid* GetWindowAndroid() const = 0;
+ virtual WebKit::WebLayer* GetWebLayer() const = 0;
virtual void LoadUrl(NavigationController::LoadURLParams& params) = 0;
virtual void OnWebPreferencesUpdated() = 0;
virtual jint GetCurrentRenderProcessId(JNIEnv* env, jobject obj) = 0;
virtual void ShowPastePopup(int x, int y) = 0;
virtual unsigned int GetScaledContentTexture(const gfx::Size& size) = 0;
- virtual WebKit::WebLayer* GetWebLayer() = 0;
+
protected:
virtual ~ContentViewCore() {};
};
diff --git a/content/public/browser/web_contents_delegate.h b/content/public/browser/web_contents_delegate.h
index b649c3c..db2fc9c 100644
--- a/content/public/browser/web_contents_delegate.h
+++ b/content/public/browser/web_contents_delegate.h
@@ -418,18 +418,6 @@ class CONTENT_EXPORT WebContentsDelegate {
const MediaStreamRequest* request,
const MediaResponseCallback& callback) {}
-#if defined(OS_ANDROID)
- // Called when a compositing layer becomes available for this web contents
- // so the delegate can add it to the layer tree.
- virtual void AttachLayer(WebContents* web_contents,
- WebKit::WebLayer* layer) {}
-
- // Called before a compositing layer becomes invalid so the delegate can
- // remove it from the layer tree.
- virtual void RemoveLayer(WebContents* web_contents,
- WebKit::WebLayer* layer) {}
-#endif
-
protected:
virtual ~WebContentsDelegate();
diff --git a/content/shell/android/java/src/org/chromium/content_shell/Shell.java b/content/shell/android/java/src/org/chromium/content_shell/Shell.java
index 1eeecbfc..b7b8457 100644
--- a/content/shell/android/java/src/org/chromium/content_shell/Shell.java
+++ b/content/shell/android/java/src/org/chromium/content_shell/Shell.java
@@ -22,6 +22,7 @@ import android.widget.TextView.OnEditorActionListener;
import org.chromium.base.CalledByNative;
import org.chromium.base.JNINamespace;
import org.chromium.content.browser.ContentView;
+import org.chromium.content.browser.ContentViewRenderView;
import org.chromium.content.browser.LoadUrlParams;
import org.chromium.ui.gfx.NativeWindow;
@@ -48,7 +49,7 @@ public class Shell extends LinearLayout {
private ClipDrawable mProgressDrawable;
- private View mContentViewRenderView;
+ private ContentViewRenderView mContentViewRenderView;
private NativeWindow mWindow;
private boolean mLoading = false;
@@ -63,7 +64,7 @@ public class Shell extends LinearLayout {
/**
* Set the SurfaceView being renderered to as soon as it is available.
*/
- public void setContentViewRenderView(View contentViewRenderView) {
+ public void setContentViewRenderView(ContentViewRenderView contentViewRenderView) {
FrameLayout contentViewHolder = (FrameLayout) findViewById(R.id.contentview_holder);
if (contentViewRenderView == null) {
if (mContentViewRenderView != null) {
@@ -211,6 +212,7 @@ public class Shell extends LinearLayout {
FrameLayout.LayoutParams.MATCH_PARENT,
FrameLayout.LayoutParams.MATCH_PARENT));
mContentView.requestFocus();
+ mContentViewRenderView.setCurrentContentView(mContentView);
}
/**
diff --git a/content/shell/android/java/src/org/chromium/content_shell/ShellManager.java b/content/shell/android/java/src/org/chromium/content_shell/ShellManager.java
index 9cfc2ea..91dc4c2 100644
--- a/content/shell/android/java/src/org/chromium/content_shell/ShellManager.java
+++ b/content/shell/android/java/src/org/chromium/content_shell/ShellManager.java
@@ -11,6 +11,7 @@ import android.widget.FrameLayout;
import org.chromium.base.CalledByNative;
import org.chromium.base.JNINamespace;
+import org.chromium.content.browser.ContentView;
import org.chromium.content.browser.ContentViewRenderView;
import org.chromium.ui.gfx.NativeWindow;
@@ -80,12 +81,6 @@ public class ShellManager extends FrameLayout {
@SuppressWarnings("unused")
@CalledByNative
- private int getContentViewLayerRenderer() {
- return mContentViewRenderView.getNativeContentViewLayerRenderer();
- }
-
- @SuppressWarnings("unused")
- @CalledByNative
private Object createShell() {
LayoutInflater inflater =
(LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
@@ -94,9 +89,8 @@ public class ShellManager extends FrameLayout {
removeAllViews();
if (mActiveShell != null) {
- if (mActiveShell.getContentView() != null) {
- mActiveShell.getContentView().onHide();
- }
+ ContentView contentView = mActiveShell.getContentView();
+ if (contentView != null) contentView.onHide();
mActiveShell.setContentViewRenderView(null);
}
@@ -104,7 +98,11 @@ public class ShellManager extends FrameLayout {
addView(shellView, new FrameLayout.LayoutParams(
FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT));
mActiveShell = shellView;
- if (mActiveShell.getContentView() != null) mActiveShell.getContentView().onShow();
+ ContentView contentView = mActiveShell.getContentView();
+ if (contentView != null) {
+ mContentViewRenderView.setCurrentContentView(contentView);
+ contentView.onShow();
+ }
return shellView;
}
diff --git a/content/shell/android/shell_manager.cc b/content/shell/android/shell_manager.cc
index 79f7803d..4b161a6 100644
--- a/content/shell/android/shell_manager.cc
+++ b/content/shell/android/shell_manager.cc
@@ -35,12 +35,6 @@ namespace content {
jobject CreateShellView(Shell* shell) {
JNIEnv* env = base::android::AttachCurrentThread();
jobject j_shell_manager = g_global_state.Get().j_shell_manager.obj();
-
- ContentViewLayerRenderer* content_view_layer_renderer =
- reinterpret_cast<ContentViewLayerRenderer*>(
- Java_ShellManager_getContentViewLayerRenderer(env, j_shell_manager));
- shell->SetContentViewLayerRenderer(content_view_layer_renderer);
-
return Java_ShellManager_createShell(env, j_shell_manager).Release();
}
diff --git a/content/shell/shell.cc b/content/shell/shell.cc
index e85d976..48f462d 100644
--- a/content/shell/shell.cc
+++ b/content/shell/shell.cc
@@ -45,8 +45,6 @@ Shell::Shell(WebContents* web_contents)
url_edit_view_(NULL)
#if defined(OS_WIN) && !defined(USE_AURA)
, default_edit_wnd_proc_(0)
-#elif defined(OS_ANDROID)
- , content_view_layer_renderer_(NULL)
#endif
{
registrar_.Add(this, NOTIFICATION_WEB_CONTENTS_TITLE_UPDATED,
diff --git a/content/shell/shell.h b/content/shell/shell.h
index bc43553..eb7485c 100644
--- a/content/shell/shell.h
+++ b/content/shell/shell.h
@@ -25,9 +25,6 @@
typedef struct _GtkToolItem GtkToolItem;
#elif defined(OS_ANDROID)
#include "base/android/scoped_java_ref.h"
-namespace content {
-class ContentViewLayerRenderer;
-}
#elif defined(USE_AURA)
namespace views {
class Widget;
@@ -98,11 +95,6 @@ class Shell : public WebContentsDelegate,
#elif defined(OS_ANDROID)
// Registers the Android Java to native methods.
static bool Register(JNIEnv* env);
- // Called by the ShellManager to specify the object that should be notified of
- // layer changes.
- // Note that |content_view_layer_renderer| is owned by the ShellManager.
- void SetContentViewLayerRenderer(
- ContentViewLayerRenderer* content_view_layer_renderer);
#endif
// WebContentsDelegate
@@ -112,10 +104,6 @@ class Shell : public WebContentsDelegate,
#if defined(OS_ANDROID)
virtual void LoadProgressChanged(WebContents* source,
double progress) OVERRIDE;
- virtual void AttachLayer(WebContents* web_contents,
- WebKit::WebLayer* layer) OVERRIDE;
- virtual void RemoveLayer(WebContents* web_contents,
- WebKit::WebLayer* layer) OVERRIDE;
#endif
virtual void CloseContents(WebContents* source) OVERRIDE;
virtual void WebContentsCreated(WebContents* source_contents,
@@ -228,9 +216,6 @@ class Shell : public WebContentsDelegate,
int content_height_;
#elif defined(OS_ANDROID)
base::android::ScopedJavaGlobalRef<jobject> java_object_;
- // The ContentViewLayerRenderer that should be notified of compositing layer
- // changes. Global so guaranteed to outlive shell.
- ContentViewLayerRenderer* content_view_layer_renderer_;
#elif defined(USE_AURA)
static aura::client::StackingClient* stacking_client_;
static views::ViewsDelegate* views_delegate_;
diff --git a/content/shell/shell_android.cc b/content/shell/shell_android.cc
index 08e6bb0..ed191f4 100644
--- a/content/shell/shell_android.cc
+++ b/content/shell/shell_android.cc
@@ -11,7 +11,6 @@
#include "base/command_line.h"
#include "base/logging.h"
#include "base/string_piece.h"
-#include "content/public/browser/android/content_view_layer_renderer.h"
#include "content/public/common/content_switches.h"
#include "content/shell/android/shell_manager.h"
#include "jni/Shell_jni.h"
@@ -72,19 +71,6 @@ void Shell::Close() {
NOTIMPLEMENTED();
}
-void Shell::AttachLayer(WebContents* web_contents, WebKit::WebLayer* layer) {
- content_view_layer_renderer_->AttachLayer(layer);
-}
-
-void Shell::RemoveLayer(WebContents* web_contents, WebKit::WebLayer* layer) {
- content_view_layer_renderer_->DetachLayer(layer);
-}
-
-void Shell::SetContentViewLayerRenderer(
- ContentViewLayerRenderer* content_view_layer_renderer) {
- content_view_layer_renderer_ = content_view_layer_renderer;
-}
-
// static
bool Shell::Register(JNIEnv* env) {
return RegisterNativesImpl(env);