Chromium Code Reviews| 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 "base/scoped_observer.h" | |
| 13 #include "components/ntp_snippets/ntp_snippets_service.h" | |
| 14 #include "content/public/browser/web_ui_message_handler.h" | |
| 15 | |
| 16 namespace base { | |
| 17 class ListValue; | |
| 18 } // namespace base | |
| 19 | |
| 20 // The implementation for the chrome://snippets-internals page. | |
| 21 class SnippetsInternalsMessageHandler | |
| 22 : public content::WebUIMessageHandler, | |
| 23 public ntp_snippets::NTPSnippetsServiceObserver { | |
| 24 public: | |
| 25 SnippetsInternalsMessageHandler(); | |
| 26 ~SnippetsInternalsMessageHandler() override; | |
| 27 | |
| 28 private: | |
| 29 // content::WebUIMessageHandler: | |
| 30 void RegisterMessages() override; | |
| 31 | |
| 32 // ntp_snippets::NTPSnippetsServiceObserver: | |
| 33 // Send everytime the service loads a new set of data. | |
| 34 void NTPSnippetsServiceLoaded() override; | |
| 35 // Send when the service is shutting down. | |
| 36 void NTPSnippetsServiceShutdown() override; | |
| 37 | |
| 38 void HandleLoaded(const base::ListValue* args); | |
| 39 void HandleClear(const base::ListValue* args); | |
| 40 void HandleClearDiscarded(const base::ListValue* args); | |
| 41 void HandleDownload(const base::ListValue* args); | |
| 42 | |
| 43 void SendInitialData(ntp_snippets::NTPSnippetsService* service); | |
|
Marc Treib
2016/04/15 09:00:30
optional: You could either store the snippets serv
jkrcal
2016/04/15 14:11:51
Done. I store it in a member.
| |
| 44 void SendSnippets(ntp_snippets::NTPSnippetsService* service); | |
| 45 void SendDiscardedSnippets(ntp_snippets::NTPSnippetsService* service); | |
| 46 void SendHosts(ntp_snippets::NTPSnippetsService* service); | |
| 47 void SendJson(const std::string& json); | |
| 48 void SendBoolean(const std::string& name, bool value); | |
| 49 void SendString(const std::string& name, const std::string& value); | |
| 50 | |
| 51 // For making sure this object is not added twice as an observer. | |
|
Marc Treib
2016/04/15 09:00:30
Not really - IMO it's mostly for the automatic unr
jkrcal
2016/04/15 14:11:51
Done.
| |
| 52 ScopedObserver<ntp_snippets::NTPSnippetsService, | |
| 53 ntp_snippets::NTPSnippetsServiceObserver> observer_; | |
| 54 | |
| 55 DISALLOW_COPY_AND_ASSIGN(SnippetsInternalsMessageHandler); | |
| 56 }; | |
| 57 | |
| 58 #endif // CHROME_BROWSER_UI_WEBUI_SNIPPETS_INTERNALS_MESSAGE_HANDLER_H_ | |
| OLD | NEW |