Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(121)

Side by Side Diff: chrome/browser/android/favicon_helper.cc

Issue 2683853003: Remove unused function for extracting colors from a favicon on Android. (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/android/java/src/org/chromium/chrome/browser/favicon/FaviconHelper.java ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include <vector> 10 #include <vector>
(...skipping 12 matching lines...) Expand all
23 #include "components/browser_sync/profile_sync_service.h" 23 #include "components/browser_sync/profile_sync_service.h"
24 #include "components/favicon/core/favicon_service.h" 24 #include "components/favicon/core/favicon_service.h"
25 #include "components/favicon/core/favicon_util.h" 25 #include "components/favicon/core/favicon_util.h"
26 #include "components/favicon_base/favicon_util.h" 26 #include "components/favicon_base/favicon_util.h"
27 #include "components/sync_sessions/open_tabs_ui_delegate.h" 27 #include "components/sync_sessions/open_tabs_ui_delegate.h"
28 #include "content/public/browser/web_contents.h" 28 #include "content/public/browser/web_contents.h"
29 #include "jni/FaviconHelper_jni.h" 29 #include "jni/FaviconHelper_jni.h"
30 #include "third_party/skia/include/core/SkBitmap.h" 30 #include "third_party/skia/include/core/SkBitmap.h"
31 #include "ui/gfx/android/java_bitmap.h" 31 #include "ui/gfx/android/java_bitmap.h"
32 #include "ui/gfx/codec/png_codec.h" 32 #include "ui/gfx/codec/png_codec.h"
33 #include "ui/gfx/color_analysis.h"
34 #include "ui/gfx/color_utils.h" 33 #include "ui/gfx/color_utils.h"
35 #include "ui/gfx/image/image_skia.h" 34 #include "ui/gfx/image/image_skia.h"
36 #include "ui/gfx/image/image_skia_rep.h" 35 #include "ui/gfx/image/image_skia_rep.h"
37 36
38 using base::android::JavaParamRef; 37 using base::android::JavaParamRef;
39 using base::android::JavaRef; 38 using base::android::JavaRef;
40 using base::android::ScopedJavaGlobalRef; 39 using base::android::ScopedJavaGlobalRef;
41 using base::android::ScopedJavaLocalRef; 40 using base::android::ScopedJavaLocalRef;
42 using base::android::AttachCurrentThread; 41 using base::android::AttachCurrentThread;
43 using base::android::ConvertJavaStringToUTF16; 42 using base::android::ConvertJavaStringToUTF16;
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 web_contents, page_url, icon_url, icon_type, j_is_temporary); 177 web_contents, page_url, icon_url, icon_type, j_is_temporary);
179 favicon::FaviconService* service = FaviconServiceFactory::GetForProfile( 178 favicon::FaviconService* service = FaviconServiceFactory::GetForProfile(
180 profile, ServiceAccessType::IMPLICIT_ACCESS); 179 profile, ServiceAccessType::IMPLICIT_ACCESS);
181 favicon::GetFaviconImageForPageURL(service, page_url, icon_type, 180 favicon::GetFaviconImageForPageURL(service, page_url, icon_type,
182 callback_runner, 181 callback_runner,
183 cancelable_task_tracker_.get()); 182 cancelable_task_tracker_.get());
184 } 183 }
185 184
186 FaviconHelper::~FaviconHelper() {} 185 FaviconHelper::~FaviconHelper() {}
187 186
188 static jint GetDominantColorForBitmap(JNIEnv* env,
189 const JavaParamRef<jclass>& clazz,
190 const JavaParamRef<jobject>& bitmap) {
191 if (!bitmap)
192 return 0;
193
194 gfx::JavaBitmap bitmap_lock(bitmap);
195 SkBitmap skbitmap = gfx::CreateSkBitmapFromJavaBitmap(bitmap_lock);
196 return color_utils::CalculateKMeanColorOfBitmap(skbitmap);
197 }
198
199 // static
200
201 // Return the index of |sizes| whose area is largest but not exceeds int type 187 // Return the index of |sizes| whose area is largest but not exceeds int type
202 // range. If all |sizes|'s area exceed int type range, return the first one. 188 // range. If all |sizes|'s area exceed int type range, return the first one.
203 size_t FaviconHelper::GetLargestSizeIndex(const std::vector<gfx::Size>& sizes) { 189 size_t FaviconHelper::GetLargestSizeIndex(const std::vector<gfx::Size>& sizes) {
204 DCHECK(!sizes.empty()); 190 DCHECK(!sizes.empty());
205 size_t ret = 0; 191 size_t ret = 0;
206 // Find the first element whose area doesn't exceed max value, then use it 192 // Find the first element whose area doesn't exceed max value, then use it
207 // to compare with rest elements to find largest size index. 193 // to compare with rest elements to find largest size index.
208 for (size_t i = 0; i < sizes.size(); ++i) { 194 for (size_t i = 0; i < sizes.size(); ++i) {
209 base::CheckedNumeric<int> checked_area = sizes[i].GetCheckedArea(); 195 base::CheckedNumeric<int> checked_area = sizes[i].GetCheckedArea();
210 if (checked_area.IsValid()) { 196 if (checked_area.IsValid()) {
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 260
275 web_contents->DownloadImage( 261 web_contents->DownloadImage(
276 icon_url, true, 0, false, 262 icon_url, true, 0, false,
277 base::Bind(&FaviconHelper::OnFaviconDownloaded, j_availability_callback, 263 base::Bind(&FaviconHelper::OnFaviconDownloaded, j_availability_callback,
278 profile, page_url, icon_type, is_temporary)); 264 profile, page_url, icon_type, is_temporary));
279 } 265 }
280 266
281 bool FaviconHelper::RegisterFaviconHelper(JNIEnv* env) { 267 bool FaviconHelper::RegisterFaviconHelper(JNIEnv* env) {
282 return RegisterNativesImpl(env); 268 return RegisterNativesImpl(env);
283 } 269 }
OLDNEW
« no previous file with comments | « chrome/android/java/src/org/chromium/chrome/browser/favicon/FaviconHelper.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698