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

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

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

Powered by Google App Engine
This is Rietveld 408576698