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 true, |
| 380 false); |
380 } | 381 } |
381 | 382 |
382 const Extension* ExtensionBrowserTest::InstallExtensionFromWebstore( | 383 const Extension* ExtensionBrowserTest::InstallExtensionFromWebstore( |
383 const base::FilePath& path, | 384 const base::FilePath& path, |
384 int expected_change) { | 385 int expected_change) { |
385 return InstallOrUpdateExtension(std::string(), | 386 return InstallOrUpdateExtension(std::string(), |
386 path, | 387 path, |
387 INSTALL_UI_TYPE_NONE, | 388 INSTALL_UI_TYPE_NONE, |
388 expected_change, | 389 expected_change, |
389 Manifest::INTERNAL, | 390 Manifest::INTERNAL, |
390 browser(), | 391 browser(), |
391 Extension::FROM_WEBSTORE, | 392 Extension::FROM_WEBSTORE, |
| 393 false, |
392 false); | 394 false); |
393 } | 395 } |
394 | 396 |
395 const Extension* ExtensionBrowserTest::InstallOrUpdateExtension( | 397 const Extension* ExtensionBrowserTest::InstallOrUpdateExtension( |
396 const std::string& id, | 398 const std::string& id, |
397 const base::FilePath& path, | 399 const base::FilePath& path, |
398 InstallUIType ui_type, | 400 InstallUIType ui_type, |
399 int expected_change) { | 401 int expected_change) { |
400 return InstallOrUpdateExtension(id, path, ui_type, expected_change, | 402 return InstallOrUpdateExtension(id, path, ui_type, expected_change, |
401 Manifest::INTERNAL, browser(), Extension::NO_FLAGS, false); | 403 Manifest::INTERNAL, browser(), Extension::NO_FLAGS, false, false); |
402 } | 404 } |
403 | 405 |
404 const Extension* ExtensionBrowserTest::InstallOrUpdateExtension( | 406 const Extension* ExtensionBrowserTest::InstallOrUpdateExtension( |
405 const std::string& id, | 407 const std::string& id, |
406 const base::FilePath& path, | 408 const base::FilePath& path, |
407 InstallUIType ui_type, | 409 InstallUIType ui_type, |
408 int expected_change, | 410 int expected_change, |
409 Browser* browser, | 411 Browser* browser, |
410 Extension::InitFromValueFlags creation_flags) { | 412 Extension::InitFromValueFlags creation_flags) { |
411 return InstallOrUpdateExtension(id, path, ui_type, expected_change, | 413 return InstallOrUpdateExtension(id, path, ui_type, expected_change, |
412 Manifest::INTERNAL, browser, creation_flags, | 414 Manifest::INTERNAL, browser, creation_flags, |
413 false); | 415 false, false); |
414 } | 416 } |
415 | 417 |
416 const Extension* ExtensionBrowserTest::InstallOrUpdateExtension( | 418 const Extension* ExtensionBrowserTest::InstallOrUpdateExtension( |
417 const std::string& id, | 419 const std::string& id, |
418 const base::FilePath& path, | 420 const base::FilePath& path, |
419 InstallUIType ui_type, | 421 InstallUIType ui_type, |
420 int expected_change, | 422 int expected_change, |
421 Manifest::Location install_source) { | 423 Manifest::Location install_source) { |
422 return InstallOrUpdateExtension(id, path, ui_type, expected_change, | 424 return InstallOrUpdateExtension(id, path, ui_type, expected_change, |
423 install_source, browser(), Extension::NO_FLAGS, false); | 425 install_source, browser(), Extension::NO_FLAGS, false, false); |
424 } | 426 } |
425 | 427 |
426 const Extension* ExtensionBrowserTest::InstallOrUpdateExtension( | 428 const Extension* ExtensionBrowserTest::InstallOrUpdateExtension( |
427 const std::string& id, | 429 const std::string& id, |
428 const base::FilePath& path, | 430 const base::FilePath& path, |
429 InstallUIType ui_type, | 431 InstallUIType ui_type, |
430 int expected_change, | 432 int expected_change, |
431 Manifest::Location install_source, | 433 Manifest::Location install_source, |
432 Browser* browser, | 434 Browser* browser, |
433 Extension::InitFromValueFlags creation_flags, | 435 Extension::InitFromValueFlags creation_flags, |
434 bool wait_for_idle) { | 436 bool wait_for_idle, |
| 437 bool is_ephemeral) { |
435 ExtensionService* service = profile()->GetExtensionService(); | 438 ExtensionService* service = profile()->GetExtensionService(); |
436 service->set_show_extensions_prompts(false); | 439 service->set_show_extensions_prompts(false); |
437 size_t num_before = service->extensions()->size(); | 440 size_t num_before = service->extensions()->size(); |
438 | 441 |
439 { | 442 { |
440 scoped_ptr<ExtensionInstallPrompt> install_ui; | 443 scoped_ptr<ExtensionInstallPrompt> install_ui; |
441 if (ui_type == INSTALL_UI_TYPE_CANCEL) { | 444 if (ui_type == INSTALL_UI_TYPE_CANCEL) { |
442 install_ui.reset(new MockAbortExtensionInstallPrompt()); | 445 install_ui.reset(new MockAbortExtensionInstallPrompt()); |
443 } else if (ui_type == INSTALL_UI_TYPE_NORMAL) { | 446 } else if (ui_type == INSTALL_UI_TYPE_NORMAL) { |
444 install_ui.reset(new ExtensionInstallPrompt( | 447 install_ui.reset(new ExtensionInstallPrompt( |
(...skipping 11 matching lines...) Expand all Loading... |
456 } | 459 } |
457 if (crx_path.empty()) | 460 if (crx_path.empty()) |
458 return NULL; | 461 return NULL; |
459 | 462 |
460 scoped_refptr<extensions::CrxInstaller> installer( | 463 scoped_refptr<extensions::CrxInstaller> installer( |
461 extensions::CrxInstaller::Create(service, install_ui.Pass())); | 464 extensions::CrxInstaller::Create(service, install_ui.Pass())); |
462 installer->set_expected_id(id); | 465 installer->set_expected_id(id); |
463 installer->set_creation_flags(creation_flags); | 466 installer->set_creation_flags(creation_flags); |
464 installer->set_install_source(install_source); | 467 installer->set_install_source(install_source); |
465 installer->set_install_wait_for_idle(wait_for_idle); | 468 installer->set_install_wait_for_idle(wait_for_idle); |
| 469 installer->set_is_ephemeral(is_ephemeral); |
466 if (!installer->is_gallery_install()) { | 470 if (!installer->is_gallery_install()) { |
467 installer->set_off_store_install_allow_reason( | 471 installer->set_off_store_install_allow_reason( |
468 extensions::CrxInstaller::OffStoreInstallAllowedInTest); | 472 extensions::CrxInstaller::OffStoreInstallAllowedInTest); |
469 } | 473 } |
470 | 474 |
471 observer_->Watch( | 475 observer_->Watch( |
472 chrome::NOTIFICATION_CRX_INSTALLER_DONE, | 476 chrome::NOTIFICATION_CRX_INSTALLER_DONE, |
473 content::Source<extensions::CrxInstaller>(installer.get())); | 477 content::Source<extensions::CrxInstaller>(installer.get())); |
474 | 478 |
475 installer->InstallCrx(crx_path); | 479 installer->InstallCrx(crx_path); |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
616 return extensions::browsertest_util::ExecuteScriptInBackgroundPage( | 620 return extensions::browsertest_util::ExecuteScriptInBackgroundPage( |
617 profile(), extension_id, script); | 621 profile(), extension_id, script); |
618 } | 622 } |
619 | 623 |
620 bool ExtensionBrowserTest::ExecuteScriptInBackgroundPageNoWait( | 624 bool ExtensionBrowserTest::ExecuteScriptInBackgroundPageNoWait( |
621 const std::string& extension_id, | 625 const std::string& extension_id, |
622 const std::string& script) { | 626 const std::string& script) { |
623 return extensions::browsertest_util::ExecuteScriptInBackgroundPageNoWait( | 627 return extensions::browsertest_util::ExecuteScriptInBackgroundPageNoWait( |
624 profile(), extension_id, script); | 628 profile(), extension_id, script); |
625 } | 629 } |
OLD | NEW |