Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2511)

Unified Diff: chrome/browser/apps/ephemeral_app_service_browsertest.cc

Issue 344543006: Disable ephemeral apps after they stop running (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed review comments and refactoring Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/apps/ephemeral_app_service.cc ('k') | chrome/browser/apps/ephemeral_app_service_factory.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/apps/ephemeral_app_service_browsertest.cc
diff --git a/chrome/browser/apps/ephemeral_app_service_browsertest.cc b/chrome/browser/apps/ephemeral_app_service_browsertest.cc
index e6b4d41487c729d37baad44172a9f74d3fc8af81..ea1fce19bf4e68523c32ea1738944fb14d43eac7 100644
--- a/chrome/browser/apps/ephemeral_app_service_browsertest.cc
+++ b/chrome/browser/apps/ephemeral_app_service_browsertest.cc
@@ -50,6 +50,13 @@ class EphemeralAppServiceBrowserTest : public EphemeralAppTestBase {
ephemeral_service->InitEphemeralAppCount();
}
+ void DisableEphemeralAppsOnStartup() {
+ EphemeralAppService* ephemeral_service =
+ EphemeralAppService::Get(browser()->profile());
+ ASSERT_TRUE(ephemeral_service);
+ ephemeral_service->DisableEphemeralAppsOnStartup();
+ }
+
std::vector<std::string> app_ids_;
};
@@ -139,7 +146,7 @@ IN_PROC_BROWSER_TEST_F(EphemeralAppServiceBrowserTest, ClearCachedApps) {
InstallAndLaunchEphemeralApp(kDispatchEventTestApp);
std::string inactive_app_id = inactive_app->id();
std::string running_app_id = running_app->id();
- CloseApp(inactive_app_id);
+ CloseAppWaitForUnload(inactive_app_id);
EphemeralAppService* ephemeral_service =
EphemeralAppService::Get(browser()->profile());
@@ -157,3 +164,46 @@ IN_PROC_BROWSER_TEST_F(EphemeralAppServiceBrowserTest, ClearCachedApps) {
EXPECT_EQ(1, ephemeral_service->ephemeral_app_count());
}
+
+// Verify that the service will unload and disable ephemeral apps on startup.
+IN_PROC_BROWSER_TEST_F(EphemeralAppServiceBrowserTest,
+ DisableEphemeralAppsOnStartup) {
+ const Extension* installed_app = InstallPlatformApp(kNotificationsTestApp);
+ const Extension* running_app =
+ InstallAndLaunchEphemeralApp(kMessagingReceiverApp);
+ const Extension* inactive_app = InstallEphemeralApp(kDispatchEventTestApp);
+ const Extension* disabled_app = InstallEphemeralApp(kFileSystemTestApp);
+ ASSERT_TRUE(installed_app);
+ ASSERT_TRUE(running_app);
+ ASSERT_TRUE(inactive_app);
+ ASSERT_TRUE(disabled_app);
+ DisableEphemeralApp(disabled_app, Extension::DISABLE_PERMISSIONS_INCREASE);
+
+ ExtensionRegistry* registry = ExtensionRegistry::Get(profile());
+ ASSERT_TRUE(registry);
+ EXPECT_TRUE(registry->enabled_extensions().Contains(installed_app->id()));
+ EXPECT_TRUE(registry->enabled_extensions().Contains(running_app->id()));
+ EXPECT_TRUE(registry->enabled_extensions().Contains(inactive_app->id()));
+ EXPECT_TRUE(registry->disabled_extensions().Contains(disabled_app->id()));
+
+ DisableEphemeralAppsOnStartup();
+
+ // Verify that the inactive app is disabled.
+ EXPECT_TRUE(registry->enabled_extensions().Contains(installed_app->id()));
+ EXPECT_TRUE(registry->enabled_extensions().Contains(running_app->id()));
+ EXPECT_TRUE(registry->disabled_extensions().Contains(inactive_app->id()));
+ EXPECT_TRUE(registry->disabled_extensions().Contains(disabled_app->id()));
+
+ ExtensionPrefs* prefs = ExtensionPrefs::Get(profile());
+ ASSERT_TRUE(prefs);
+ EXPECT_FALSE(prefs->HasDisableReason(
+ installed_app->id(), Extension::DISABLE_INACTIVE_EPHEMERAL_APP));
+ EXPECT_FALSE(prefs->HasDisableReason(
+ running_app->id(), Extension::DISABLE_INACTIVE_EPHEMERAL_APP));
+ EXPECT_TRUE(prefs->HasDisableReason(
+ inactive_app->id(), Extension::DISABLE_INACTIVE_EPHEMERAL_APP));
+ EXPECT_TRUE(prefs->HasDisableReason(
+ disabled_app->id(), Extension::DISABLE_INACTIVE_EPHEMERAL_APP));
+ EXPECT_TRUE(prefs->HasDisableReason(
+ disabled_app->id(), Extension::DISABLE_PERMISSIONS_INCREASE));
+}
« no previous file with comments | « chrome/browser/apps/ephemeral_app_service.cc ('k') | chrome/browser/apps/ephemeral_app_service_factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698