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

Side by Side Diff: chrome/browser/policy/test/local_policy_test_server.cc

Issue 2792573002: Remove base::Value::CreateNullValue (Closed)
Patch Set: Rebase Created 3 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/policy/test/local_policy_test_server.h" 5 #include "chrome/browser/policy/test/local_policy_test_server.h"
6 6
7 #include <ctype.h> 7 #include <ctype.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/base_paths.h" 13 #include "base/base_paths.h"
14 #include "base/files/file_util.h" 14 #include "base/files/file_util.h"
15 #include "base/json/json_writer.h" 15 #include "base/json/json_writer.h"
16 #include "base/memory/ptr_util.h"
16 #include "base/numerics/safe_conversions.h" 17 #include "base/numerics/safe_conversions.h"
17 #include "base/path_service.h" 18 #include "base/path_service.h"
18 #include "base/strings/stringprintf.h" 19 #include "base/strings/stringprintf.h"
19 #include "base/values.h" 20 #include "base/values.h"
20 #include "build/build_config.h" 21 #include "build/build_config.h"
21 #include "components/policy/core/common/cloud/cloud_policy_constants.h" 22 #include "components/policy/core/common/cloud/cloud_policy_constants.h"
22 #include "crypto/rsa_private_key.h" 23 #include "crypto/rsa_private_key.h"
23 #include "net/test/python_utils.h" 24 #include "net/test/python_utils.h"
24 25
25 namespace policy { 26 namespace policy {
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 bool LocalPolicyTestServer::GenerateAdditionalArguments( 239 bool LocalPolicyTestServer::GenerateAdditionalArguments(
239 base::DictionaryValue* arguments) const { 240 base::DictionaryValue* arguments) const {
240 if (!net::LocalTestServer::GenerateAdditionalArguments(arguments)) 241 if (!net::LocalTestServer::GenerateAdditionalArguments(arguments))
241 return false; 242 return false;
242 243
243 arguments->SetString("config-file", config_file_.AsUTF8Unsafe()); 244 arguments->SetString("config-file", config_file_.AsUTF8Unsafe());
244 if (!policy_key_.empty()) 245 if (!policy_key_.empty())
245 arguments->SetString("policy-key", policy_key_.AsUTF8Unsafe()); 246 arguments->SetString("policy-key", policy_key_.AsUTF8Unsafe());
246 if (automatic_rotation_of_signing_keys_enabled_) { 247 if (automatic_rotation_of_signing_keys_enabled_) {
247 arguments->Set("rotate-policy-keys-automatically", 248 arguments->Set("rotate-policy-keys-automatically",
248 base::Value::CreateNullValue()); 249 base::MakeUnique<base::Value>());
249 } 250 }
250 if (server_data_dir_.IsValid()) { 251 if (server_data_dir_.IsValid()) {
251 arguments->SetString("data-dir", server_data_dir_.GetPath().AsUTF8Unsafe()); 252 arguments->SetString("data-dir", server_data_dir_.GetPath().AsUTF8Unsafe());
252 253
253 if (!clients_.empty()) { 254 if (!clients_.empty()) {
254 std::string json; 255 std::string json;
255 base::JSONWriter::Write(clients_, &json); 256 base::JSONWriter::Write(clients_, &json);
256 base::FilePath client_state_file = 257 base::FilePath client_state_file =
257 server_data_dir_.GetPath().Append(kClientStateFileName); 258 server_data_dir_.GetPath().Append(kClientStateFileName);
258 if (base::WriteFile(client_state_file, json.c_str(), json.size()) != 259 if (base::WriteFile(client_state_file, json.c_str(), json.size()) !=
(...skipping 10 matching lines...) Expand all
269 std::string LocalPolicyTestServer::GetSelector(const std::string& type, 270 std::string LocalPolicyTestServer::GetSelector(const std::string& type,
270 const std::string& entity_id) { 271 const std::string& entity_id) {
271 std::string selector = type; 272 std::string selector = type;
272 if (!entity_id.empty()) 273 if (!entity_id.empty())
273 selector = base::StringPrintf("%s/%s", type.c_str(), entity_id.c_str()); 274 selector = base::StringPrintf("%s/%s", type.c_str(), entity_id.c_str());
274 std::replace_if(selector.begin(), selector.end(), IsUnsafeCharacter, '_'); 275 std::replace_if(selector.begin(), selector.end(), IsUnsafeCharacter, '_');
275 return selector; 276 return selector;
276 } 277 }
277 278
278 } // namespace policy 279 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698