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

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

Issue 74653002: sync: Add --enable-sync-sessions-v2 and necessary plumbing to use SessionsSyncManager. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 1 month 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/foreign_session_helper.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_string.h" 10 #include "base/android/jni_string.h"
11 #include "base/android/scoped_java_ref.h" 11 #include "base/android/scoped_java_ref.h"
12 #include "base/bind.h" 12 #include "base/bind.h"
13 #include "base/strings/string_util.h" 13 #include "base/strings/string_util.h"
14 #include "base/strings/utf_string_conversions.h" 14 #include "base/strings/utf_string_conversions.h"
15 #include "chrome/browser/favicon/favicon_service.h" 15 #include "chrome/browser/favicon/favicon_service.h"
16 #include "chrome/browser/favicon/favicon_service_factory.h" 16 #include "chrome/browser/favicon/favicon_service_factory.h"
17 #include "chrome/browser/profiles/profile.h" 17 #include "chrome/browser/profiles/profile.h"
18 #include "chrome/browser/profiles/profile_android.h" 18 #include "chrome/browser/profiles/profile_android.h"
19 #include "chrome/browser/sync/glue/session_model_associator.h" 19 #include "chrome/browser/sync/open_tabs_ui_delegate.h"
20 #include "chrome/browser/sync/glue/session_model_associator.h"
21 #include "chrome/browser/sync/profile_sync_service.h" 20 #include "chrome/browser/sync/profile_sync_service.h"
22 #include "chrome/browser/sync/profile_sync_service_factory.h" 21 #include "chrome/browser/sync/profile_sync_service_factory.h"
23 #include "chrome/browser/sync/profile_sync_service_factory.h" 22 #include "chrome/browser/sync/profile_sync_service_factory.h"
24 #include "jni/FaviconHelper_jni.h" 23 #include "jni/FaviconHelper_jni.h"
25 #include "third_party/skia/include/core/SkBitmap.h" 24 #include "third_party/skia/include/core/SkBitmap.h"
26 #include "ui/gfx/android/java_bitmap.h" 25 #include "ui/gfx/android/java_bitmap.h"
27 #include "ui/gfx/color_analysis.h" 26 #include "ui/gfx/color_analysis.h"
28 #include "ui/gfx/color_utils.h" 27 #include "ui/gfx/color_utils.h"
29 28
30 using base::android::ScopedJavaGlobalRef; 29 using base::android::ScopedJavaGlobalRef;
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 Profile* profile = ProfileAndroid::FromProfileAndroid(jprofile); 115 Profile* profile = ProfileAndroid::FromProfileAndroid(jprofile);
117 DCHECK(profile); 116 DCHECK(profile);
118 117
119 std::string page_url = ConvertJavaStringToUTF8(env, j_page_url); 118 std::string page_url = ConvertJavaStringToUTF8(env, j_page_url);
120 119
121 ProfileSyncService* sync_service = 120 ProfileSyncService* sync_service =
122 ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile); 121 ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile);
123 DCHECK(sync_service); 122 DCHECK(sync_service);
124 123
125 scoped_refptr<base::RefCountedMemory> favicon_png; 124 scoped_refptr<base::RefCountedMemory> favicon_png;
126 browser_sync::SessionModelAssociator* associator = 125 browser_sync::OpenTabsUIDelegate* open_tabs =
127 sync_service->GetSessionModelAssociator(); 126 sync_service->GetOpenTabsUIDelegate();
128 DCHECK(associator); 127 DCHECK(open_tabs);
129 128
130 if (!associator->GetSyncedFaviconForPageURL(page_url, &favicon_png)) 129 if (!open_tabs->GetSyncedFaviconForPageURL(page_url, &favicon_png))
131 return ScopedJavaLocalRef<jobject>(); 130 return ScopedJavaLocalRef<jobject>();
132 131
133 // Convert favicon_image_result to java objects. 132 // Convert favicon_image_result to java objects.
134 gfx::Image favicon_image = gfx::Image::CreateFrom1xPNGBytes( 133 gfx::Image favicon_image = gfx::Image::CreateFrom1xPNGBytes(
135 favicon_png->front(), favicon_png->size()); 134 favicon_png->front(), favicon_png->size());
136 SkBitmap favicon_bitmap = favicon_image.AsBitmap(); 135 SkBitmap favicon_bitmap = favicon_image.AsBitmap();
137 136
138 ScopedJavaLocalRef<jobject> j_favicon_bitmap; 137 ScopedJavaLocalRef<jobject> j_favicon_bitmap;
139 if (favicon_bitmap.isNull()) 138 if (favicon_bitmap.isNull())
140 return ScopedJavaLocalRef<jobject>(); 139 return ScopedJavaLocalRef<jobject>();
(...skipping 18 matching lines...) Expand all
159 return color_utils::CalculateKMeanColorOfPNG( 158 return color_utils::CalculateKMeanColorOfPNG(
160 png_data, min_darkness, max_brightness, &sampler); 159 png_data, min_darkness, max_brightness, &sampler);
161 } 160 }
162 161
163 FaviconHelper::~FaviconHelper() {} 162 FaviconHelper::~FaviconHelper() {}
164 163
165 // static 164 // static
166 bool FaviconHelper::RegisterFaviconHelper(JNIEnv* env) { 165 bool FaviconHelper::RegisterFaviconHelper(JNIEnv* env) {
167 return RegisterNativesImpl(env); 166 return RegisterNativesImpl(env);
168 } 167 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/android/foreign_session_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698