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

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

Issue 1927993002: Allow dumping raw json fetched from the server. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Some fixes 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.cc
diff --git a/chrome/browser/ui/webui/snippets_internals_message_handler.cc b/chrome/browser/ui/webui/snippets_internals_message_handler.cc
index e7a7d233aa0a78c3a02fd25c7016b23abb2106f1..a5914d106591c261c0e56f58c819ffcde2a47a6d 100644
--- a/chrome/browser/ui/webui/snippets_internals_message_handler.cc
+++ b/chrome/browser/ui/webui/snippets_internals_message_handler.cc
@@ -59,6 +59,7 @@ std::unique_ptr<base::DictionaryValue> PrepareSnippet(
SnippetsInternalsMessageHandler::SnippetsInternalsMessageHandler()
: observer_(this),
dom_loaded_(false),
+ dump_current_fetch_(false),
ntp_snippets_service_(nullptr) {}
SnippetsInternalsMessageHandler::~SnippetsInternalsMessageHandler() {}
@@ -70,6 +71,11 @@ void SnippetsInternalsMessageHandler::NTPSnippetsServiceLoaded() {
SendSnippets();
SendDiscardedSnippets();
+
+ if (dump_current_fetch_) {
Bernhard Bauer 2016/04/29 12:02:22 If we have the last downloaded JSON anyway, we cou
jkrcal 2016/04/29 13:11:48 Done, with an extra download button. Did not forma
+ SendJson(ntp_snippets_service_->last_json());
+ dump_current_fetch_ = false;
+ }
}
void SnippetsInternalsMessageHandler::RegisterMessages() {
@@ -125,8 +131,7 @@ void SnippetsInternalsMessageHandler::HandleDump(const base::ListValue* args) {
base::JSONWriter::Write(
*pref_service->GetList(ntp_snippets::prefs::kSnippets), &json);
- web_ui()->CallJavascriptFunction("chrome.SnippetsInternals.receiveJson",
- base::StringValue(json));
+ SendJson(json);
}
void SnippetsInternalsMessageHandler::HandleClearDiscarded(
@@ -139,12 +144,13 @@ void SnippetsInternalsMessageHandler::HandleClearDiscarded(
void SnippetsInternalsMessageHandler::HandleDownload(
const base::ListValue* args) {
- DCHECK_EQ(1u, args->GetSize());
+ DCHECK_EQ(2u, args->GetSize());
SendString("hosts-status", std::string());
std::string hosts_string;
args->GetString(0, &hosts_string);
+ args->GetBoolean(1, &dump_current_fetch_);
std::vector<std::string> hosts_vector = base::SplitString(
hosts_string, " ", base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY);
@@ -218,6 +224,11 @@ void SnippetsInternalsMessageHandler::SendHosts() {
result);
}
+void SnippetsInternalsMessageHandler::SendJson(const std::string& json) {
+ web_ui()->CallJavascriptFunction("chrome.SnippetsInternals.receiveJson",
+ base::StringValue(json));
+}
+
void SnippetsInternalsMessageHandler::SendBoolean(const std::string& name,
bool value) {
SendString(name, value ? "True" : "False");

Powered by Google App Engine
This is Rietveld 408576698