OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/shell/browser/shell.h" | 5 #include "content/shell/browser/shell.h" |
6 | 6 |
7 #include <jni.h> | 7 #include <jni.h> |
8 | 8 |
9 #include "base/android/jni_string.h" | 9 #include "base/android/jni_string.h" |
10 #include "base/android/scoped_java_ref.h" | 10 #include "base/android/scoped_java_ref.h" |
(...skipping 15 matching lines...) Expand all Loading... |
26 void Shell::PlatformInitialize(const gfx::Size& default_window_size) { | 26 void Shell::PlatformInitialize(const gfx::Size& default_window_size) { |
27 } | 27 } |
28 | 28 |
29 void Shell::PlatformExit() { | 29 void Shell::PlatformExit() { |
30 } | 30 } |
31 | 31 |
32 void Shell::PlatformCleanUp() { | 32 void Shell::PlatformCleanUp() { |
33 JNIEnv* env = AttachCurrentThread(); | 33 JNIEnv* env = AttachCurrentThread(); |
34 if (java_object_.is_null()) | 34 if (java_object_.is_null()) |
35 return; | 35 return; |
36 Java_Shell_onNativeDestroyed(env, java_object_.obj()); | 36 Java_Shell_onNativeDestroyed(env, java_object_); |
37 } | 37 } |
38 | 38 |
39 void Shell::PlatformEnableUIControl(UIControl control, bool is_enabled) { | 39 void Shell::PlatformEnableUIControl(UIControl control, bool is_enabled) { |
40 JNIEnv* env = AttachCurrentThread(); | 40 JNIEnv* env = AttachCurrentThread(); |
41 if (java_object_.is_null()) | 41 if (java_object_.is_null()) |
42 return; | 42 return; |
43 Java_Shell_enableUiControl(env, java_object_.obj(), control, is_enabled); | 43 Java_Shell_enableUiControl(env, java_object_, control, is_enabled); |
44 } | 44 } |
45 | 45 |
46 void Shell::PlatformSetAddressBarURL(const GURL& url) { | 46 void Shell::PlatformSetAddressBarURL(const GURL& url) { |
47 JNIEnv* env = AttachCurrentThread(); | 47 JNIEnv* env = AttachCurrentThread(); |
48 ScopedJavaLocalRef<jstring> j_url = ConvertUTF8ToJavaString(env, url.spec()); | 48 ScopedJavaLocalRef<jstring> j_url = ConvertUTF8ToJavaString(env, url.spec()); |
49 Java_Shell_onUpdateUrl(env, java_object_.obj(), j_url.obj()); | 49 Java_Shell_onUpdateUrl(env, java_object_, j_url); |
50 } | 50 } |
51 | 51 |
52 void Shell::PlatformSetIsLoading(bool loading) { | 52 void Shell::PlatformSetIsLoading(bool loading) { |
53 JNIEnv* env = AttachCurrentThread(); | 53 JNIEnv* env = AttachCurrentThread(); |
54 Java_Shell_setIsLoading(env, java_object_.obj(), loading); | 54 Java_Shell_setIsLoading(env, java_object_, loading); |
55 } | 55 } |
56 | 56 |
57 void Shell::PlatformCreateWindow(int width, int height) { | 57 void Shell::PlatformCreateWindow(int width, int height) { |
58 java_object_.Reset(CreateShellView(this)); | 58 java_object_.Reset(CreateShellView(this)); |
59 } | 59 } |
60 | 60 |
61 void Shell::PlatformSetContents() { | 61 void Shell::PlatformSetContents() { |
62 JNIEnv* env = AttachCurrentThread(); | 62 JNIEnv* env = AttachCurrentThread(); |
63 Java_Shell_initFromNativeTabContents( | 63 Java_Shell_initFromNativeTabContents(env, java_object_, |
64 env, java_object_.obj(), web_contents()->GetJavaWebContents().obj()); | 64 web_contents()->GetJavaWebContents()); |
65 } | 65 } |
66 | 66 |
67 void Shell::PlatformResizeSubViews() { | 67 void Shell::PlatformResizeSubViews() { |
68 // Not needed; subviews are bound. | 68 // Not needed; subviews are bound. |
69 } | 69 } |
70 | 70 |
71 void Shell::PlatformSetTitle(const base::string16& title) { | 71 void Shell::PlatformSetTitle(const base::string16& title) { |
72 NOTIMPLEMENTED() << ": " << title; | 72 NOTIMPLEMENTED() << ": " << title; |
73 } | 73 } |
74 | 74 |
75 void Shell::LoadProgressChanged(WebContents* source, double progress) { | 75 void Shell::LoadProgressChanged(WebContents* source, double progress) { |
76 JNIEnv* env = AttachCurrentThread(); | 76 JNIEnv* env = AttachCurrentThread(); |
77 Java_Shell_onLoadProgressChanged(env, java_object_.obj(), progress); | 77 Java_Shell_onLoadProgressChanged(env, java_object_, progress); |
78 } | 78 } |
79 | 79 |
80 void Shell::PlatformToggleFullscreenModeForTab(WebContents* web_contents, | 80 void Shell::PlatformToggleFullscreenModeForTab(WebContents* web_contents, |
81 bool enter_fullscreen) { | 81 bool enter_fullscreen) { |
82 JNIEnv* env = AttachCurrentThread(); | 82 JNIEnv* env = AttachCurrentThread(); |
83 Java_Shell_toggleFullscreenModeForTab( | 83 Java_Shell_toggleFullscreenModeForTab(env, java_object_, enter_fullscreen); |
84 env, java_object_.obj(), enter_fullscreen); | |
85 } | 84 } |
86 | 85 |
87 bool Shell::PlatformIsFullscreenForTabOrPending( | 86 bool Shell::PlatformIsFullscreenForTabOrPending( |
88 const WebContents* web_contents) const { | 87 const WebContents* web_contents) const { |
89 JNIEnv* env = AttachCurrentThread(); | 88 JNIEnv* env = AttachCurrentThread(); |
90 return Java_Shell_isFullscreenForTabOrPending(env, java_object_.obj()); | 89 return Java_Shell_isFullscreenForTabOrPending(env, java_object_); |
91 } | 90 } |
92 | 91 |
93 void Shell::Close() { | 92 void Shell::Close() { |
94 RemoveShellView(java_object_.obj()); | 93 RemoveShellView(java_object_.obj()); |
95 delete this; | 94 delete this; |
96 } | 95 } |
97 | 96 |
98 // static | 97 // static |
99 bool Shell::Register(JNIEnv* env) { | 98 bool Shell::Register(JNIEnv* env) { |
100 return RegisterNativesImpl(env); | 99 return RegisterNativesImpl(env); |
101 } | 100 } |
102 | 101 |
103 // static | 102 // static |
104 void CloseShell(JNIEnv* env, | 103 void CloseShell(JNIEnv* env, |
105 const JavaParamRef<jclass>& clazz, | 104 const JavaParamRef<jclass>& clazz, |
106 jlong shellPtr) { | 105 jlong shellPtr) { |
107 Shell* shell = reinterpret_cast<Shell*>(shellPtr); | 106 Shell* shell = reinterpret_cast<Shell*>(shellPtr); |
108 shell->Close(); | 107 shell->Close(); |
109 } | 108 } |
110 | 109 |
111 } // namespace content | 110 } // namespace content |
OLD | NEW |