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 <algorithm> | 7 #include <algorithm> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/base64.h" | 10 #include "base/base64.h" |
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
473 | 473 |
474 Status ProcessExtension(const std::string& extension, | 474 Status ProcessExtension(const std::string& extension, |
475 const base::FilePath& temp_dir, | 475 const base::FilePath& temp_dir, |
476 base::FilePath* path, | 476 base::FilePath* path, |
477 std::string* bg_page) { | 477 std::string* bg_page) { |
478 // Decodes extension string. | 478 // Decodes extension string. |
479 // Some WebDriver client base64 encoders follow RFC 1521, which require that | 479 // Some WebDriver client base64 encoders follow RFC 1521, which require that |
480 // 'encoded lines be no more than 76 characters long'. Just remove any | 480 // 'encoded lines be no more than 76 characters long'. Just remove any |
481 // newlines. | 481 // newlines. |
482 std::string extension_base64; | 482 std::string extension_base64; |
483 RemoveChars(extension, "\n", &extension_base64); | 483 base::RemoveChars(extension, "\n", &extension_base64); |
484 std::string decoded_extension; | 484 std::string decoded_extension; |
485 if (!base::Base64Decode(extension_base64, &decoded_extension)) | 485 if (!base::Base64Decode(extension_base64, &decoded_extension)) |
486 return Status(kUnknownError, "cannot base64 decode"); | 486 return Status(kUnknownError, "cannot base64 decode"); |
487 | 487 |
488 // Get extension's ID from public key in crx file. | 488 // Get extension's ID from public key in crx file. |
489 // Assumes crx v2. See http://developer.chrome.com/extensions/crx.html. | 489 // Assumes crx v2. See http://developer.chrome.com/extensions/crx.html. |
490 std::string key_len_str = decoded_extension.substr(8, 4); | 490 std::string key_len_str = decoded_extension.substr(8, 4); |
491 if (key_len_str.size() != 4) | 491 if (key_len_str.size() != 4) |
492 return Status(kUnknownError, "cannot extract public key length"); | 492 return Status(kUnknownError, "cannot extract public key length"); |
493 uint32 key_len = *reinterpret_cast<const uint32*>(key_len_str.c_str()); | 493 uint32 key_len = *reinterpret_cast<const uint32*>(key_len_str.c_str()); |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
655 // Write empty "First Run" file, otherwise Chrome will wipe the default | 655 // Write empty "First Run" file, otherwise Chrome will wipe the default |
656 // profile that was written. | 656 // profile that was written. |
657 if (file_util::WriteFile( | 657 if (file_util::WriteFile( |
658 user_data_dir.AppendASCII("First Run"), "", 0) != 0) { | 658 user_data_dir.AppendASCII("First Run"), "", 0) != 0) { |
659 return Status(kUnknownError, "failed to write first run file"); | 659 return Status(kUnknownError, "failed to write first run file"); |
660 } | 660 } |
661 return Status(kOk); | 661 return Status(kOk); |
662 } | 662 } |
663 | 663 |
664 } // namespace internal | 664 } // namespace internal |
OLD | NEW |