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 454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
465 size) { | 465 size) { |
466 return Status(kUnknownError, "cannot write file"); | 466 return Status(kUnknownError, "cannot write file"); |
467 } | 467 } |
468 base::FilePath extension_dir = temp_dir.AppendASCII("extension_" + id); | 468 base::FilePath extension_dir = temp_dir.AppendASCII("extension_" + id); |
469 if (!zip::Unzip(extension_crx, extension_dir)) | 469 if (!zip::Unzip(extension_crx, extension_dir)) |
470 return Status(kUnknownError, "cannot unzip"); | 470 return Status(kUnknownError, "cannot unzip"); |
471 | 471 |
472 // Parse the manifest and set the 'key' if not already present. | 472 // Parse the manifest and set the 'key' if not already present. |
473 base::FilePath manifest_path(extension_dir.AppendASCII("manifest.json")); | 473 base::FilePath manifest_path(extension_dir.AppendASCII("manifest.json")); |
474 std::string manifest_data; | 474 std::string manifest_data; |
475 if (!file_util::ReadFileToString(manifest_path, &manifest_data)) | 475 if (!base::ReadFileToString(manifest_path, &manifest_data)) |
476 return Status(kUnknownError, "cannot read manifest"); | 476 return Status(kUnknownError, "cannot read manifest"); |
477 scoped_ptr<base::Value> manifest_value(base::JSONReader::Read(manifest_data)); | 477 scoped_ptr<base::Value> manifest_value(base::JSONReader::Read(manifest_data)); |
478 base::DictionaryValue* manifest; | 478 base::DictionaryValue* manifest; |
479 if (!manifest_value || !manifest_value->GetAsDictionary(&manifest)) | 479 if (!manifest_value || !manifest_value->GetAsDictionary(&manifest)) |
480 return Status(kUnknownError, "invalid manifest"); | 480 return Status(kUnknownError, "invalid manifest"); |
481 if (!manifest->HasKey("key")) { | 481 if (!manifest->HasKey("key")) { |
482 manifest->SetString("key", public_key_base64); | 482 manifest->SetString("key", public_key_base64); |
483 base::JSONWriter::Write(manifest, &manifest_data); | 483 base::JSONWriter::Write(manifest, &manifest_data); |
484 if (file_util::WriteFile( | 484 if (file_util::WriteFile( |
485 manifest_path, manifest_data.c_str(), manifest_data.size()) != | 485 manifest_path, manifest_data.c_str(), manifest_data.size()) != |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
599 // Write empty "First Run" file, otherwise Chrome will wipe the default | 599 // Write empty "First Run" file, otherwise Chrome will wipe the default |
600 // profile that was written. | 600 // profile that was written. |
601 if (file_util::WriteFile( | 601 if (file_util::WriteFile( |
602 user_data_dir.AppendASCII("First Run"), "", 0) != 0) { | 602 user_data_dir.AppendASCII("First Run"), "", 0) != 0) { |
603 return Status(kUnknownError, "failed to write first run file"); | 603 return Status(kUnknownError, "failed to write first run file"); |
604 } | 604 } |
605 return Status(kOk); | 605 return Status(kOk); |
606 } | 606 } |
607 | 607 |
608 } // namespace internal | 608 } // namespace internal |
OLD | NEW |