| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/ntp_snippets_bridge.h" | 5 #include "chrome/browser/android/ntp/ntp_snippets_bridge.h" |
| 6 | 6 |
| 7 #include <jni.h> | 7 #include <jni.h> |
| 8 | 8 |
| 9 #include "base/android/callback_android.h" | 9 #include "base/android/callback_android.h" |
| 10 #include "base/android/jni_android.h" | 10 #include "base/android/jni_android.h" |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 const JavaParamRef<jstring>& jurl) { | 111 const JavaParamRef<jstring>& jurl) { |
| 112 base::android::ScopedJavaGlobalRef<jobject> callback(jcallback); | 112 base::android::ScopedJavaGlobalRef<jobject> callback(jcallback); |
| 113 | 113 |
| 114 history_service_->QueryURL( | 114 history_service_->QueryURL( |
| 115 GURL(ConvertJavaStringToUTF8(env, jurl)), | 115 GURL(ConvertJavaStringToUTF8(env, jurl)), |
| 116 false, | 116 false, |
| 117 base::Bind(&SnippetVisitedHistoryRequestCallback, callback), | 117 base::Bind(&SnippetVisitedHistoryRequestCallback, callback), |
| 118 &tracker_); | 118 &tracker_); |
| 119 } | 119 } |
| 120 | 120 |
| 121 int NTPSnippetsBridge::GetDisabledReason(JNIEnv* env, |
| 122 const JavaParamRef<jobject>& obj) { |
| 123 return static_cast<int>(ntp_snippets_service_->GetDisabledReason()); |
| 124 } |
| 125 |
| 121 NTPSnippetsBridge::~NTPSnippetsBridge() {} | 126 NTPSnippetsBridge::~NTPSnippetsBridge() {} |
| 122 | 127 |
| 123 void NTPSnippetsBridge::NTPSnippetsServiceLoaded() { | 128 void NTPSnippetsBridge::NTPSnippetsServiceLoaded() { |
| 124 if (observer_.is_null()) | 129 if (observer_.is_null()) |
| 125 return; | 130 return; |
| 126 | 131 |
| 127 std::vector<std::string> ids; | 132 std::vector<std::string> ids; |
| 128 std::vector<std::string> titles; | 133 std::vector<std::string> titles; |
| 129 // URL for the article. This will also be used to find the favicon for the | 134 // URL for the article. This will also be used to find the favicon for the |
| 130 // article. | 135 // article. |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 if (!image.IsEmpty()) | 189 if (!image.IsEmpty()) |
| 185 j_bitmap = gfx::ConvertToJavaBitmap(image.ToSkBitmap()); | 190 j_bitmap = gfx::ConvertToJavaBitmap(image.ToSkBitmap()); |
| 186 | 191 |
| 187 base::android::RunCallbackAndroid(callback, j_bitmap); | 192 base::android::RunCallbackAndroid(callback, j_bitmap); |
| 188 } | 193 } |
| 189 | 194 |
| 190 // static | 195 // static |
| 191 bool NTPSnippetsBridge::Register(JNIEnv* env) { | 196 bool NTPSnippetsBridge::Register(JNIEnv* env) { |
| 192 return RegisterNativesImpl(env); | 197 return RegisterNativesImpl(env); |
| 193 } | 198 } |
| OLD | NEW |