| 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" |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 : observer_(env, obj) {} | 62 : observer_(env, obj) {} |
| 63 | 63 |
| 64 void MostVisitedSitesBridge::Observer::OnMostVisitedURLsAvailable( | 64 void MostVisitedSitesBridge::Observer::OnMostVisitedURLsAvailable( |
| 65 const MostVisitedSites::SuggestionsVector& suggestions) { | 65 const MostVisitedSites::SuggestionsVector& suggestions) { |
| 66 JNIEnv* env = AttachCurrentThread(); | 66 JNIEnv* env = AttachCurrentThread(); |
| 67 std::vector<base::string16> titles; | 67 std::vector<base::string16> titles; |
| 68 std::vector<std::string> urls; | 68 std::vector<std::string> urls; |
| 69 std::vector<std::string> whitelist_icon_paths; | 69 std::vector<std::string> whitelist_icon_paths; |
| 70 titles.reserve(suggestions.size()); | 70 titles.reserve(suggestions.size()); |
| 71 urls.reserve(suggestions.size()); | 71 urls.reserve(suggestions.size()); |
| 72 whitelist_icon_paths.reserve(suggestions.size()); |
| 72 for (const auto& suggestion : suggestions) { | 73 for (const auto& suggestion : suggestions) { |
| 73 titles.push_back(suggestion.title); | 74 titles.emplace_back(suggestion.title); |
| 74 urls.push_back(suggestion.url.spec()); | 75 urls.emplace_back(suggestion.url.spec()); |
| 75 whitelist_icon_paths.push_back(suggestion.whitelist_icon_path.value()); | 76 whitelist_icon_paths.emplace_back(suggestion.whitelist_icon_path.value()); |
| 76 } | 77 } |
| 77 Java_MostVisitedURLsObserver_onMostVisitedURLsAvailable( | 78 Java_MostVisitedURLsObserver_onMostVisitedURLsAvailable( |
| 78 env, observer_.obj(), ToJavaArrayOfStrings(env, titles).obj(), | 79 env, observer_.obj(), ToJavaArrayOfStrings(env, titles).obj(), |
| 79 ToJavaArrayOfStrings(env, urls).obj(), | 80 ToJavaArrayOfStrings(env, urls).obj(), |
| 80 ToJavaArrayOfStrings(env, whitelist_icon_paths).obj()); | 81 ToJavaArrayOfStrings(env, whitelist_icon_paths).obj()); |
| 81 } | 82 } |
| 82 | 83 |
| 83 void MostVisitedSitesBridge::Observer::OnPopularURLsAvailable( | 84 void MostVisitedSitesBridge::Observer::OnPopularURLsAvailable( |
| 84 const MostVisitedSites::PopularSitesVector& sites) { | 85 const MostVisitedSites::PopularSitesVector& sites) { |
| 85 JNIEnv* env = AttachCurrentThread(); | 86 JNIEnv* env = AttachCurrentThread(); |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 } | 161 } |
| 161 | 162 |
| 162 static jlong Init(JNIEnv* env, | 163 static jlong Init(JNIEnv* env, |
| 163 const JavaParamRef<jobject>& obj, | 164 const JavaParamRef<jobject>& obj, |
| 164 const JavaParamRef<jobject>& jprofile) { | 165 const JavaParamRef<jobject>& jprofile) { |
| 165 MostVisitedSitesBridge* most_visited_sites = | 166 MostVisitedSitesBridge* most_visited_sites = |
| 166 new MostVisitedSitesBridge( | 167 new MostVisitedSitesBridge( |
| 167 ProfileAndroid::FromProfileAndroid(jprofile)); | 168 ProfileAndroid::FromProfileAndroid(jprofile)); |
| 168 return reinterpret_cast<intptr_t>(most_visited_sites); | 169 return reinterpret_cast<intptr_t>(most_visited_sites); |
| 169 } | 170 } |
| OLD | NEW |