OLD | NEW |
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 <stddef.h> | 7 #include <stddef.h> |
8 #include <utility> | 8 #include <utility> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
358 if (!base::PathExists(dir_path)) { | 358 if (!base::PathExists(dir_path)) { |
359 ADD_FAILURE() << "Extension dir not found: " << dir_path.value(); | 359 ADD_FAILURE() << "Extension dir not found: " << dir_path.value(); |
360 return base::FilePath(); | 360 return base::FilePath(); |
361 } | 361 } |
362 | 362 |
363 if (!base::PathExists(pem_path) && pem_out_path.empty()) { | 363 if (!base::PathExists(pem_path) && pem_out_path.empty()) { |
364 ADD_FAILURE() << "Must specify a PEM file or PEM output path"; | 364 ADD_FAILURE() << "Must specify a PEM file or PEM output path"; |
365 return base::FilePath(); | 365 return base::FilePath(); |
366 } | 366 } |
367 | 367 |
368 scoped_ptr<ExtensionCreator> creator(new ExtensionCreator()); | 368 std::unique_ptr<ExtensionCreator> creator(new ExtensionCreator()); |
369 if (!creator->Run(dir_path, | 369 if (!creator->Run(dir_path, |
370 crx_path, | 370 crx_path, |
371 pem_path, | 371 pem_path, |
372 pem_out_path, | 372 pem_out_path, |
373 ExtensionCreator::kOverwriteCRX)) { | 373 ExtensionCreator::kOverwriteCRX)) { |
374 ADD_FAILURE() << "ExtensionCreator::Run() failed: " | 374 ADD_FAILURE() << "ExtensionCreator::Run() failed: " |
375 << creator->error_message(); | 375 << creator->error_message(); |
376 return base::FilePath(); | 376 return base::FilePath(); |
377 } | 377 } |
378 | 378 |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
462 Browser* browser, | 462 Browser* browser, |
463 Extension::InitFromValueFlags creation_flags, | 463 Extension::InitFromValueFlags creation_flags, |
464 bool install_immediately) { | 464 bool install_immediately) { |
465 ExtensionService* service = | 465 ExtensionService* service = |
466 extensions::ExtensionSystem::Get(profile())->extension_service(); | 466 extensions::ExtensionSystem::Get(profile())->extension_service(); |
467 ExtensionRegistry* registry = ExtensionRegistry::Get(profile()); | 467 ExtensionRegistry* registry = ExtensionRegistry::Get(profile()); |
468 service->set_show_extensions_prompts(false); | 468 service->set_show_extensions_prompts(false); |
469 size_t num_before = registry->enabled_extensions().size(); | 469 size_t num_before = registry->enabled_extensions().size(); |
470 | 470 |
471 { | 471 { |
472 scoped_ptr<ScopedTestDialogAutoConfirm> prompt_auto_confirm; | 472 std::unique_ptr<ScopedTestDialogAutoConfirm> prompt_auto_confirm; |
473 if (ui_type == INSTALL_UI_TYPE_CANCEL) { | 473 if (ui_type == INSTALL_UI_TYPE_CANCEL) { |
474 prompt_auto_confirm.reset(new ScopedTestDialogAutoConfirm( | 474 prompt_auto_confirm.reset(new ScopedTestDialogAutoConfirm( |
475 ScopedTestDialogAutoConfirm::CANCEL)); | 475 ScopedTestDialogAutoConfirm::CANCEL)); |
476 } else if (ui_type == INSTALL_UI_TYPE_NORMAL) { | 476 } else if (ui_type == INSTALL_UI_TYPE_NORMAL) { |
477 prompt_auto_confirm.reset(new ScopedTestDialogAutoConfirm( | 477 prompt_auto_confirm.reset(new ScopedTestDialogAutoConfirm( |
478 ScopedTestDialogAutoConfirm::NONE)); | 478 ScopedTestDialogAutoConfirm::NONE)); |
479 } else if (ui_type == INSTALL_UI_TYPE_AUTO_CONFIRM) { | 479 } else if (ui_type == INSTALL_UI_TYPE_AUTO_CONFIRM) { |
480 prompt_auto_confirm.reset(new ScopedTestDialogAutoConfirm( | 480 prompt_auto_confirm.reset(new ScopedTestDialogAutoConfirm( |
481 ScopedTestDialogAutoConfirm::ACCEPT)); | 481 ScopedTestDialogAutoConfirm::ACCEPT)); |
482 } | 482 } |
483 | 483 |
484 // TODO(tessamac): Update callers to always pass an unpacked extension | 484 // TODO(tessamac): Update callers to always pass an unpacked extension |
485 // and then always pack the extension here. | 485 // and then always pack the extension here. |
486 base::FilePath crx_path = path; | 486 base::FilePath crx_path = path; |
487 if (crx_path.Extension() != FILE_PATH_LITERAL(".crx")) { | 487 if (crx_path.Extension() != FILE_PATH_LITERAL(".crx")) { |
488 crx_path = PackExtension(path); | 488 crx_path = PackExtension(path); |
489 } | 489 } |
490 if (crx_path.empty()) | 490 if (crx_path.empty()) |
491 return NULL; | 491 return NULL; |
492 | 492 |
493 scoped_ptr<ExtensionInstallPrompt> install_ui; | 493 std::unique_ptr<ExtensionInstallPrompt> install_ui; |
494 if (prompt_auto_confirm) { | 494 if (prompt_auto_confirm) { |
495 install_ui.reset(new ExtensionInstallPrompt( | 495 install_ui.reset(new ExtensionInstallPrompt( |
496 browser->tab_strip_model()->GetActiveWebContents())); | 496 browser->tab_strip_model()->GetActiveWebContents())); |
497 } | 497 } |
498 scoped_refptr<extensions::CrxInstaller> installer( | 498 scoped_refptr<extensions::CrxInstaller> installer( |
499 extensions::CrxInstaller::Create(service, std::move(install_ui))); | 499 extensions::CrxInstaller::Create(service, std::move(install_ui))); |
500 installer->set_expected_id(id); | 500 installer->set_expected_id(id); |
501 installer->set_creation_flags(creation_flags); | 501 installer->set_creation_flags(creation_flags); |
502 installer->set_install_source(install_source); | 502 installer->set_install_source(install_source); |
503 installer->set_install_immediately(install_immediately); | 503 installer->set_install_immediately(install_immediately); |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
654 return extensions::browsertest_util::ExecuteScriptInBackgroundPage( | 654 return extensions::browsertest_util::ExecuteScriptInBackgroundPage( |
655 profile(), extension_id, script); | 655 profile(), extension_id, script); |
656 } | 656 } |
657 | 657 |
658 bool ExtensionBrowserTest::ExecuteScriptInBackgroundPageNoWait( | 658 bool ExtensionBrowserTest::ExecuteScriptInBackgroundPageNoWait( |
659 const std::string& extension_id, | 659 const std::string& extension_id, |
660 const std::string& script) { | 660 const std::string& script) { |
661 return extensions::browsertest_util::ExecuteScriptInBackgroundPageNoWait( | 661 return extensions::browsertest_util::ExecuteScriptInBackgroundPageNoWait( |
662 profile(), extension_id, script); | 662 profile(), extension_id, script); |
663 } | 663 } |
OLD | NEW |