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 #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 | 18 // A container for Physical Web metadata. This is primarily a wrapper for a |
19 // ListValue so we can append to it over JNI. | 19 // ListValue so we can append to it over JNI. |
20 class PhysicalWebCollection { | 20 class PhysicalWebCollection { |
21 public: | 21 public: |
22 PhysicalWebCollection(); | 22 PhysicalWebCollection(); |
23 ~PhysicalWebCollection(); | 23 ~PhysicalWebCollection(); |
24 | 24 |
25 void AppendMetadataItem( | 25 void AppendMetadataItem( |
26 JNIEnv* env, | 26 JNIEnv* env, |
27 const base::android::JavaParamRef<jobject>& obj, | 27 const base::android::JavaParamRef<jobject>& obj, |
28 const base::android::JavaParamRef<jstring>& j_request_url, | 28 const base::android::JavaParamRef<jstring>& j_request_url, |
29 jdouble distance_estimate, | 29 jdouble distance_estimate, |
30 jint scan_timestamp, | 30 jlong scan_timestamp, |
31 const base::android::JavaParamRef<jstring>& j_site_url, | 31 const base::android::JavaParamRef<jstring>& j_site_url, |
32 const base::android::JavaParamRef<jstring>& j_icon_url, | 32 const base::android::JavaParamRef<jstring>& j_icon_url, |
33 const base::android::JavaParamRef<jstring>& j_title, | 33 const base::android::JavaParamRef<jstring>& j_title, |
34 const base::android::JavaParamRef<jstring>& j_description, | 34 const base::android::JavaParamRef<jstring>& j_description, |
35 const base::android::JavaParamRef<jstring>& j_group_id); | 35 const base::android::JavaParamRef<jstring>& j_group_id); |
36 | 36 |
37 // Returns the metadata list and transfers ownership of the list to the | 37 // Returns the metadata list and transfers ownership of the list to the |
38 // caller. Call only once. | 38 // caller. Call only once. |
39 std::unique_ptr<base::ListValue> GetMetadataList(); | 39 std::unique_ptr<physical_web::MetadataList> GetMetadataList(); |
40 | |
41 // Returns the metadata list and transfers ownership of the list to the | |
42 // caller. Call only once. | |
43 // TODO(cco3): Remove when we no longer rely on this. | |
vitaliii
2016/12/07 10:14:04
nit: explicitly say that this is deprecated and ne
cco3
2016/12/08 23:52:50
Done.
| |
44 std::unique_ptr<base::ListValue> GetMetadataListValue(); | |
40 | 45 |
41 private: | 46 private: |
42 std::unique_ptr<base::ListValue> metadata_list_; | 47 std::unique_ptr<base::ListValue> dictionary_value_list_; |
48 std::unique_ptr<physical_web::MetadataList> metadata_list_; | |
43 bool accessed_once_; | 49 bool accessed_once_; |
44 | 50 |
45 DISALLOW_COPY_AND_ASSIGN(PhysicalWebCollection); | 51 DISALLOW_COPY_AND_ASSIGN(PhysicalWebCollection); |
46 }; | 52 }; |
47 | 53 |
48 class PhysicalWebDataSourceAndroid | 54 class PhysicalWebDataSourceAndroid |
49 : public physical_web::PhysicalWebDataSourceImpl { | 55 : public physical_web::PhysicalWebDataSourceImpl { |
50 public: | 56 public: |
51 PhysicalWebDataSourceAndroid(); | 57 PhysicalWebDataSourceAndroid(); |
52 ~PhysicalWebDataSourceAndroid() override; | 58 ~PhysicalWebDataSourceAndroid() override; |
53 | 59 |
54 static bool RegisterPhysicalWebDataSource(JNIEnv* env); | 60 static bool RegisterPhysicalWebDataSource(JNIEnv* env); |
55 | 61 |
56 void Initialize(); | 62 void Initialize(); |
57 | 63 |
58 void StartDiscovery(bool network_request_enabled) override; | 64 void StartDiscovery(bool network_request_enabled) override; |
59 void StopDiscovery() override; | 65 void StopDiscovery() override; |
60 | 66 |
61 std::unique_ptr<base::ListValue> GetMetadata() override; | 67 std::unique_ptr<base::ListValue> GetMetadataListValue() override; |
68 std::unique_ptr<physical_web::MetadataList> GetMetadata() override; | |
62 bool HasUnresolvedDiscoveries() override; | 69 bool HasUnresolvedDiscoveries() override; |
63 | 70 |
64 void OnFound(JNIEnv* env, | 71 void OnFound(JNIEnv* env, |
65 const base::android::JavaParamRef<jobject>& obj, | 72 const base::android::JavaParamRef<jobject>& obj, |
66 const base::android::JavaParamRef<jstring>& j_url); | 73 const base::android::JavaParamRef<jstring>& j_url); |
67 void OnLost(JNIEnv* env, | 74 void OnLost(JNIEnv* env, |
68 const base::android::JavaParamRef<jobject>& obj, | 75 const base::android::JavaParamRef<jobject>& obj, |
69 const base::android::JavaParamRef<jstring>& j_url); | 76 const base::android::JavaParamRef<jstring>& j_url); |
70 void OnDistanceChanged(JNIEnv* env, | 77 void OnDistanceChanged(JNIEnv* env, |
71 const base::android::JavaParamRef<jobject>& obj, | 78 const base::android::JavaParamRef<jobject>& obj, |
72 const base::android::JavaParamRef<jstring>& j_url, | 79 const base::android::JavaParamRef<jstring>& j_url, |
73 jdouble distance_estimate); | 80 jdouble distance_estimate); |
74 | 81 |
75 private: | 82 private: |
76 // A reference to the Java UrlManager singleton. | 83 // A reference to the Java UrlManager singleton. |
77 base::android::ScopedJavaGlobalRef<jobject> url_manager_; | 84 base::android::ScopedJavaGlobalRef<jobject> url_manager_; |
78 | 85 |
79 DISALLOW_COPY_AND_ASSIGN(PhysicalWebDataSourceAndroid); | 86 DISALLOW_COPY_AND_ASSIGN(PhysicalWebDataSourceAndroid); |
80 }; | 87 }; |
81 | 88 |
82 #endif // CHROME_BROWSER_ANDROID_PHYSICAL_WEB_PHYSICAL_WEB_DATA_SOURCE_ANDROID_ H_ | 89 #endif // CHROME_BROWSER_ANDROID_PHYSICAL_WEB_PHYSICAL_WEB_DATA_SOURCE_ANDROID_ H_ |
OLD | NEW |