Chromium Code Reviews| Index: components/ntp_tiles/webui/site_tiles_internals_message_handler.h | 
| diff --git a/components/ntp_tiles/webui/site_tiles_internals_message_handler.h b/components/ntp_tiles/webui/site_tiles_internals_message_handler.h | 
| new file mode 100644 | 
| index 0000000000000000000000000000000000000000..29d665fde9a848b9e1fdbab5e16670042df499b8 | 
| --- /dev/null | 
| +++ b/components/ntp_tiles/webui/site_tiles_internals_message_handler.h | 
| @@ -0,0 +1,65 @@ | 
| +// 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_SITE_TILES_HANDLER_H_ | 
| +#define COMPONENTS_NTP_TILES_WEBUI_SITE_TILES_HANDLER_H_ | 
| 
 
Marc Treib
2016/12/09 10:52:12
Doesn't match the file name
 
 | 
| + | 
| +#include <memory> | 
| +#include <string> | 
| + | 
| +#include "base/macros.h" | 
| +#include "base/memory/weak_ptr.h" | 
| +#include "components/ntp_tiles/most_visited_sites.h" | 
| + | 
| +namespace base { | 
| +class ListValue; | 
| +} // namespace base | 
| + | 
| +namespace ntp_tiles { | 
| + | 
| +class MostVisitedSites; | 
| +class SiteTilesInternalsMessageHandlerClient; | 
| + | 
| +// Implements the WebUI message handler for chrome://site-tiles-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 SiteTilesInternalsMessageHandler : public MostVisitedSites::Observer { | 
| + public: | 
| + explicit SiteTilesInternalsMessageHandler(); | 
| + ~SiteTilesInternalsMessageHandler() override; | 
| + | 
| + // Called when the WebUI page's JavaScript has loaded and it is ready to | 
| + // receive RegisterMessageCallback() calls. | 
| + void RegisterMessages( | 
| + SiteTilesInternalsMessageHandlerClient* client); | 
| + | 
| + private: | 
| + // Callbacks registered in RegisterMessages(). | 
| + void HandleRegisterForEvents(const base::ListValue* args); | 
| + void HandleUpdate(const base::ListValue* args); | 
| + void HandleGetFavicon(const base::ListValue* args); | 
| + | 
| + void SendSourceInfo(); | 
| + void SendTiles(const NTPTilesVector& tiles); | 
| + | 
| + // MostVisitedSites::Observer. | 
| + void OnMostVisitedURLsAvailable(const NTPTilesVector& tiles) override; | 
| + void OnIconMadeAvailable(const GURL& site_url) override; | 
| + | 
| + // Bridge to embedder's API. | 
| + SiteTilesInternalsMessageHandlerClient* client_; | 
| + | 
| + int site_count_; | 
| + std::unique_ptr<MostVisitedSites> most_visited_sites_; | 
| + | 
| + base::WeakPtrFactory<SiteTilesInternalsMessageHandler> weak_ptr_factory_; | 
| 
 
Marc Treib
2016/12/09 10:52:12
Unused I think
 
sfiera
2016/12/09 17:35:28
Ah, yes, it was just for the removed JSON reading
 
 | 
| + | 
| + DISALLOW_COPY_AND_ASSIGN(SiteTilesInternalsMessageHandler); | 
| +}; | 
| + | 
| +} // namespace ntp_tiles | 
| + | 
| +#endif // COMPONENTS_NTP_TILES_WEBUI_SITE_TILES_HANDLER_H_ |