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

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: Implementing last suggestions from Bernhard 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..89ef4ee602f3d6e39d0d44762aecefe190c1a371
--- /dev/null
+++ b/chrome/browser/ui/webui/snippets_internals_message_handler.h
@@ -0,0 +1,59 @@
+// 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();
+ void SendSnippets();
+ void SendDiscardedSnippets();
+ void SendHosts();
+ void SendJson(const std::string& json);
+ void SendBoolean(const std::string& name, bool value);
+ void SendString(const std::string& name, const std::string& value);
+
+ ScopedObserver<ntp_snippets::NTPSnippetsService,
+ ntp_snippets::NTPSnippetsServiceObserver> observer_;
+ bool dom_loaded_;
+ ntp_snippets::NTPSnippetsService* ntp_snippets_service_;
+
+ DISALLOW_COPY_AND_ASSIGN(SnippetsInternalsMessageHandler);
+};
+
+#endif // CHROME_BROWSER_UI_WEBUI_SNIPPETS_INTERNALS_MESSAGE_HANDLER_H_

Powered by Google App Engine
This is Rietveld 408576698