OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 "chrome/browser/android/tab_android.h" | 5 #include "chrome/browser/android/tab_android.h" |
6 | 6 |
7 #include "base/android/jni_android.h" | 7 #include "base/android/jni_android.h" |
8 #include "base/android/jni_string.h" | 8 #include "base/android/jni_string.h" |
9 #include "chrome/browser/android/chrome_web_contents_delegate_android.h" | 9 #include "chrome/browser/android/chrome_web_contents_delegate_android.h" |
10 #include "chrome/browser/android/webapps/single_tab_mode_tab_helper.h" | 10 #include "chrome/browser/android/webapps/single_tab_mode_tab_helper.h" |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 } | 168 } |
169 | 169 |
170 int TabAndroid::GetSyncId() const { | 170 int TabAndroid::GetSyncId() const { |
171 JNIEnv* env = base::android::AttachCurrentThread(); | 171 JNIEnv* env = base::android::AttachCurrentThread(); |
172 ScopedJavaLocalRef<jobject> obj = weak_java_tab_.get(env); | 172 ScopedJavaLocalRef<jobject> obj = weak_java_tab_.get(env); |
173 if (obj.is_null()) | 173 if (obj.is_null()) |
174 return 0; | 174 return 0; |
175 return Java_TabBase_getSyncId(env, obj.obj()); | 175 return Java_TabBase_getSyncId(env, obj.obj()); |
176 } | 176 } |
177 | 177 |
178 string16 TabAndroid::GetTitle() const { | 178 base::string16 TabAndroid::GetTitle() const { |
179 JNIEnv* env = base::android::AttachCurrentThread(); | 179 JNIEnv* env = base::android::AttachCurrentThread(); |
180 ScopedJavaLocalRef<jobject> obj = weak_java_tab_.get(env); | 180 ScopedJavaLocalRef<jobject> obj = weak_java_tab_.get(env); |
181 if (obj.is_null()) | 181 if (obj.is_null()) |
182 return string16(); | 182 return base::string16(); |
183 return base::android::ConvertJavaStringToUTF16( | 183 return base::android::ConvertJavaStringToUTF16( |
184 Java_TabBase_getTitle(env, obj.obj())); | 184 Java_TabBase_getTitle(env, obj.obj())); |
185 } | 185 } |
186 | 186 |
187 GURL TabAndroid::GetURL() const { | 187 GURL TabAndroid::GetURL() const { |
188 JNIEnv* env = base::android::AttachCurrentThread(); | 188 JNIEnv* env = base::android::AttachCurrentThread(); |
189 ScopedJavaLocalRef<jobject> obj = weak_java_tab_.get(env); | 189 ScopedJavaLocalRef<jobject> obj = weak_java_tab_.get(env); |
190 if (obj.is_null()) | 190 if (obj.is_null()) |
191 return GURL::EmptyGURL(); | 191 return GURL::EmptyGURL(); |
192 return GURL(base::android::ConvertJavaStringToUTF8( | 192 return GURL(base::android::ConvertJavaStringToUTF8( |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
378 jobject obj) { | 378 jobject obj) { |
379 return ToolbarModelImpl::GetSecurityLevelForWebContents(web_contents()); | 379 return ToolbarModelImpl::GetSecurityLevelForWebContents(web_contents()); |
380 } | 380 } |
381 | 381 |
382 void TabAndroid::SetActiveNavigationEntryTitleForUrl(JNIEnv* env, | 382 void TabAndroid::SetActiveNavigationEntryTitleForUrl(JNIEnv* env, |
383 jobject obj, | 383 jobject obj, |
384 jstring jurl, | 384 jstring jurl, |
385 jstring jtitle) { | 385 jstring jtitle) { |
386 DCHECK(web_contents()); | 386 DCHECK(web_contents()); |
387 | 387 |
388 string16 title; | 388 base::string16 title; |
389 if (jtitle) | 389 if (jtitle) |
390 title = base::android::ConvertJavaStringToUTF16(env, jtitle); | 390 title = base::android::ConvertJavaStringToUTF16(env, jtitle); |
391 | 391 |
392 std::string url; | 392 std::string url; |
393 if (jurl) | 393 if (jurl) |
394 url = base::android::ConvertJavaStringToUTF8(env, jurl); | 394 url = base::android::ConvertJavaStringToUTF8(env, jurl); |
395 | 395 |
396 content::NavigationEntry* entry = | 396 content::NavigationEntry* entry = |
397 web_contents()->GetController().GetVisibleEntry(); | 397 web_contents()->GetController().GetVisibleEntry(); |
398 if (entry && url == entry->GetVirtualURL().spec()) | 398 if (entry && url == entry->GetVirtualURL().spec()) |
(...skipping 10 matching lines...) Expand all Loading... |
409 if (print_view_manager == NULL) | 409 if (print_view_manager == NULL) |
410 return false; | 410 return false; |
411 | 411 |
412 print_view_manager->PrintNow(); | 412 print_view_manager->PrintNow(); |
413 return true; | 413 return true; |
414 } | 414 } |
415 | 415 |
416 bool TabAndroid::RegisterTabAndroid(JNIEnv* env) { | 416 bool TabAndroid::RegisterTabAndroid(JNIEnv* env) { |
417 return RegisterNativesImpl(env); | 417 return RegisterNativesImpl(env); |
418 } | 418 } |
OLD | NEW |