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

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

Issue 2457033003: Add chrome://popular-sites-internals/ to iOS. (Closed)
Patch Set: Break out ...Client. 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
11 #include "base/macros.h"
12 #include "base/memory/weak_ptr.h"
13
14 namespace base {
15 class ListValue;
16 } // namespace base
17
18 namespace ntp_tiles {
19
20 class PopularSites;
21 class PopularSitesInternalsMessageHandlerClient;
22
23 // Implements the WebUI message handler for chrome://popular-sites-internals/
24 //
25 // Because content and iOS use different implementations of WebUI, this class
26 // implements the generic portion and depends on the embedder to inject a bridge
27 // to the embedder's API. It cannot itself implement either API directly.
28 class PopularSitesInternalsMessageHandler {
29 public:
30 explicit PopularSitesInternalsMessageHandler(
31 PopularSitesInternalsMessageHandlerClient* web_ui);
32 ~PopularSitesInternalsMessageHandler();
33
34 // Called when the WebUI page's JavaScript has loaded and it is ready to
35 // receive RegisterMessageCallback() calls.
36 void RegisterMessages();
37
38 private:
39 // Callbacks registered in RegisterMessages().
40 void HandleRegisterForEvents(const base::ListValue* args);
41 void HandleUpdate(const base::ListValue* args);
42 void HandleViewJson(const base::ListValue* args);
43
44 void SendOverrides();
45 void SendDownloadResult(bool success);
46 void SendSites();
47 void SendJson(const std::string& json);
48
49 // Completion handler for popular_sites_->StartFetch().
50 void OnPopularSitesAvailable(bool explicit_request, bool success);
51
52 // Bridge to embedder's API.
53 PopularSitesInternalsMessageHandlerClient* web_ui_;
54
55 std::unique_ptr<PopularSites> popular_sites_;
56
57 base::WeakPtrFactory<PopularSitesInternalsMessageHandler> weak_ptr_factory_;
58
59 DISALLOW_COPY_AND_ASSIGN(PopularSitesInternalsMessageHandler);
60 };
61
62 } // namespace ntp_tiles
63
64 #endif // COMPONENTS_NTP_TILES_WEBUI_POPULAR_SITES_HANDLER_H_
OLDNEW
« no previous file with comments | « components/ntp_tiles/DEPS ('k') | components/ntp_tiles/webui/popular_sites_internals_message_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698