| 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 | 8 |
| 9 #include <utility> | 9 #include <utility> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 382 ADD_FAILURE() << crx_path.value() << " was not created."; | 382 ADD_FAILURE() << crx_path.value() << " was not created."; |
| 383 return base::FilePath(); | 383 return base::FilePath(); |
| 384 } | 384 } |
| 385 return crx_path; | 385 return crx_path; |
| 386 } | 386 } |
| 387 | 387 |
| 388 const Extension* ExtensionBrowserTest::UpdateExtensionWaitForIdle( | 388 const Extension* ExtensionBrowserTest::UpdateExtensionWaitForIdle( |
| 389 const std::string& id, | 389 const std::string& id, |
| 390 const base::FilePath& path, | 390 const base::FilePath& path, |
| 391 int expected_change) { | 391 int expected_change) { |
| 392 return InstallOrUpdateExtension(id, | 392 return InstallOrUpdateExtension(id, path, INSTALL_UI_TYPE_NONE, |
| 393 path, | 393 expected_change, Manifest::INTERNAL, |
| 394 INSTALL_UI_TYPE_NONE, | 394 browser(), Extension::NO_FLAGS, false, false); |
| 395 expected_change, | |
| 396 Manifest::INTERNAL, | |
| 397 browser(), | |
| 398 Extension::NO_FLAGS, | |
| 399 false); | |
| 400 } | 395 } |
| 401 | 396 |
| 402 const Extension* ExtensionBrowserTest::InstallExtensionFromWebstore( | 397 const Extension* ExtensionBrowserTest::InstallExtensionFromWebstore( |
| 403 const base::FilePath& path, | 398 const base::FilePath& path, |
| 404 int expected_change) { | 399 int expected_change) { |
| 405 return InstallOrUpdateExtension( | 400 return InstallOrUpdateExtension( |
| 406 std::string(), path, INSTALL_UI_TYPE_AUTO_CONFIRM, expected_change, | 401 std::string(), path, INSTALL_UI_TYPE_AUTO_CONFIRM, expected_change, |
| 407 Manifest::INTERNAL, browser(), Extension::FROM_WEBSTORE, true); | 402 Manifest::INTERNAL, browser(), Extension::FROM_WEBSTORE, true, false); |
| 408 } | 403 } |
| 409 | 404 |
| 410 const Extension* ExtensionBrowserTest::InstallOrUpdateExtension( | 405 const Extension* ExtensionBrowserTest::InstallOrUpdateExtension( |
| 411 const std::string& id, | 406 const std::string& id, |
| 412 const base::FilePath& path, | 407 const base::FilePath& path, |
| 413 InstallUIType ui_type, | 408 InstallUIType ui_type, |
| 414 int expected_change) { | 409 int expected_change) { |
| 415 return InstallOrUpdateExtension(id, | 410 return InstallOrUpdateExtension(id, path, ui_type, expected_change, |
| 416 path, | 411 Manifest::INTERNAL, browser(), |
| 417 ui_type, | 412 Extension::NO_FLAGS, true, false); |
| 418 expected_change, | |
| 419 Manifest::INTERNAL, | |
| 420 browser(), | |
| 421 Extension::NO_FLAGS, | |
| 422 true); | |
| 423 } | 413 } |
| 424 | 414 |
| 425 const Extension* ExtensionBrowserTest::InstallOrUpdateExtension( | 415 const Extension* ExtensionBrowserTest::InstallOrUpdateExtension( |
| 426 const std::string& id, | 416 const std::string& id, |
| 427 const base::FilePath& path, | 417 const base::FilePath& path, |
| 428 InstallUIType ui_type, | 418 InstallUIType ui_type, |
| 429 int expected_change, | 419 int expected_change, |
| 430 Browser* browser, | 420 Browser* browser, |
| 431 Extension::InitFromValueFlags creation_flags) { | 421 Extension::InitFromValueFlags creation_flags) { |
| 432 return InstallOrUpdateExtension(id, | 422 return InstallOrUpdateExtension(id, path, ui_type, expected_change, |
| 433 path, | 423 Manifest::INTERNAL, browser, creation_flags, |
| 434 ui_type, | 424 true, false); |
| 435 expected_change, | |
| 436 Manifest::INTERNAL, | |
| 437 browser, | |
| 438 creation_flags, | |
| 439 true); | |
| 440 } | 425 } |
| 441 | 426 |
| 442 const Extension* ExtensionBrowserTest::InstallOrUpdateExtension( | 427 const Extension* ExtensionBrowserTest::InstallOrUpdateExtension( |
| 443 const std::string& id, | 428 const std::string& id, |
| 444 const base::FilePath& path, | 429 const base::FilePath& path, |
| 445 InstallUIType ui_type, | 430 InstallUIType ui_type, |
| 446 int expected_change, | 431 int expected_change, |
| 447 Manifest::Location install_source) { | 432 Manifest::Location install_source) { |
| 448 return InstallOrUpdateExtension(id, | 433 return InstallOrUpdateExtension(id, path, ui_type, expected_change, |
| 449 path, | 434 install_source, browser(), |
| 450 ui_type, | 435 Extension::NO_FLAGS, true, false); |
| 451 expected_change, | |
| 452 install_source, | |
| 453 browser(), | |
| 454 Extension::NO_FLAGS, | |
| 455 true); | |
| 456 } | 436 } |
| 457 | 437 |
| 458 const Extension* ExtensionBrowserTest::InstallOrUpdateExtension( | 438 const Extension* ExtensionBrowserTest::InstallOrUpdateExtension( |
| 459 const std::string& id, | 439 const std::string& id, |
| 460 const base::FilePath& path, | 440 const base::FilePath& path, |
| 461 InstallUIType ui_type, | 441 InstallUIType ui_type, |
| 462 int expected_change, | 442 int expected_change, |
| 463 Manifest::Location install_source, | 443 Manifest::Location install_source, |
| 464 Browser* browser, | 444 Browser* browser, |
| 465 Extension::InitFromValueFlags creation_flags, | 445 Extension::InitFromValueFlags creation_flags, |
| 466 bool install_immediately) { | 446 bool install_immediately, |
| 447 bool grant_permissions) { |
| 467 ExtensionService* service = | 448 ExtensionService* service = |
| 468 extensions::ExtensionSystem::Get(profile())->extension_service(); | 449 extensions::ExtensionSystem::Get(profile())->extension_service(); |
| 469 ExtensionRegistry* registry = ExtensionRegistry::Get(profile()); | 450 ExtensionRegistry* registry = ExtensionRegistry::Get(profile()); |
| 470 service->set_show_extensions_prompts(false); | 451 service->set_show_extensions_prompts(false); |
| 471 size_t num_before = registry->enabled_extensions().size(); | 452 size_t num_before = registry->enabled_extensions().size(); |
| 472 | 453 |
| 473 { | 454 { |
| 474 std::unique_ptr<ScopedTestDialogAutoConfirm> prompt_auto_confirm; | 455 std::unique_ptr<ScopedTestDialogAutoConfirm> prompt_auto_confirm; |
| 475 if (ui_type == INSTALL_UI_TYPE_CANCEL) { | 456 if (ui_type == INSTALL_UI_TYPE_CANCEL) { |
| 476 prompt_auto_confirm.reset(new ScopedTestDialogAutoConfirm( | 457 prompt_auto_confirm.reset(new ScopedTestDialogAutoConfirm( |
| (...skipping 19 matching lines...) Expand all Loading... |
| 496 if (prompt_auto_confirm) { | 477 if (prompt_auto_confirm) { |
| 497 install_ui.reset(new ExtensionInstallPrompt( | 478 install_ui.reset(new ExtensionInstallPrompt( |
| 498 browser->tab_strip_model()->GetActiveWebContents())); | 479 browser->tab_strip_model()->GetActiveWebContents())); |
| 499 } | 480 } |
| 500 scoped_refptr<extensions::CrxInstaller> installer( | 481 scoped_refptr<extensions::CrxInstaller> installer( |
| 501 extensions::CrxInstaller::Create(service, std::move(install_ui))); | 482 extensions::CrxInstaller::Create(service, std::move(install_ui))); |
| 502 installer->set_expected_id(id); | 483 installer->set_expected_id(id); |
| 503 installer->set_creation_flags(creation_flags); | 484 installer->set_creation_flags(creation_flags); |
| 504 installer->set_install_source(install_source); | 485 installer->set_install_source(install_source); |
| 505 installer->set_install_immediately(install_immediately); | 486 installer->set_install_immediately(install_immediately); |
| 487 installer->set_allow_silent_install(grant_permissions); |
| 506 if (!installer->is_gallery_install()) { | 488 if (!installer->is_gallery_install()) { |
| 507 installer->set_off_store_install_allow_reason( | 489 installer->set_off_store_install_allow_reason( |
| 508 extensions::CrxInstaller::OffStoreInstallAllowedInTest); | 490 extensions::CrxInstaller::OffStoreInstallAllowedInTest); |
| 509 } | 491 } |
| 510 | 492 |
| 511 observer_->Watch( | 493 observer_->Watch( |
| 512 extensions::NOTIFICATION_CRX_INSTALLER_DONE, | 494 extensions::NOTIFICATION_CRX_INSTALLER_DONE, |
| 513 content::Source<extensions::CrxInstaller>(installer.get())); | 495 content::Source<extensions::CrxInstaller>(installer.get())); |
| 514 | 496 |
| 515 installer->InstallCrx(crx_path); | 497 installer->InstallCrx(crx_path); |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 656 return extensions::browsertest_util::ExecuteScriptInBackgroundPage( | 638 return extensions::browsertest_util::ExecuteScriptInBackgroundPage( |
| 657 profile(), extension_id, script); | 639 profile(), extension_id, script); |
| 658 } | 640 } |
| 659 | 641 |
| 660 bool ExtensionBrowserTest::ExecuteScriptInBackgroundPageNoWait( | 642 bool ExtensionBrowserTest::ExecuteScriptInBackgroundPageNoWait( |
| 661 const std::string& extension_id, | 643 const std::string& extension_id, |
| 662 const std::string& script) { | 644 const std::string& script) { |
| 663 return extensions::browsertest_util::ExecuteScriptInBackgroundPageNoWait( | 645 return extensions::browsertest_util::ExecuteScriptInBackgroundPageNoWait( |
| 664 profile(), extension_id, script); | 646 profile(), extension_id, script); |
| 665 } | 647 } |
| OLD | NEW |