| 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 "ui/android/window_android.h" | 5 #include "ui/android/window_android.h" |
| 6 | 6 |
| 7 #include "base/android/context_utils.h" | 7 #include "base/android/context_utils.h" |
| 8 #include "base/android/jni_android.h" | 8 #include "base/android/jni_android.h" |
| 9 #include "base/android/jni_array.h" | 9 #include "base/android/jni_array.h" |
| 10 #include "base/android/jni_string.h" | 10 #include "base/android/jni_string.h" |
| 11 #include "base/android/jni_weak_ref.h" | 11 #include "base/android/jni_weak_ref.h" |
| 12 #include "base/android/scoped_java_ref.h" | 12 #include "base/android/scoped_java_ref.h" |
| 13 #include "base/strings/utf_string_conversions.h" |
| 13 #include "jni/WindowAndroid_jni.h" | 14 #include "jni/WindowAndroid_jni.h" |
| 14 #include "ui/android/window_android_compositor.h" | 15 #include "ui/android/window_android_compositor.h" |
| 15 #include "ui/android/window_android_observer.h" | 16 #include "ui/android/window_android_observer.h" |
| 16 | 17 |
| 17 namespace ui { | 18 namespace ui { |
| 18 | 19 |
| 19 using base::android::AttachCurrentThread; | 20 using base::android::AttachCurrentThread; |
| 20 using base::android::JavaParamRef; | 21 using base::android::JavaParamRef; |
| 21 using base::android::JavaRef; | 22 using base::android::JavaRef; |
| 22 using base::android::ScopedJavaLocalRef; | 23 using base::android::ScopedJavaLocalRef; |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 base::android::ConvertUTF8ToJavaString(env, permission)); | 142 base::android::ConvertUTF8ToJavaString(env, permission)); |
| 142 } | 143 } |
| 143 | 144 |
| 144 bool WindowAndroid::CanRequestPermission(const std::string& permission) { | 145 bool WindowAndroid::CanRequestPermission(const std::string& permission) { |
| 145 JNIEnv* env = AttachCurrentThread(); | 146 JNIEnv* env = AttachCurrentThread(); |
| 146 return Java_WindowAndroid_canRequestPermission( | 147 return Java_WindowAndroid_canRequestPermission( |
| 147 env, GetJavaObject(), | 148 env, GetJavaObject(), |
| 148 base::android::ConvertUTF8ToJavaString(env, permission)); | 149 base::android::ConvertUTF8ToJavaString(env, permission)); |
| 149 } | 150 } |
| 150 | 151 |
| 152 void WindowAndroid::StartContentIntent(const GURL& content_url, |
| 153 bool is_main_frame) { |
| 154 JNIEnv* env = AttachCurrentThread(); |
| 155 ScopedJavaLocalRef<jstring> jcontent_url = |
| 156 base::android::ConvertUTF8ToJavaString(env, content_url.spec()); |
| 157 Java_WindowAndroid_onStartContentIntent(env, GetJavaObject(), jcontent_url, |
| 158 is_main_frame); |
| 159 } |
| 160 |
| 151 WindowAndroid* WindowAndroid::GetWindowAndroid() const { | 161 WindowAndroid* WindowAndroid::GetWindowAndroid() const { |
| 152 DCHECK(parent_ == nullptr); | 162 DCHECK(parent_ == nullptr); |
| 153 return const_cast<WindowAndroid*>(this); | 163 return const_cast<WindowAndroid*>(this); |
| 154 } | 164 } |
| 155 | 165 |
| 156 // ---------------------------------------------------------------------------- | 166 // ---------------------------------------------------------------------------- |
| 157 // Native JNI methods | 167 // Native JNI methods |
| 158 // ---------------------------------------------------------------------------- | 168 // ---------------------------------------------------------------------------- |
| 159 | 169 |
| 160 jlong Init(JNIEnv* env, const JavaParamRef<jobject>& obj) { | 170 jlong Init(JNIEnv* env, const JavaParamRef<jobject>& obj) { |
| 161 WindowAndroid* window = new WindowAndroid(env, obj); | 171 WindowAndroid* window = new WindowAndroid(env, obj); |
| 162 return reinterpret_cast<intptr_t>(window); | 172 return reinterpret_cast<intptr_t>(window); |
| 163 } | 173 } |
| 164 | 174 |
| 165 } // namespace ui | 175 } // namespace ui |
| OLD | NEW |