OLD | NEW |
| (Empty) |
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. | |
4 | |
5 #include "content/shell/shell.h" | |
6 | |
7 #include <jni.h> | |
8 | |
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" | |
17 | |
18 using base::android::AttachCurrentThread; | |
19 using base::android::ConvertUTF8ToJavaString; | |
20 | |
21 namespace content { | |
22 | |
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)); | |
27 } | |
28 | |
29 void Shell::PlatformCleanUp() { | |
30 } | |
31 | |
32 void Shell::PlatformEnableUIControl(UIControl control, bool is_enabled) { | |
33 } | |
34 | |
35 void Shell::PlatformSetAddressBarURL(const GURL& url) { | |
36 JNIEnv* env = AttachCurrentThread(); | |
37 ScopedJavaLocalRef<jstring> j_url = ConvertUTF8ToJavaString(env, url.spec()); | |
38 Java_Shell_onUpdateUrl(env, java_object_.obj(), j_url.obj()); | |
39 } | |
40 | |
41 void Shell::PlatformSetIsLoading(bool loading) { | |
42 JNIEnv* env = AttachCurrentThread(); | |
43 Java_Shell_setIsLoading(env, java_object_.obj(), loading); | |
44 } | |
45 | |
46 void Shell::PlatformCreateWindow(int width, int height) { | |
47 java_object_.Reset(AttachCurrentThread(), CreateShellView(this)); | |
48 } | |
49 | |
50 void Shell::PlatformSetContents() { | |
51 JNIEnv* env = AttachCurrentThread(); | |
52 Java_Shell_initFromNativeTabContents( | |
53 env, java_object_.obj(), reinterpret_cast<jint>(web_contents())); | |
54 } | |
55 | |
56 void Shell::PlatformResizeSubViews() { | |
57 // Not needed; subviews are bound. | |
58 } | |
59 | |
60 void Shell::PlatformSetTitle(const string16& title) { | |
61 NOTIMPLEMENTED(); | |
62 } | |
63 | |
64 void Shell::LoadProgressChanged(WebContents* source, double progress) { | |
65 JNIEnv* env = AttachCurrentThread(); | |
66 Java_Shell_onLoadProgressChanged(env, java_object_.obj(), progress); | |
67 } | |
68 | |
69 void Shell::PlatformToggleFullscreenModeForTab(WebContents* web_contents, | |
70 bool enter_fullscreen) { | |
71 JNIEnv* env = AttachCurrentThread(); | |
72 Java_Shell_toggleFullscreenModeForTab( | |
73 env, java_object_.obj(), enter_fullscreen); | |
74 } | |
75 | |
76 bool Shell::PlatformIsFullscreenForTabOrPending( | |
77 const WebContents* web_contents) const { | |
78 JNIEnv* env = AttachCurrentThread(); | |
79 return Java_Shell_isFullscreenForTabOrPending(env, java_object_.obj()); | |
80 } | |
81 | |
82 void Shell::Close() { | |
83 CloseShellView(java_object_.obj()); | |
84 java_object_.Reset(); | |
85 delete this; | |
86 } | |
87 | |
88 // static | |
89 bool Shell::Register(JNIEnv* env) { | |
90 return RegisterNativesImpl(env); | |
91 } | |
92 | |
93 } // namespace content | |
OLD | NEW |