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/test_blacklist.h" | 10 #include "chrome/browser/extensions/test_blacklist.h" |
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
419 IN_PROC_BROWSER_TEST_F(EphemeralAppLauncherTest, BlockedByPolicy) { | 419 IN_PROC_BROWSER_TEST_F(EphemeralAppLauncherTest, BlockedByPolicy) { |
420 // Register a provider that blocks the installation of all apps. | 420 // Register a provider that blocks the installation of all apps. |
421 ManagementPolicyMock policy; | 421 ManagementPolicyMock policy; |
422 ExtensionSystem::Get(profile())->management_policy()->RegisterProvider( | 422 ExtensionSystem::Get(profile())->management_policy()->RegisterProvider( |
423 &policy); | 423 &policy); |
424 | 424 |
425 RunLaunchTest(kDefaultAppId, webstore_install::BLOCKED_BY_POLICY, false); | 425 RunLaunchTest(kDefaultAppId, webstore_install::BLOCKED_BY_POLICY, false); |
426 EXPECT_FALSE(GetInstalledExtension(kDefaultAppId)); | 426 EXPECT_FALSE(GetInstalledExtension(kDefaultAppId)); |
427 } | 427 } |
428 | 428 |
| 429 // The blacklist relies on safe-browsing database infrastructure. |
| 430 #if defined(SAFE_BROWSING_DATABASE) |
429 // Verifies that an app blacklisted for malware is not installed ephemerally. | 431 // Verifies that an app blacklisted for malware is not installed ephemerally. |
430 IN_PROC_BROWSER_TEST_F(EphemeralAppLauncherTest, BlacklistedForMalware) { | 432 IN_PROC_BROWSER_TEST_F(EphemeralAppLauncherTest, BlacklistedForMalware) { |
431 // Mock a BLACKLISTED_MALWARE return status. | 433 // Mock a BLACKLISTED_MALWARE return status. |
432 extensions::TestBlacklist blacklist_tester( | 434 extensions::TestBlacklist blacklist_tester( |
433 ExtensionSystem::Get(profile())->blacklist()); | 435 ExtensionSystem::Get(profile())->blacklist()); |
434 blacklist_tester.SetBlacklistState( | 436 blacklist_tester.SetBlacklistState( |
435 kDefaultAppId, extensions::BLACKLISTED_MALWARE, false); | 437 kDefaultAppId, extensions::BLACKLISTED_MALWARE, false); |
436 | 438 |
437 RunLaunchTest(kDefaultAppId, webstore_install::BLACKLISTED, false); | 439 RunLaunchTest(kDefaultAppId, webstore_install::BLACKLISTED, false); |
438 EXPECT_FALSE(GetInstalledExtension(kDefaultAppId)); | 440 EXPECT_FALSE(GetInstalledExtension(kDefaultAppId)); |
439 } | 441 } |
440 | 442 |
441 // Verifies that an app with unknown blacklist status is installed ephemerally | 443 // Verifies that an app with unknown blacklist status is installed ephemerally |
442 // and launched. | 444 // and launched. |
443 IN_PROC_BROWSER_TEST_F(EphemeralAppLauncherTest, BlacklistStateUnknown) { | 445 IN_PROC_BROWSER_TEST_F(EphemeralAppLauncherTest, BlacklistStateUnknown) { |
444 // Mock a BLACKLISTED_MALWARE return status. | 446 // Mock a BLACKLISTED_MALWARE return status. |
445 extensions::TestBlacklist blacklist_tester( | 447 extensions::TestBlacklist blacklist_tester( |
446 ExtensionSystem::Get(profile())->blacklist()); | 448 ExtensionSystem::Get(profile())->blacklist()); |
447 blacklist_tester.SetBlacklistState( | 449 blacklist_tester.SetBlacklistState( |
448 kDefaultAppId, extensions::BLACKLISTED_UNKNOWN, false); | 450 kDefaultAppId, extensions::BLACKLISTED_UNKNOWN, false); |
449 | 451 |
450 RunLaunchTest(kDefaultAppId, webstore_install::SUCCESS, true); | 452 RunLaunchTest(kDefaultAppId, webstore_install::SUCCESS, true); |
451 ValidateAppInstalledEphemerally(kDefaultAppId); | 453 ValidateAppInstalledEphemerally(kDefaultAppId); |
452 } | 454 } |
| 455 #endif |
453 | 456 |
454 // Verifies that an app with unsupported requirements is not installed | 457 // Verifies that an app with unsupported requirements is not installed |
455 // ephemerally. | 458 // ephemerally. |
456 IN_PROC_BROWSER_TEST_F(EphemeralAppLauncherTest, UnsupportedRequirements) { | 459 IN_PROC_BROWSER_TEST_F(EphemeralAppLauncherTest, UnsupportedRequirements) { |
457 scoped_refptr<EphemeralAppLauncherForTest> launcher( | 460 scoped_refptr<EphemeralAppLauncherForTest> launcher( |
458 new EphemeralAppLauncherForTest(kDefaultAppId, profile())); | 461 new EphemeralAppLauncherForTest(kDefaultAppId, profile())); |
459 launcher->set_requirements_error("App has unsupported requirements"); | 462 launcher->set_requirements_error("App has unsupported requirements"); |
460 | 463 |
461 StartLauncherAndCheckResult( | 464 StartLauncherAndCheckResult( |
462 launcher.get(), webstore_install::REQUIREMENT_VIOLATIONS, false); | 465 launcher.get(), webstore_install::REQUIREMENT_VIOLATIONS, false); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
512 // Verifies that an installed app with unsupported requirements cannot be | 515 // Verifies that an installed app with unsupported requirements cannot be |
513 // launched. | 516 // launched. |
514 IN_PROC_BROWSER_TEST_F(EphemeralAppLauncherTest, | 517 IN_PROC_BROWSER_TEST_F(EphemeralAppLauncherTest, |
515 LaunchAppWithUnsupportedRequirements) { | 518 LaunchAppWithUnsupportedRequirements) { |
516 const Extension* app = InstallAndDisableApp( | 519 const Extension* app = InstallAndDisableApp( |
517 kDefaultAppTestPath, Extension::DISABLE_UNSUPPORTED_REQUIREMENT); | 520 kDefaultAppTestPath, Extension::DISABLE_UNSUPPORTED_REQUIREMENT); |
518 ASSERT_TRUE(app); | 521 ASSERT_TRUE(app); |
519 | 522 |
520 RunLaunchTest(app->id(), webstore_install::REQUIREMENT_VIOLATIONS, false); | 523 RunLaunchTest(app->id(), webstore_install::REQUIREMENT_VIOLATIONS, false); |
521 } | 524 } |
OLD | NEW |