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

Side by Side Diff: chrome/browser/extensions/extension_browsertest.cc

Issue 18286004: Move PathExists to base namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 5 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/browser/extensions/extension_browsertest.h" 5 #include "chrome/browser/extensions/extension_browsertest.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/file_util.h" 10 #include "base/file_util.h"
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 if (!base::Delete(crx_path, false)) { 243 if (!base::Delete(crx_path, false)) {
244 ADD_FAILURE() << "Failed to delete crx: " << crx_path.value(); 244 ADD_FAILURE() << "Failed to delete crx: " << crx_path.value();
245 return base::FilePath(); 245 return base::FilePath();
246 } 246 }
247 247
248 // Look for PEM files with the same name as the directory. 248 // Look for PEM files with the same name as the directory.
249 base::FilePath pem_path = 249 base::FilePath pem_path =
250 dir_path.ReplaceExtension(FILE_PATH_LITERAL(".pem")); 250 dir_path.ReplaceExtension(FILE_PATH_LITERAL(".pem"));
251 base::FilePath pem_path_out; 251 base::FilePath pem_path_out;
252 252
253 if (!file_util::PathExists(pem_path)) { 253 if (!base::PathExists(pem_path)) {
254 pem_path = base::FilePath(); 254 pem_path = base::FilePath();
255 pem_path_out = crx_path.DirName().AppendASCII("temp.pem"); 255 pem_path_out = crx_path.DirName().AppendASCII("temp.pem");
256 if (!base::Delete(pem_path_out, false)) { 256 if (!base::Delete(pem_path_out, false)) {
257 ADD_FAILURE() << "Failed to delete pem: " << pem_path_out.value(); 257 ADD_FAILURE() << "Failed to delete pem: " << pem_path_out.value();
258 return base::FilePath(); 258 return base::FilePath();
259 } 259 }
260 } 260 }
261 261
262 return PackExtensionWithOptions(dir_path, crx_path, pem_path, pem_path_out); 262 return PackExtensionWithOptions(dir_path, crx_path, pem_path, pem_path_out);
263 } 263 }
264 264
265 base::FilePath ExtensionBrowserTest::PackExtensionWithOptions( 265 base::FilePath ExtensionBrowserTest::PackExtensionWithOptions(
266 const base::FilePath& dir_path, 266 const base::FilePath& dir_path,
267 const base::FilePath& crx_path, 267 const base::FilePath& crx_path,
268 const base::FilePath& pem_path, 268 const base::FilePath& pem_path,
269 const base::FilePath& pem_out_path) { 269 const base::FilePath& pem_out_path) {
270 if (!file_util::PathExists(dir_path)) { 270 if (!base::PathExists(dir_path)) {
271 ADD_FAILURE() << "Extension dir not found: " << dir_path.value(); 271 ADD_FAILURE() << "Extension dir not found: " << dir_path.value();
272 return base::FilePath(); 272 return base::FilePath();
273 } 273 }
274 274
275 if (!file_util::PathExists(pem_path) && pem_out_path.empty()) { 275 if (!base::PathExists(pem_path) && pem_out_path.empty()) {
276 ADD_FAILURE() << "Must specify a PEM file or PEM output path"; 276 ADD_FAILURE() << "Must specify a PEM file or PEM output path";
277 return base::FilePath(); 277 return base::FilePath();
278 } 278 }
279 279
280 scoped_ptr<ExtensionCreator> creator(new ExtensionCreator()); 280 scoped_ptr<ExtensionCreator> creator(new ExtensionCreator());
281 if (!creator->Run(dir_path, 281 if (!creator->Run(dir_path,
282 crx_path, 282 crx_path,
283 pem_path, 283 pem_path,
284 pem_out_path, 284 pem_out_path,
285 ExtensionCreator::kOverwriteCRX)) { 285 ExtensionCreator::kOverwriteCRX)) {
286 ADD_FAILURE() << "ExtensionCreator::Run() failed: " 286 ADD_FAILURE() << "ExtensionCreator::Run() failed: "
287 << creator->error_message(); 287 << creator->error_message();
288 return base::FilePath(); 288 return base::FilePath();
289 } 289 }
290 290
291 if (!file_util::PathExists(crx_path)) { 291 if (!base::PathExists(crx_path)) {
292 ADD_FAILURE() << crx_path.value() << " was not created."; 292 ADD_FAILURE() << crx_path.value() << " was not created.";
293 return base::FilePath(); 293 return base::FilePath();
294 } 294 }
295 return crx_path; 295 return crx_path;
296 } 296 }
297 297
298 // This class is used to simulate an installation abort by the user. 298 // This class is used to simulate an installation abort by the user.
299 class MockAbortExtensionInstallPrompt : public ExtensionInstallPrompt { 299 class MockAbortExtensionInstallPrompt : public ExtensionInstallPrompt {
300 public: 300 public:
301 MockAbortExtensionInstallPrompt() : ExtensionInstallPrompt(NULL) { 301 MockAbortExtensionInstallPrompt() : ExtensionInstallPrompt(NULL) {
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after
734 case content::NOTIFICATION_LOAD_STOP: 734 case content::NOTIFICATION_LOAD_STOP:
735 VLOG(1) << "Got LOAD_STOP notification."; 735 VLOG(1) << "Got LOAD_STOP notification.";
736 base::MessageLoopForUI::current()->Quit(); 736 base::MessageLoopForUI::current()->Quit();
737 break; 737 break;
738 738
739 default: 739 default:
740 NOTREACHED(); 740 NOTREACHED();
741 break; 741 break;
742 } 742 }
743 } 743 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/convert_web_app_unittest.cc ('k') | chrome/browser/extensions/extension_creator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698