1 // Copyright 2013 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/browser/shell.h"
9 #include "base/android/jni_string.h"
10 #include "base/android/scoped_java_ref.h"
11 #include "base/command_line.h"
12 #include "base/logging.h"
13 #include "base/strings/string_piece.h"
14 #include "content/public/common/content_switches.h"
15 #include "content/shell/android/shell_manager.h"
16 #include "jni/Shell_jni.h"
18 using base::android::AttachCurrentThread
;
19 using base::android::ConvertUTF8ToJavaString
;
23 void Shell::PlatformInitialize(const gfx::Size
& default_window_size
) {
26 void Shell::PlatformExit() {
29 void Shell::PlatformCleanUp() {
30 JNIEnv
* env
= AttachCurrentThread();
31 if (java_object_
.is_null())
33 Java_Shell_onNativeDestroyed(env
, java_object_
.obj());
36 void Shell::PlatformEnableUIControl(UIControl control
, bool is_enabled
) {
37 JNIEnv
* env
= AttachCurrentThread();
38 if (java_object_
.is_null())
40 Java_Shell_enableUiControl(env
, java_object_
.obj(), control
, is_enabled
);
43 void Shell::PlatformSetAddressBarURL(const GURL
& url
) {
44 JNIEnv
* env
= AttachCurrentThread();
45 ScopedJavaLocalRef
<jstring
> j_url
= ConvertUTF8ToJavaString(env
, url
.spec());
46 Java_Shell_onUpdateUrl(env
, java_object_
.obj(), j_url
.obj());
49 void Shell::PlatformSetIsLoading(bool loading
) {
50 JNIEnv
* env
= AttachCurrentThread();
51 Java_Shell_setIsLoading(env
, java_object_
.obj(), loading
);
54 void Shell::PlatformCreateWindow(int width
, int height
) {
55 java_object_
.Reset(AttachCurrentThread(), CreateShellView(this));
58 void Shell::PlatformSetContents() {
59 JNIEnv
* env
= AttachCurrentThread();
60 Java_Shell_initFromNativeTabContents(
61 env
, java_object_
.obj(), reinterpret_cast<intptr_t>(web_contents()));
64 void Shell::PlatformResizeSubViews() {
65 // Not needed; subviews are bound.
68 void Shell::PlatformSetTitle(const base::string16
& title
) {
72 void Shell::LoadProgressChanged(WebContents
* source
, double progress
) {
73 JNIEnv
* env
= AttachCurrentThread();
74 Java_Shell_onLoadProgressChanged(env
, java_object_
.obj(), progress
);
77 void Shell::PlatformToggleFullscreenModeForTab(WebContents
* web_contents
,
78 bool enter_fullscreen
) {
79 JNIEnv
* env
= AttachCurrentThread();
80 Java_Shell_toggleFullscreenModeForTab(
81 env
, java_object_
.obj(), enter_fullscreen
);
84 bool Shell::PlatformIsFullscreenForTabOrPending(
85 const WebContents
* web_contents
) const {
86 JNIEnv
* env
= AttachCurrentThread();
87 return Java_Shell_isFullscreenForTabOrPending(env
, java_object_
.obj());
90 bool Shell::PlatformHandleContextMenu(
91 const content::ContextMenuParams
& params
) {
96 RemoveShellView(java_object_
.obj());
101 bool Shell::Register(JNIEnv
* env
) {
102 return RegisterNativesImpl(env
);
106 void CloseShell(JNIEnv
* env
, jclass clazz
, jlong shellPtr
) {
107 Shell
* shell
= reinterpret_cast<Shell
*>(shellPtr
);
111 } // namespace content