| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/android/jni_android.h" | 9 #include "base/android/jni_android.h" |
| 10 #include "base/android/jni_string.h" | 10 #include "base/android/jni_string.h" |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 #include "content/public/browser/user_metrics.h" | 76 #include "content/public/browser/user_metrics.h" |
| 77 #include "content/public/browser/web_contents.h" | 77 #include "content/public/browser/web_contents.h" |
| 78 #include "content/public/common/resource_request_body.h" | 78 #include "content/public/common/resource_request_body.h" |
| 79 #include "content/public/common/top_controls_state.h" | 79 #include "content/public/common/top_controls_state.h" |
| 80 #include "jni/Tab_jni.h" | 80 #include "jni/Tab_jni.h" |
| 81 #include "net/base/escape.h" | 81 #include "net/base/escape.h" |
| 82 #include "skia/ext/image_operations.h" | 82 #include "skia/ext/image_operations.h" |
| 83 #include "third_party/WebKit/public/platform/WebReferrerPolicy.h" | 83 #include "third_party/WebKit/public/platform/WebReferrerPolicy.h" |
| 84 #include "ui/base/resource/resource_bundle.h" | 84 #include "ui/base/resource/resource_bundle.h" |
| 85 #include "ui/base/window_open_disposition.h" | 85 #include "ui/base/window_open_disposition.h" |
| 86 #include "ui/gfx/android/device_display_info.h" | 86 #include "ui/display/display.h" |
| 87 #include "ui/display/screen.h" |
| 87 #include "ui/gfx/android/java_bitmap.h" | 88 #include "ui/gfx/android/java_bitmap.h" |
| 88 #include "ui/gfx/favicon_size.h" | 89 #include "ui/gfx/favicon_size.h" |
| 89 #include "ui/gfx/image/image_skia.h" | 90 #include "ui/gfx/image/image_skia.h" |
| 90 | 91 |
| 91 using base::android::AttachCurrentThread; | 92 using base::android::AttachCurrentThread; |
| 92 using base::android::ConvertUTF8ToJavaString; | 93 using base::android::ConvertUTF8ToJavaString; |
| 93 using content::BrowserThread; | 94 using content::BrowserThread; |
| 94 using content::GlobalRequestID; | 95 using content::GlobalRequestID; |
| 95 using content::NavigationController; | 96 using content::NavigationController; |
| 96 using content::WebContents; | 97 using content::WebContents; |
| (...skipping 559 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 656 ScopedJavaLocalRef<jobject> bitmap; | 657 ScopedJavaLocalRef<jobject> bitmap; |
| 657 favicon::FaviconDriver* favicon_driver = | 658 favicon::FaviconDriver* favicon_driver = |
| 658 favicon::ContentFaviconDriver::FromWebContents(web_contents_.get()); | 659 favicon::ContentFaviconDriver::FromWebContents(web_contents_.get()); |
| 659 | 660 |
| 660 if (!favicon_driver) | 661 if (!favicon_driver) |
| 661 return bitmap; | 662 return bitmap; |
| 662 | 663 |
| 663 // Always return the default favicon in Android. | 664 // Always return the default favicon in Android. |
| 664 SkBitmap favicon = favicon_driver->GetFavicon().AsBitmap(); | 665 SkBitmap favicon = favicon_driver->GetFavicon().AsBitmap(); |
| 665 if (!favicon.empty()) { | 666 if (!favicon.empty()) { |
| 666 gfx::DeviceDisplayInfo device_info; | 667 const float device_scale_factor = |
| 667 const float device_scale_factor = device_info.GetDIPScale(); | 668 display::Screen::GetScreen()->GetPrimaryDisplay().device_scale_factor(); |
| 668 int target_size_dip = device_scale_factor * gfx::kFaviconSize; | 669 int target_size_dip = device_scale_factor * gfx::kFaviconSize; |
| 669 if (favicon.width() != target_size_dip || | 670 if (favicon.width() != target_size_dip || |
| 670 favicon.height() != target_size_dip) { | 671 favicon.height() != target_size_dip) { |
| 671 favicon = | 672 favicon = |
| 672 skia::ImageOperations::Resize(favicon, | 673 skia::ImageOperations::Resize(favicon, |
| 673 skia::ImageOperations::RESIZE_BEST, | 674 skia::ImageOperations::RESIZE_BEST, |
| 674 target_size_dip, | 675 target_size_dip, |
| 675 target_size_dip); | 676 target_size_dip); |
| 676 } | 677 } |
| 677 | 678 |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 901 static void Init(JNIEnv* env, const JavaParamRef<jobject>& obj) { | 902 static void Init(JNIEnv* env, const JavaParamRef<jobject>& obj) { |
| 902 TRACE_EVENT0("native", "TabAndroid::Init"); | 903 TRACE_EVENT0("native", "TabAndroid::Init"); |
| 903 // This will automatically bind to the Java object and pass ownership there. | 904 // This will automatically bind to the Java object and pass ownership there. |
| 904 new TabAndroid(env, obj); | 905 new TabAndroid(env, obj); |
| 905 } | 906 } |
| 906 | 907 |
| 907 // static | 908 // static |
| 908 bool TabAndroid::RegisterTabAndroid(JNIEnv* env) { | 909 bool TabAndroid::RegisterTabAndroid(JNIEnv* env) { |
| 909 return RegisterNativesImpl(env); | 910 return RegisterNativesImpl(env); |
| 910 } | 911 } |
| OLD | NEW |