| 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/file_util.h" | 10 #include "base/file_util.h" |
| (...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 369 const std::string& id, | 369 const std::string& id, |
| 370 const base::FilePath& path, | 370 const base::FilePath& path, |
| 371 int expected_change) { | 371 int expected_change) { |
| 372 return InstallOrUpdateExtension(id, | 372 return InstallOrUpdateExtension(id, |
| 373 path, | 373 path, |
| 374 INSTALL_UI_TYPE_NONE, | 374 INSTALL_UI_TYPE_NONE, |
| 375 expected_change, | 375 expected_change, |
| 376 Manifest::INTERNAL, | 376 Manifest::INTERNAL, |
| 377 browser(), | 377 browser(), |
| 378 Extension::NO_FLAGS, | 378 Extension::NO_FLAGS, |
| 379 true, | 379 false, |
| 380 false); | 380 false); |
| 381 } | 381 } |
| 382 | 382 |
| 383 const Extension* ExtensionBrowserTest::InstallExtensionFromWebstore( | 383 const Extension* ExtensionBrowserTest::InstallExtensionFromWebstore( |
| 384 const base::FilePath& path, | 384 const base::FilePath& path, |
| 385 int expected_change) { | 385 int expected_change) { |
| 386 return InstallOrUpdateExtension(std::string(), | 386 return InstallOrUpdateExtension(std::string(), |
| 387 path, | 387 path, |
| 388 INSTALL_UI_TYPE_NONE, | 388 INSTALL_UI_TYPE_NONE, |
| 389 expected_change, | 389 expected_change, |
| 390 Manifest::INTERNAL, | 390 Manifest::INTERNAL, |
| 391 browser(), | 391 browser(), |
| 392 Extension::FROM_WEBSTORE, | 392 Extension::FROM_WEBSTORE, |
| 393 false, | 393 true, |
| 394 false); | 394 false); |
| 395 } | 395 } |
| 396 | 396 |
| 397 const Extension* ExtensionBrowserTest::InstallOrUpdateExtension( | 397 const Extension* ExtensionBrowserTest::InstallOrUpdateExtension( |
| 398 const std::string& id, | 398 const std::string& id, |
| 399 const base::FilePath& path, | 399 const base::FilePath& path, |
| 400 InstallUIType ui_type, | 400 InstallUIType ui_type, |
| 401 int expected_change) { | 401 int expected_change) { |
| 402 return InstallOrUpdateExtension(id, path, ui_type, expected_change, | 402 return InstallOrUpdateExtension(id, |
| 403 Manifest::INTERNAL, browser(), Extension::NO_FLAGS, false, false); | 403 path, |
| 404 ui_type, |
| 405 expected_change, |
| 406 Manifest::INTERNAL, |
| 407 browser(), |
| 408 Extension::NO_FLAGS, |
| 409 true, |
| 410 false); |
| 404 } | 411 } |
| 405 | 412 |
| 406 const Extension* ExtensionBrowserTest::InstallOrUpdateExtension( | 413 const Extension* ExtensionBrowserTest::InstallOrUpdateExtension( |
| 407 const std::string& id, | 414 const std::string& id, |
| 408 const base::FilePath& path, | 415 const base::FilePath& path, |
| 409 InstallUIType ui_type, | 416 InstallUIType ui_type, |
| 410 int expected_change, | 417 int expected_change, |
| 411 Browser* browser, | 418 Browser* browser, |
| 412 Extension::InitFromValueFlags creation_flags) { | 419 Extension::InitFromValueFlags creation_flags) { |
| 413 return InstallOrUpdateExtension(id, path, ui_type, expected_change, | 420 return InstallOrUpdateExtension(id, |
| 414 Manifest::INTERNAL, browser, creation_flags, | 421 path, |
| 415 false, false); | 422 ui_type, |
| 423 expected_change, |
| 424 Manifest::INTERNAL, |
| 425 browser, |
| 426 creation_flags, |
| 427 true, |
| 428 false); |
| 416 } | 429 } |
| 417 | 430 |
| 418 const Extension* ExtensionBrowserTest::InstallOrUpdateExtension( | 431 const Extension* ExtensionBrowserTest::InstallOrUpdateExtension( |
| 419 const std::string& id, | 432 const std::string& id, |
| 420 const base::FilePath& path, | 433 const base::FilePath& path, |
| 421 InstallUIType ui_type, | 434 InstallUIType ui_type, |
| 422 int expected_change, | 435 int expected_change, |
| 423 Manifest::Location install_source) { | 436 Manifest::Location install_source) { |
| 424 return InstallOrUpdateExtension(id, path, ui_type, expected_change, | 437 return InstallOrUpdateExtension(id, |
| 425 install_source, browser(), Extension::NO_FLAGS, false, false); | 438 path, |
| 439 ui_type, |
| 440 expected_change, |
| 441 install_source, |
| 442 browser(), |
| 443 Extension::NO_FLAGS, |
| 444 true, |
| 445 false); |
| 426 } | 446 } |
| 427 | 447 |
| 428 const Extension* ExtensionBrowserTest::InstallOrUpdateExtension( | 448 const Extension* ExtensionBrowserTest::InstallOrUpdateExtension( |
| 429 const std::string& id, | 449 const std::string& id, |
| 430 const base::FilePath& path, | 450 const base::FilePath& path, |
| 431 InstallUIType ui_type, | 451 InstallUIType ui_type, |
| 432 int expected_change, | 452 int expected_change, |
| 433 Manifest::Location install_source, | 453 Manifest::Location install_source, |
| 434 Browser* browser, | 454 Browser* browser, |
| 435 Extension::InitFromValueFlags creation_flags, | 455 Extension::InitFromValueFlags creation_flags, |
| 436 bool wait_for_idle, | 456 bool install_immediately, |
| 437 bool is_ephemeral) { | 457 bool is_ephemeral) { |
| 438 ExtensionService* service = profile()->GetExtensionService(); | 458 ExtensionService* service = profile()->GetExtensionService(); |
| 439 service->set_show_extensions_prompts(false); | 459 service->set_show_extensions_prompts(false); |
| 440 size_t num_before = service->extensions()->size(); | 460 size_t num_before = service->extensions()->size(); |
| 441 | 461 |
| 442 { | 462 { |
| 443 scoped_ptr<ExtensionInstallPrompt> install_ui; | 463 scoped_ptr<ExtensionInstallPrompt> install_ui; |
| 444 if (ui_type == INSTALL_UI_TYPE_CANCEL) { | 464 if (ui_type == INSTALL_UI_TYPE_CANCEL) { |
| 445 install_ui.reset(new MockAbortExtensionInstallPrompt()); | 465 install_ui.reset(new MockAbortExtensionInstallPrompt()); |
| 446 } else if (ui_type == INSTALL_UI_TYPE_NORMAL) { | 466 } else if (ui_type == INSTALL_UI_TYPE_NORMAL) { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 458 crx_path = PackExtension(path); | 478 crx_path = PackExtension(path); |
| 459 } | 479 } |
| 460 if (crx_path.empty()) | 480 if (crx_path.empty()) |
| 461 return NULL; | 481 return NULL; |
| 462 | 482 |
| 463 scoped_refptr<extensions::CrxInstaller> installer( | 483 scoped_refptr<extensions::CrxInstaller> installer( |
| 464 extensions::CrxInstaller::Create(service, install_ui.Pass())); | 484 extensions::CrxInstaller::Create(service, install_ui.Pass())); |
| 465 installer->set_expected_id(id); | 485 installer->set_expected_id(id); |
| 466 installer->set_creation_flags(creation_flags); | 486 installer->set_creation_flags(creation_flags); |
| 467 installer->set_install_source(install_source); | 487 installer->set_install_source(install_source); |
| 468 installer->set_install_wait_for_idle(wait_for_idle); | 488 installer->set_install_immediately(install_immediately); |
| 469 installer->set_is_ephemeral(is_ephemeral); | 489 installer->set_is_ephemeral(is_ephemeral); |
| 470 if (!installer->is_gallery_install()) { | 490 if (!installer->is_gallery_install()) { |
| 471 installer->set_off_store_install_allow_reason( | 491 installer->set_off_store_install_allow_reason( |
| 472 extensions::CrxInstaller::OffStoreInstallAllowedInTest); | 492 extensions::CrxInstaller::OffStoreInstallAllowedInTest); |
| 473 } | 493 } |
| 474 | 494 |
| 475 observer_->Watch( | 495 observer_->Watch( |
| 476 chrome::NOTIFICATION_CRX_INSTALLER_DONE, | 496 chrome::NOTIFICATION_CRX_INSTALLER_DONE, |
| 477 content::Source<extensions::CrxInstaller>(installer.get())); | 497 content::Source<extensions::CrxInstaller>(installer.get())); |
| 478 | 498 |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 620 return extensions::browsertest_util::ExecuteScriptInBackgroundPage( | 640 return extensions::browsertest_util::ExecuteScriptInBackgroundPage( |
| 621 profile(), extension_id, script); | 641 profile(), extension_id, script); |
| 622 } | 642 } |
| 623 | 643 |
| 624 bool ExtensionBrowserTest::ExecuteScriptInBackgroundPageNoWait( | 644 bool ExtensionBrowserTest::ExecuteScriptInBackgroundPageNoWait( |
| 625 const std::string& extension_id, | 645 const std::string& extension_id, |
| 626 const std::string& script) { | 646 const std::string& script) { |
| 627 return extensions::browsertest_util::ExecuteScriptInBackgroundPageNoWait( | 647 return extensions::browsertest_util::ExecuteScriptInBackgroundPageNoWait( |
| 628 profile(), extension_id, script); | 648 profile(), extension_id, script); |
| 629 } | 649 } |
| OLD | NEW |