| 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/util.h" | 5 #include "chrome/test/chromedriver/util.h" |
| 6 | 6 |
| 7 #include "base/base64.h" | 7 #include "base/base64.h" |
| 8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/files/file_enumerator.h" | 9 #include "base/files/file_enumerator.h" |
| 10 #include "base/files/scoped_temp_dir.h" | 10 #include "base/files/scoped_temp_dir.h" |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 *sticky_modifiers = sticky_modifiers_tmp; | 69 *sticky_modifiers = sticky_modifiers_tmp; |
| 70 return status; | 70 return status; |
| 71 } | 71 } |
| 72 | 72 |
| 73 bool Base64Decode(const std::string& base64, | 73 bool Base64Decode(const std::string& base64, |
| 74 std::string* bytes) { | 74 std::string* bytes) { |
| 75 std::string copy = base64; | 75 std::string copy = base64; |
| 76 // Some WebDriver client base64 encoders follow RFC 1521, which require that | 76 // Some WebDriver client base64 encoders follow RFC 1521, which require that |
| 77 // 'encoded lines be no more than 76 characters long'. Just remove any | 77 // 'encoded lines be no more than 76 characters long'. Just remove any |
| 78 // newlines. | 78 // newlines. |
| 79 RemoveChars(copy, "\n", ©); | 79 base::RemoveChars(copy, "\n", ©); |
| 80 return base::Base64Decode(copy, bytes); | 80 return base::Base64Decode(copy, bytes); |
| 81 } | 81 } |
| 82 | 82 |
| 83 namespace { | 83 namespace { |
| 84 | 84 |
| 85 Status UnzipArchive(const base::FilePath& unzip_dir, | 85 Status UnzipArchive(const base::FilePath& unzip_dir, |
| 86 const std::string& bytes) { | 86 const std::string& bytes) { |
| 87 base::ScopedTempDir dir; | 87 base::ScopedTempDir dir; |
| 88 if (!dir.CreateUniqueTempDir()) | 88 if (!dir.CreateUniqueTempDir()) |
| 89 return Status(kUnknownError, "unable to create temp dir"); | 89 return Status(kUnknownError, "unable to create temp dir"); |
| (...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 394 if (first_file.empty()) | 394 if (first_file.empty()) |
| 395 return Status(kUnknownError, "contained 0 files"); | 395 return Status(kUnknownError, "contained 0 files"); |
| 396 | 396 |
| 397 base::FilePath second_file = enumerator.Next(); | 397 base::FilePath second_file = enumerator.Next(); |
| 398 if (!second_file.empty()) | 398 if (!second_file.empty()) |
| 399 return Status(kUnknownError, "contained multiple files"); | 399 return Status(kUnknownError, "contained multiple files"); |
| 400 | 400 |
| 401 *file = first_file; | 401 *file = first_file; |
| 402 return Status(kOk); | 402 return Status(kOk); |
| 403 } | 403 } |
| OLD | NEW |