Chromium Code Reviews| Index: components/physical_web/webui/physical_web_base_message_handler.h |
| diff --git a/components/physical_web/webui/physical_web_base_message_handler.h b/components/physical_web/webui/physical_web_base_message_handler.h |
| index 190cf294b11f142fbfe0243aebc3881a11d2cd07..3e2a0d2d8d982d1fac5b64bc4eaef101b7164d60 100644 |
| --- a/components/physical_web/webui/physical_web_base_message_handler.h |
| +++ b/components/physical_web/webui/physical_web_base_message_handler.h |
| @@ -5,9 +5,13 @@ |
| #ifndef COMPONENTS_PHYSICAL_WEB_WEBUI_PHYSICAL_WEB_BASE_MESSAGE_HANDLER_H_ |
| #define COMPONENTS_PHYSICAL_WEB_WEBUI_PHYSICAL_WEB_BASE_MESSAGE_HANDLER_H_ |
| +#include <unordered_map> |
| + |
| #include "base/callback.h" |
| #include "base/macros.h" |
| #include "base/values.h" |
| +#include "components/physical_web/data_source/physical_web_data_source.h" |
| +#include "components/physical_web/data_source/physical_web_listener.h" |
| namespace physical_web { |
| @@ -22,14 +26,19 @@ typedef base::Callback<void(const base::ListValue*)> MessageCallback; |
| // The base handler for Javascript messages for the chrome://physical-web page. |
| // This does not implement WebUIMessageHandler or register its methods. |
| -class PhysicalWebBaseMessageHandler { |
| +class PhysicalWebBaseMessageHandler : physical_web::PhysicalWebListener { |
| public: |
| PhysicalWebBaseMessageHandler(); |
| virtual ~PhysicalWebBaseMessageHandler(); |
| - // Handles the RequestNearbyURLs message, returning URLs that are currently |
| - // being broadcasted by Physical Web transports. |
| - void HandleRequestNearbyURLs(const base::ListValue* args); |
| + // PhysicalWebListener |
| + void OnFound(const GURL& url) override; |
| + void OnLost(const GURL& url) override; |
| + void OnDistanceChanged(const GURL& url, double distance_estimate) override; |
| + |
| + // Return URLs that are currently being broadcasted by Physical Web |
| + // transports. |
| + void ReturnNearbyURLs(const base::ListValue* args); |
|
mmocny
2017/03/24 17:15:12
I think we don't need this ListValue* parameter an
Ran
2017/03/24 18:45:19
Done.
|
| // Handles a click on a Physical Web URL, recording the click and |
| // directing the user appropriately. |
| @@ -42,14 +51,17 @@ class PhysicalWebBaseMessageHandler { |
| // Subclasses should implement these protected methods as a pass through to |
| // the similarly named methods of the appropriate WebUI object (the exact |
| // WebUI class differs per platform). |
| - virtual void RegisterMessageCallback( |
| - const std::string& message, |
| - const MessageCallback& callback) = 0; |
| + virtual void RegisterMessageCallback(const std::string& message, |
| + const MessageCallback& callback) = 0; |
| virtual void CallJavaScriptFunction(const std::string& function, |
| const base::Value& arg) = 0; |
| virtual physical_web::PhysicalWebDataSource* GetPhysicalWebDataSource() = 0; |
| private: |
| + physical_web::PhysicalWebDataSource* data_source_; |
| + std::vector<std::string> ordered_group_ids_; |
| + std::unordered_map<std::string, physical_web::Metadata> metadata_map_; |
| + |
| DISALLOW_COPY_AND_ASSIGN(PhysicalWebBaseMessageHandler); |
| }; |