Chromium Code Reviews| Index: chrome/browser/android/physical_web/physical_web_data_source_android.cc |
| diff --git a/chrome/browser/android/physical_web/physical_web_data_source_android.cc b/chrome/browser/android/physical_web/physical_web_data_source_android.cc |
| index 9e078b391b3f3acf2ffb191dd4998c0d3a1ba0ba..6d0a80465b0907a92018cd486524fad7e1387b36 100644 |
| --- a/chrome/browser/android/physical_web/physical_web_data_source_android.cc |
| +++ b/chrome/browser/android/physical_web/physical_web_data_source_android.cc |
| @@ -4,34 +4,60 @@ |
| #include "chrome/browser/android/physical_web/physical_web_data_source_android.h" |
| +#include <jni.h> |
| + |
| #include "base/memory/ptr_util.h" |
| #include "base/values.h" |
| +#include "chrome/browser/browser_process.h" |
| +#include "jni/UrlManager_jni.h" |
| + |
| +using base::android::AttachCurrentThread; |
| +using base::android::JavaParamRef; |
| +using base::android::ScopedJavaLocalRef; |
| PhysicalWebDataSourceAndroid::PhysicalWebDataSourceAndroid() { |
| + Initialize(); |
| } |
| -PhysicalWebDataSourceAndroid::~PhysicalWebDataSourceAndroid() { |
| +PhysicalWebDataSourceAndroid::~PhysicalWebDataSourceAndroid() {} |
| + |
| +void PhysicalWebDataSourceAndroid::Initialize() { |
| + JNIEnv* env = AttachCurrentThread(); |
| + |
| + // Cache a reference to the singleton instance of UrlManager. |
| + ScopedJavaLocalRef<jobject> url_manager = Java_UrlManager_getInstance(env); |
| + url_manager_.Reset(env, env->NewGlobalRef(url_manager.obj())); |
| + DCHECK(url_manager_.obj()); |
|
gone
2016/10/11 00:18:07
Should be more straightforward; check:
AppBannerM
mattreynolds
2016/10/11 19:44:35
I think you're suggesting we should be able to do
gone
2016/10/11 19:50:33
Oh, I was actually referring to the thing you chan
|
| } |
| void PhysicalWebDataSourceAndroid::StartDiscovery( |
| bool network_request_enabled) { |
| + // On Android, scanning is started and stopped through the Java layer. |
| + NOTREACHED(); |
| } |
| void PhysicalWebDataSourceAndroid::StopDiscovery() { |
| + // On Android, scanning is started and stopped through the Java layer. |
| + NOTREACHED(); |
| } |
| std::unique_ptr<base::ListValue> PhysicalWebDataSourceAndroid::GetMetadata() { |
| + // TODO(mattreynolds): get the metadata from the Java layer |
| return base::MakeUnique<base::ListValue>(); |
| } |
| bool PhysicalWebDataSourceAndroid::HasUnresolvedDiscoveries() { |
| + NOTIMPLEMENTED(); |
| return false; |
| } |
| -void PhysicalWebDataSourceAndroid::RegisterListener( |
| - PhysicalWebListener* listener) { |
| +// static |
| +bool PhysicalWebDataSourceAndroid::RegisterPhysicalWebDataSource(JNIEnv* env) { |
| + return RegisterNativesImpl(env); |
| } |
| -void PhysicalWebDataSourceAndroid::UnregisterListener( |
| - PhysicalWebListener* listener) { |
| +static jlong Init(JNIEnv* env, const JavaParamRef<jobject>& obj) { |
| + PhysicalWebDataSource* data_source = |
| + g_browser_process->GetPhysicalWebDataSource(); |
| + return reinterpret_cast<intptr_t>(data_source); |
| } |