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

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

Issue 19579005: Move ReadFileToString to the base namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 3 months 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 454 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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
OLDNEW
« no previous file with comments | « chrome/test/base/web_ui_browsertest.cc ('k') | chrome/test/chromedriver/chrome_launcher_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698