diff options
author | tmdiep@chromium.org <tmdiep@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-06-18 07:32:10 +0000 |
---|---|---|
committer | tmdiep@chromium.org <tmdiep@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-06-18 07:32:10 +0000 |
commit | 9a87b6cdd35fa0a638d3cfbc1f3656c1621caa67 (patch) | |
tree | e3c81dea2f031ddb7b07b847fc37be0e7352ff02 | |
parent | 170e6d1bae7ae55efb46b8acb0ac559d9e3a116b (diff) | |
download | chromium_src-9a87b6cdd35fa0a638d3cfbc1f3656c1621caa67.zip chromium_src-9a87b6cdd35fa0a638d3cfbc1f3656c1621caa67.tar.gz chromium_src-9a87b6cdd35fa0a638d3cfbc1f3656c1621caa67.tar.bz2 |
Remove the ability to retain local data of evicted ephemeral apps
This is effectively a revert of http://crrev.com/202763005
BUG=339004
Review URL: https://codereview.chromium.org/337323003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@277972 0039d316-1c4b-4281-b951-d872f2087c98
13 files changed, 15 insertions, 607 deletions
diff --git a/chrome/browser/apps/ephemeral_app_browsertest.cc b/chrome/browser/apps/ephemeral_app_browsertest.cc index ff2f4b7..732dd436 100644 --- a/chrome/browser/apps/ephemeral_app_browsertest.cc +++ b/chrome/browser/apps/ephemeral_app_browsertest.cc @@ -11,7 +11,6 @@ #include "base/scoped_observer.h" #include "base/stl_util.h" #include "chrome/browser/apps/app_browsertest_util.h" -#include "chrome/browser/apps/ephemeral_app_service.h" #include "chrome/browser/extensions/api/file_system/file_system_api.h" #include "chrome/browser/extensions/app_sync_data.h" #include "chrome/browser/extensions/extension_service.h" @@ -44,7 +43,6 @@ using extensions::AppSyncData; using extensions::Event; using extensions::EventRouter; using extensions::Extension; -using extensions::ExtensionInfo; using extensions::ExtensionPrefs; using extensions::ExtensionRegistry; using extensions::ExtensionRegistryObserver; @@ -58,7 +56,6 @@ namespace alarms = extensions::api::alarms; const char kDispatchEventTestApp[] = "ephemeral_apps/dispatch_event"; const char kNotificationsTestApp[] = "ephemeral_apps/notification_settings"; const char kFileSystemTestApp[] = "ephemeral_apps/filesystem_retain_entries"; -const char kRetainDataApp[] = "ephemeral_apps/retain_data"; typedef std::vector<message_center::Notifier*> NotifierList; @@ -74,17 +71,6 @@ bool IsNotifierInList(const message_center::NotifierId& notifier_id, return false; } -bool IsAppInExtensionsInfo(const ExtensionPrefs::ExtensionsInfo& ext_info, - const std::string& extension_id) { - for (size_t i = 0; i < ext_info.size(); ++i) { - ExtensionInfo* info = ext_info.at(i).get(); - if (info->extension_id == extension_id) - return true; - } - - return false; -} - // Saves some parameters from the extension installed notification in order // to verify them in tests. class InstallObserver : public ExtensionRegistryObserver { @@ -301,13 +287,6 @@ class EphemeralAppBrowserTest : public EphemeralAppTestBase { event_router->DispatchEventToExtension(app_id, event.Pass()); } - void GarbageCollectData() { - EphemeralAppService* service = - EphemeralAppService::Get(profile()); - ASSERT_TRUE(service); - service->GarbageCollectData(); - } - const Extension* ReplaceEphemeralApp(const std::string& app_id, const char* test_path) { return UpdateExtensionWaitForIdle(app_id, GetTestPath(test_path), 0); @@ -541,169 +520,11 @@ IN_PROC_BROWSER_TEST_F(EphemeralAppBrowserTest, ASSERT_TRUE(LaunchAppAndRunTest(app, "RestoreRetainedFile")) << message_; } -// Verify that once evicted from the cache, the data of ephemeral apps will not -// be deleted. -IN_PROC_BROWSER_TEST_F(EphemeralAppBrowserTest, RetainData) { - // Phase 1 - Install the ephemeral app and write data to various storage. - const Extension* app = InstallEphemeralApp(kRetainDataApp); - ASSERT_TRUE(app); - ASSERT_TRUE(LaunchAppAndRunTest(app, "WriteData")) << message_; - - // Sanity check to ensure that the ReadData tests should pass before the app - // is removed. - ASSERT_TRUE(LaunchAppAndRunTest(app, "ReadData")) << message_; - - // Remove the app. - const std::string app_id = app->id(); - EvictApp(app->id()); - app = NULL; - - // The app should be in the list of evicted apps. - ExtensionPrefs* prefs = ExtensionPrefs::Get(profile()); - ASSERT_TRUE(prefs); - scoped_ptr<ExtensionPrefs::ExtensionsInfo> extensions_info( - prefs->GetEvictedEphemeralAppsInfo()); - EXPECT_TRUE(IsAppInExtensionsInfo(*extensions_info, app_id)); - scoped_ptr<ExtensionInfo> single_extension_info( - prefs->GetEvictedEphemeralAppInfo(app_id)); - EXPECT_TRUE(single_extension_info.get()); - - // The app should not be in the list of installed extensions. - extensions_info = prefs->GetInstalledExtensionsInfo(); - EXPECT_FALSE(IsAppInExtensionsInfo(*extensions_info, app_id)); - EXPECT_FALSE(prefs->IsEphemeralApp(app_id)); - - // Ensure the evicted app is considered to have isolated storage. This will - // prevent its data from getting garbage collected by - // ExtensionService::GarbageCollectIsolatedStorage(). - GURL site_url = extensions::util::GetSiteForExtensionId( - app_id, profile()); - EXPECT_TRUE(extensions::util::SiteHasIsolatedStorage( - site_url, profile())); - - // Phase 2 - Reinstall the ephemeral app and verify that data still exists - // in the storage. - app = InstallEphemeralApp(kRetainDataApp); - ASSERT_TRUE(app); - EXPECT_TRUE(LaunchAppAndRunTest(app, "ReadData")) << message_; - - // The app should now be in the list of installed extensions, but not in the - // list of evicted apps. - extensions_info = prefs->GetInstalledExtensionsInfo(); - EXPECT_TRUE(IsAppInExtensionsInfo(*extensions_info, app_id)); - extensions_info = prefs->GetEvictedEphemeralAppsInfo(); - EXPECT_FALSE(IsAppInExtensionsInfo(*extensions_info, app_id)); - single_extension_info = prefs->GetEvictedEphemeralAppInfo(app_id); - EXPECT_FALSE(single_extension_info.get()); - EXPECT_TRUE(prefs->IsEphemeralApp(app_id)); -} - -// Verify that preferences are updated correctly when an evicted ephemeral app -// is re-installed permanently. -IN_PROC_BROWSER_TEST_F(EphemeralAppBrowserTest, InstallEvictedEphemeralApp) { - const Extension* app = InstallEphemeralApp(kRetainDataApp); - ASSERT_TRUE(app); - - // Remove the app. - EvictApp(app->id()); - app = NULL; - - // Install the app permanently. - app = InstallPlatformApp(kRetainDataApp); - ASSERT_TRUE(app); - - // Verify that preferences are correct. - ExtensionPrefs* prefs = ExtensionPrefs::Get(profile()); - ASSERT_TRUE(prefs); - EXPECT_FALSE(prefs->IsEphemeralApp(app->id())); - - scoped_ptr<ExtensionPrefs::ExtensionsInfo> extensions_info( - prefs->GetEvictedEphemeralAppsInfo()); - EXPECT_FALSE(IsAppInExtensionsInfo(*extensions_info, app->id())); - extensions_info = prefs->GetInstalledExtensionsInfo(); - EXPECT_TRUE(IsAppInExtensionsInfo(*extensions_info, app->id())); -} - -// Verify that the data of regular installed apps are deleted on uninstall. -IN_PROC_BROWSER_TEST_F(EphemeralAppBrowserTest, RemoveInstalledData) { - // Install the ephemeral app and write data to various storage. - const Extension* app = InstallPlatformApp(kRetainDataApp); - ASSERT_TRUE(app); - ASSERT_TRUE(LaunchAppAndRunTest(app, "WriteData")) << message_; - - // Remove the app. - const std::string app_id = app->id(); - EvictApp(app->id()); - app = NULL; - - // The app should not be in the preferences. - ExtensionPrefs* prefs = ExtensionPrefs::Get(profile()); - ASSERT_TRUE(prefs); - scoped_ptr<ExtensionPrefs::ExtensionsInfo> extensions_info( - prefs->GetEvictedEphemeralAppsInfo()); - EXPECT_FALSE(IsAppInExtensionsInfo(*extensions_info, app_id)); - extensions_info = prefs->GetInstalledExtensionsInfo(); - EXPECT_FALSE(IsAppInExtensionsInfo(*extensions_info, app_id)); - - // Reinstall the app and verify that all data has been reset. - app = InstallPlatformApp(kRetainDataApp); - ASSERT_TRUE(LaunchAppAndRunTest(app, "DataReset")) << message_; -} - -// Verify that once evicted from the cache, ephemeral apps will remain in -// extension prefs, but marked as evicted. After garbage collection of data, -// both their data and preferences should be removed. -IN_PROC_BROWSER_TEST_F(EphemeralAppBrowserTest, GarbageCollectData) { - // Create two apps. Both will be evicted from the cache, but the data of - // one will be garbage collected. - const Extension* evict_app = InstallEphemeralApp(kRetainDataApp); - ASSERT_TRUE(evict_app); - ASSERT_TRUE(LaunchAppAndRunTest(evict_app, "WriteData")) << message_; - std::string evict_app_id = evict_app->id(); - EvictApp(evict_app_id); - evict_app = NULL; - - const Extension* retain_app = InstallEphemeralApp(kDispatchEventTestApp); - ASSERT_TRUE(retain_app); - std::string retain_app_id = retain_app->id(); - EvictApp(retain_app_id); - retain_app = NULL; - - ExtensionPrefs* prefs = ExtensionPrefs::Get(profile()); - ASSERT_TRUE(prefs); - - // Both apps should be in the list of evicted apps. - scoped_ptr<ExtensionPrefs::ExtensionsInfo> extensions_info( - prefs->GetEvictedEphemeralAppsInfo()); - EXPECT_TRUE(IsAppInExtensionsInfo(*extensions_info, retain_app_id)); - EXPECT_TRUE(IsAppInExtensionsInfo(*extensions_info, evict_app_id)); - - // Set a fake last launch time so that the ephemeral app's data will be - // garbage collected. - base::Time launch_time = - base::Time::Now() - base::TimeDelta::FromDays( - EphemeralAppService::kDataInactiveThreshold + 1); - prefs->SetLastLaunchTime(evict_app_id, launch_time); - prefs->SetLastLaunchTime(retain_app_id, base::Time::Now()); - - // Garbage collect data. - GarbageCollectData(); - - // The garbage collected app should no longer be in the preferences. - extensions_info = prefs->GetEvictedEphemeralAppsInfo(); - EXPECT_TRUE(IsAppInExtensionsInfo(*extensions_info, retain_app_id)); - ASSERT_FALSE(IsAppInExtensionsInfo(*extensions_info, evict_app_id)); - - // Reinstall the app and verify that all data has been reset. - evict_app = InstallEphemeralApp(kRetainDataApp); - ASSERT_TRUE(LaunchAppAndRunTest(evict_app, "DataReset")) << message_; -} - // Checks the process of installing and then promoting an ephemeral app. IN_PROC_BROWSER_TEST_F(EphemeralAppBrowserTest, PromoteEphemeralApp) { InitSyncService(); - const Extension* app = InstallEphemeralApp(kRetainDataApp); + const Extension* app = InstallEphemeralApp(kNotificationsTestApp); ASSERT_TRUE(app); // Ephemeral apps should not be synced. @@ -730,7 +551,7 @@ IN_PROC_BROWSER_TEST_F(EphemeralAppBrowserTest, PromoteEphemeralApp) { IN_PROC_BROWSER_TEST_F(EphemeralAppBrowserTest, PromoteEphemeralAppAndEnable) { InitSyncService(); - const Extension* app = InstallEphemeralApp(kRetainDataApp); + const Extension* app = InstallEphemeralApp(kNotificationsTestApp); ASSERT_TRUE(app); // Disable the ephemeral app. @@ -754,7 +575,7 @@ IN_PROC_BROWSER_TEST_F(EphemeralAppBrowserTest, PromoteUnsupportedEphemeralApp) { InitSyncService(); - const Extension* app = InstallEphemeralApp(kRetainDataApp); + const Extension* app = InstallEphemeralApp(kNotificationsTestApp); ASSERT_TRUE(app); // Disable the ephemeral app. @@ -777,7 +598,7 @@ IN_PROC_BROWSER_TEST_F(EphemeralAppBrowserTest, IN_PROC_BROWSER_TEST_F(EphemeralAppBrowserTest, PromoteEphemeralAppFromSync) { InitSyncService(); - const Extension* app = InstallEphemeralApp(kRetainDataApp); + const Extension* app = InstallEphemeralApp(kNotificationsTestApp); ASSERT_TRUE(app); std::string app_id = app->id(); @@ -813,13 +634,13 @@ IN_PROC_BROWSER_TEST_F(EphemeralAppBrowserTest, PromoteEphemeralAppFromSync) { // to race conditions). Ensure that the app is still installed correctly. IN_PROC_BROWSER_TEST_F(EphemeralAppBrowserTest, ReplaceEphemeralAppWithInstalledApp) { - const Extension* app = InstallEphemeralApp(kRetainDataApp); + const Extension* app = InstallEphemeralApp(kNotificationsTestApp); ASSERT_TRUE(app); std::string app_id = app->id(); app = NULL; InstallObserver installed_observer(profile()); - ReplaceEphemeralApp(app_id, kRetainDataApp); + ReplaceEphemeralApp(app_id, kNotificationsTestApp); VerifyPromotedApp(app_id, ExtensionRegistry::ENABLED); // Check the notification parameters. @@ -833,13 +654,13 @@ IN_PROC_BROWSER_TEST_F(EphemeralAppBrowserTest, // be delayed until the app is idle. IN_PROC_BROWSER_TEST_F(EphemeralAppBrowserTest, ReplaceEphemeralAppWithDelayedInstalledApp) { - const Extension* app = InstallAndLaunchEphemeralApp(kRetainDataApp); + const Extension* app = InstallAndLaunchEphemeralApp(kNotificationsTestApp); ASSERT_TRUE(app); std::string app_id = app->id(); app = NULL; // Initiate install. - ReplaceEphemeralApp(app_id, kRetainDataApp); + ReplaceEphemeralApp(app_id, kNotificationsTestApp); // The delayed installation will occur when the ephemeral app is closed. content::WindowedNotificationObserver installed_signal( diff --git a/chrome/browser/apps/ephemeral_app_service.cc b/chrome/browser/apps/ephemeral_app_service.cc index c7b4cb2..067de9c 100644 --- a/chrome/browser/apps/ephemeral_app_service.cc +++ b/chrome/browser/apps/ephemeral_app_service.cc @@ -7,7 +7,6 @@ #include "base/command_line.h" #include "chrome/browser/apps/ephemeral_app_service_factory.h" #include "chrome/browser/chrome_notification_types.h" -#include "chrome/browser/extensions/data_deleter.h" #include "chrome/browser/extensions/extension_service.h" #include "chrome/browser/extensions/extension_util.h" #include "chrome/browser/profiles/profile.h" @@ -23,11 +22,9 @@ #include "extensions/common/extension_set.h" using extensions::Extension; -using extensions::ExtensionInfo; using extensions::ExtensionPrefs; using extensions::ExtensionSet; using extensions::ExtensionSystem; -using extensions::InstalledExtensionInfo; namespace { @@ -44,16 +41,11 @@ const int kGarbageCollectAppsInstallDelay = 15; // kMaxEphemeralAppsCount. const int kGarbageCollectAppsTriggerCount = 35; -// The number of seconds after startup before performing garbage collection -// of the data of evicted ephemeral apps. -const int kGarbageCollectDataStartupDelay = 120; - } // namespace const int EphemeralAppService::kAppInactiveThreshold = 10; const int EphemeralAppService::kAppKeepThreshold = 1; const int EphemeralAppService::kMaxEphemeralAppsCount = 30; -const int EphemeralAppService::kDataInactiveThreshold = 90; // static EphemeralAppService* EphemeralAppService::Get(Profile* profile) { @@ -131,12 +123,6 @@ void EphemeralAppService::Init() { InitEphemeralAppCount(); TriggerGarbageCollect( base::TimeDelta::FromSeconds(kGarbageCollectAppsStartupDelay)); - - garbage_collect_data_timer_.Start( - FROM_HERE, - base::TimeDelta::FromSeconds(kGarbageCollectDataStartupDelay), - this, - &EphemeralAppService::GarbageCollectData); } void EphemeralAppService::InitEphemeralAppCount() { @@ -245,52 +231,3 @@ void EphemeralAppService::GetAppsToRemove( } } } - -void EphemeralAppService::GarbageCollectData() { - ExtensionService* service = - ExtensionSystem::Get(profile_)->extension_service(); - DCHECK(service); - ExtensionPrefs* prefs = ExtensionPrefs::Get(profile_); - DCHECK(prefs); - scoped_ptr<ExtensionPrefs::ExtensionsInfo> evicted_apps_info( - prefs->GetEvictedEphemeralAppsInfo()); - - base::Time time_now = base::Time::Now(); - const base::Time inactive_threshold = - time_now - base::TimeDelta::FromDays(kDataInactiveThreshold); - - for (size_t i = 0; i < evicted_apps_info->size(); ++i) { - ExtensionInfo* info = evicted_apps_info->at(i).get(); - base::Time last_launch_time = prefs->GetLastLaunchTime(info->extension_id); - if (last_launch_time > inactive_threshold) - continue; - - // Sanity check to ensure the app is not currently installed. - if (service->GetInstalledExtension(info->extension_id)) { - NOTREACHED(); - continue; - } - - // Ensure the app is not waiting to be installed. - scoped_ptr<ExtensionInfo> delayed_install( - prefs->GetDelayedInstallInfo(info->extension_id)); - if (delayed_install.get()) - continue; - - if (info->extension_manifest.get()) { - std::string error; - scoped_refptr<const Extension> extension(Extension::Create( - info->extension_path, - info->extension_location, - *info->extension_manifest, - prefs->GetCreationFlags(info->extension_id), - info->extension_id, - &error)); - - if (extension.get()) - extensions::DataDeleter::StartDeleting(profile_, extension.get()); - } - - prefs->RemoveEvictedEphemeralApp(info->extension_id); - } -} diff --git a/chrome/browser/apps/ephemeral_app_service.h b/chrome/browser/apps/ephemeral_app_service.h index 94990ca..ee4b9b1 100644 --- a/chrome/browser/apps/ephemeral_app_service.h +++ b/chrome/browser/apps/ephemeral_app_service.h @@ -45,9 +45,6 @@ class EphemeralAppService : public KeyedService, static const int kAppKeepThreshold; // The maximum number of ephemeral apps to keep cached. Excess may be removed. static const int kMaxEphemeralAppsCount; - // The number of days of inactivity before the data of an already evicted - // ephemeral app will be removed. - static const int kDataInactiveThreshold; private: // A map used to order the ephemeral apps by their last launch time. @@ -79,25 +76,18 @@ class EphemeralAppService : public KeyedService, const LaunchTimeAppMap& app_launch_times, std::set<std::string>* remove_app_ids); - // Garbage collect the data of ephemeral apps that have been evicted and - // inactive for a long period of time. - void GarbageCollectData(); - Profile* profile_; content::NotificationRegistrar registrar_; - ScopedObserver<extensions::ExtensionRegistry, extensions::ExtensionRegistryObserver> extension_registry_observer_; base::OneShotTimer<EphemeralAppService> garbage_collect_apps_timer_; - base::OneShotTimer<EphemeralAppService> garbage_collect_data_timer_; // The count of cached ephemeral apps. int ephemeral_app_count_; - friend class EphemeralAppBrowserTest; friend class EphemeralAppServiceTest; friend class EphemeralAppServiceBrowserTest; diff --git a/chrome/browser/extensions/extension_garbage_collector.cc b/chrome/browser/extensions/extension_garbage_collector.cc index b9af2ea..7701c3c 100644 --- a/chrome/browser/extensions/extension_garbage_collector.cc +++ b/chrome/browser/extensions/extension_garbage_collector.cc @@ -227,20 +227,6 @@ void ExtensionGarbageCollector::GarbageCollectIsolatedStorageIfNeeded() { } } - // The data of ephemeral apps can outlive their cache lifetime. Ensure - // they are not garbage collected. - scoped_ptr<ExtensionPrefs::ExtensionsInfo> evicted_apps_info( - extension_prefs->GetEvictedEphemeralAppsInfo()); - for (size_t i = 0; i < evicted_apps_info->size(); ++i) { - ExtensionInfo* info = evicted_apps_info->at(i).get(); - if (util::HasIsolatedStorage(*info)) { - active_paths->insert(content::BrowserContext::GetStoragePartitionForSite( - context_, - util::GetSiteForExtensionId( - info->extension_id, context_))->GetPath()); - } - } - ExtensionService* service = ExtensionSystem::Get(context_)->extension_service(); service->OnGarbageCollectIsolatedStorageStart(); diff --git a/chrome/browser/extensions/extension_service.cc b/chrome/browser/extensions/extension_service.cc index f7450f3..c467214 100644 --- a/chrome/browser/extensions/extension_service.cc +++ b/chrome/browser/extensions/extension_service.cc @@ -768,10 +768,7 @@ bool ExtensionService::UninstallExtension( NOTREACHED(); } - // Do not remove the data of ephemeral apps. They will be garbage collected by - // EphemeralAppService. - if (!extension_prefs_->IsEphemeralApp(extension->id())) - extensions::DataDeleter::StartDeleting(profile_, extension.get()); + extensions::DataDeleter::StartDeleting(profile_, extension.get()); UntrackTerminatedExtension(extension->id()); diff --git a/chrome/browser/extensions/extension_util.cc b/chrome/browser/extensions/extension_util.cc index 45dc740..9273ed4 100644 --- a/chrome/browser/extensions/extension_util.cc +++ b/chrome/browser/extensions/extension_util.cc @@ -256,22 +256,10 @@ bool SiteHasIsolatedStorage(const GURL& extension_site_url, content::BrowserContext* context) { const Extension* extension = ExtensionRegistry::Get(context)-> enabled_extensions().GetExtensionOrAppByURL(extension_site_url); - if (extension) - return AppIsolationInfo::HasIsolatedStorage(extension); - - if (extension_site_url.SchemeIs(kExtensionScheme)) { - // The site URL may also be from an evicted ephemeral app. We do not - // immediately delete their data when they are removed from extension - // system. - ExtensionPrefs* prefs = ExtensionPrefs::Get(context); - DCHECK(prefs); - scoped_ptr<ExtensionInfo> info = prefs->GetEvictedEphemeralAppInfo( - extension_site_url.host()); - if (info.get()) - return HasIsolatedStorage(*info); - } + if (!extension) + return false; - return false; + return AppIsolationInfo::HasIsolatedStorage(extension); } const gfx::ImageSkia& GetDefaultAppIcon() { diff --git a/chrome/test/data/extensions/platform_apps/ephemeral_apps/retain_data.pem b/chrome/test/data/extensions/platform_apps/ephemeral_apps/retain_data.pem deleted file mode 100644 index 17f7fac..0000000 --- a/chrome/test/data/extensions/platform_apps/ephemeral_apps/retain_data.pem +++ /dev/null @@ -1,15 +0,0 @@ ------BEGIN PRIVATE KEY----- -MIICdQIBADANBgkqhkiG9w0BAQEFAASCAl8wggJbAgEAAoGBANPxk3C4VXX4xnwrj -QcPozskZDd0lHEp+Pjl62niY5XTiWrZkYX2At521OeDV1Ylwfweg7uwxpatoylJP8 -6o8X2qJWii9mp2j+LMnkckbt/dkI60xII58EazzPfZhRhzKZxsoE4Ytt2D7zhyRbE -a7qXyI8S4nD0Qj7w/9ac6lDh/AgMBAAECgYB/v2aNVK4+U1rf0ShKD0TmCwNU4bHv -m8rzyzHgOpKn5j835jfutN/500p02Re1V0DbhFEGuoCYpcRoyDvrhq03ZWgpidE2e -8NQ3A0EXYLAUwuOlsdn/jcMEwRtrHpgiXrPMxpn2I0kSRklHYI66KnEvAt6UBvmYG -5g9NJGQ1Zs0QJBAP+nkuYwh28Av0eglgIs0SLev+D7PemKNHZUoYHcLJM3XAOKbaL -sb/xm16sdRKvN7qrMIv0jJYiBnLO6qKMCdysCQQDUOuIg664kDK20atzjUsddhBvG -2czxOsdFaYFHDlZnu9x96rw2xCLbgArg9IypyVw2m5lPYwP7y5iz76Sd49n9AkBvr -u8XrF+d+H+XdOnTbWy3hQPh7x/u5Ddi8jnUFzFJ5sdFrLWUlSGe6/aPhCu5ui7nYm -Jun2oIJkckpQiCndMdAkBMd27UR7Z1vK+1iq9NpJy6gAf2DLF/1RrJUqtGq87MD27 -xW2s3HFIm3iqNRO+NmUSFVGjXpqhfx8qcQmMAlIENAkBtde4Pk8q6AZMMPVN+dFEn -Tr2oJdvvASJ6HSLBWDaGTCOtPIuoCf6TXnfpTkNPE3BBZPspwDbwPyIB+f4D26Ny ------END PRIVATE KEY----- diff --git a/chrome/test/data/extensions/platform_apps/ephemeral_apps/retain_data/index.html b/chrome/test/data/extensions/platform_apps/ephemeral_apps/retain_data/index.html deleted file mode 100644 index 84c6401..0000000 --- a/chrome/test/data/extensions/platform_apps/ephemeral_apps/retain_data/index.html +++ /dev/null @@ -1,11 +0,0 @@ -<!-- - * Copyright 2014 The Chromium Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. ---> -<!DOCTYPE html> -<html> -<body> - <script src="index.js"></script> -</body> -</html> diff --git a/chrome/test/data/extensions/platform_apps/ephemeral_apps/retain_data/index.js b/chrome/test/data/extensions/platform_apps/ephemeral_apps/retain_data/index.js deleted file mode 100644 index 21d21b3..0000000 --- a/chrome/test/data/extensions/platform_apps/ephemeral_apps/retain_data/index.js +++ /dev/null @@ -1,180 +0,0 @@ -// Copyright 2014 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -var callbackPass = chrome.test.callbackPass; -var callbackFail = chrome.test.callbackFail; - -var kSavedKey = 'ephemeral'; -var kSavedValue = 'app'; -var kTestFileName = 'ephemeral.txt'; -var kTestDBName = 'ephemeral_db'; - -function FileSystemWriteError() { - chrome.test.fail('Filesystem write error'); -} - -function FileSystemReadError() { - chrome.test.fail('Filesystem read error'); -} - -function IndexDBError() { - chrome.test.fail('IndexDB error'); -} - -function WriteLocalStorage() { - var data = {}; - data[kSavedKey] = kSavedValue; - chrome.storage.local.set(data, callbackPass(function() {})); -} - -function WriteFileSystem() { - // Testing the existence of a file is sufficient. - window.webkitRequestFileSystem( - PERSISTENT, - 512, - callbackPass(function(fs) { - fs.root.getFile( - kTestFileName, - {create: true, exclusive: true}, - callbackPass(function(fileEntry) { - // Succeeded - }), - FileSystemWriteError); - }), FileSystemWriteError); -} - -function WriteIndexedDB() { - var openDB = indexedDB.open(kTestDBName, 1); - openDB.onerror = IndexDBError; - - openDB.onsuccess = callbackPass(function(e) { - var db = e.target.result; - var transaction = db.transaction([kTestDBName], 'readwrite'); - var store = transaction.objectStore(kTestDBName); - - var request = store.add(kSavedValue, kSavedKey); - request.onerror = IndexDBError; - - request.onsuccess = callbackPass(function(e) { - // Succeeded - }); - }); - - openDB.onupgradeneeded = function(e) { - var db = e.target.result; - db.createObjectStore(kTestDBName); - }; -} - -function ReadLocalStorage() { - chrome.storage.local.get(kSavedKey, callbackPass(function(items) { - chrome.test.assertTrue(typeof(items[kSavedKey]) !== 'undefined'); - chrome.test.assertEq(kSavedValue, items[kSavedKey]); - })); -} - -function ReadFileSystem() { - window.webkitRequestFileSystem( - PERSISTENT, - 512, - callbackPass(function(fs) { - fs.root.getFile( - kTestFileName, - {}, - callbackPass(function(fileEntry) { - // Succeeded - }), - FileSystemReadError); - }), - FileSystemReadError); -} - -function ReadIndexedDB() { - var openDB = indexedDB.open(kTestDBName, 1); - openDB.onerror = IndexDBError; - - openDB.onsuccess = callbackPass(function(e) { - var db = e.target.result; - var transaction = db.transaction([kTestDBName], 'readonly'); - var store = transaction.objectStore(kTestDBName); - - var request = store.get(kSavedKey); - request.onerror = IndexDBError; - - request.onsuccess = callbackPass(function(e) { - chrome.test.assertEq(kSavedValue, e.target.result); - }); - }); - - openDB.onupgradeneeded = function(e) { - chrome.test.fail('Indexed DB not initialized'); - }; -} - -function CheckLocalStorageReset() { - chrome.storage.local.get(kSavedKey, callbackPass(function(items) { - chrome.test.assertEq('undefined', typeof(items[kSavedKey])); - })); -} - -function CheckFileSystemReset() { - window.webkitRequestFileSystem( - PERSISTENT, - 512, - callbackPass(function(fs) { - fs.root.getFile( - kTestFileName, - {}, - function(fileEntry) { - chrome.test.fail('File ' + kTestFileName + ' should not exist'); - }, - callbackPass(function(e) { - // Expected failure - })); - }), - FileSystemReadError); -} - -function CheckIndexedDBReset() { - var openDB = indexedDB.open(kTestDBName, 1); - openDB.onerror = IndexDBError; - - openDB.onsuccess = callbackPass(function(e) { - var db = e.target.result; - chrome.test.assertFalse(db.objectStoreNames.contains(kTestDBName)); - }); -} - -// Phase 1 - Write data to various storage types. -function WriteData() { - chrome.test.runTests([ - WriteLocalStorage, - WriteFileSystem, - WriteIndexedDB - ]); -} - -// Phase 2 - Read data back from the various storage types. -function ReadData() { - chrome.test.runTests([ - ReadLocalStorage, - ReadFileSystem, - ReadIndexedDB - ]); -} - -// Verify that all data has been reset. -function DataReset() { - chrome.test.runTests([ - CheckLocalStorageReset, - CheckFileSystemReset, - CheckIndexedDBReset - ]); -} - -onload = function() { - chrome.test.sendMessage('launched', function(reply) { - window[reply](); - }); -}; diff --git a/chrome/test/data/extensions/platform_apps/ephemeral_apps/retain_data/main.js b/chrome/test/data/extensions/platform_apps/ephemeral_apps/retain_data/main.js deleted file mode 100644 index f9e810e..0000000 --- a/chrome/test/data/extensions/platform_apps/ephemeral_apps/retain_data/main.js +++ /dev/null @@ -1,7 +0,0 @@ -// Copyright 2014 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -chrome.app.runtime.onLaunched.addListener(function() { - chrome.app.window.create('index.html', {}); -}); diff --git a/chrome/test/data/extensions/platform_apps/ephemeral_apps/retain_data/manifest.json b/chrome/test/data/extensions/platform_apps/ephemeral_apps/retain_data/manifest.json deleted file mode 100644 index 4b9b7ef..0000000 --- a/chrome/test/data/extensions/platform_apps/ephemeral_apps/retain_data/manifest.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "name": "Ephemeral Apps Retain Data", - "version": "1.0", - "manifest_version": 2, - "key": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDT8ZNwuFV1+MZ8K40HD6M7JGQ3dJRxKfj45etp4mOV04lq2ZGF9gLedtTng1dWJcH8HoO7sMaWraMpST/OqPF9qiVoovZqdo/izJ5HJG7f3ZCOtMSCOfBGs8z32YUYcymcbKBOGLbdg+84ckWxGu6l8iPEuJw9EI+8P/WnOpQ4fwIDAQAB", - "app": { - "background": { - "scripts": ["main.js"] - } - }, - "permissions": ["storage", "unlimitedStorage"] -} diff --git a/extensions/browser/extension_prefs.cc b/extensions/browser/extension_prefs.cc index 2dc5c37..87b739b 100644 --- a/extensions/browser/extension_prefs.cc +++ b/extensions/browser/extension_prefs.cc @@ -182,11 +182,6 @@ const char kPrefGeometryCache[] = "geometry_cache"; // A preference that indicates when an extension is last launched. const char kPrefLastLaunchTime[] = "last_launch_time"; -// A preference that marks an ephemeral app that was evicted from the cache. -// Their data is retained and garbage collected when inactive for a long period -// of time. -const char kPrefEvictedEphemeralApp[] = "evicted_ephemeral_app"; - // A preference indicating whether the extension is an ephemeral app. const char kPrefEphemeralApp[] = "ephemeral_app"; @@ -241,11 +236,6 @@ bool IsBlacklistBitSet(const base::DictionaryValue* ext) { return ext->GetBoolean(kPrefBlacklist, &bool_value) && bool_value; } -bool IsEvictedEphemeralApp(const base::DictionaryValue* ext) { - bool bool_value; - return ext->GetBoolean(kPrefEvictedEphemeralApp, &bool_value) && bool_value; -} - void LoadExtensionControlledPrefs(ExtensionPrefs* prefs, ExtensionPrefValueMap* value_map, const std::string& extension_id, @@ -1279,13 +1269,7 @@ void ExtensionPrefs::OnExtensionUninstalled(const std::string& extension_id, observer_list_, OnExtensionStateChanged(extension_id, false)); } else { - if (IsEphemeralApp(extension_id)) { - // Keep ephemeral apps around, but mark them as evicted. - UpdateExtensionPref(extension_id, kPrefEvictedEphemeralApp, - new base::FundamentalValue(true)); - } else { - DeleteExtensionPrefs(extension_id); - } + DeleteExtensionPrefs(extension_id); } } @@ -1413,11 +1397,6 @@ scoped_ptr<ExtensionInfo> ExtensionPrefs::GetInstalledExtensionInfo( return scoped_ptr<ExtensionInfo>(); } - if (IsEvictedEphemeralApp(ext)) { - // Hide evicted ephemeral apps. - return scoped_ptr<ExtensionInfo>(); - } - return GetInstalledInfoHelper(extension_id, ext); } @@ -1594,55 +1573,7 @@ scoped_ptr<ExtensionPrefs::ExtensionsInfo> ExtensionPrefs:: return extensions_info.Pass(); } -scoped_ptr<ExtensionPrefs::ExtensionsInfo> -ExtensionPrefs::GetEvictedEphemeralAppsInfo() const { - scoped_ptr<ExtensionsInfo> extensions_info(new ExtensionsInfo); - - const base::DictionaryValue* extensions = - prefs_->GetDictionary(pref_names::kExtensions); - for (base::DictionaryValue::Iterator extension_id(*extensions); - !extension_id.IsAtEnd(); extension_id.Advance()) { - const base::DictionaryValue* ext = NULL; - if (!Extension::IdIsValid(extension_id.key()) || - !extension_id.value().GetAsDictionary(&ext)) { - continue; - } - - if (!IsEvictedEphemeralApp(ext)) - continue; - - scoped_ptr<ExtensionInfo> info = - GetInstalledInfoHelper(extension_id.key(), ext); - if (info) - extensions_info->push_back(linked_ptr<ExtensionInfo>(info.release())); - } - - return extensions_info.Pass(); -} - -scoped_ptr<ExtensionInfo> ExtensionPrefs::GetEvictedEphemeralAppInfo( - const std::string& extension_id) const { - const base::DictionaryValue* extension_prefs = GetExtensionPref(extension_id); - if (!extension_prefs) - return scoped_ptr<ExtensionInfo>(); - - if (!IsEvictedEphemeralApp(extension_prefs)) - return scoped_ptr<ExtensionInfo>(); - - return GetInstalledInfoHelper(extension_id, extension_prefs); -} - -void ExtensionPrefs::RemoveEvictedEphemeralApp( - const std::string& extension_id) { - if (ReadPrefAsBooleanAndReturn(extension_id, kPrefEvictedEphemeralApp)) - DeleteExtensionPrefs(extension_id); -} - bool ExtensionPrefs::IsEphemeralApp(const std::string& extension_id) const { - // Hide the data of evicted ephemeral apps. - if (ReadPrefAsBooleanAndReturn(extension_id, kPrefEvictedEphemeralApp)) - return false; - if (ReadPrefAsBooleanAndReturn(extension_id, kPrefEphemeralApp)) return true; @@ -1654,11 +1585,8 @@ bool ExtensionPrefs::IsEphemeralApp(const std::string& extension_id) const { void ExtensionPrefs::OnEphemeralAppPromoted(const std::string& extension_id) { DCHECK(IsEphemeralApp(extension_id)); - ScopedExtensionPrefUpdate update(prefs_, extension_id); - update->Set(kPrefEphemeralApp, new base::FundamentalValue(false)); - - DCHECK(!IsEvictedEphemeralApp(update.Get())); - update->Remove(kPrefEvictedEphemeralApp, NULL); + UpdateExtensionPref( + extension_id, kPrefEphemeralApp, new base::FundamentalValue(false)); } bool ExtensionPrefs::WasAppDraggedByUser(const std::string& extension_id) { @@ -2224,9 +2152,6 @@ void ExtensionPrefs::FinishExtensionInfoPrefs( // Clear state that may be registered from a previous install. extension_dict->Remove(EventRouter::kRegisteredEvents, NULL); - // When evicted ephemeral apps are re-installed, this flag must be reset. - extension_dict->Remove(kPrefEvictedEphemeralApp, NULL); - // FYI, all code below here races on sudden shutdown because |extension_dict|, // |app_sorting_|, |extension_pref_value_map_|, and (potentially) observers // are updated non-transactionally. This is probably not fixable without diff --git a/extensions/browser/extension_prefs.h b/extensions/browser/extension_prefs.h index ad1712d..351722c 100644 --- a/extensions/browser/extension_prefs.h +++ b/extensions/browser/extension_prefs.h @@ -481,17 +481,6 @@ class ExtensionPrefs : public ExtensionScopedPrefs, public KeyedService { // information. scoped_ptr<ExtensionsInfo> GetAllDelayedInstallInfo() const; - // Returns information about evicted ephemeral apps. - scoped_ptr<ExtensionsInfo> GetEvictedEphemeralAppsInfo() const; - - // Return information about a specific evicted ephemeral app. Can return NULL - // if no such evicted app exists or is currently installed. - scoped_ptr<ExtensionInfo> GetEvictedEphemeralAppInfo( - const std::string& extension_id) const; - - // Permanently remove the preferences for an evicted ephemeral app. - void RemoveEvictedEphemeralApp(const std::string& extension_id); - // Returns true if the extension is an ephemeral app. bool IsEphemeralApp(const std::string& extension_id) const; |