| 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_POPULAR_SITES_HANDLER_CLIENT_H_ |
| 6 #define COMPONENTS_NTP_TILES_WEBUI_POPULAR_SITES_HANDLER_CLIENT_H_ |
| 7 |
| 8 #include <memory> |
| 9 #include <string> |
| 10 #include <vector> |
| 11 |
| 12 #include "base/callback_forward.h" |
| 13 #include "base/macros.h" |
| 14 |
| 15 class PrefService; |
| 16 |
| 17 namespace base { |
| 18 class Value; |
| 19 class ListValue; |
| 20 class SequencedWorkerPool; |
| 21 } // namespace base |
| 22 |
| 23 namespace ntp_tiles { |
| 24 |
| 25 class PopularSites; |
| 26 |
| 27 // Implemented by embedders to hook up PopularSitesInternalsMessageHandler. |
| 28 class PopularSitesInternalsMessageHandlerClient { |
| 29 public: |
| 30 // Returns the blocking pool for hte embedder. |
| 31 virtual base::SequencedWorkerPool* GetBlockingPool() = 0; |
| 32 |
| 33 // Returns the PrefService for the embedder and containing WebUI page. |
| 34 virtual PrefService* GetPrefs() = 0; |
| 35 |
| 36 // Creates a new PopularSites based on the context pf the WebUI page. |
| 37 virtual std::unique_ptr<ntp_tiles::PopularSites> MakePopularSites() = 0; |
| 38 |
| 39 // Registers a callback in Javascript. See content::WebUI and web::WebUIIOS. |
| 40 virtual void RegisterMessageCallback( |
| 41 const std::string& message, |
| 42 const base::Callback<void(const base::ListValue*)>& callback) = 0; |
| 43 |
| 44 // Invokes a function in Javascript. See content::WebUI and web::WebUIIOS. |
| 45 virtual void CallJavascriptFunctionVector( |
| 46 const std::string& name, |
| 47 const std::vector<const base::Value*>& values) = 0; |
| 48 |
| 49 // Helper function for CallJavascriptFunctionVector(). |
| 50 template <typename... Arg> |
| 51 void CallJavascriptFunction(const std::string& name, const Arg&... arg) { |
| 52 CallJavascriptFunctionVector(name, {&arg...}); |
| 53 } |
| 54 |
| 55 protected: |
| 56 PopularSitesInternalsMessageHandlerClient(); |
| 57 virtual ~PopularSitesInternalsMessageHandlerClient(); |
| 58 |
| 59 private: |
| 60 DISALLOW_COPY_AND_ASSIGN(PopularSitesInternalsMessageHandlerClient); |
| 61 }; |
| 62 |
| 63 } // namespace ntp_tiles |
| 64 |
| 65 #endif // COMPONENTS_NTP_TILES_WEBUI_POPULAR_SITES_HANDLER_CLIENT_H_ |
| OLD | NEW |