OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/ui/webui/local_state/local_state_ui.h" | 5 #include "chrome/browser/ui/webui/local_state/local_state_ui.h" |
6 | 6 |
7 #include "base/json/json_string_value_serializer.h" | 7 #include "base/json/json_string_value_serializer.h" |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 } | 55 } |
56 | 56 |
57 void LocalStateUIHandler::RegisterMessages() { | 57 void LocalStateUIHandler::RegisterMessages() { |
58 web_ui()->RegisterMessageCallback( | 58 web_ui()->RegisterMessageCallback( |
59 "requestJson", base::Bind(&LocalStateUIHandler::HandleRequestJson, | 59 "requestJson", base::Bind(&LocalStateUIHandler::HandleRequestJson, |
60 base::Unretained(this))); | 60 base::Unretained(this))); |
61 } | 61 } |
62 | 62 |
63 void LocalStateUIHandler::HandleRequestJson(const base::ListValue* args) { | 63 void LocalStateUIHandler::HandleRequestJson(const base::ListValue* args) { |
64 std::unique_ptr<base::DictionaryValue> local_state_values( | 64 std::unique_ptr<base::DictionaryValue> local_state_values( |
65 g_browser_process->local_state()->GetPreferenceValuesOmitDefaults()); | 65 g_browser_process->local_state()->GetPreferenceValues( |
| 66 PrefService::EXCLUDE_DEFAULTS)); |
66 if (ENABLE_FILTERING) { | 67 if (ENABLE_FILTERING) { |
67 std::vector<std::string> whitelisted_prefixes = { | 68 std::vector<std::string> whitelisted_prefixes = { |
68 "variations", "user_experience_metrics", "uninstall_metrics"}; | 69 "variations", "user_experience_metrics", "uninstall_metrics"}; |
69 internal::FilterPrefs(whitelisted_prefixes, local_state_values.get()); | 70 internal::FilterPrefs(whitelisted_prefixes, local_state_values.get()); |
70 } | 71 } |
71 std::string json; | 72 std::string json; |
72 JSONStringValueSerializer serializer(&json); | 73 JSONStringValueSerializer serializer(&json); |
73 serializer.set_pretty_print(true); | 74 serializer.set_pretty_print(true); |
74 bool result = serializer.Serialize(*local_state_values); | 75 bool result = serializer.Serialize(*local_state_values); |
75 if (!result) | 76 if (!result) |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 content::WebUIDataSource* html_source = | 116 content::WebUIDataSource* html_source = |
116 content::WebUIDataSource::Create(chrome::kChromeUILocalStateHost); | 117 content::WebUIDataSource::Create(chrome::kChromeUILocalStateHost); |
117 html_source->SetDefaultResource(IDR_LOCAL_STATE_HTML); | 118 html_source->SetDefaultResource(IDR_LOCAL_STATE_HTML); |
118 html_source->AddResourcePath("local_state.js", IDR_LOCAL_STATE_JS); | 119 html_source->AddResourcePath("local_state.js", IDR_LOCAL_STATE_JS); |
119 content::WebUIDataSource::Add(Profile::FromWebUI(web_ui), html_source); | 120 content::WebUIDataSource::Add(Profile::FromWebUI(web_ui), html_source); |
120 web_ui->AddMessageHandler(base::MakeUnique<LocalStateUIHandler>()); | 121 web_ui->AddMessageHandler(base::MakeUnique<LocalStateUIHandler>()); |
121 } | 122 } |
122 | 123 |
123 LocalStateUI::~LocalStateUI() { | 124 LocalStateUI::~LocalStateUI() { |
124 } | 125 } |
OLD | NEW |