Chromium Code Reviews| 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 ScopedJavaLocalRef<jobject> url_manager = Java_UrlManager_getInstance(env); | |
| 29 url_manager_.Reset(env, env->NewGlobalRef(url_manager.obj())); | |
| 30 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
| |
| 14 } | 31 } |
| 15 | 32 |
| 16 void PhysicalWebDataSourceAndroid::StartDiscovery( | 33 void PhysicalWebDataSourceAndroid::StartDiscovery( |
| 17 bool network_request_enabled) { | 34 bool network_request_enabled) { |
| 35 // On Android, scanning is started and stopped through the Java layer. | |
| 36 NOTREACHED(); | |
| 18 } | 37 } |
| 19 | 38 |
| 20 void PhysicalWebDataSourceAndroid::StopDiscovery() { | 39 void PhysicalWebDataSourceAndroid::StopDiscovery() { |
| 40 // On Android, scanning is started and stopped through the Java layer. | |
| 41 NOTREACHED(); | |
| 21 } | 42 } |
| 22 | 43 |
| 23 std::unique_ptr<base::ListValue> PhysicalWebDataSourceAndroid::GetMetadata() { | 44 std::unique_ptr<base::ListValue> PhysicalWebDataSourceAndroid::GetMetadata() { |
| 45 // TODO(mattreynolds): get the metadata from the Java layer | |
| 24 return base::MakeUnique<base::ListValue>(); | 46 return base::MakeUnique<base::ListValue>(); |
| 25 } | 47 } |
| 26 | 48 |
| 27 bool PhysicalWebDataSourceAndroid::HasUnresolvedDiscoveries() { | 49 bool PhysicalWebDataSourceAndroid::HasUnresolvedDiscoveries() { |
| 50 NOTIMPLEMENTED(); | |
| 28 return false; | 51 return false; |
| 29 } | 52 } |
| 30 | 53 |
| 31 void PhysicalWebDataSourceAndroid::RegisterListener( | 54 // static |
| 32 PhysicalWebListener* listener) { | 55 bool PhysicalWebDataSourceAndroid::RegisterPhysicalWebDataSource(JNIEnv* env) { |
| 56 return RegisterNativesImpl(env); | |
| 33 } | 57 } |
| 34 | 58 |
| 35 void PhysicalWebDataSourceAndroid::UnregisterListener( | 59 static jlong Init(JNIEnv* env, const JavaParamRef<jobject>& obj) { |
| 36 PhysicalWebListener* listener) { | 60 PhysicalWebDataSource* data_source = |
| 61 g_browser_process->GetPhysicalWebDataSource(); | |
| 62 return reinterpret_cast<intptr_t>(data_source); | |
| 37 } | 63 } |
| OLD | NEW |