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

Unified Diff: components/physical_web/webui/physical_web_base_message_handler.h

Issue 2571853003: Move PW message handler logic to components (Closed)
Patch Set: Limit ourselves to the sadness that is single inheritance Created 4 years 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
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..cf8e7cc9f30b3beefc8e3edbff09a9b604e6a21d
--- /dev/null
+++ b/components/physical_web/webui/physical_web_base_message_handler.h
@@ -0,0 +1,48 @@
+// 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
Eugene But (OOO till 7-30) 2016/12/22 19:04:47 COMPONENTS_PHYSICAL_WEB_WEBUI_PHYSICAL_WEB_BASE_ME
cco3 2016/12/22 20:14:45 Done.
+#define COMPONENTS_PHYSICAL_WEB_WEBUI_PHYSICAL_WEB_BASE_MESSAGE_HANDLER
+
+#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.
+// (Does not implement WebUIMessageHandler or register its methods)
Eugene But (OOO till 7-30) 2016/12/22 19:04:47 nit: Please finish comment with full stop
cco3 2016/12/22 20:14:45 Done.
+class PhysicalWebBaseMessageHandler {
+ public:
+ PhysicalWebBaseMessageHandler();
+ ~PhysicalWebBaseMessageHandler();
+
+ void HandleRequestNearbyURLs(const base::ListValue* args);
Eugene But (OOO till 7-30) 2016/12/22 19:04:47 Please add comments to the methods. https://engdo
cco3 2016/12/22 20:14:45 Done.
+ void HandlePhysicalWebItemClicked(const base::ListValue* args);
+
+ protected:
+ void RegisterMessagesImpl();
Eugene But (OOO till 7-30) 2016/12/22 19:04:47 Should this function be protected or private?
Eugene But (OOO till 7-30) 2016/12/22 19:04:47 nit: Do you need an Impl suffix here?
cco3 2016/12/22 20:14:45 Not any more.
cco3 2016/12/22 20:14:45 Done.
+ 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;
Eugene But (OOO till 7-30) 2016/12/22 19:04:47 Should this be a const method?
cco3 2016/12/22 20:14:45 Done.
Eugene But (OOO till 7-30) 2016/12/22 21:26:32 Sorry, I meant "const method", which is: virtual p
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(PhysicalWebBaseMessageHandler);
+};
+
+} // namespace physical_web_ui
+
+#endif // COMPONENTS_PHYSICAL_WEB_WEBUI_PHYSICAL_WEB_BASE_MESSAGE_HANDLER

Powered by Google App Engine
This is Rietveld 408576698