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

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

Issue 2725903002: [WebUI] Add a chrome://prefs-internals page (Closed)
Patch Set: Dan's Created 3 years, 9 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
« no previous file with comments | « chrome/browser/ui/webui/prefs_internals_source.h ('k') | chrome/common/url_constants.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/webui/prefs_internals_source.cc
diff --git a/chrome/browser/ui/webui/prefs_internals_source.cc b/chrome/browser/ui/webui/prefs_internals_source.cc
new file mode 100644
index 0000000000000000000000000000000000000000..a8606d0f176b97207f272b4bc2bdda9e72e63128
--- /dev/null
+++ b/chrome/browser/ui/webui/prefs_internals_source.cc
@@ -0,0 +1,42 @@
+// Copyright 2017 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.
+
+#include "chrome/browser/ui/webui/prefs_internals_source.h"
+
+#include <string>
+
+#include "base/json/json_writer.h"
+#include "base/memory/ref_counted_memory.h"
+#include "base/values.h"
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/common/url_constants.h"
+#include "components/prefs/pref_service.h"
+#include "content/public/browser/browser_thread.h"
+
+PrefsInternalsSource::PrefsInternalsSource(Profile* profile)
+ : profile_(profile) {}
+
+PrefsInternalsSource::~PrefsInternalsSource() = default;
+
+std::string PrefsInternalsSource::GetSource() const {
+ return chrome::kChromeUIPrefsInternalsHost;
+}
+
+std::string PrefsInternalsSource::GetMimeType(const std::string& path) const {
+ return "text/plain";
+}
+
+void PrefsInternalsSource::StartDataRequest(
+ const std::string& path,
+ const content::ResourceRequestInfo::WebContentsGetter& wc_getter,
+ const content::URLDataSource::GotDataCallback& callback) {
+ DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
+ std::string json;
+ std::unique_ptr<base::DictionaryValue> prefs =
+ profile_->GetPrefs()->GetPreferenceValues();
+ DCHECK(prefs);
+ CHECK(base::JSONWriter::WriteWithOptions(
+ *prefs, base::JSONWriter::OPTIONS_PRETTY_PRINT, &json));
+ callback.Run(base::RefCountedString::TakeString(&json));
+}
« no previous file with comments | « chrome/browser/ui/webui/prefs_internals_source.h ('k') | chrome/common/url_constants.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698