| 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 98 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 109     jstring j_page_url, | 109     jstring j_page_url, | 
| 110     jint j_icon_types, | 110     jint j_icon_types, | 
| 111     jint j_desired_size_in_pixel, | 111     jint j_desired_size_in_pixel, | 
| 112     jobject j_favicon_image_callback) { | 112     jobject j_favicon_image_callback) { | 
| 113   Profile* profile = ProfileAndroid::FromProfileAndroid(j_profile); | 113   Profile* profile = ProfileAndroid::FromProfileAndroid(j_profile); | 
| 114   DCHECK(profile); | 114   DCHECK(profile); | 
| 115   if (!profile) | 115   if (!profile) | 
| 116     return false; | 116     return false; | 
| 117 | 117 | 
| 118   FaviconService* favicon_service = FaviconServiceFactory::GetForProfile( | 118   FaviconService* favicon_service = FaviconServiceFactory::GetForProfile( | 
| 119       profile, Profile::EXPLICIT_ACCESS); | 119       profile, ServiceAccessType::EXPLICIT_ACCESS); | 
| 120   DCHECK(favicon_service); | 120   DCHECK(favicon_service); | 
| 121   if (!favicon_service) | 121   if (!favicon_service) | 
| 122     return false; | 122     return false; | 
| 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   favicon_base::FaviconRawBitmapCallback callback_runner = base::Bind( | 128   favicon_base::FaviconRawBitmapCallback callback_runner = base::Bind( | 
| 129       &OnLocalFaviconAvailable, base::Owned(j_scoped_favicon_callback)); | 129       &OnLocalFaviconAvailable, base::Owned(j_scoped_favicon_callback)); | 
| (...skipping 15 matching lines...) Expand all  Loading... | 
| 145     jstring j_page_url, | 145     jstring j_page_url, | 
| 146     jintArray j_icon_types, | 146     jintArray j_icon_types, | 
| 147     jint j_min_size_threshold_px, | 147     jint j_min_size_threshold_px, | 
| 148     jobject j_favicon_image_callback) { | 148     jobject j_favicon_image_callback) { | 
| 149   Profile* profile = ProfileAndroid::FromProfileAndroid(j_profile); | 149   Profile* profile = ProfileAndroid::FromProfileAndroid(j_profile); | 
| 150   DCHECK(profile); | 150   DCHECK(profile); | 
| 151   if (!profile) | 151   if (!profile) | 
| 152     return; | 152     return; | 
| 153 | 153 | 
| 154   FaviconService* favicon_service = FaviconServiceFactory::GetForProfile( | 154   FaviconService* favicon_service = FaviconServiceFactory::GetForProfile( | 
| 155       profile, Profile::EXPLICIT_ACCESS); | 155       profile, ServiceAccessType::EXPLICIT_ACCESS); | 
| 156   DCHECK(favicon_service); | 156   DCHECK(favicon_service); | 
| 157   if (!favicon_service) | 157   if (!favicon_service) | 
| 158     return; | 158     return; | 
| 159 | 159 | 
| 160   std::vector<int> icon_types; | 160   std::vector<int> icon_types; | 
| 161   base::android::JavaIntArrayToIntVector(env, j_icon_types, &icon_types); | 161   base::android::JavaIntArrayToIntVector(env, j_icon_types, &icon_types); | 
| 162 | 162 | 
| 163   ScopedJavaGlobalRef<jobject>* j_scoped_favicon_callback = | 163   ScopedJavaGlobalRef<jobject>* j_scoped_favicon_callback = | 
| 164       new ScopedJavaGlobalRef<jobject>(); | 164       new ScopedJavaGlobalRef<jobject>(); | 
| 165   j_scoped_favicon_callback->Reset(env, j_favicon_image_callback); | 165   j_scoped_favicon_callback->Reset(env, j_favicon_image_callback); | 
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 218 | 218 | 
| 219     gfx::JavaBitmap bitmap_lock(bitmap); | 219     gfx::JavaBitmap bitmap_lock(bitmap); | 
| 220     SkBitmap skbitmap = gfx::CreateSkBitmapFromJavaBitmap(bitmap_lock); | 220     SkBitmap skbitmap = gfx::CreateSkBitmapFromJavaBitmap(bitmap_lock); | 
| 221     return color_utils::CalculateKMeanColorOfBitmap(skbitmap); | 221     return color_utils::CalculateKMeanColorOfBitmap(skbitmap); | 
| 222 } | 222 } | 
| 223 | 223 | 
| 224 // static | 224 // static | 
| 225 bool FaviconHelper::RegisterFaviconHelper(JNIEnv* env) { | 225 bool FaviconHelper::RegisterFaviconHelper(JNIEnv* env) { | 
| 226   return RegisterNativesImpl(env); | 226   return RegisterNativesImpl(env); | 
| 227 } | 227 } | 
| OLD | NEW | 
|---|