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