Fix build break
[chromium-blink-merge.git] / content / shell / android / shell_manager.cc
blob0b12e1da831f1bff4f049600eb3beaa8a188afbf
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "content/shell/android/shell_manager.h"
7 #include "base/android/jni_android.h"
8 #include "base/android/jni_string.h"
9 #include "base/android/scoped_java_ref.h"
10 #include "base/bind.h"
11 #include "base/lazy_instance.h"
12 #include "content/shell/shell.h"
13 #include "content/shell/shell_browser_context.h"
14 #include "content/shell/shell_content_browser_client.h"
15 #include "content/public/browser/web_contents.h"
16 #include "content/shell/shell.h"
17 #include "googleurl/src/gurl.h"
18 #include "jni/ShellManager_jni.h"
20 using base::android::ScopedJavaLocalRef;
22 namespace {
24 struct GlobalState {
25 GlobalState() {}
26 base::android::ScopedJavaGlobalRef<jobject> j_shell_manager;
29 base::LazyInstance<GlobalState> g_global_state = LAZY_INSTANCE_INITIALIZER;
31 } // namespace
33 namespace content {
35 jobject CreateShellView(Shell* shell) {
36 JNIEnv* env = base::android::AttachCurrentThread();
37 jobject j_shell_manager = g_global_state.Get().j_shell_manager.obj();
38 return Java_ShellManager_createShell(env, j_shell_manager).Release();
41 // Register native methods
42 bool RegisterShellManager(JNIEnv* env) {
43 return RegisterNativesImpl(env);
46 static void Init(JNIEnv* env, jclass clazz, jobject obj) {
47 g_global_state.Get().j_shell_manager.Reset(
48 base::android::ScopedJavaLocalRef<jobject>(env, obj));
51 void LaunchShell(JNIEnv* env, jclass clazz, jstring jurl) {
52 ShellBrowserContext* browserContext =
53 ShellContentBrowserClient::Get()->browser_context();
54 GURL url(base::android::ConvertJavaStringToUTF8(env, jurl));
55 Shell::CreateNewWindow(browserContext,
56 url,
57 NULL,
58 MSG_ROUTING_NONE,
59 gfx::Size());
62 } // namespace content