| 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_array.h" | 8 #include "base/android/jni_array.h" |
| 9 #include "base/android/jni_string.h" | 9 #include "base/android/jni_string.h" |
| 10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
| (...skipping 617 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 628 if (jurl) | 628 if (jurl) |
| 629 url = base::android::ConvertJavaStringToUTF8(env, jurl); | 629 url = base::android::ConvertJavaStringToUTF8(env, jurl); |
| 630 | 630 |
| 631 content::NavigationEntry* entry = | 631 content::NavigationEntry* entry = |
| 632 web_contents()->GetController().GetVisibleEntry(); | 632 web_contents()->GetController().GetVisibleEntry(); |
| 633 if (entry && url == entry->GetVirtualURL().spec()) | 633 if (entry && url == entry->GetVirtualURL().spec()) |
| 634 entry->SetTitle(title); | 634 entry->SetTitle(title); |
| 635 } | 635 } |
| 636 | 636 |
| 637 bool TabAndroid::Print(JNIEnv* env, jobject obj) { | 637 bool TabAndroid::Print(JNIEnv* env, jobject obj) { |
| 638 if (!web_contents()) | 638 LOG(INFO) << "DGN TabAndroid::Print"; |
| 639 if (!web_contents()) { |
| 640 LOG(INFO) << "DGN TabAndroid::Print - No webcontents"; |
| 639 return false; | 641 return false; |
| 642 } |
| 640 | 643 |
| 641 printing::PrintViewManagerBasic::CreateForWebContents(web_contents()); | 644 printing::PrintViewManagerBasic::CreateForWebContents(web_contents()); |
| 642 printing::PrintViewManagerBasic* print_view_manager = | 645 printing::PrintViewManagerBasic* print_view_manager = |
| 643 printing::PrintViewManagerBasic::FromWebContents(web_contents()); | 646 printing::PrintViewManagerBasic::FromWebContents(web_contents()); |
| 644 if (print_view_manager == NULL) | 647 if (print_view_manager == NULL) { |
| 648 LOG(INFO) << "DGN TabAndroid::Print - No print_view_manager"; |
| 645 return false; | 649 return false; |
| 650 } |
| 646 | 651 |
| 647 print_view_manager->PrintNow(); | 652 print_view_manager->PrintNow(); |
| 648 return true; | 653 return true; |
| 649 } | 654 } |
| 650 | 655 |
| 656 void TabAndroid::ShowPrintDialog() { |
| 657 JNIEnv* env = base::android::AttachCurrentThread(); |
| 658 Java_Tab_showPrintDialog(env, weak_java_tab_.get(env).obj()); |
| 659 } |
| 660 |
| 651 ScopedJavaLocalRef<jobject> TabAndroid::GetDefaultFavicon(JNIEnv* env, | 661 ScopedJavaLocalRef<jobject> TabAndroid::GetDefaultFavicon(JNIEnv* env, |
| 652 jobject obj) { | 662 jobject obj) { |
| 653 ScopedJavaLocalRef<jobject> bitmap; | 663 ScopedJavaLocalRef<jobject> bitmap; |
| 654 FaviconTabHelper* favicon_tab_helper = | 664 FaviconTabHelper* favicon_tab_helper = |
| 655 FaviconTabHelper::FromWebContents(web_contents_.get()); | 665 FaviconTabHelper::FromWebContents(web_contents_.get()); |
| 656 | 666 |
| 657 if (!favicon_tab_helper) | 667 if (!favicon_tab_helper) |
| 658 return bitmap; | 668 return bitmap; |
| 659 | 669 |
| 660 // Always return the default favicon in Android. | 670 // Always return the default favicon in Android. |
| (...skipping 30 matching lines...) Expand all Loading... |
| 691 | 701 |
| 692 static void Init(JNIEnv* env, jobject obj) { | 702 static void Init(JNIEnv* env, jobject obj) { |
| 693 TRACE_EVENT0("native", "TabAndroid::Init"); | 703 TRACE_EVENT0("native", "TabAndroid::Init"); |
| 694 // This will automatically bind to the Java object and pass ownership there. | 704 // This will automatically bind to the Java object and pass ownership there. |
| 695 new TabAndroid(env, obj); | 705 new TabAndroid(env, obj); |
| 696 } | 706 } |
| 697 | 707 |
| 698 bool TabAndroid::RegisterTabAndroid(JNIEnv* env) { | 708 bool TabAndroid::RegisterTabAndroid(JNIEnv* env) { |
| 699 return RegisterNativesImpl(env); | 709 return RegisterNativesImpl(env); |
| 700 } | 710 } |
| OLD | NEW |