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

Unified Diff: components/ntp_tiles/webui/popular_sites_internals_message_handler.h

Issue 2457033003: Add chrome://popular-sites-internals/ to iOS. (Closed)
Patch Set: Break out ...Client. 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/ntp_tiles/DEPS ('k') | components/ntp_tiles/webui/popular_sites_internals_message_handler.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/ntp_tiles/webui/popular_sites_internals_message_handler.h
diff --git a/components/ntp_tiles/webui/popular_sites_internals_message_handler.h b/components/ntp_tiles/webui/popular_sites_internals_message_handler.h
new file mode 100644
index 0000000000000000000000000000000000000000..3dbc74522e6301f4751708b2f5e8cb593651fbd0
--- /dev/null
+++ b/components/ntp_tiles/webui/popular_sites_internals_message_handler.h
@@ -0,0 +1,64 @@
+// 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_NTP_TILES_WEBUI_POPULAR_SITES_HANDLER_H_
+#define COMPONENTS_NTP_TILES_WEBUI_POPULAR_SITES_HANDLER_H_
+
+#include <memory>
+#include <string>
+
+#include "base/macros.h"
+#include "base/memory/weak_ptr.h"
+
+namespace base {
+class ListValue;
+} // namespace base
+
+namespace ntp_tiles {
+
+class PopularSites;
+class PopularSitesInternalsMessageHandlerClient;
+
+// Implements the WebUI message handler for chrome://popular-sites-internals/
+//
+// Because content and iOS use different implementations of WebUI, this class
+// implements the generic portion and depends on the embedder to inject a bridge
+// to the embedder's API. It cannot itself implement either API directly.
+class PopularSitesInternalsMessageHandler {
+ public:
+ explicit PopularSitesInternalsMessageHandler(
+ PopularSitesInternalsMessageHandlerClient* web_ui);
+ ~PopularSitesInternalsMessageHandler();
+
+ // Called when the WebUI page's JavaScript has loaded and it is ready to
+ // receive RegisterMessageCallback() calls.
+ void RegisterMessages();
+
+ private:
+ // Callbacks registered in RegisterMessages().
+ void HandleRegisterForEvents(const base::ListValue* args);
+ void HandleUpdate(const base::ListValue* args);
+ void HandleViewJson(const base::ListValue* args);
+
+ void SendOverrides();
+ void SendDownloadResult(bool success);
+ void SendSites();
+ void SendJson(const std::string& json);
+
+ // Completion handler for popular_sites_->StartFetch().
+ void OnPopularSitesAvailable(bool explicit_request, bool success);
+
+ // Bridge to embedder's API.
+ PopularSitesInternalsMessageHandlerClient* web_ui_;
+
+ std::unique_ptr<PopularSites> popular_sites_;
+
+ base::WeakPtrFactory<PopularSitesInternalsMessageHandler> weak_ptr_factory_;
+
+ DISALLOW_COPY_AND_ASSIGN(PopularSitesInternalsMessageHandler);
+};
+
+} // namespace ntp_tiles
+
+#endif // COMPONENTS_NTP_TILES_WEBUI_POPULAR_SITES_HANDLER_H_
« no previous file with comments | « components/ntp_tiles/DEPS ('k') | components/ntp_tiles/webui/popular_sites_internals_message_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698