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::kEnableThreadedCompositing
));
28 void Shell::PlatformExit() {
31 void Shell::PlatformCleanUp() {
32 JNIEnv
* env
= AttachCurrentThread();
33 if (java_object_
.is_null())
35 Java_Shell_onNativeDestroyed(env
, java_object_
.obj());
38 void Shell::PlatformEnableUIControl(UIControl control
, bool is_enabled
) {
41 void Shell::PlatformSetAddressBarURL(const GURL
& url
) {
42 JNIEnv
* env
= AttachCurrentThread();
43 ScopedJavaLocalRef
<jstring
> j_url
= ConvertUTF8ToJavaString(env
, url
.spec());
44 Java_Shell_onUpdateUrl(env
, java_object_
.obj(), j_url
.obj());
47 void Shell::PlatformSetIsLoading(bool loading
) {
48 JNIEnv
* env
= AttachCurrentThread();
49 Java_Shell_setIsLoading(env
, java_object_
.obj(), loading
);
52 void Shell::PlatformCreateWindow(int width
, int height
) {
53 java_object_
.Reset(AttachCurrentThread(), CreateShellView(this));
56 void Shell::PlatformSetContents() {
57 JNIEnv
* env
= AttachCurrentThread();
58 Java_Shell_initFromNativeTabContents(
59 env
, java_object_
.obj(), reinterpret_cast<intptr_t>(web_contents()));
62 void Shell::PlatformResizeSubViews() {
63 // Not needed; subviews are bound.
66 void Shell::PlatformSetTitle(const base::string16
& title
) {
70 void Shell::LoadProgressChanged(WebContents
* source
, double progress
) {
71 JNIEnv
* env
= AttachCurrentThread();
72 Java_Shell_onLoadProgressChanged(env
, java_object_
.obj(), progress
);
75 void Shell::PlatformToggleFullscreenModeForTab(WebContents
* web_contents
,
76 bool enter_fullscreen
) {
77 JNIEnv
* env
= AttachCurrentThread();
78 Java_Shell_toggleFullscreenModeForTab(
79 env
, java_object_
.obj(), enter_fullscreen
);
82 bool Shell::PlatformIsFullscreenForTabOrPending(
83 const WebContents
* web_contents
) const {
84 JNIEnv
* env
= AttachCurrentThread();
85 return Java_Shell_isFullscreenForTabOrPending(env
, java_object_
.obj());
88 bool Shell::PlatformHandleContextMenu(
89 const content::ContextMenuParams
& params
) {
94 RemoveShellView(java_object_
.obj());
99 bool Shell::Register(JNIEnv
* env
) {
100 return RegisterNativesImpl(env
);
104 void CloseShell(JNIEnv
* env
, jclass clazz
, jlong shellPtr
) {
105 Shell
* shell
= reinterpret_cast<Shell
*>(shellPtr
);
109 } // namespace content