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

Side by Side Diff: components/ntp_tiles/webui/ntp_tiles_internals_message_handler_client.h

Issue 2572133002: Add more features to ntp-tiles-internal (Closed)
Patch Set: address comments Created 4 years 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 unified diff | Download patch
OLDNEW
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_NTP_TILES_INTERNALS_MESSAGE_HANDLER_CLIENT_H_ 5 #ifndef COMPONENTS_NTP_TILES_WEBUI_NTP_TILES_INTERNALS_MESSAGE_HANDLER_CLIENT_H_
6 #define COMPONENTS_NTP_TILES_WEBUI_NTP_TILES_INTERNALS_MESSAGE_HANDLER_CLIENT_H_ 6 #define COMPONENTS_NTP_TILES_WEBUI_NTP_TILES_INTERNALS_MESSAGE_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 #include "components/ntp_tiles/ntp_tile_source.h" 14 #include "components/ntp_tiles/ntp_tile_source.h"
15 15
16 class PrefService; 16 class PrefService;
17 17
18 namespace base { 18 namespace base {
19 class Value; 19 class Value;
20 class ListValue; 20 class ListValue;
21 class SequencedWorkerPool;
21 } // namespace base 22 } // namespace base
22 23
23 namespace ntp_tiles { 24 namespace ntp_tiles {
24 25
25 class MostVisitedSites; 26 class MostVisitedSites;
26 class PopularSites;
27 27
28 // Implemented by embedders to hook up NTPTilesInternalsMessageHandler. 28 // Implemented by embedders to hook up NTPTilesInternalsMessageHandler.
29 class NTPTilesInternalsMessageHandlerClient { 29 class NTPTilesInternalsMessageHandlerClient {
30 public: 30 public:
31 // Returns the PrefService for the embedder and containing WebUI page. 31 // Returns the PrefService for the embedder and containing WebUI page.
32 virtual PrefService* GetPrefs() = 0; 32 virtual PrefService* GetPrefs() = 0;
33 33
34 // Returns true if the given source is enabled (even if, in practice, none of 34 virtual base::SequencedWorkerPool* GetBlockingPool() = 0;
35 // the tiles would come from it).
36 virtual bool DoesSourceExist(NTPTileSource source) = 0;
37 35
38 // Creates a new MostVisitedSites based on the context pf the WebUI page. 36 // Creates a new MostVisitedSites based on the context pf the WebUI page.
39 virtual std::unique_ptr<ntp_tiles::MostVisitedSites> 37 virtual std::unique_ptr<ntp_tiles::MostVisitedSites>
40 MakeMostVisitedSites() = 0; 38 MakeMostVisitedSites() = 0;
41 39
42 // Creates a new PopularSites based on the context pf the WebUI page.
43 virtual std::unique_ptr<ntp_tiles::PopularSites> MakePopularSites() = 0;
44
45 // Registers a callback in Javascript. See content::WebUI and web::WebUIIOS. 40 // Registers a callback in Javascript. See content::WebUI and web::WebUIIOS.
46 virtual void RegisterMessageCallback( 41 virtual void RegisterMessageCallback(
47 const std::string& message, 42 const std::string& message,
48 const base::Callback<void(const base::ListValue*)>& callback) = 0; 43 const base::Callback<void(const base::ListValue*)>& callback) = 0;
49 44
50 // Invokes a function in Javascript. See content::WebUI and web::WebUIIOS. 45 // Invokes a function in Javascript. See content::WebUI and web::WebUIIOS.
51 virtual void CallJavascriptFunctionVector( 46 virtual void CallJavascriptFunctionVector(
52 const std::string& name, 47 const std::string& name,
53 const std::vector<const base::Value*>& values) = 0; 48 const std::vector<const base::Value*>& values) = 0;
54 49
55 // Convenience function for CallJavascriptFunctionVector(). 50 // Convenience function for CallJavascriptFunctionVector().
56 template <typename... Arg> 51 template <typename... Arg>
57 void CallJavascriptFunction(const std::string& name, const Arg&... arg) { 52 void CallJavascriptFunction(const std::string& name, const Arg&... arg) {
58 CallJavascriptFunctionVector(name, {&arg...}); 53 CallJavascriptFunctionVector(name, {&arg...});
59 } 54 }
60 55
61 protected: 56 protected:
62 NTPTilesInternalsMessageHandlerClient(); 57 NTPTilesInternalsMessageHandlerClient();
63 virtual ~NTPTilesInternalsMessageHandlerClient(); 58 virtual ~NTPTilesInternalsMessageHandlerClient();
64 59
65 private: 60 private:
66 DISALLOW_COPY_AND_ASSIGN(NTPTilesInternalsMessageHandlerClient); 61 DISALLOW_COPY_AND_ASSIGN(NTPTilesInternalsMessageHandlerClient);
67 }; 62 };
68 63
69 } // namespace ntp_tiles 64 } // namespace ntp_tiles
70 65
71 #endif // COMPONENTS_NTP_TILES_WEBUI_NTP_TILES_INTERNALS_MESSAGE_HANDLER_CLIENT _H_ 66 #endif // COMPONENTS_NTP_TILES_WEBUI_NTP_TILES_INTERNALS_MESSAGE_HANDLER_CLIENT _H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698