Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1134)

Unified Diff: chrome/browser/android/physical_web/physical_web_data_source_android.cc

Issue 2377513002: Add a Physical Web JNI bridge to support native Physical Web clients (Closed)
Patch Set: split Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/android/physical_web/physical_web_data_source_android.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
}
« no previous file with comments | « chrome/browser/android/physical_web/physical_web_data_source_android.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698