| 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 <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| (...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 415 const std::string& id, | 415 const std::string& id, |
| 416 const base::FilePath& path, | 416 const base::FilePath& path, |
| 417 int expected_change) { | 417 int expected_change) { |
| 418 return InstallOrUpdateExtension(id, | 418 return InstallOrUpdateExtension(id, |
| 419 path, | 419 path, |
| 420 INSTALL_UI_TYPE_NONE, | 420 INSTALL_UI_TYPE_NONE, |
| 421 expected_change, | 421 expected_change, |
| 422 Manifest::INTERNAL, | 422 Manifest::INTERNAL, |
| 423 browser(), | 423 browser(), |
| 424 Extension::NO_FLAGS, | 424 Extension::NO_FLAGS, |
| 425 false, | |
| 426 false); | 425 false); |
| 427 } | 426 } |
| 428 | 427 |
| 429 const Extension* ExtensionBrowserTest::InstallExtensionFromWebstore( | 428 const Extension* ExtensionBrowserTest::InstallExtensionFromWebstore( |
| 430 const base::FilePath& path, | 429 const base::FilePath& path, |
| 431 int expected_change) { | 430 int expected_change) { |
| 432 return InstallOrUpdateExtension( | 431 return InstallOrUpdateExtension( |
| 433 std::string(), path, INSTALL_UI_TYPE_AUTO_CONFIRM, expected_change, | 432 std::string(), path, INSTALL_UI_TYPE_AUTO_CONFIRM, expected_change, |
| 434 Manifest::INTERNAL, browser(), Extension::FROM_WEBSTORE, true, false); | 433 Manifest::INTERNAL, browser(), Extension::FROM_WEBSTORE, true); |
| 435 } | 434 } |
| 436 | 435 |
| 437 const Extension* ExtensionBrowserTest::InstallOrUpdateExtension( | 436 const Extension* ExtensionBrowserTest::InstallOrUpdateExtension( |
| 438 const std::string& id, | 437 const std::string& id, |
| 439 const base::FilePath& path, | 438 const base::FilePath& path, |
| 440 InstallUIType ui_type, | 439 InstallUIType ui_type, |
| 441 int expected_change) { | 440 int expected_change) { |
| 442 return InstallOrUpdateExtension(id, | 441 return InstallOrUpdateExtension(id, |
| 443 path, | 442 path, |
| 444 ui_type, | 443 ui_type, |
| 445 expected_change, | 444 expected_change, |
| 446 Manifest::INTERNAL, | 445 Manifest::INTERNAL, |
| 447 browser(), | 446 browser(), |
| 448 Extension::NO_FLAGS, | 447 Extension::NO_FLAGS, |
| 449 true, | 448 true); |
| 450 false); | |
| 451 } | 449 } |
| 452 | 450 |
| 453 const Extension* ExtensionBrowserTest::InstallOrUpdateExtension( | 451 const Extension* ExtensionBrowserTest::InstallOrUpdateExtension( |
| 454 const std::string& id, | 452 const std::string& id, |
| 455 const base::FilePath& path, | 453 const base::FilePath& path, |
| 456 InstallUIType ui_type, | 454 InstallUIType ui_type, |
| 457 int expected_change, | 455 int expected_change, |
| 458 Browser* browser, | 456 Browser* browser, |
| 459 Extension::InitFromValueFlags creation_flags) { | 457 Extension::InitFromValueFlags creation_flags) { |
| 460 return InstallOrUpdateExtension(id, | 458 return InstallOrUpdateExtension(id, |
| 461 path, | 459 path, |
| 462 ui_type, | 460 ui_type, |
| 463 expected_change, | 461 expected_change, |
| 464 Manifest::INTERNAL, | 462 Manifest::INTERNAL, |
| 465 browser, | 463 browser, |
| 466 creation_flags, | 464 creation_flags, |
| 467 true, | 465 true); |
| 468 false); | |
| 469 } | 466 } |
| 470 | 467 |
| 471 const Extension* ExtensionBrowserTest::InstallOrUpdateExtension( | 468 const Extension* ExtensionBrowserTest::InstallOrUpdateExtension( |
| 472 const std::string& id, | 469 const std::string& id, |
| 473 const base::FilePath& path, | 470 const base::FilePath& path, |
| 474 InstallUIType ui_type, | 471 InstallUIType ui_type, |
| 475 int expected_change, | 472 int expected_change, |
| 476 Manifest::Location install_source) { | 473 Manifest::Location install_source) { |
| 477 return InstallOrUpdateExtension(id, | 474 return InstallOrUpdateExtension(id, |
| 478 path, | 475 path, |
| 479 ui_type, | 476 ui_type, |
| 480 expected_change, | 477 expected_change, |
| 481 install_source, | 478 install_source, |
| 482 browser(), | 479 browser(), |
| 483 Extension::NO_FLAGS, | 480 Extension::NO_FLAGS, |
| 484 true, | 481 true); |
| 485 false); | |
| 486 } | 482 } |
| 487 | 483 |
| 488 const Extension* ExtensionBrowserTest::InstallOrUpdateExtension( | 484 const Extension* ExtensionBrowserTest::InstallOrUpdateExtension( |
| 489 const std::string& id, | 485 const std::string& id, |
| 490 const base::FilePath& path, | 486 const base::FilePath& path, |
| 491 InstallUIType ui_type, | 487 InstallUIType ui_type, |
| 492 int expected_change, | 488 int expected_change, |
| 493 Manifest::Location install_source, | 489 Manifest::Location install_source, |
| 494 Browser* browser, | 490 Browser* browser, |
| 495 Extension::InitFromValueFlags creation_flags, | 491 Extension::InitFromValueFlags creation_flags, |
| 496 bool install_immediately, | 492 bool install_immediately) { |
| 497 bool is_ephemeral) { | |
| 498 ExtensionService* service = | 493 ExtensionService* service = |
| 499 extensions::ExtensionSystem::Get(profile())->extension_service(); | 494 extensions::ExtensionSystem::Get(profile())->extension_service(); |
| 500 ExtensionRegistry* registry = ExtensionRegistry::Get(profile()); | 495 ExtensionRegistry* registry = ExtensionRegistry::Get(profile()); |
| 501 service->set_show_extensions_prompts(false); | 496 service->set_show_extensions_prompts(false); |
| 502 size_t num_before = registry->enabled_extensions().size(); | 497 size_t num_before = registry->enabled_extensions().size(); |
| 503 | 498 |
| 504 { | 499 { |
| 505 scoped_ptr<ExtensionInstallPrompt> install_ui; | 500 scoped_ptr<ExtensionInstallPrompt> install_ui; |
| 506 if (ui_type == INSTALL_UI_TYPE_CANCEL) { | 501 if (ui_type == INSTALL_UI_TYPE_CANCEL) { |
| 507 install_ui.reset(new MockAbortExtensionInstallPrompt()); | 502 install_ui.reset(new MockAbortExtensionInstallPrompt()); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 521 } | 516 } |
| 522 if (crx_path.empty()) | 517 if (crx_path.empty()) |
| 523 return NULL; | 518 return NULL; |
| 524 | 519 |
| 525 scoped_refptr<extensions::CrxInstaller> installer( | 520 scoped_refptr<extensions::CrxInstaller> installer( |
| 526 extensions::CrxInstaller::Create(service, install_ui.Pass())); | 521 extensions::CrxInstaller::Create(service, install_ui.Pass())); |
| 527 installer->set_expected_id(id); | 522 installer->set_expected_id(id); |
| 528 installer->set_creation_flags(creation_flags); | 523 installer->set_creation_flags(creation_flags); |
| 529 installer->set_install_source(install_source); | 524 installer->set_install_source(install_source); |
| 530 installer->set_install_immediately(install_immediately); | 525 installer->set_install_immediately(install_immediately); |
| 531 installer->set_is_ephemeral(is_ephemeral); | |
| 532 if (!installer->is_gallery_install()) { | 526 if (!installer->is_gallery_install()) { |
| 533 installer->set_off_store_install_allow_reason( | 527 installer->set_off_store_install_allow_reason( |
| 534 extensions::CrxInstaller::OffStoreInstallAllowedInTest); | 528 extensions::CrxInstaller::OffStoreInstallAllowedInTest); |
| 535 } | 529 } |
| 536 | 530 |
| 537 observer_->Watch( | 531 observer_->Watch( |
| 538 extensions::NOTIFICATION_CRX_INSTALLER_DONE, | 532 extensions::NOTIFICATION_CRX_INSTALLER_DONE, |
| 539 content::Source<extensions::CrxInstaller>(installer.get())); | 533 content::Source<extensions::CrxInstaller>(installer.get())); |
| 540 | 534 |
| 541 installer->InstallCrx(crx_path); | 535 installer->InstallCrx(crx_path); |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 682 return extensions::browsertest_util::ExecuteScriptInBackgroundPage( | 676 return extensions::browsertest_util::ExecuteScriptInBackgroundPage( |
| 683 profile(), extension_id, script); | 677 profile(), extension_id, script); |
| 684 } | 678 } |
| 685 | 679 |
| 686 bool ExtensionBrowserTest::ExecuteScriptInBackgroundPageNoWait( | 680 bool ExtensionBrowserTest::ExecuteScriptInBackgroundPageNoWait( |
| 687 const std::string& extension_id, | 681 const std::string& extension_id, |
| 688 const std::string& script) { | 682 const std::string& script) { |
| 689 return extensions::browsertest_util::ExecuteScriptInBackgroundPageNoWait( | 683 return extensions::browsertest_util::ExecuteScriptInBackgroundPageNoWait( |
| 690 profile(), extension_id, script); | 684 profile(), extension_id, script); |
| 691 } | 685 } |
| OLD | NEW |