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 #include <algorithm> | 9 #include <algorithm> |
10 #include <utility> | 10 #include <utility> |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 switches.SetFromSwitches(capabilities.switches); | 144 switches.SetFromSwitches(capabilities.switches); |
145 | 145 |
146 base::FilePath user_data_dir_path; | 146 base::FilePath user_data_dir_path; |
147 if (switches.HasSwitch("user-data-dir")) { | 147 if (switches.HasSwitch("user-data-dir")) { |
148 user_data_dir_path = base::FilePath( | 148 user_data_dir_path = base::FilePath( |
149 switches.GetSwitchValueNative("user-data-dir")); | 149 switches.GetSwitchValueNative("user-data-dir")); |
150 } else { | 150 } else { |
151 command.AppendArg("data:,"); | 151 command.AppendArg("data:,"); |
152 if (!user_data_dir->CreateUniqueTempDir()) | 152 if (!user_data_dir->CreateUniqueTempDir()) |
153 return Status(kUnknownError, "cannot create temp dir for user data dir"); | 153 return Status(kUnknownError, "cannot create temp dir for user data dir"); |
154 switches.SetSwitch("user-data-dir", user_data_dir->path().value()); | 154 switches.SetSwitch("user-data-dir", user_data_dir->GetPath().value()); |
155 user_data_dir_path = user_data_dir->path(); | 155 user_data_dir_path = user_data_dir->GetPath(); |
156 } | 156 } |
157 | 157 |
158 Status status = internal::PrepareUserDataDir(user_data_dir_path, | 158 Status status = internal::PrepareUserDataDir(user_data_dir_path, |
159 capabilities.prefs.get(), | 159 capabilities.prefs.get(), |
160 capabilities.local_state.get()); | 160 capabilities.local_state.get()); |
161 if (status.IsError()) | 161 if (status.IsError()) |
162 return status; | 162 return status; |
163 | 163 |
164 if (!extension_dir->CreateUniqueTempDir()) { | 164 if (!extension_dir->CreateUniqueTempDir()) { |
165 return Status(kUnknownError, | 165 return Status(kUnknownError, |
166 "cannot create temp dir for unpacking extensions"); | 166 "cannot create temp dir for unpacking extensions"); |
167 } | 167 } |
168 status = internal::ProcessExtensions(capabilities.extensions, | 168 status = internal::ProcessExtensions(capabilities.extensions, |
169 extension_dir->path(), | 169 extension_dir->GetPath(), true, |
170 true, | 170 &switches, extension_bg_pages); |
171 &switches, | |
172 extension_bg_pages); | |
173 if (status.IsError()) | 171 if (status.IsError()) |
174 return status; | 172 return status; |
175 switches.AppendToCommandLine(&command); | 173 switches.AppendToCommandLine(&command); |
176 *prepared_command = command; | 174 *prepared_command = command; |
177 return Status(kOk); | 175 return Status(kOk); |
178 } | 176 } |
179 | 177 |
180 Status WaitForDevToolsAndCheckVersion( | 178 Status WaitForDevToolsAndCheckVersion( |
181 const NetAddress& address, | 179 const NetAddress& address, |
182 URLRequestContextGetter* context_getter, | 180 URLRequestContextGetter* context_getter, |
(...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
668 public_key_vector.size()); | 666 public_key_vector.size()); |
669 } | 667 } |
670 std::string public_key_base64; | 668 std::string public_key_base64; |
671 base::Base64Encode(public_key, &public_key_base64); | 669 base::Base64Encode(public_key, &public_key_base64); |
672 std::string id = GenerateExtensionId(public_key); | 670 std::string id = GenerateExtensionId(public_key); |
673 | 671 |
674 // Unzip the crx file. | 672 // Unzip the crx file. |
675 base::ScopedTempDir temp_crx_dir; | 673 base::ScopedTempDir temp_crx_dir; |
676 if (!temp_crx_dir.CreateUniqueTempDir()) | 674 if (!temp_crx_dir.CreateUniqueTempDir()) |
677 return Status(kUnknownError, "cannot create temp dir"); | 675 return Status(kUnknownError, "cannot create temp dir"); |
678 base::FilePath extension_crx = temp_crx_dir.path().AppendASCII("temp.crx"); | 676 base::FilePath extension_crx = temp_crx_dir.GetPath().AppendASCII("temp.crx"); |
679 int size = static_cast<int>(decoded_extension.length()); | 677 int size = static_cast<int>(decoded_extension.length()); |
680 if (base::WriteFile(extension_crx, decoded_extension.c_str(), size) != | 678 if (base::WriteFile(extension_crx, decoded_extension.c_str(), size) != |
681 size) { | 679 size) { |
682 return Status(kUnknownError, "cannot write file"); | 680 return Status(kUnknownError, "cannot write file"); |
683 } | 681 } |
684 base::FilePath extension_dir = temp_dir.AppendASCII("extension_" + id); | 682 base::FilePath extension_dir = temp_dir.AppendASCII("extension_" + id); |
685 if (!zip::Unzip(extension_crx, extension_dir)) | 683 if (!zip::Unzip(extension_crx, extension_dir)) |
686 return Status(kUnknownError, "cannot unzip"); | 684 return Status(kUnknownError, "cannot unzip"); |
687 | 685 |
688 // Parse the manifest and set the 'key' if not already present. | 686 // Parse the manifest and set the 'key' if not already present. |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
877 // Write empty "First Run" file, otherwise Chrome will wipe the default | 875 // Write empty "First Run" file, otherwise Chrome will wipe the default |
878 // profile that was written. | 876 // profile that was written. |
879 if (base::WriteFile( | 877 if (base::WriteFile( |
880 user_data_dir.Append(chrome::kFirstRunSentinel), "", 0) != 0) { | 878 user_data_dir.Append(chrome::kFirstRunSentinel), "", 0) != 0) { |
881 return Status(kUnknownError, "failed to write first run file"); | 879 return Status(kUnknownError, "failed to write first run file"); |
882 } | 880 } |
883 return Status(kOk); | 881 return Status(kOk); |
884 } | 882 } |
885 | 883 |
886 } // namespace internal | 884 } // namespace internal |
OLD | NEW |