Commit c04fd3dd authored by rkc@chromium.org's avatar rkc@chromium.org

Add a hack to allow us to disable extension garbage collection.

This allows us to disable extension garbage collection for the kiosk mode screensaver extension.

See associated bug for details.

R=asargent@chromium.org
BUG=280363
TEST=Screensaver plays through and loops in retail kiosk mode.

Review URL: https://chromiumcodereview.appspot.com/23629027

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@221366 0039d316-1c4b-4281-b951-d872f2087c98
parent 36a6e3e1
......@@ -36,6 +36,14 @@ namespace chromeos {
namespace {
ExtensionService* GetDefaultExtensionService() {
Profile* default_profile = ProfileManager::GetDefaultProfile();
if (!default_profile)
return NULL;
return extensions::ExtensionSystem::Get(
default_profile)->extension_service();
}
typedef base::Callback<void(
scoped_refptr<Extension>,
const base::FilePath&)> UnpackCallback;
......@@ -96,6 +104,12 @@ void ScreensaverUnpackerClient::LoadScreensaverExtension(
const base::FilePath& screensaver_extension_path) {
DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE));
ExtensionService* service = GetDefaultExtensionService();
// TODO(rkc): This is a HACK, please remove this method from extension
// service once this code is deprecated. See crbug.com/280363
if (service)
service->disable_garbage_collection();
std::string error;
scoped_refptr<Extension> screensaver_extension =
extension_file_util::LoadExtension(screensaver_extension_path,
......@@ -153,6 +167,12 @@ KioskModeScreensaver::KioskModeScreensaver()
KioskModeScreensaver::~KioskModeScreensaver() {
// If the extension was unpacked.
if (!extension_base_path_.empty()) {
ExtensionService* service = GetDefaultExtensionService();
// TODO(rkc): This is a HACK, please remove this method from extension
// service once this code is deprecated. See crbug.com/280363
if (service)
service->enable_garbage_collection();
// Delete it.
content::BrowserThread::PostTask(
content::BrowserThread::FILE,
......@@ -183,8 +203,8 @@ void KioskModeScreensaver::ScreensaverPathCallback(
Profile* default_profile = ProfileManager::GetDefaultProfile();
if (!default_profile)
return;
base::FilePath extensions_dir = extensions::ExtensionSystem::Get(
default_profile)->extension_service()->install_directory();
base::FilePath extensions_dir =
GetDefaultExtensionService()->install_directory();
scoped_refptr<SandboxedUnpacker> screensaver_unpacker(
new SandboxedUnpacker(
screensaver_crx,
......
......@@ -374,6 +374,9 @@ ExtensionService::ExtensionService(Profile* profile,
is_first_run_(false),
app_sync_bundle_(this),
extension_sync_bundle_(this) {
#if defined(OS_CHROMEOS)
disable_garbage_collection_ = false;
#endif
CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
// Figure out if extension installation should be enabled.
......@@ -1994,6 +1997,11 @@ void ExtensionService::ReloadExtensions() {
}
void ExtensionService::GarbageCollectExtensions() {
#if defined(OS_CHROMEOS)
if (disable_garbage_collection_)
return;
#endif
if (extension_prefs_->pref_service()->ReadOnly())
return;
......
......@@ -700,6 +700,15 @@ class ExtensionService
// sync_start_util for more.
void SetSyncStartFlare(const syncer::SyncableService::StartSyncFlare& flare);
#if defined(OS_CHROMEOS)
void disable_garbage_collection() {
disable_garbage_collection_ = true;
}
void enable_garbage_collection() {
disable_garbage_collection_ = false;
}
#endif
private:
// Contains Extension data that can change during the life of the process,
// but does not persist across restarts.
......@@ -965,6 +974,14 @@ class ExtensionService
// asynchronously via MergeDataAndStartSyncing as soon as possible.
syncer::SyncableService::StartSyncFlare flare_;
#if defined(OS_CHROMEOS)
// TODO(rkc): HACK alert - this is only in place to allow the
// kiosk_mode_screensaver to prevent its extension from getting garbage
// collected. Remove this once KioskModeScreensaver is removed.
// See crbug.com/280363
bool disable_garbage_collection_;
#endif
FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest,
InstallAppsWithUnlimtedStorage);
FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment