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
) {
24 CommandLine
* command_line
= CommandLine::ForCurrentProcess();
25 DCHECK(command_line
->HasSwitch(switches::kForceCompositingMode
));
26 DCHECK(command_line
->HasSwitch(switches::kEnableThreadedCompositing
));
29 void Shell::PlatformExit() {
32 void Shell::PlatformCleanUp() {
33 JNIEnv
* env
= AttachCurrentThread();
34 if (java_object_
.is_null())
36 Java_Shell_onNativeDestroyed(env
, java_object_
.obj());
39 void Shell::PlatformEnableUIControl(UIControl control
, bool is_enabled
) {
42 void Shell::PlatformSetAddressBarURL(const GURL
& url
) {
43 JNIEnv
* env
= AttachCurrentThread();
44 ScopedJavaLocalRef
<jstring
> j_url
= ConvertUTF8ToJavaString(env
, url
.spec());
45 Java_Shell_onUpdateUrl(env
, java_object_
.obj(), j_url
.obj());
48 void Shell::PlatformSetIsLoading(bool loading
) {
49 JNIEnv
* env
= AttachCurrentThread();
50 Java_Shell_setIsLoading(env
, java_object_
.obj(), loading
);
53 void Shell::PlatformCreateWindow(int width
, int height
) {
54 java_object_
.Reset(AttachCurrentThread(), CreateShellView(this));
57 void Shell::PlatformSetContents() {
58 JNIEnv
* env
= AttachCurrentThread();
59 Java_Shell_initFromNativeTabContents(
60 env
, java_object_
.obj(), reinterpret_cast<intptr_t>(web_contents()));
63 void Shell::PlatformResizeSubViews() {
64 // Not needed; subviews are bound.
67 void Shell::PlatformSetTitle(const base::string16
& title
) {
71 void Shell::LoadProgressChanged(WebContents
* source
, double progress
) {
72 JNIEnv
* env
= AttachCurrentThread();
73 Java_Shell_onLoadProgressChanged(env
, java_object_
.obj(), progress
);
76 void Shell::PlatformToggleFullscreenModeForTab(WebContents
* web_contents
,
77 bool enter_fullscreen
) {
78 JNIEnv
* env
= AttachCurrentThread();
79 Java_Shell_toggleFullscreenModeForTab(
80 env
, java_object_
.obj(), enter_fullscreen
);
83 bool Shell::PlatformIsFullscreenForTabOrPending(
84 const WebContents
* web_contents
) const {
85 JNIEnv
* env
= AttachCurrentThread();
86 return Java_Shell_isFullscreenForTabOrPending(env
, java_object_
.obj());
89 bool Shell::PlatformHandleContextMenu(
90 const content::ContextMenuParams
& params
) {
95 RemoveShellView(java_object_
.obj());
100 bool Shell::Register(JNIEnv
* env
) {
101 return RegisterNativesImpl(env
);
105 void CloseShell(JNIEnv
* env
, jclass clazz
, jlong shellPtr
) {
106 Shell
* shell
= reinterpret_cast<Shell
*>(shellPtr
);
110 } // namespace content