| OLD | NEW |
| (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 CHROME_BROWSER_UI_WEBUI_SNIPPETS_INTERNALS_MESSAGE_HANDLER_H_ |
| 6 #define CHROME_BROWSER_UI_WEBUI_SNIPPETS_INTERNALS_MESSAGE_HANDLER_H_ |
| 7 |
| 8 #include <string> |
| 9 |
| 10 #include "base/macros.h" |
| 11 #include "base/memory/weak_ptr.h" |
| 12 #include "components/ntp_snippets/ntp_snippets_service.h" |
| 13 #include "content/public/browser/web_ui_message_handler.h" |
| 14 |
| 15 namespace base { |
| 16 class ListValue; |
| 17 } // namespace base |
| 18 |
| 19 // The implementation for the chrome://snippets-internals page. |
| 20 class SnippetsInternalsMessageHandler |
| 21 : public content::WebUIMessageHandler, |
| 22 public ntp_snippets::NTPSnippetsServiceObserver { |
| 23 public: |
| 24 SnippetsInternalsMessageHandler(); |
| 25 ~SnippetsInternalsMessageHandler() override; |
| 26 |
| 27 private: |
| 28 // content::WebUIMessageHandler: |
| 29 void RegisterMessages() override; |
| 30 |
| 31 // ntp_snippets::NTPSnippetsServiceObserver: |
| 32 // Send everytime the service loads a new set of data. |
| 33 void NTPSnippetsServiceLoaded() override; |
| 34 // Send when the service is shutting down. |
| 35 void NTPSnippetsServiceShutdown() override; |
| 36 |
| 37 void HandleLoaded(const base::ListValue* args); |
| 38 void HandleClear(const base::ListValue* args); |
| 39 void HandleClearDiscarded(const base::ListValue* args); |
| 40 void HandleDownload(const base::ListValue* args); |
| 41 |
| 42 void SendInitialData(ntp_snippets::NTPSnippetsService* service); |
| 43 void SendSnippets(ntp_snippets::NTPSnippetsService* service); |
| 44 void SendDiscardedSnippets(ntp_snippets::NTPSnippetsService* service); |
| 45 void SendHosts(ntp_snippets::NTPSnippetsService* service); |
| 46 void SendJson(const std::string& json); |
| 47 void SendBoolean(const std::string& name, bool value); |
| 48 void SendString(const std::string& name, const std::string& value); |
| 49 |
| 50 DISALLOW_COPY_AND_ASSIGN(SnippetsInternalsMessageHandler); |
| 51 }; |
| 52 |
| 53 #endif // CHROME_BROWSER_UI_WEBUI_SNIPPETS_INTERNALS_MESSAGE_HANDLER_H_ |
| OLD | NEW |