| 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 "chrome/browser/android/favicon_helper.h" | 5 #include "chrome/browser/android/favicon_helper.h" |
| 6 | 6 |
| 7 #include <jni.h> | 7 #include <jni.h> |
| 8 | 8 |
| 9 #include "base/android/jni_android.h" | 9 #include "base/android/jni_android.h" |
| 10 #include "base/android/jni_array.h" | 10 #include "base/android/jni_array.h" |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 | 118 |
| 119 FaviconService::FaviconForURLParams params( | 119 FaviconService::FaviconForURLParams params( |
| 120 GURL(ConvertJavaStringToUTF16(env, j_page_url)), | 120 GURL(ConvertJavaStringToUTF16(env, j_page_url)), |
| 121 static_cast<int>(j_icon_types), | 121 static_cast<int>(j_icon_types), |
| 122 static_cast<int>(j_desired_size_in_dip)); | 122 static_cast<int>(j_desired_size_in_dip)); |
| 123 | 123 |
| 124 ScopedJavaGlobalRef<jobject>* j_scoped_favicon_callback = | 124 ScopedJavaGlobalRef<jobject>* j_scoped_favicon_callback = |
| 125 new ScopedJavaGlobalRef<jobject>(); | 125 new ScopedJavaGlobalRef<jobject>(); |
| 126 j_scoped_favicon_callback->Reset(env, j_favicon_image_callback); | 126 j_scoped_favicon_callback->Reset(env, j_favicon_image_callback); |
| 127 | 127 |
| 128 FaviconService::FaviconImageCallback callback_runner = base::Bind( | 128 favicon_base::FaviconImageCallback callback_runner = base::Bind( |
| 129 &OnLocalFaviconAvailable, base::Owned(j_scoped_favicon_callback)); | 129 &OnLocalFaviconAvailable, base::Owned(j_scoped_favicon_callback)); |
| 130 | 130 |
| 131 favicon_service->GetFaviconImageForURL( | 131 favicon_service->GetFaviconImageForURL( |
| 132 params, callback_runner, | 132 params, callback_runner, |
| 133 cancelable_task_tracker_.get()); | 133 cancelable_task_tracker_.get()); |
| 134 | 134 |
| 135 return true; | 135 return true; |
| 136 } | 136 } |
| 137 | 137 |
| 138 void FaviconHelper::GetLargestRawFaviconForUrl( | 138 void FaviconHelper::GetLargestRawFaviconForUrl( |
| (...skipping 15 matching lines...) Expand all Loading... |
| 154 if (!favicon_service) | 154 if (!favicon_service) |
| 155 return; | 155 return; |
| 156 | 156 |
| 157 std::vector<int> icon_types; | 157 std::vector<int> icon_types; |
| 158 base::android::JavaIntArrayToIntVector(env, j_icon_types, &icon_types); | 158 base::android::JavaIntArrayToIntVector(env, j_icon_types, &icon_types); |
| 159 | 159 |
| 160 ScopedJavaGlobalRef<jobject>* j_scoped_favicon_callback = | 160 ScopedJavaGlobalRef<jobject>* j_scoped_favicon_callback = |
| 161 new ScopedJavaGlobalRef<jobject>(); | 161 new ScopedJavaGlobalRef<jobject>(); |
| 162 j_scoped_favicon_callback->Reset(env, j_favicon_image_callback); | 162 j_scoped_favicon_callback->Reset(env, j_favicon_image_callback); |
| 163 | 163 |
| 164 FaviconService::FaviconRawCallback callback_runner = base::Bind( | 164 favicon_base::FaviconRawCallback callback_runner = base::Bind( |
| 165 &OnFaviconBitmapResultAvailable, base::Owned(j_scoped_favicon_callback)); | 165 &OnFaviconBitmapResultAvailable, base::Owned(j_scoped_favicon_callback)); |
| 166 favicon_service->GetLargestRawFaviconForURL( | 166 favicon_service->GetLargestRawFaviconForURL( |
| 167 profile, | 167 profile, |
| 168 GURL(ConvertJavaStringToUTF16(env, j_page_url)), | 168 GURL(ConvertJavaStringToUTF16(env, j_page_url)), |
| 169 icon_types, | 169 icon_types, |
| 170 static_cast<int>(j_min_size_threshold_px), | 170 static_cast<int>(j_min_size_threshold_px), |
| 171 callback_runner, | 171 callback_runner, |
| 172 cancelable_task_tracker_.get()); | 172 cancelable_task_tracker_.get()); |
| 173 } | 173 } |
| 174 | 174 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 | 215 |
| 216 gfx::JavaBitmap bitmap_lock(bitmap); | 216 gfx::JavaBitmap bitmap_lock(bitmap); |
| 217 SkBitmap skbitmap = gfx::CreateSkBitmapFromJavaBitmap(bitmap_lock); | 217 SkBitmap skbitmap = gfx::CreateSkBitmapFromJavaBitmap(bitmap_lock); |
| 218 return color_utils::CalculateKMeanColorOfBitmap(skbitmap); | 218 return color_utils::CalculateKMeanColorOfBitmap(skbitmap); |
| 219 } | 219 } |
| 220 | 220 |
| 221 // static | 221 // static |
| 222 bool FaviconHelper::RegisterFaviconHelper(JNIEnv* env) { | 222 bool FaviconHelper::RegisterFaviconHelper(JNIEnv* env) { |
| 223 return RegisterNativesImpl(env); | 223 return RegisterNativesImpl(env); |
| 224 } | 224 } |
| OLD | NEW |