summaryrefslogtreecommitdiffstats
path: root/content/shell/android/shell_manager.cc
diff options
context:
space:
mode:
Diffstat (limited to 'content/shell/android/shell_manager.cc')
-rw-r--r--content/shell/android/shell_manager.cc95
1 files changed, 13 insertions, 82 deletions
diff --git a/content/shell/android/shell_manager.cc b/content/shell/android/shell_manager.cc
index 71ed3ab..79f7803d 100644
--- a/content/shell/android/shell_manager.cc
+++ b/content/shell/android/shell_manager.cc
@@ -9,78 +9,39 @@
#include "base/android/scoped_java_ref.h"
#include "base/bind.h"
#include "base/lazy_instance.h"
-#include "base/memory/scoped_ptr.h"
-#include "base/message_loop.h"
#include "content/shell/shell.h"
#include "content/shell/shell_browser_context.h"
#include "content/shell/shell_content_browser_client.h"
-#include "content/public/browser/android/compositor.h"
-#include "content/public/browser/android/draw_delegate.h"
#include "content/public/browser/web_contents.h"
#include "content/shell/shell.h"
#include "googleurl/src/gurl.h"
#include "jni/ShellManager_jni.h"
-#include "third_party/WebKit/Source/Platform/chromium/public/WebLayer.h"
-#include "ui/gfx/size.h"
-
-#include <android/native_window_jni.h>
using base::android::ScopedJavaLocalRef;
-using content::Compositor;
-using content::DrawDelegate;
namespace {
-class CompositorClient : public Compositor::Client {
- public:
- virtual void ScheduleComposite() OVERRIDE;
-};
-
struct GlobalState {
- GlobalState()
- : g_scheduled_composite(false) {}
- base::android::ScopedJavaGlobalRef<jobject> j_obj;
- CompositorClient client;
- scoped_ptr<content::Compositor> compositor;
- scoped_ptr<WebKit::WebLayer> root_layer;
- bool g_scheduled_composite;
+ GlobalState() {}
+ base::android::ScopedJavaGlobalRef<jobject> j_shell_manager;
};
base::LazyInstance<GlobalState> g_global_state = LAZY_INSTANCE_INITIALIZER;
-content::Compositor* GetCompositor() {
- return g_global_state.Get().compositor.get();
-}
-
-void Composite() {
- g_global_state.Get().g_scheduled_composite = false;
- if (GetCompositor()) {
- GetCompositor()->Composite();
- }
-}
-
-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));
- }
-}
-
-} // anonymous namespace
+} // namespace
namespace content {
-jobject CreateShellView() {
+jobject CreateShellView(Shell* shell) {
JNIEnv* env = base::android::AttachCurrentThread();
- if (!GetCompositor()) {
- 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());
- }
- return Java_ShellManager_createShell(
- env, g_global_state.Get().j_obj.obj()).Release();
+ 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();
}
// Register native methods
@@ -89,31 +50,10 @@ bool RegisterShellManager(JNIEnv* env) {
}
static void Init(JNIEnv* env, jclass clazz, jobject obj) {
- g_global_state.Get().j_obj.Reset(
+ g_global_state.Get().j_shell_manager.Reset(
base::android::ScopedJavaLocalRef<jobject>(env, obj));
}
-static void SurfaceCreated(
- JNIEnv* env, jclass clazz, jobject jsurface) {
- 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());
- }
-}
-
-static void SurfaceDestroyed(JNIEnv* env, jclass clazz) {
- GetCompositor()->SetWindowSurface(NULL);
-}
-
-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 LaunchShell(JNIEnv* env, jclass clazz, jstring jurl) {
ShellBrowserContext* browserContext =
static_cast<ShellContentBrowserClient*>(
@@ -126,13 +66,4 @@ void LaunchShell(JNIEnv* env, jclass clazz, jstring jurl) {
NULL);
}
-void ShellAttachLayer(WebKit::WebLayer* layer) {
- g_global_state.Get().root_layer->addChild(layer);
-}
-
-
-void ShellRemoveLayer(WebKit::WebLayer* layer) {
- layer->removeFromParent();
-}
-
} // namespace content