Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 CHROME_BROWSER_UI_WEBUI_POPULAR_SITES_INTERNALS_MESSAGE_HANDLER_H_ | 5 #ifndef CHROME_BROWSER_UI_WEBUI_POPULAR_SITES_INTERNALS_MESSAGE_HANDLER_H_ |
| 6 #define CHROME_BROWSER_UI_WEBUI_POPULAR_SITES_INTERNALS_MESSAGE_HANDLER_H_ | 6 #define CHROME_BROWSER_UI_WEBUI_POPULAR_SITES_INTERNALS_MESSAGE_HANDLER_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/memory/weak_ptr.h" | 12 #include "components/ntp_tiles/webui/popular_sites_internals_message_handler_imp l.h" |
| 13 #include "content/public/browser/web_ui_message_handler.h" | 13 #include "content/public/browser/web_ui_message_handler.h" |
| 14 | 14 |
| 15 namespace base { | |
| 16 class ListValue; | |
| 17 } // namespace base | |
| 18 | |
| 19 namespace ntp_tiles { | |
| 20 class PopularSites; | |
| 21 } // namespace ntp_tiles | |
| 22 | |
| 23 // The implementation for the chrome://popular-sites-internals page. | 15 // The implementation for the chrome://popular-sites-internals page. |
| 24 class PopularSitesInternalsMessageHandler | 16 class PopularSitesInternalsMessageHandler |
|
Bernhard Bauer
2016/10/28 16:56:38
Nit: At the risk of embiggening the class name eve
| |
| 25 : public content::WebUIMessageHandler { | 17 : public content::WebUIMessageHandler, |
| 18 public ntp_tiles::PopularSitesInternalsMessageHandlerClient { | |
| 26 public: | 19 public: |
| 27 PopularSitesInternalsMessageHandler(); | 20 PopularSitesInternalsMessageHandler(); |
| 28 ~PopularSitesInternalsMessageHandler() override; | 21 ~PopularSitesInternalsMessageHandler() override; |
| 29 | 22 |
| 30 private: | 23 private: |
| 31 // content::WebUIMessageHandler: | 24 // content::WebUIMessageHandler: |
| 32 void RegisterMessages() override; | 25 void RegisterMessages() override; |
| 33 | 26 |
| 34 void HandleRegisterForEvents(const base::ListValue* args); | 27 // PopularSitesInternalsMessageHandlerClient |
| 35 void HandleUpdate(const base::ListValue* args); | 28 base::SequencedWorkerPool* GetBlockingPool() override; |
| 36 void HandleViewJson(const base::ListValue* args); | 29 std::unique_ptr<ntp_tiles::PopularSites> MakePopularSites() override; |
| 30 PrefService* GetPrefs() override; | |
| 31 void RegisterMessageCallback( | |
| 32 const std::string& message, | |
| 33 const base::Callback<void(const base::ListValue*)>& callback) override; | |
| 34 void CallJavascriptFunctionVector( | |
| 35 const std::string& name, | |
| 36 const std::vector<const base::Value*>& values) override; | |
| 37 | 37 |
| 38 void SendOverrides(); | 38 ntp_tiles::PopularSitesInternalsMessageHandlerImpl impl_; |
| 39 void SendDownloadResult(bool success); | |
| 40 void SendSites(); | |
| 41 void SendJson(const std::string& json); | |
| 42 | |
| 43 void OnPopularSitesAvailable(bool explicit_request, bool success); | |
| 44 | |
| 45 std::unique_ptr<ntp_tiles::PopularSites> popular_sites_; | |
| 46 | |
| 47 base::WeakPtrFactory<PopularSitesInternalsMessageHandler> weak_ptr_factory_; | |
| 48 | 39 |
| 49 DISALLOW_COPY_AND_ASSIGN(PopularSitesInternalsMessageHandler); | 40 DISALLOW_COPY_AND_ASSIGN(PopularSitesInternalsMessageHandler); |
| 50 }; | 41 }; |
| 51 | 42 |
| 52 #endif // CHROME_BROWSER_UI_WEBUI_POPULAR_SITES_INTERNALS_MESSAGE_HANDLER_H_ | 43 #endif // CHROME_BROWSER_UI_WEBUI_POPULAR_SITES_INTERNALS_MESSAGE_HANDLER_H_ |
| OLD | NEW |