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 |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..fd0161b27f48ff6a2c6112872163deb5b4877f58 |
| --- /dev/null |
| +++ b/components/physical_web/webui/physical_web_base_message_handler.h |
| @@ -0,0 +1,55 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef COMPONENTS_PHYSICAL_WEB_WEBUI_PHYSICAL_WEB_BASE_MESSAGE_HANDLER_H_ |
| +#define COMPONENTS_PHYSICAL_WEB_WEBUI_PHYSICAL_WEB_BASE_MESSAGE_HANDLER_H_ |
| + |
| +#include "base/callback.h" |
| +#include "base/macros.h" |
| +#include "base/values.h" |
| + |
| +namespace physical_web { |
| + |
| +class PhysicalWebDataSource; |
| + |
| +} // namespace physical_web |
| + |
| +namespace physical_web_ui { |
| + |
| +// This is the equivalent of content::WebUI::MessageCallback. |
| +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 { |
| + public: |
| + PhysicalWebBaseMessageHandler(); |
| + ~PhysicalWebBaseMessageHandler(); |
| + |
| + // This method handles the RequestNearbyURLs message, returning URLs that are |
|
Eugene But (OOO till 7-30)
2016/12/22 21:26:32
Optional nit: How about s/This method handles/Hand
cco3
2016/12/22 22:07:07
Done.
|
| + // currently being broadcasted by Physical Web transports. |
| + void HandleRequestNearbyURLs(const base::ListValue* args); |
| + |
| + // This method handles a click on a Physical Web URL, recording the click and |
|
Eugene But (OOO till 7-30)
2016/12/22 21:26:33
ditto
cco3
2016/12/22 22:07:07
Done.
|
| + // directing the user appropriately. |
| + void HandlePhysicalWebItemClicked(const base::ListValue* args); |
| + |
| + // Register the messages that this MessageHandler can handle. |
|
Eugene But (OOO till 7-30)
2016/12/22 21:26:32
s/Register/Registers
cco3
2016/12/22 22:07:07
Done.
|
| + void RegisterMessages(); |
| + |
| + protected: |
| + virtual void RegisterMessageCallback( |
|
Eugene But (OOO till 7-30)
2016/12/22 21:26:32
Do you want to add comments for protected methods
cco3
2016/12/22 22:07:07
Done.
|
| + 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: |
| + DISALLOW_COPY_AND_ASSIGN(PhysicalWebBaseMessageHandler); |
| +}; |
| + |
| +} // namespace physical_web_ui |
| + |
| +#endif // COMPONENTS_PHYSICAL_WEB_WEBUI_PHYSICAL_WEB_BASE_MESSAGE_HANDLER_H_ |