OLD | NEW |
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/test/chromedriver/chrome_launcher.h" | 5 #include "chrome/test/chromedriver/chrome_launcher.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 |
9 #include <algorithm> | 10 #include <algorithm> |
10 #include <memory> | 11 #include <memory> |
11 #include <utility> | 12 #include <utility> |
12 #include <vector> | 13 #include <vector> |
13 | 14 |
14 #include "base/base64.h" | 15 #include "base/base64.h" |
15 #include "base/bind.h" | 16 #include "base/bind.h" |
16 #include "base/command_line.h" | 17 #include "base/command_line.h" |
17 #include "base/files/file_path.h" | 18 #include "base/files/file_path.h" |
18 #include "base/files/file_util.h" | 19 #include "base/files/file_util.h" |
19 #include "base/files/scoped_file.h" | 20 #include "base/files/scoped_file.h" |
20 #include "base/format_macros.h" | 21 #include "base/format_macros.h" |
21 #include "base/json/json_reader.h" | 22 #include "base/json/json_reader.h" |
22 #include "base/json/json_writer.h" | 23 #include "base/json/json_writer.h" |
23 #include "base/logging.h" | 24 #include "base/logging.h" |
| 25 #include "base/memory/ptr_util.h" |
24 #include "base/process/kill.h" | 26 #include "base/process/kill.h" |
25 #include "base/process/launch.h" | 27 #include "base/process/launch.h" |
26 #include "base/process/process.h" | 28 #include "base/process/process.h" |
27 #include "base/strings/string_number_conversions.h" | 29 #include "base/strings/string_number_conversions.h" |
28 #include "base/strings/string_util.h" | 30 #include "base/strings/string_util.h" |
29 #include "base/strings/stringprintf.h" | 31 #include "base/strings/stringprintf.h" |
30 #include "base/strings/utf_string_conversions.h" | 32 #include "base/strings/utf_string_conversions.h" |
31 #include "base/threading/platform_thread.h" | 33 #include "base/threading/platform_thread.h" |
32 #include "base/time/time.h" | 34 #include "base/time/time.h" |
33 #include "base/values.h" | 35 #include "base/values.h" |
(...skipping 775 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
809 &error_msg); | 811 &error_msg); |
810 base::DictionaryValue* prefs; | 812 base::DictionaryValue* prefs; |
811 if (!template_value || !template_value->GetAsDictionary(&prefs)) { | 813 if (!template_value || !template_value->GetAsDictionary(&prefs)) { |
812 return Status(kUnknownError, | 814 return Status(kUnknownError, |
813 "cannot parse internal JSON template: " + error_msg); | 815 "cannot parse internal JSON template: " + error_msg); |
814 } | 816 } |
815 | 817 |
816 if (custom_prefs) { | 818 if (custom_prefs) { |
817 for (base::DictionaryValue::Iterator it(*custom_prefs); !it.IsAtEnd(); | 819 for (base::DictionaryValue::Iterator it(*custom_prefs); !it.IsAtEnd(); |
818 it.Advance()) { | 820 it.Advance()) { |
819 prefs->Set(it.key(), it.value().DeepCopy()); | 821 prefs->Set(it.key(), base::MakeUnique<base::Value>(it.value())); |
820 } | 822 } |
821 } | 823 } |
822 | 824 |
823 std::string prefs_str; | 825 std::string prefs_str; |
824 base::JSONWriter::Write(*prefs, &prefs_str); | 826 base::JSONWriter::Write(*prefs, &prefs_str); |
825 VLOG(0) << "Populating " << path.BaseName().value() | 827 VLOG(0) << "Populating " << path.BaseName().value() |
826 << " file: " << PrettyPrintValue(*prefs); | 828 << " file: " << PrettyPrintValue(*prefs); |
827 if (static_cast<int>(prefs_str.length()) != base::WriteFile( | 829 if (static_cast<int>(prefs_str.length()) != base::WriteFile( |
828 path, prefs_str.c_str(), prefs_str.length())) { | 830 path, prefs_str.c_str(), prefs_str.length())) { |
829 return Status(kUnknownError, "failed to write prefs file"); | 831 return Status(kUnknownError, "failed to write prefs file"); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
874 // Write empty "First Run" file, otherwise Chrome will wipe the default | 876 // Write empty "First Run" file, otherwise Chrome will wipe the default |
875 // profile that was written. | 877 // profile that was written. |
876 if (base::WriteFile( | 878 if (base::WriteFile( |
877 user_data_dir.Append(chrome::kFirstRunSentinel), "", 0) != 0) { | 879 user_data_dir.Append(chrome::kFirstRunSentinel), "", 0) != 0) { |
878 return Status(kUnknownError, "failed to write first run file"); | 880 return Status(kUnknownError, "failed to write first run file"); |
879 } | 881 } |
880 return Status(kOk); | 882 return Status(kOk); |
881 } | 883 } |
882 | 884 |
883 } // namespace internal | 885 } // namespace internal |
OLD | NEW |