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

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: Add ntp_tiles owners to client webui owners Created 3 years, 10 months 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 } // namespace base 21 } // namespace base
22 22
23 namespace ntp_tiles { 23 namespace ntp_tiles {
24 24
25 class MostVisitedSites; 25 class MostVisitedSites;
26 class PopularSites;
27 26
28 // Implemented by embedders to hook up NTPTilesInternalsMessageHandler. 27 // Implemented by embedders to hook up NTPTilesInternalsMessageHandler.
29 class NTPTilesInternalsMessageHandlerClient { 28 class NTPTilesInternalsMessageHandlerClient {
30 public: 29 public:
31 // Returns the PrefService for the embedder and containing WebUI page. 30 // Returns the PrefService for the embedder and containing WebUI page.
32 virtual PrefService* GetPrefs() = 0; 31 virtual PrefService* GetPrefs() = 0;
33 32
34 // False if in a browser mode (e.g. incognito) where tiles aren't supported. 33 // False if in a browser mode (e.g. incognito) where tiles aren't supported.
35 virtual bool SupportsNTPTiles() = 0; 34 virtual bool SupportsNTPTiles() = 0;
36 35
37 // Returns true if the given source is enabled (even if, in practice, none of 36 // Returns true if the given source is enabled (even if, in practice, none of
38 // the tiles would come from it). 37 // the tiles would come from it).
39 virtual bool DoesSourceExist(NTPTileSource source) = 0; 38 virtual bool DoesSourceExist(NTPTileSource source) = 0;
40 39
41 // Creates a new MostVisitedSites based on the context pf the WebUI page. 40 // Creates a new MostVisitedSites based on the context pf the WebUI page.
42 virtual std::unique_ptr<ntp_tiles::MostVisitedSites> 41 virtual std::unique_ptr<ntp_tiles::MostVisitedSites>
43 MakeMostVisitedSites() = 0; 42 MakeMostVisitedSites() = 0;
44 43
45 // Creates a new PopularSites based on the context pf the WebUI page.
46 virtual std::unique_ptr<ntp_tiles::PopularSites> MakePopularSites() = 0;
47
48 // Registers a callback in Javascript. See content::WebUI and web::WebUIIOS. 44 // Registers a callback in Javascript. See content::WebUI and web::WebUIIOS.
49 virtual void RegisterMessageCallback( 45 virtual void RegisterMessageCallback(
50 const std::string& message, 46 const std::string& message,
51 const base::Callback<void(const base::ListValue*)>& callback) = 0; 47 const base::Callback<void(const base::ListValue*)>& callback) = 0;
52 48
53 // Invokes a function in Javascript. See content::WebUI and web::WebUIIOS. 49 // Invokes a function in Javascript. See content::WebUI and web::WebUIIOS.
54 virtual void CallJavascriptFunctionVector( 50 virtual void CallJavascriptFunctionVector(
55 const std::string& name, 51 const std::string& name,
56 const std::vector<const base::Value*>& values) = 0; 52 const std::vector<const base::Value*>& values) = 0;
57 53
58 // Convenience function for CallJavascriptFunctionVector(). 54 // Convenience function for CallJavascriptFunctionVector().
59 template <typename... Arg> 55 template <typename... Arg>
60 void CallJavascriptFunction(const std::string& name, const Arg&... arg) { 56 void CallJavascriptFunction(const std::string& name, const Arg&... arg) {
61 CallJavascriptFunctionVector(name, {&arg...}); 57 CallJavascriptFunctionVector(name, {&arg...});
62 } 58 }
63 59
64 protected: 60 protected:
65 NTPTilesInternalsMessageHandlerClient(); 61 NTPTilesInternalsMessageHandlerClient();
66 virtual ~NTPTilesInternalsMessageHandlerClient(); 62 virtual ~NTPTilesInternalsMessageHandlerClient();
67 63
68 private: 64 private:
69 DISALLOW_COPY_AND_ASSIGN(NTPTilesInternalsMessageHandlerClient); 65 DISALLOW_COPY_AND_ASSIGN(NTPTilesInternalsMessageHandlerClient);
70 }; 66 };
71 67
72 } // namespace ntp_tiles 68 } // namespace ntp_tiles
73 69
74 #endif // COMPONENTS_NTP_TILES_WEBUI_NTP_TILES_INTERNALS_MESSAGE_HANDLER_CLIENT _H_ 70 #endif // COMPONENTS_NTP_TILES_WEBUI_NTP_TILES_INTERNALS_MESSAGE_HANDLER_CLIENT _H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698