Chromium Code Reviews| Index: chrome/browser/ui/webui/snippets_internals_message_handler.h |
| diff --git a/chrome/browser/ui/webui/snippets_internals_message_handler.h b/chrome/browser/ui/webui/snippets_internals_message_handler.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..a4da285d6823f1c4228ac89d1794ec154d107c44 |
| --- /dev/null |
| +++ b/chrome/browser/ui/webui/snippets_internals_message_handler.h |
| @@ -0,0 +1,57 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CHROME_BROWSER_UI_WEBUI_SNIPPETS_INTERNALS_MESSAGE_HANDLER_H_ |
| +#define CHROME_BROWSER_UI_WEBUI_SNIPPETS_INTERNALS_MESSAGE_HANDLER_H_ |
| + |
| +#include <string> |
| + |
| +#include "base/macros.h" |
| +#include "base/memory/weak_ptr.h" |
| +#include "base/scoped_observer.h" |
| +#include "components/ntp_snippets/ntp_snippets_service.h" |
| +#include "content/public/browser/web_ui_message_handler.h" |
| + |
| +namespace base { |
| +class ListValue; |
| +} // namespace base |
| + |
| +// The implementation for the chrome://snippets-internals page. |
| +class SnippetsInternalsMessageHandler |
| + : public content::WebUIMessageHandler, |
| + public ntp_snippets::NTPSnippetsServiceObserver { |
| + public: |
| + SnippetsInternalsMessageHandler(); |
| + ~SnippetsInternalsMessageHandler() override; |
| + |
| + private: |
| + // content::WebUIMessageHandler: |
| + void RegisterMessages() override; |
| + |
| + // ntp_snippets::NTPSnippetsServiceObserver: |
| + // Send everytime the service loads a new set of data. |
| + void NTPSnippetsServiceLoaded() override; |
| + // Send when the service is shutting down. |
| + void NTPSnippetsServiceShutdown() override; |
| + |
| + void HandleLoaded(const base::ListValue* args); |
| + void HandleClear(const base::ListValue* args); |
| + void HandleClearDiscarded(const base::ListValue* args); |
| + void HandleDownload(const base::ListValue* args); |
| + |
| + void SendInitialData(ntp_snippets::NTPSnippetsService* service); |
| + void SendSnippets(ntp_snippets::NTPSnippetsService* service); |
| + void SendDiscardedSnippets(ntp_snippets::NTPSnippetsService* service); |
| + void SendHosts(ntp_snippets::NTPSnippetsService* service); |
| + void SendJson(const std::string& json); |
| + void SendBoolean(const std::string& name, bool value); |
| + void SendString(const std::string& name, const std::string& value); |
| + |
| + // For making sure this object is not added twice as an observer. |
| + ScopedObserver<ntp_snippets::NTPSnippetsService, ntp_snippets::NTPSnippetsServiceObserver> observer_; |
|
Bernhard Bauer
2016/04/14 16:50:25
This needs to be broken to fit into 80 columns.
jkrcal
2016/04/15 08:39:54
Done.
(I wonder why I did not get an error messag
Marc Treib
2016/04/15 09:00:30
No, this seems to be an error in the presubmit hoo
|
| + |
| + DISALLOW_COPY_AND_ASSIGN(SnippetsInternalsMessageHandler); |
| +}; |
| + |
| +#endif // CHROME_BROWSER_UI_WEBUI_SNIPPETS_INTERNALS_MESSAGE_HANDLER_H_ |