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/shell.h"
9 #include "base/android/scoped_java_ref.h"
10 #include "base/android/jni_string.h"
11 #include "base/command_line.h"
12 #include "base/logging.h"
13 #include "base/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() {
24 CommandLine
* command_line
= CommandLine::ForCurrentProcess();
25 DCHECK(command_line
->HasSwitch(switches::kForceCompositingMode
));
26 DCHECK(command_line
->HasSwitch(switches::kEnableThreadedCompositing
));
29 void Shell::PlatformCleanUp() {
32 void Shell::PlatformEnableUIControl(UIControl control
, bool is_enabled
) {
35 void Shell::PlatformSetAddressBarURL(const GURL
& url
) {
36 JNIEnv
* env
= AttachCurrentThread();
37 ScopedJavaLocalRef
<jstring
> j_url
=
38 ConvertUTF8ToJavaString(env
, url
.spec());
39 Java_Shell_onUpdateUrl(env
, java_object_
.obj(), j_url
.obj());
42 void Shell::PlatformSetIsLoading(bool loading
) {
45 void Shell::PlatformCreateWindow(int width
, int height
) {
46 java_object_
.Reset(AttachCurrentThread(), CreateShellView());
49 void Shell::PlatformSetContents() {
50 JNIEnv
* env
= AttachCurrentThread();
51 Java_Shell_initFromNativeTabContents(
52 env
, java_object_
.obj(), reinterpret_cast<jint
>(web_contents()));
55 void Shell::PlatformResizeSubViews() {
56 // Not needed; subviews are bound.
59 void Shell::PlatformSetTitle(const string16
& title
) {
63 void Shell::LoadProgressChanged(WebContents
* source
, double progress
) {
64 JNIEnv
* env
= AttachCurrentThread();
65 Java_Shell_onLoadProgressChanged(env
, java_object_
.obj(), progress
);
69 // TODO(tedchoc): Implement Close method for android shell
73 void Shell::AttachLayer(WebContents
* web_contents
, WebKit::WebLayer
* layer
) {
74 ShellAttachLayer(layer
);
77 void Shell::RemoveLayer(WebContents
* web_contents
, WebKit::WebLayer
* layer
) {
78 ShellRemoveLayer(layer
);
82 bool Shell::Register(JNIEnv
* env
) {
83 return RegisterNativesImpl(env
);
86 } // namespace content