| 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 <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 } | 136 } |
| 137 | 137 |
| 138 web_contents->DownloadImage(favicon_url, true, 0, false, | 138 web_contents->DownloadImage(favicon_url, true, 0, false, |
| 139 base::Bind(OnFaviconDownloaded, | 139 base::Bind(OnFaviconDownloaded, |
| 140 j_availability_callback, | 140 j_availability_callback, |
| 141 profile, page_url)); | 141 profile, page_url)); |
| 142 } | 142 } |
| 143 | 143 |
| 144 } // namespace | 144 } // namespace |
| 145 | 145 |
| 146 static jlong Init(JNIEnv* env, jclass clazz) { | 146 static jlong Init(JNIEnv* env, const JavaParamRef<jclass>& clazz) { |
| 147 return reinterpret_cast<intptr_t>(new FaviconHelper()); | 147 return reinterpret_cast<intptr_t>(new FaviconHelper()); |
| 148 } | 148 } |
| 149 | 149 |
| 150 FaviconHelper::FaviconHelper() { | 150 FaviconHelper::FaviconHelper() { |
| 151 cancelable_task_tracker_.reset(new base::CancelableTaskTracker()); | 151 cancelable_task_tracker_.reset(new base::CancelableTaskTracker()); |
| 152 } | 152 } |
| 153 | 153 |
| 154 void FaviconHelper::Destroy(JNIEnv* env, jobject obj) { | 154 void FaviconHelper::Destroy(JNIEnv* env, jobject obj) { |
| 155 delete this; | 155 delete this; |
| 156 } | 156 } |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 287 profile, web_contents, page_url, favicon_url); | 287 profile, web_contents, page_url, favicon_url); |
| 288 favicon::FaviconService* service = FaviconServiceFactory::GetForProfile( | 288 favicon::FaviconService* service = FaviconServiceFactory::GetForProfile( |
| 289 profile, ServiceAccessType::IMPLICIT_ACCESS); | 289 profile, ServiceAccessType::IMPLICIT_ACCESS); |
| 290 service->GetFaviconImageForPageURL(page_url, callback_runner, | 290 service->GetFaviconImageForPageURL(page_url, callback_runner, |
| 291 cancelable_task_tracker_.get()); | 291 cancelable_task_tracker_.get()); |
| 292 } | 292 } |
| 293 | 293 |
| 294 FaviconHelper::~FaviconHelper() {} | 294 FaviconHelper::~FaviconHelper() {} |
| 295 | 295 |
| 296 static jint GetDominantColorForBitmap(JNIEnv* env, | 296 static jint GetDominantColorForBitmap(JNIEnv* env, |
| 297 jclass clazz, | 297 const JavaParamRef<jclass>& clazz, |
| 298 jobject bitmap) { | 298 const JavaParamRef<jobject>& bitmap) { |
| 299 if (!bitmap) | 299 if (!bitmap) |
| 300 return 0; | 300 return 0; |
| 301 | 301 |
| 302 gfx::JavaBitmap bitmap_lock(bitmap); | 302 gfx::JavaBitmap bitmap_lock(bitmap); |
| 303 SkBitmap skbitmap = gfx::CreateSkBitmapFromJavaBitmap(bitmap_lock); | 303 SkBitmap skbitmap = gfx::CreateSkBitmapFromJavaBitmap(bitmap_lock); |
| 304 return color_utils::CalculateKMeanColorOfBitmap(skbitmap); | 304 return color_utils::CalculateKMeanColorOfBitmap(skbitmap); |
| 305 } | 305 } |
| 306 | 306 |
| 307 // static | 307 // static |
| 308 bool FaviconHelper::RegisterFaviconHelper(JNIEnv* env) { | 308 bool FaviconHelper::RegisterFaviconHelper(JNIEnv* env) { |
| 309 return RegisterNativesImpl(env); | 309 return RegisterNativesImpl(env); |
| 310 } | 310 } |
| OLD | NEW |