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

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

Issue 330603004: Rename FaviconBitmapXxx to FaviconRawBitmapXxx (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix android Created 6 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/android/provider/chrome_browser_provider.cc » ('j') | 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 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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 if (!favicon_bitmap.isNull()) 50 if (!favicon_bitmap.isNull())
51 j_favicon_bitmap = gfx::ConvertToJavaBitmap(&favicon_bitmap); 51 j_favicon_bitmap = gfx::ConvertToJavaBitmap(&favicon_bitmap);
52 52
53 // Call java side OnLocalFaviconAvailable method. 53 // Call java side OnLocalFaviconAvailable method.
54 Java_FaviconImageCallback_onFaviconAvailable(env, 54 Java_FaviconImageCallback_onFaviconAvailable(env,
55 j_favicon_image_callback->obj(), 55 j_favicon_image_callback->obj(),
56 j_favicon_bitmap.obj(), 56 j_favicon_bitmap.obj(),
57 j_icon_url.obj()); 57 j_icon_url.obj());
58 } 58 }
59 59
60 void OnFaviconBitmapResultAvailable( 60 void OnFaviconRawBitmapResultAvailable(
61 ScopedJavaGlobalRef<jobject>* j_favicon_image_callback, 61 ScopedJavaGlobalRef<jobject>* j_favicon_image_callback,
62 const favicon_base::FaviconBitmapResult& favicon_bitmap_result) { 62 const favicon_base::FaviconRawBitmapResult& favicon_bitmap_result) {
63 JNIEnv* env = AttachCurrentThread(); 63 JNIEnv* env = AttachCurrentThread();
64 64
65 // Convert favicon_image_result to java objects. 65 // Convert favicon_image_result to java objects.
66 ScopedJavaLocalRef<jstring> j_icon_url = 66 ScopedJavaLocalRef<jstring> j_icon_url =
67 ConvertUTF8ToJavaString(env, favicon_bitmap_result.icon_url.spec()); 67 ConvertUTF8ToJavaString(env, favicon_bitmap_result.icon_url.spec());
68 68
69 SkBitmap favicon_bitmap; 69 SkBitmap favicon_bitmap;
70 if (favicon_bitmap_result.is_valid()) { 70 if (favicon_bitmap_result.is_valid()) {
71 gfx::PNGCodec::Decode(favicon_bitmap_result.bitmap_data->front(), 71 gfx::PNGCodec::Decode(favicon_bitmap_result.bitmap_data->front(),
72 favicon_bitmap_result.bitmap_data->size(), 72 favicon_bitmap_result.bitmap_data->size(),
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 DCHECK(profile); 109 DCHECK(profile);
110 if (!profile) 110 if (!profile)
111 return false; 111 return false;
112 112
113 FaviconService* favicon_service = FaviconServiceFactory::GetForProfile( 113 FaviconService* favicon_service = FaviconServiceFactory::GetForProfile(
114 profile, Profile::EXPLICIT_ACCESS); 114 profile, Profile::EXPLICIT_ACCESS);
115 DCHECK(favicon_service); 115 DCHECK(favicon_service);
116 if (!favicon_service) 116 if (!favicon_service)
117 return false; 117 return false;
118 118
119 FaviconService::FaviconForURLParams params( 119 FaviconService::FaviconForPageURLParams 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 favicon_base::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->GetFaviconImageForPageURL(
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(
139 JNIEnv* env, 139 JNIEnv* env,
140 jobject obj, 140 jobject obj,
141 jobject j_profile, 141 jobject j_profile,
(...skipping 12 matching lines...) Expand all
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 favicon_base::FaviconRawCallback callback_runner = base::Bind( 164 favicon_base::FaviconRawBitmapCallback callback_runner =
165 &OnFaviconBitmapResultAvailable, base::Owned(j_scoped_favicon_callback)); 165 base::Bind(&OnFaviconRawBitmapResultAvailable,
166 favicon_service->GetLargestRawFaviconForURL( 166 base::Owned(j_scoped_favicon_callback));
167 favicon_service->GetLargestRawFaviconForPageURL(
167 profile, 168 profile,
168 GURL(ConvertJavaStringToUTF16(env, j_page_url)), 169 GURL(ConvertJavaStringToUTF16(env, j_page_url)),
169 icon_types, 170 icon_types,
170 static_cast<int>(j_min_size_threshold_px), 171 static_cast<int>(j_min_size_threshold_px),
171 callback_runner, 172 callback_runner,
172 cancelable_task_tracker_.get()); 173 cancelable_task_tracker_.get());
173 } 174 }
174 175
175 ScopedJavaLocalRef<jobject> FaviconHelper::GetSyncedFaviconImageForURL( 176 ScopedJavaLocalRef<jobject> FaviconHelper::GetSyncedFaviconImageForURL(
176 JNIEnv* env, 177 JNIEnv* env,
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 216
216 gfx::JavaBitmap bitmap_lock(bitmap); 217 gfx::JavaBitmap bitmap_lock(bitmap);
217 SkBitmap skbitmap = gfx::CreateSkBitmapFromJavaBitmap(bitmap_lock); 218 SkBitmap skbitmap = gfx::CreateSkBitmapFromJavaBitmap(bitmap_lock);
218 return color_utils::CalculateKMeanColorOfBitmap(skbitmap); 219 return color_utils::CalculateKMeanColorOfBitmap(skbitmap);
219 } 220 }
220 221
221 // static 222 // static
222 bool FaviconHelper::RegisterFaviconHelper(JNIEnv* env) { 223 bool FaviconHelper::RegisterFaviconHelper(JNIEnv* env) {
223 return RegisterNativesImpl(env); 224 return RegisterNativesImpl(env);
224 } 225 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/android/provider/chrome_browser_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698