| 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/apps/ephemeral_app_service.h" | 7 #include "chrome/browser/apps/ephemeral_app_service.h" |
| 8 #include "chrome/browser/extensions/extension_install_checker.h" | 8 #include "chrome/browser/extensions/extension_install_checker.h" |
| 9 #include "chrome/browser/extensions/extension_service.h" | 9 #include "chrome/browser/extensions/extension_service.h" |
| 10 #include "chrome/browser/extensions/install_tracker.h" | 10 #include "chrome/browser/extensions/install_tracker.h" |
| (...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 443 IN_PROC_BROWSER_TEST_F(EphemeralAppLauncherTest, BlockedByPolicy) { | 443 IN_PROC_BROWSER_TEST_F(EphemeralAppLauncherTest, BlockedByPolicy) { |
| 444 // Register a provider that blocks the installation of all apps. | 444 // Register a provider that blocks the installation of all apps. |
| 445 ManagementPolicyMock policy; | 445 ManagementPolicyMock policy; |
| 446 ExtensionSystem::Get(profile())->management_policy()->RegisterProvider( | 446 ExtensionSystem::Get(profile())->management_policy()->RegisterProvider( |
| 447 &policy); | 447 &policy); |
| 448 | 448 |
| 449 RunLaunchTest(kDefaultAppId, webstore_install::BLOCKED_BY_POLICY, false); | 449 RunLaunchTest(kDefaultAppId, webstore_install::BLOCKED_BY_POLICY, false); |
| 450 EXPECT_FALSE(GetInstalledExtension(kDefaultAppId)); | 450 EXPECT_FALSE(GetInstalledExtension(kDefaultAppId)); |
| 451 } | 451 } |
| 452 | 452 |
| 453 // The blacklist relies on safe-browsing database infrastructure. |
| 454 #if defined(SAFE_BROWSING_DB_LOCAL) |
| 453 // Verifies that an app blacklisted for malware is not installed ephemerally. | 455 // Verifies that an app blacklisted for malware is not installed ephemerally. |
| 454 IN_PROC_BROWSER_TEST_F(EphemeralAppLauncherTest, BlacklistedForMalware) { | 456 IN_PROC_BROWSER_TEST_F(EphemeralAppLauncherTest, BlacklistedForMalware) { |
| 455 // Mock a BLACKLISTED_MALWARE return status. | 457 // Mock a BLACKLISTED_MALWARE return status. |
| 456 extensions::TestBlacklist blacklist_tester( | 458 extensions::TestBlacklist blacklist_tester( |
| 457 extensions::Blacklist::Get(profile())); | 459 extensions::Blacklist::Get(profile())); |
| 458 blacklist_tester.SetBlacklistState( | 460 blacklist_tester.SetBlacklistState( |
| 459 kDefaultAppId, extensions::BLACKLISTED_MALWARE, false); | 461 kDefaultAppId, extensions::BLACKLISTED_MALWARE, false); |
| 460 | 462 |
| 461 RunLaunchTest(kDefaultAppId, webstore_install::BLACKLISTED, false); | 463 RunLaunchTest(kDefaultAppId, webstore_install::BLACKLISTED, false); |
| 462 EXPECT_FALSE(GetInstalledExtension(kDefaultAppId)); | 464 EXPECT_FALSE(GetInstalledExtension(kDefaultAppId)); |
| 463 } | 465 } |
| 464 | 466 |
| 465 // Verifies that an app with unknown blacklist status is installed ephemerally | 467 // Verifies that an app with unknown blacklist status is installed ephemerally |
| 466 // and launched. | 468 // and launched. |
| 467 IN_PROC_BROWSER_TEST_F(EphemeralAppLauncherTest, BlacklistStateUnknown) { | 469 IN_PROC_BROWSER_TEST_F(EphemeralAppLauncherTest, BlacklistStateUnknown) { |
| 468 // Mock a BLACKLISTED_MALWARE return status. | 470 // Mock a BLACKLISTED_MALWARE return status. |
| 469 extensions::TestBlacklist blacklist_tester( | 471 extensions::TestBlacklist blacklist_tester( |
| 470 extensions::Blacklist::Get(profile())); | 472 extensions::Blacklist::Get(profile())); |
| 471 blacklist_tester.SetBlacklistState( | 473 blacklist_tester.SetBlacklistState( |
| 472 kDefaultAppId, extensions::BLACKLISTED_UNKNOWN, false); | 474 kDefaultAppId, extensions::BLACKLISTED_UNKNOWN, false); |
| 473 | 475 |
| 474 RunLaunchTest(kDefaultAppId, webstore_install::SUCCESS, true); | 476 RunLaunchTest(kDefaultAppId, webstore_install::SUCCESS, true); |
| 475 ValidateAppInstalledEphemerally(kDefaultAppId); | 477 ValidateAppInstalledEphemerally(kDefaultAppId); |
| 476 } | 478 } |
| 479 #endif |
| 477 | 480 |
| 478 // Verifies that an app with unsupported requirements is not installed | 481 // Verifies that an app with unsupported requirements is not installed |
| 479 // ephemerally. | 482 // ephemerally. |
| 480 IN_PROC_BROWSER_TEST_F(EphemeralAppLauncherTest, UnsupportedRequirements) { | 483 IN_PROC_BROWSER_TEST_F(EphemeralAppLauncherTest, UnsupportedRequirements) { |
| 481 scoped_refptr<EphemeralAppLauncherForTest> launcher( | 484 scoped_refptr<EphemeralAppLauncherForTest> launcher( |
| 482 new EphemeralAppLauncherForTest(kDefaultAppId, profile())); | 485 new EphemeralAppLauncherForTest(kDefaultAppId, profile())); |
| 483 launcher->set_requirements_error("App has unsupported requirements"); | 486 launcher->set_requirements_error("App has unsupported requirements"); |
| 484 | 487 |
| 485 StartLauncherAndCheckResult( | 488 StartLauncherAndCheckResult( |
| 486 launcher.get(), webstore_install::REQUIREMENT_VIOLATIONS, false); | 489 launcher.get(), webstore_install::REQUIREMENT_VIOLATIONS, false); |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 559 } | 562 } |
| 560 | 563 |
| 561 // Verifies that a launch will fail if a duplicate launch is in progress. | 564 // Verifies that a launch will fail if a duplicate launch is in progress. |
| 562 IN_PROC_BROWSER_TEST_F(EphemeralAppLauncherTest, DuplicateLaunchInProgress) { | 565 IN_PROC_BROWSER_TEST_F(EphemeralAppLauncherTest, DuplicateLaunchInProgress) { |
| 563 extensions::ActiveInstallData install_data(kDefaultAppId); | 566 extensions::ActiveInstallData install_data(kDefaultAppId); |
| 564 install_data.is_ephemeral = true; | 567 install_data.is_ephemeral = true; |
| 565 InstallTracker::Get(profile())->AddActiveInstall(install_data); | 568 InstallTracker::Get(profile())->AddActiveInstall(install_data); |
| 566 | 569 |
| 567 RunLaunchTest(kDefaultAppId, webstore_install::LAUNCH_IN_PROGRESS, false); | 570 RunLaunchTest(kDefaultAppId, webstore_install::LAUNCH_IN_PROGRESS, false); |
| 568 } | 571 } |
| OLD | NEW |