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

Side by Side Diff: chrome/browser/android/physical_web/physical_web_data_source_android.h

Issue 2403423005: Expose Physical Web metadata to native clients over JNI (Closed)
Patch Set: remove unit test Created 4 years, 1 month 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 unified diff | Download patch
OLDNEW
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 #ifndef CHROME_BROWSER_ANDROID_PHYSICAL_WEB_PHYSICAL_WEB_DATA_SOURCE_ANDROID_H_ 5 #ifndef CHROME_BROWSER_ANDROID_PHYSICAL_WEB_PHYSICAL_WEB_DATA_SOURCE_ANDROID_H_
6 #define CHROME_BROWSER_ANDROID_PHYSICAL_WEB_PHYSICAL_WEB_DATA_SOURCE_ANDROID_H_ 6 #define CHROME_BROWSER_ANDROID_PHYSICAL_WEB_PHYSICAL_WEB_DATA_SOURCE_ANDROID_H_
7 7
8 #include <jni.h> 8 #include <jni.h>
9 9
10 #include "base/android/scoped_java_ref.h" 10 #include "base/android/scoped_java_ref.h"
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "components/physical_web/data_source/physical_web_data_source_impl.h" 12 #include "components/physical_web/data_source/physical_web_data_source_impl.h"
13 13
14 namespace base { 14 namespace base {
15 class ListValue; 15 class ListValue;
16 } 16 }
17 17
18 // A container for Physical Web metadata. This is primarily a wrapper for a
19 // ListValue so we can append to it over JNI.
20 class PhysicalWebCollection {
21 public:
22 PhysicalWebCollection();
23 ~PhysicalWebCollection();
24
25 void AppendMetadataItem(
26 JNIEnv* env,
27 const base::android::JavaParamRef<jobject>& obj,
28 const base::android::JavaParamRef<jstring>& j_request_url,
29 jdouble distance_estimate,
30 jint scan_timestamp,
31 const base::android::JavaParamRef<jstring>& j_site_url,
32 const base::android::JavaParamRef<jstring>& j_icon_url,
33 const base::android::JavaParamRef<jstring>& j_title,
34 const base::android::JavaParamRef<jstring>& j_description,
35 const base::android::JavaParamRef<jstring>& j_group_id);
36
37 // Returns the metadata list and transfers ownership of the list to the
38 // caller. Call only once.
39 std::unique_ptr<base::ListValue> GetMetadataList();
40
41 private:
42 std::unique_ptr<base::ListValue> metadata_list_;
43 bool accessed_once_;
44
45 DISALLOW_COPY_AND_ASSIGN(PhysicalWebCollection);
46 };
47
18 class PhysicalWebDataSourceAndroid : public PhysicalWebDataSourceImpl { 48 class PhysicalWebDataSourceAndroid : public PhysicalWebDataSourceImpl {
19 public: 49 public:
20 PhysicalWebDataSourceAndroid(); 50 PhysicalWebDataSourceAndroid();
21 ~PhysicalWebDataSourceAndroid() override; 51 ~PhysicalWebDataSourceAndroid() override;
22 52
23 static bool RegisterPhysicalWebDataSource(JNIEnv* env); 53 static bool RegisterPhysicalWebDataSource(JNIEnv* env);
24 54
25 void Initialize(); 55 void Initialize();
26 56
27 void StartDiscovery(bool network_request_enabled) override; 57 void StartDiscovery(bool network_request_enabled) override;
28 void StopDiscovery() override; 58 void StopDiscovery() override;
29 59
30 std::unique_ptr<base::ListValue> GetMetadata() override; 60 std::unique_ptr<base::ListValue> GetMetadata() override;
31 bool HasUnresolvedDiscoveries() override; 61 bool HasUnresolvedDiscoveries() override;
32 62
33 private: 63 private:
34 // A reference to the Java UrlManager singleton. 64 // A reference to the Java UrlManager singleton.
35 base::android::ScopedJavaGlobalRef<jobject> url_manager_; 65 base::android::ScopedJavaGlobalRef<jobject> url_manager_;
36 66
37 DISALLOW_COPY_AND_ASSIGN(PhysicalWebDataSourceAndroid); 67 DISALLOW_COPY_AND_ASSIGN(PhysicalWebDataSourceAndroid);
38 }; 68 };
39 69
40 #endif // CHROME_BROWSER_ANDROID_PHYSICAL_WEB_PHYSICAL_WEB_DATA_SOURCE_ANDROID_ H_ 70 #endif // CHROME_BROWSER_ANDROID_PHYSICAL_WEB_PHYSICAL_WEB_DATA_SOURCE_ANDROID_ H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698