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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/ui/webui/prefs_internals_source.h"
6
7 #include <string>
8
9 #include "base/json/json_writer.h"
10 #include "base/memory/ref_counted_memory.h"
11 #include "base/values.h"
12 #include "chrome/browser/profiles/profile.h"
13 #include "chrome/common/url_constants.h"
14 #include "components/prefs/pref_service.h"
15 #include "content/public/browser/browser_thread.h"
16
17 PrefsInternalsSource::PrefsInternalsSource(Profile* profile)
18 : profile_(profile) {}
19
20 PrefsInternalsSource::~PrefsInternalsSource() = default;
21
22 std::string PrefsInternalsSource::GetSource() const {
23 return chrome::kChromeUIPrefsInternalsHost;
24 }
25
26 std::string PrefsInternalsSource::GetMimeType(const std::string& path) const {
27 return "text/plain";
28 }
29
30 void PrefsInternalsSource::StartDataRequest(
31 const std::string& path,
32 const content::ResourceRequestInfo::WebContentsGetter& wc_getter,
33 const content::URLDataSource::GotDataCallback& callback) {
34 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
35 std::string json;
36 std::unique_ptr<base::DictionaryValue> prefs =
37 profile_->GetPrefs()->GetPreferenceValues();
38 DCHECK(prefs);
39 CHECK(base::JSONWriter::WriteWithOptions(
40 *prefs, base::JSONWriter::OPTIONS_PRETTY_PRINT, &json));
41 callback.Run(base::RefCountedString::TakeString(&json));
42 }
OLDNEW
« 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