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

Unified Diff: chrome/browser/ui/webui/snippets_internals_message_handler.h

Issue 1883523002: chrome://snippets-internals page for debugging NTP snippets. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Third code review ( rebase-update) Created 4 years, 8 months 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 side-by-side diff with in-line comments
Download patch
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..f2173e97ee50f7ae69461c21f56d257288fb1084
--- /dev/null
+++ b/chrome/browser/ui/webui/snippets_internals_message_handler.h
@@ -0,0 +1,58 @@
+// 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);
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.
+ 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.
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.
+ ScopedObserver<ntp_snippets::NTPSnippetsService,
+ ntp_snippets::NTPSnippetsServiceObserver> observer_;
+
+ DISALLOW_COPY_AND_ASSIGN(SnippetsInternalsMessageHandler);
+};
+
+#endif // CHROME_BROWSER_UI_WEBUI_SNIPPETS_INTERNALS_MESSAGE_HANDLER_H_

Powered by Google App Engine
This is Rietveld 408576698