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

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

Issue 2457033003: Add chrome://popular-sites-internals/ to iOS. (Closed)
Patch Set: Inline message handler impl. Created 4 years, 1 month 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_POPULAR_SITES_HANDLER_H_
6 #define COMPONENTS_NTP_TILES_WEBUI_POPULAR_SITES_HANDLER_H_
7
8 #include <memory>
9 #include <string>
10 #include <vector>
11
12 #include "base/callback.h"
sdefresne 2016/10/28 13:34:02 #include "base/callback_forward.h" should be enoug
sfiera 2016/10/28 14:12:43 Done.
13 #include "base/macros.h"
14 #include "base/memory/weak_ptr.h"
15
16 class PrefService;
17
18 namespace base {
19 class Value;
20 class ListValue;
21 class SequencedWorkerPool;
22 } // namespace base
23
24 namespace ntp_tiles {
25
26 class PopularSites;
27
28 class PopularSitesInternalsMessageHandlerInterface {
Bernhard Bauer 2016/10/28 13:23:07 This is a bit weird: 1) Two classes defined in the
sdefresne 2016/10/28 13:34:02 Is this an interface implemented by embedder (desk
sfiera 2016/10/28 13:38:14 Basically, the problem is that the WebUI handlers
sfiera 2016/10/28 14:12:43 Renamed to Client.
29 public:
sdefresne 2016/10/28 13:34:02 The class needs a virtual destructor.
sfiera 2016/10/28 14:12:43 Done.
30 virtual base::SequencedWorkerPool* GetBlockingPool() = 0;
sdefresne 2016/10/28 13:34:02 Can you document this class and its methods?
sfiera 2016/10/28 14:12:42 Done.
31 virtual std::unique_ptr<ntp_tiles::PopularSites> MakePopularSites() = 0;
32 virtual PrefService* GetPrefs() = 0;
33 virtual void RegisterMessageCallback(
34 const std::string& message,
35 const base::Callback<void(const base::ListValue*)>& callback) = 0;
36 virtual void CallJavascriptFunctionVector(
37 const std::string& name,
38 const std::vector<const base::Value*>& values) = 0;
39
40 template <typename... Arg>
41 void CallJavascriptFunction(const std::string& name, const Arg&... arg) {
42 CallJavascriptFunctionVector(name, {&arg...});
43 }
sdefresne 2016/10/28 13:34:03 I would recommend making the class non-copyable si
sfiera 2016/10/28 14:12:42 Done.
Bernhard Bauer 2016/10/28 16:56:38 OOC, why are virtual methods the criterium here? W
44 };
45
46 class PopularSitesInternalsMessageHandlerImpl {
sdefresne 2016/10/28 13:34:02 Can you document this class and its methods?
sfiera 2016/10/28 14:12:42 Done. (the public ones—most of them actually no lo
47 public:
48 PopularSitesInternalsMessageHandlerImpl(
49 PopularSitesInternalsMessageHandlerInterface* web_ui);
50 ~PopularSitesInternalsMessageHandlerImpl();
51
52 void RegisterMessages();
53
54 void HandleRegisterForEvents(const base::ListValue* args);
55 void HandleUpdate(const base::ListValue* args);
56 void HandleViewJson(const base::ListValue* args);
57
58 void SendOverrides();
59 void SendDownloadResult(bool success);
60 void SendSites();
61 void SendJson(const std::string& json);
62
63 void OnPopularSitesAvailable(bool explicit_request, bool success);
64
65 private:
66 std::unique_ptr<PopularSites> popular_sites_;
67 PopularSitesInternalsMessageHandlerInterface* web_ui_;
68 base::WeakPtrFactory<PopularSitesInternalsMessageHandlerImpl>
69 weak_ptr_factory_;
70
71 DISALLOW_COPY_AND_ASSIGN(PopularSitesInternalsMessageHandlerImpl);
72 };
73
74 } // namespace ntp_tiles
75
76 #endif // COMPONENTS_NTP_TILES_WEBUI_POPULAR_SITES_HANDLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698