Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef COMPONENTS_NTP_TILES_WEBUI_NTP_TILES_HANDLER_H_ | |
| 6 #define COMPONENTS_NTP_TILES_WEBUI_NTP_TILES_HANDLER_H_ | |
|
Marc Treib
2016/12/12 10:51:22
Doesn't match the file name.
sfiera
2016/12/12 16:08:32
Done.
| |
| 7 | |
| 8 #include <memory> | |
| 9 #include <string> | |
| 10 | |
| 11 #include "base/macros.h" | |
| 12 #include "base/memory/weak_ptr.h" | |
| 13 #include "components/ntp_tiles/most_visited_sites.h" | |
| 14 | |
| 15 namespace base { | |
| 16 class ListValue; | |
| 17 } // namespace base | |
| 18 | |
| 19 namespace ntp_tiles { | |
| 20 | |
| 21 class MostVisitedSites; | |
| 22 class NTPTilesInternalsMessageHandlerClient; | |
| 23 | |
| 24 // Implements the WebUI message handler for chrome://ntp-tiles-internals/ | |
| 25 // | |
| 26 // Because content and iOS use different implementations of WebUI, this class | |
| 27 // implements the generic portion and depends on the embedder to inject a bridge | |
| 28 // to the embedder's API. It cannot itself implement either API directly. | |
| 29 class NTPTilesInternalsMessageHandler : public MostVisitedSites::Observer { | |
| 30 public: | |
| 31 explicit NTPTilesInternalsMessageHandler(); | |
|
Marc Treib
2016/12/12 10:51:22
nit: explicit not needed
sfiera
2016/12/12 16:08:32
Done.
| |
| 32 ~NTPTilesInternalsMessageHandler() override; | |
| 33 | |
| 34 // Called when the WebUI page's JavaScript has loaded and it is ready to | |
| 35 // receive RegisterMessageCallback() calls. | |
| 36 void RegisterMessages(NTPTilesInternalsMessageHandlerClient* client); | |
|
Marc Treib
2016/12/12 10:51:22
|client| must outlive us.
sfiera
2016/12/12 16:08:32
Done.
| |
| 37 | |
| 38 private: | |
| 39 // Callbacks registered in RegisterMessages(). | |
| 40 void HandleRegisterForEvents(const base::ListValue* args); | |
| 41 void HandleUpdate(const base::ListValue* args); | |
| 42 | |
| 43 void SendSourceInfo(); | |
| 44 void SendTiles(const NTPTilesVector& tiles); | |
| 45 | |
| 46 // MostVisitedSites::Observer. | |
| 47 void OnMostVisitedURLsAvailable(const NTPTilesVector& tiles) override; | |
| 48 void OnIconMadeAvailable(const GURL& site_url) override; | |
| 49 | |
| 50 // Bridge to embedder's API. | |
| 51 NTPTilesInternalsMessageHandlerClient* client_; | |
| 52 | |
| 53 int site_count_; | |
| 54 std::unique_ptr<MostVisitedSites> most_visited_sites_; | |
| 55 | |
| 56 DISALLOW_COPY_AND_ASSIGN(NTPTilesInternalsMessageHandler); | |
| 57 }; | |
| 58 | |
| 59 } // namespace ntp_tiles | |
| 60 | |
| 61 #endif // COMPONENTS_NTP_TILES_WEBUI_NTP_TILES_HANDLER_H_ | |
| OLD | NEW |