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 <string> | 7 #include <string> |
8 | 8 |
9 #include "base/json/json_string_value_serializer.h" | 9 #include "base/json/json_string_value_serializer.h" |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 } | 45 } |
46 | 46 |
47 void LocalStateUIHandler::RegisterMessages() { | 47 void LocalStateUIHandler::RegisterMessages() { |
48 web_ui()->RegisterMessageCallback( | 48 web_ui()->RegisterMessageCallback( |
49 "requestJson", base::Bind(&LocalStateUIHandler::HandleRequestJson, | 49 "requestJson", base::Bind(&LocalStateUIHandler::HandleRequestJson, |
50 base::Unretained(this))); | 50 base::Unretained(this))); |
51 } | 51 } |
52 | 52 |
53 void LocalStateUIHandler::HandleRequestJson(const base::ListValue* args) { | 53 void LocalStateUIHandler::HandleRequestJson(const base::ListValue* args) { |
54 #if !defined(OS_CHROMEOS) | 54 #if !defined(OS_CHROMEOS) |
55 scoped_ptr<base::DictionaryValue> local_state_values( | 55 std::unique_ptr<base::DictionaryValue> local_state_values( |
56 g_browser_process->local_state()->GetPreferenceValuesOmitDefaults()); | 56 g_browser_process->local_state()->GetPreferenceValuesOmitDefaults()); |
57 | 57 |
58 std::string json; | 58 std::string json; |
59 JSONStringValueSerializer serializer(&json); | 59 JSONStringValueSerializer serializer(&json); |
60 serializer.set_pretty_print(true); | 60 serializer.set_pretty_print(true); |
61 bool result = serializer.Serialize(*local_state_values); | 61 bool result = serializer.Serialize(*local_state_values); |
62 if (!result) | 62 if (!result) |
63 json = "Error loading Local State file."; | 63 json = "Error loading Local State file."; |
64 | 64 |
65 web_ui()->CallJavascriptFunction("localState.setLocalState", | 65 web_ui()->CallJavascriptFunction("localState.setLocalState", |
(...skipping 10 matching lines...) Expand all Loading... |
76 html_source->SetDefaultResource(IDR_LOCAL_STATE_HTML); | 76 html_source->SetDefaultResource(IDR_LOCAL_STATE_HTML); |
77 html_source->AddResourcePath("local_state.js", IDR_LOCAL_STATE_JS); | 77 html_source->AddResourcePath("local_state.js", IDR_LOCAL_STATE_JS); |
78 content::WebUIDataSource::Add(Profile::FromWebUI(web_ui), html_source); | 78 content::WebUIDataSource::Add(Profile::FromWebUI(web_ui), html_source); |
79 | 79 |
80 // AddMessageHandler takes ownership of LocalStateUIHandler. | 80 // AddMessageHandler takes ownership of LocalStateUIHandler. |
81 web_ui->AddMessageHandler(new LocalStateUIHandler); | 81 web_ui->AddMessageHandler(new LocalStateUIHandler); |
82 } | 82 } |
83 | 83 |
84 LocalStateUI::~LocalStateUI() { | 84 LocalStateUI::~LocalStateUI() { |
85 } | 85 } |
OLD | NEW |