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" |
11 #include "chrome/browser/extensions/test_blacklist.h" | 11 #include "chrome/browser/extensions/test_blacklist.h" |
12 #include "chrome/browser/extensions/webstore_installer_test.h" | 12 #include "chrome/browser/extensions/webstore_installer_test.h" |
13 #include "chrome/browser/ui/browser_finder.h" | 13 #include "chrome/browser/ui/browser_finder.h" |
14 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 14 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
15 #include "chrome/common/chrome_switches.h" | 15 #include "chrome/common/chrome_switches.h" |
16 #include "content/public/browser/web_contents.h" | 16 #include "content/public/browser/web_contents.h" |
17 #include "content/public/test/test_utils.h" | 17 #include "content/public/test/test_utils.h" |
18 #include "extensions/browser/extension_prefs.h" | 18 #include "extensions/browser/extension_prefs.h" |
19 #include "extensions/browser/extension_registry.h" | 19 #include "extensions/browser/extension_registry.h" |
20 #include "extensions/browser/extension_system.h" | 20 #include "extensions/browser/extension_system.h" |
21 #include "extensions/browser/extension_util.h" | 21 #include "extensions/browser/extension_util.h" |
22 #include "extensions/browser/management_policy.h" | 22 #include "extensions/browser/management_policy.h" |
23 #include "extensions/browser/process_manager.h" | 23 #include "extensions/browser/process_manager.h" |
| 24 #include "extensions/browser/test_extension_registry_observer.h" |
24 #include "extensions/test/extension_test_message_listener.h" | 25 #include "extensions/test/extension_test_message_listener.h" |
25 | 26 |
26 using extensions::Extension; | 27 using extensions::Extension; |
27 using extensions::ExtensionPrefs; | 28 using extensions::ExtensionPrefs; |
28 using extensions::ExtensionRegistry; | 29 using extensions::ExtensionRegistry; |
29 using extensions::ExtensionSystem; | 30 using extensions::ExtensionSystem; |
30 using extensions::InstallTracker; | 31 using extensions::InstallTracker; |
31 namespace webstore_install = extensions::webstore_install; | 32 namespace webstore_install = extensions::webstore_install; |
32 | 33 |
33 namespace { | 34 namespace { |
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 IN_PROC_BROWSER_TEST_F(EphemeralAppLauncherTestDisabled, FeatureDisabled) { | 315 IN_PROC_BROWSER_TEST_F(EphemeralAppLauncherTestDisabled, FeatureDisabled) { |
315 RunLaunchTest( | 316 RunLaunchTest( |
316 kDefaultAppCrxFilename, webstore_install::LAUNCH_FEATURE_DISABLED, false); | 317 kDefaultAppCrxFilename, webstore_install::LAUNCH_FEATURE_DISABLED, false); |
317 EXPECT_FALSE(GetInstalledExtension(kDefaultAppId)); | 318 EXPECT_FALSE(GetInstalledExtension(kDefaultAppId)); |
318 } | 319 } |
319 | 320 |
320 // Verifies that an app with no permission warnings will be installed | 321 // Verifies that an app with no permission warnings will be installed |
321 // ephemerally and launched without prompting the user. | 322 // ephemerally and launched without prompting the user. |
322 IN_PROC_BROWSER_TEST_F(EphemeralAppLauncherTest, | 323 IN_PROC_BROWSER_TEST_F(EphemeralAppLauncherTest, |
323 LaunchAppWithNoPermissionWarnings) { | 324 LaunchAppWithNoPermissionWarnings) { |
324 content::WindowedNotificationObserver unloaded_signal( | 325 extensions::TestExtensionRegistryObserver observer( |
325 extensions::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED, | 326 ExtensionRegistry::Get(profile())); |
326 content::Source<Profile>(profile())); | |
327 | 327 |
328 scoped_refptr<EphemeralAppLauncherForTest> launcher( | 328 scoped_refptr<EphemeralAppLauncherForTest> launcher( |
329 new EphemeralAppLauncherForTest(kDefaultAppId, profile())); | 329 new EphemeralAppLauncherForTest(kDefaultAppId, profile())); |
330 StartLauncherAndCheckResult(launcher.get(), webstore_install::SUCCESS, true); | 330 StartLauncherAndCheckResult(launcher.get(), webstore_install::SUCCESS, true); |
331 ValidateAppInstalledEphemerally(kDefaultAppId); | 331 ValidateAppInstalledEphemerally(kDefaultAppId); |
332 | 332 |
333 // Apps with no permission warnings should not result in a prompt. | 333 // Apps with no permission warnings should not result in a prompt. |
334 EXPECT_FALSE(launcher->install_prompt_created()); | 334 EXPECT_FALSE(launcher->install_prompt_created()); |
335 | 335 |
336 // Ephemeral apps are unloaded after they stop running. | 336 // Ephemeral apps are unloaded after they stop running. |
337 unloaded_signal.Wait(); | 337 observer.WaitForExtensionUnloaded(); |
338 | 338 |
339 // After an app has been installed ephemerally, it can be launched again | 339 // After an app has been installed ephemerally, it can be launched again |
340 // without installing from the web store. | 340 // without installing from the web store. |
341 RunLaunchTest(kDefaultAppId, webstore_install::SUCCESS, false); | 341 RunLaunchTest(kDefaultAppId, webstore_install::SUCCESS, false); |
342 } | 342 } |
343 | 343 |
344 // Verifies that an app with permission warnings will be installed | 344 // Verifies that an app with permission warnings will be installed |
345 // ephemerally and launched if accepted by the user. | 345 // ephemerally and launched if accepted by the user. |
346 IN_PROC_BROWSER_TEST_F(EphemeralAppLauncherTest, | 346 IN_PROC_BROWSER_TEST_F(EphemeralAppLauncherTest, |
347 LaunchAppWithPermissionsWarnings) { | 347 LaunchAppWithPermissionsWarnings) { |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
559 } | 559 } |
560 | 560 |
561 // Verifies that a launch will fail if a duplicate launch is in progress. | 561 // Verifies that a launch will fail if a duplicate launch is in progress. |
562 IN_PROC_BROWSER_TEST_F(EphemeralAppLauncherTest, DuplicateLaunchInProgress) { | 562 IN_PROC_BROWSER_TEST_F(EphemeralAppLauncherTest, DuplicateLaunchInProgress) { |
563 extensions::ActiveInstallData install_data(kDefaultAppId); | 563 extensions::ActiveInstallData install_data(kDefaultAppId); |
564 install_data.is_ephemeral = true; | 564 install_data.is_ephemeral = true; |
565 InstallTracker::Get(profile())->AddActiveInstall(install_data); | 565 InstallTracker::Get(profile())->AddActiveInstall(install_data); |
566 | 566 |
567 RunLaunchTest(kDefaultAppId, webstore_install::LAUNCH_IN_PROGRESS, false); | 567 RunLaunchTest(kDefaultAppId, webstore_install::LAUNCH_IN_PROGRESS, false); |
568 } | 568 } |
OLD | NEW |