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

Side by Side Diff: trunk/src/chrome/test/chromedriver/chrome_launcher.cc

Issue 101113004: Revert 239759 "The comment in base64.h implies that base::Base64..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 7 years 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 | Annotate | Revision Log
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/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 479 matching lines...) Expand 10 before | Expand all | Expand 10 after
490 // Get extension's ID from public key in crx file. 490 // Get extension's ID from public key in crx file.
491 // Assumes crx v2. See http://developer.chrome.com/extensions/crx.html. 491 // Assumes crx v2. See http://developer.chrome.com/extensions/crx.html.
492 std::string key_len_str = decoded_extension.substr(8, 4); 492 std::string key_len_str = decoded_extension.substr(8, 4);
493 if (key_len_str.size() != 4) 493 if (key_len_str.size() != 4)
494 return Status(kUnknownError, "cannot extract public key length"); 494 return Status(kUnknownError, "cannot extract public key length");
495 uint32 key_len = *reinterpret_cast<const uint32*>(key_len_str.c_str()); 495 uint32 key_len = *reinterpret_cast<const uint32*>(key_len_str.c_str());
496 std::string public_key = decoded_extension.substr(16, key_len); 496 std::string public_key = decoded_extension.substr(16, key_len);
497 if (key_len != public_key.size()) 497 if (key_len != public_key.size())
498 return Status(kUnknownError, "invalid public key length"); 498 return Status(kUnknownError, "invalid public key length");
499 std::string public_key_base64; 499 std::string public_key_base64;
500 base::Base64Encode(public_key, &public_key_base64); 500 if (!base::Base64Encode(public_key, &public_key_base64))
501 return Status(kUnknownError, "cannot base64 encode public key");
501 std::string id = GenerateExtensionId(public_key); 502 std::string id = GenerateExtensionId(public_key);
502 503
503 // Unzip the crx file. 504 // Unzip the crx file.
504 base::ScopedTempDir temp_crx_dir; 505 base::ScopedTempDir temp_crx_dir;
505 if (!temp_crx_dir.CreateUniqueTempDir()) 506 if (!temp_crx_dir.CreateUniqueTempDir())
506 return Status(kUnknownError, "cannot create temp dir"); 507 return Status(kUnknownError, "cannot create temp dir");
507 base::FilePath extension_crx = temp_crx_dir.path().AppendASCII("temp.crx"); 508 base::FilePath extension_crx = temp_crx_dir.path().AppendASCII("temp.crx");
508 int size = static_cast<int>(decoded_extension.length()); 509 int size = static_cast<int>(decoded_extension.length());
509 if (file_util::WriteFile(extension_crx, decoded_extension.c_str(), size) != 510 if (file_util::WriteFile(extension_crx, decoded_extension.c_str(), size) !=
510 size) { 511 size) {
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
676 // Write empty "First Run" file, otherwise Chrome will wipe the default 677 // Write empty "First Run" file, otherwise Chrome will wipe the default
677 // profile that was written. 678 // profile that was written.
678 if (file_util::WriteFile( 679 if (file_util::WriteFile(
679 user_data_dir.AppendASCII("First Run"), "", 0) != 0) { 680 user_data_dir.AppendASCII("First Run"), "", 0) != 0) {
680 return Status(kUnknownError, "failed to write first run file"); 681 return Status(kUnknownError, "failed to write first run file");
681 } 682 }
682 return Status(kOk); 683 return Status(kOk);
683 } 684 }
684 685
685 } // namespace internal 686 } // namespace internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698