| 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/ntp/most_visited_sites_bridge.h" | 5 #include "chrome/browser/android/ntp/most_visited_sites_bridge.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 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" |
| 11 #include "base/android/jni_string.h" | 11 #include "base/android/jni_string.h" |
| 12 #include "base/android/scoped_java_ref.h" | 12 #include "base/android/scoped_java_ref.h" |
| 13 #include "base/bind.h" | 13 #include "base/bind.h" |
| 14 #include "base/callback.h" | 14 #include "base/callback.h" |
| 15 #include "chrome/browser/android/ntp/popular_sites.h" | 15 #include "chrome/browser/android/ntp/popular_sites.h" |
| 16 #include "chrome/browser/browser_process.h" |
| 16 #include "chrome/browser/profiles/profile_android.h" | 17 #include "chrome/browser/profiles/profile_android.h" |
| 17 #include "jni/MostVisitedSites_jni.h" | 18 #include "jni/MostVisitedSites_jni.h" |
| 18 #include "ui/gfx/android/java_bitmap.h" | 19 #include "ui/gfx/android/java_bitmap.h" |
| 19 #include "url/gurl.h" | 20 #include "url/gurl.h" |
| 20 | 21 |
| 21 using base::android::AttachCurrentThread; | 22 using base::android::AttachCurrentThread; |
| 22 using base::android::ConvertJavaStringToUTF8; | 23 using base::android::ConvertJavaStringToUTF8; |
| 23 using base::android::ScopedJavaGlobalRef; | 24 using base::android::ScopedJavaGlobalRef; |
| 24 using base::android::ScopedJavaLocalRef; | 25 using base::android::ScopedJavaLocalRef; |
| 25 using base::android::ToJavaArrayOfStrings; | 26 using base::android::ToJavaArrayOfStrings; |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 favicon_urls.emplace_back(site.favicon_url.spec()); | 93 favicon_urls.emplace_back(site.favicon_url.spec()); |
| 93 large_icon_urls.emplace_back(site.large_icon_url.spec()); | 94 large_icon_urls.emplace_back(site.large_icon_url.spec()); |
| 94 } | 95 } |
| 95 Java_MostVisitedURLsObserver_onPopularURLsAvailable( | 96 Java_MostVisitedURLsObserver_onPopularURLsAvailable( |
| 96 env, observer_.obj(), ToJavaArrayOfStrings(env, urls).obj(), | 97 env, observer_.obj(), ToJavaArrayOfStrings(env, urls).obj(), |
| 97 ToJavaArrayOfStrings(env, favicon_urls).obj(), | 98 ToJavaArrayOfStrings(env, favicon_urls).obj(), |
| 98 ToJavaArrayOfStrings(env, large_icon_urls).obj()); | 99 ToJavaArrayOfStrings(env, large_icon_urls).obj()); |
| 99 } | 100 } |
| 100 | 101 |
| 101 MostVisitedSitesBridge::MostVisitedSitesBridge(Profile* profile) | 102 MostVisitedSitesBridge::MostVisitedSitesBridge(Profile* profile) |
| 102 : most_visited_(profile) {} | 103 : most_visited_(profile, |
| 104 g_browser_process->variations_service()) {} |
| 103 | 105 |
| 104 MostVisitedSitesBridge::~MostVisitedSitesBridge() {} | 106 MostVisitedSitesBridge::~MostVisitedSitesBridge() {} |
| 105 | 107 |
| 106 void MostVisitedSitesBridge::Destroy( | 108 void MostVisitedSitesBridge::Destroy( |
| 107 JNIEnv* env, const JavaParamRef<jobject>& obj) { | 109 JNIEnv* env, const JavaParamRef<jobject>& obj) { |
| 108 delete this; | 110 delete this; |
| 109 } | 111 } |
| 110 | 112 |
| 111 void MostVisitedSitesBridge::SetMostVisitedURLsObserver( | 113 void MostVisitedSitesBridge::SetMostVisitedURLsObserver( |
| 112 JNIEnv* env, | 114 JNIEnv* env, |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 } | 163 } |
| 162 | 164 |
| 163 static jlong Init(JNIEnv* env, | 165 static jlong Init(JNIEnv* env, |
| 164 const JavaParamRef<jobject>& obj, | 166 const JavaParamRef<jobject>& obj, |
| 165 const JavaParamRef<jobject>& jprofile) { | 167 const JavaParamRef<jobject>& jprofile) { |
| 166 MostVisitedSitesBridge* most_visited_sites = | 168 MostVisitedSitesBridge* most_visited_sites = |
| 167 new MostVisitedSitesBridge( | 169 new MostVisitedSitesBridge( |
| 168 ProfileAndroid::FromProfileAndroid(jprofile)); | 170 ProfileAndroid::FromProfileAndroid(jprofile)); |
| 169 return reinterpret_cast<intptr_t>(most_visited_sites); | 171 return reinterpret_cast<intptr_t>(most_visited_sites); |
| 170 } | 172 } |
| OLD | NEW |