| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "base/message_loop/message_loop_proxy.h" | 5 #include "base/message_loop/message_loop_proxy.h" |
| 6 #include "chrome/browser/apps/ephemeral_app_launcher.h" | 6 #include "chrome/browser/apps/ephemeral_app_launcher.h" |
| 7 #include "chrome/browser/extensions/extension_install_checker.h" | 7 #include "chrome/browser/extensions/extension_install_checker.h" |
| 8 #include "chrome/browser/extensions/extension_service.h" | 8 #include "chrome/browser/extensions/extension_service.h" |
| 9 #include "chrome/browser/extensions/extension_test_message_listener.h" | 9 #include "chrome/browser/extensions/extension_test_message_listener.h" |
| 10 #include "chrome/browser/extensions/install_tracker.h" | 10 #include "chrome/browser/extensions/install_tracker.h" |
| (...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 428 IN_PROC_BROWSER_TEST_F(EphemeralAppLauncherTest, BlockedByPolicy) { | 428 IN_PROC_BROWSER_TEST_F(EphemeralAppLauncherTest, BlockedByPolicy) { |
| 429 // Register a provider that blocks the installation of all apps. | 429 // Register a provider that blocks the installation of all apps. |
| 430 ManagementPolicyMock policy; | 430 ManagementPolicyMock policy; |
| 431 ExtensionSystem::Get(profile())->management_policy()->RegisterProvider( | 431 ExtensionSystem::Get(profile())->management_policy()->RegisterProvider( |
| 432 &policy); | 432 &policy); |
| 433 | 433 |
| 434 RunLaunchTest(kDefaultAppId, webstore_install::BLOCKED_BY_POLICY, false); | 434 RunLaunchTest(kDefaultAppId, webstore_install::BLOCKED_BY_POLICY, false); |
| 435 EXPECT_FALSE(GetInstalledExtension(kDefaultAppId)); | 435 EXPECT_FALSE(GetInstalledExtension(kDefaultAppId)); |
| 436 } | 436 } |
| 437 | 437 |
| 438 // The blacklist relies on safe-browsing database infrastructure. |
| 439 #if defined(SAFE_BROWSING_DATABASE) |
| 438 // Verifies that an app blacklisted for malware is not installed ephemerally. | 440 // Verifies that an app blacklisted for malware is not installed ephemerally. |
| 439 IN_PROC_BROWSER_TEST_F(EphemeralAppLauncherTest, BlacklistedForMalware) { | 441 IN_PROC_BROWSER_TEST_F(EphemeralAppLauncherTest, BlacklistedForMalware) { |
| 440 // Mock a BLACKLISTED_MALWARE return status. | 442 // Mock a BLACKLISTED_MALWARE return status. |
| 441 extensions::TestBlacklist blacklist_tester( | 443 extensions::TestBlacklist blacklist_tester( |
| 442 ExtensionSystem::Get(profile())->blacklist()); | 444 ExtensionSystem::Get(profile())->blacklist()); |
| 443 blacklist_tester.SetBlacklistState( | 445 blacklist_tester.SetBlacklistState( |
| 444 kDefaultAppId, extensions::BLACKLISTED_MALWARE, false); | 446 kDefaultAppId, extensions::BLACKLISTED_MALWARE, false); |
| 445 | 447 |
| 446 RunLaunchTest(kDefaultAppId, webstore_install::BLACKLISTED, false); | 448 RunLaunchTest(kDefaultAppId, webstore_install::BLACKLISTED, false); |
| 447 EXPECT_FALSE(GetInstalledExtension(kDefaultAppId)); | 449 EXPECT_FALSE(GetInstalledExtension(kDefaultAppId)); |
| 448 } | 450 } |
| 449 | 451 |
| 450 // Verifies that an app with unknown blacklist status is installed ephemerally | 452 // Verifies that an app with unknown blacklist status is installed ephemerally |
| 451 // and launched. | 453 // and launched. |
| 452 IN_PROC_BROWSER_TEST_F(EphemeralAppLauncherTest, BlacklistStateUnknown) { | 454 IN_PROC_BROWSER_TEST_F(EphemeralAppLauncherTest, BlacklistStateUnknown) { |
| 453 // Mock a BLACKLISTED_MALWARE return status. | 455 // Mock a BLACKLISTED_MALWARE return status. |
| 454 extensions::TestBlacklist blacklist_tester( | 456 extensions::TestBlacklist blacklist_tester( |
| 455 ExtensionSystem::Get(profile())->blacklist()); | 457 ExtensionSystem::Get(profile())->blacklist()); |
| 456 blacklist_tester.SetBlacklistState( | 458 blacklist_tester.SetBlacklistState( |
| 457 kDefaultAppId, extensions::BLACKLISTED_UNKNOWN, false); | 459 kDefaultAppId, extensions::BLACKLISTED_UNKNOWN, false); |
| 458 | 460 |
| 459 RunLaunchTest(kDefaultAppId, webstore_install::SUCCESS, true); | 461 RunLaunchTest(kDefaultAppId, webstore_install::SUCCESS, true); |
| 460 ValidateAppInstalledEphemerally(kDefaultAppId); | 462 ValidateAppInstalledEphemerally(kDefaultAppId); |
| 461 } | 463 } |
| 464 #endif |
| 462 | 465 |
| 463 // Verifies that an app with unsupported requirements is not installed | 466 // Verifies that an app with unsupported requirements is not installed |
| 464 // ephemerally. | 467 // ephemerally. |
| 465 IN_PROC_BROWSER_TEST_F(EphemeralAppLauncherTest, UnsupportedRequirements) { | 468 IN_PROC_BROWSER_TEST_F(EphemeralAppLauncherTest, UnsupportedRequirements) { |
| 466 scoped_refptr<EphemeralAppLauncherForTest> launcher( | 469 scoped_refptr<EphemeralAppLauncherForTest> launcher( |
| 467 new EphemeralAppLauncherForTest(kDefaultAppId, profile())); | 470 new EphemeralAppLauncherForTest(kDefaultAppId, profile())); |
| 468 launcher->set_requirements_error("App has unsupported requirements"); | 471 launcher->set_requirements_error("App has unsupported requirements"); |
| 469 | 472 |
| 470 StartLauncherAndCheckResult( | 473 StartLauncherAndCheckResult( |
| 471 launcher.get(), webstore_install::REQUIREMENT_VIOLATIONS, false); | 474 launcher.get(), webstore_install::REQUIREMENT_VIOLATIONS, false); |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 538 } | 541 } |
| 539 | 542 |
| 540 // Verifies that a launch will fail if a duplicate launch is in progress. | 543 // Verifies that a launch will fail if a duplicate launch is in progress. |
| 541 IN_PROC_BROWSER_TEST_F(EphemeralAppLauncherTest, DuplicateLaunchInProgress) { | 544 IN_PROC_BROWSER_TEST_F(EphemeralAppLauncherTest, DuplicateLaunchInProgress) { |
| 542 extensions::ActiveInstallData install_data(kDefaultAppId); | 545 extensions::ActiveInstallData install_data(kDefaultAppId); |
| 543 install_data.is_ephemeral = true; | 546 install_data.is_ephemeral = true; |
| 544 InstallTracker::Get(profile())->AddActiveInstall(install_data); | 547 InstallTracker::Get(profile())->AddActiveInstall(install_data); |
| 545 | 548 |
| 546 RunLaunchTest(kDefaultAppId, webstore_install::LAUNCH_IN_PROGRESS, false); | 549 RunLaunchTest(kDefaultAppId, webstore_install::LAUNCH_IN_PROGRESS, false); |
| 547 } | 550 } |
| OLD | NEW |