| 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/physical_web/physical_web_data_source_android.h
" | 5 #include "chrome/browser/android/physical_web/physical_web_data_source_android.h
" |
| 6 | 6 |
| 7 #include <jni.h> |
| 8 |
| 7 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 8 #include "base/values.h" | 10 #include "base/values.h" |
| 11 #include "chrome/browser/browser_process.h" |
| 12 #include "jni/UrlManager_jni.h" |
| 13 |
| 14 using base::android::AttachCurrentThread; |
| 15 using base::android::JavaParamRef; |
| 16 using base::android::ScopedJavaLocalRef; |
| 9 | 17 |
| 10 PhysicalWebDataSourceAndroid::PhysicalWebDataSourceAndroid() { | 18 PhysicalWebDataSourceAndroid::PhysicalWebDataSourceAndroid() { |
| 19 Initialize(); |
| 11 } | 20 } |
| 12 | 21 |
| 13 PhysicalWebDataSourceAndroid::~PhysicalWebDataSourceAndroid() { | 22 PhysicalWebDataSourceAndroid::~PhysicalWebDataSourceAndroid() {} |
| 23 |
| 24 void PhysicalWebDataSourceAndroid::Initialize() { |
| 25 JNIEnv* env = AttachCurrentThread(); |
| 26 |
| 27 // Cache a reference to the singleton instance of UrlManager. |
| 28 url_manager_.Reset(Java_UrlManager_getInstance(env)); |
| 29 DCHECK(url_manager_.obj()); |
| 14 } | 30 } |
| 15 | 31 |
| 16 void PhysicalWebDataSourceAndroid::StartDiscovery( | 32 void PhysicalWebDataSourceAndroid::StartDiscovery( |
| 17 bool network_request_enabled) { | 33 bool network_request_enabled) { |
| 34 // On Android, scanning is started and stopped through the Java layer. |
| 35 NOTREACHED(); |
| 18 } | 36 } |
| 19 | 37 |
| 20 void PhysicalWebDataSourceAndroid::StopDiscovery() { | 38 void PhysicalWebDataSourceAndroid::StopDiscovery() { |
| 39 // On Android, scanning is started and stopped through the Java layer. |
| 40 NOTREACHED(); |
| 21 } | 41 } |
| 22 | 42 |
| 23 std::unique_ptr<base::ListValue> PhysicalWebDataSourceAndroid::GetMetadata() { | 43 std::unique_ptr<base::ListValue> PhysicalWebDataSourceAndroid::GetMetadata() { |
| 44 // TODO(mattreynolds): get the metadata from the Java layer |
| 24 return base::MakeUnique<base::ListValue>(); | 45 return base::MakeUnique<base::ListValue>(); |
| 25 } | 46 } |
| 26 | 47 |
| 27 bool PhysicalWebDataSourceAndroid::HasUnresolvedDiscoveries() { | 48 bool PhysicalWebDataSourceAndroid::HasUnresolvedDiscoveries() { |
| 49 NOTIMPLEMENTED(); |
| 28 return false; | 50 return false; |
| 29 } | 51 } |
| 30 | 52 |
| 31 void PhysicalWebDataSourceAndroid::RegisterListener( | 53 // static |
| 32 PhysicalWebListener* listener) { | 54 bool PhysicalWebDataSourceAndroid::RegisterPhysicalWebDataSource(JNIEnv* env) { |
| 55 return RegisterNativesImpl(env); |
| 33 } | 56 } |
| 34 | 57 |
| 35 void PhysicalWebDataSourceAndroid::UnregisterListener( | 58 static jlong Init(JNIEnv* env, const JavaParamRef<jobject>& obj) { |
| 36 PhysicalWebListener* listener) { | 59 PhysicalWebDataSource* data_source = |
| 60 g_browser_process->GetPhysicalWebDataSource(); |
| 61 return reinterpret_cast<intptr_t>(data_source); |
| 37 } | 62 } |
| OLD | NEW |