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

Side by Side Diff: chrome/browser/chromeos/kiosk_mode/kiosk_mode_screensaver.cc

Issue 23629027: Add a hack to allow us to disable extension garbage collection. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 3 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/extensions/extension_service.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chrome/browser/chromeos/kiosk_mode/kiosk_mode_screensaver.h" 5 #include "chrome/browser/chromeos/kiosk_mode/kiosk_mode_screensaver.h"
6 6
7 #include "ash/screensaver/screensaver_view.h" 7 #include "ash/screensaver/screensaver_view.h"
8 #include "ash/shell.h" 8 #include "ash/shell.h"
9 #include "ash/wm/user_activity_detector.h" 9 #include "ash/wm/user_activity_detector.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 18 matching lines...) Expand all
29 #include "content/public/browser/browser_thread.h" 29 #include "content/public/browser/browser_thread.h"
30 #include "content/public/browser/notification_service.h" 30 #include "content/public/browser/notification_service.h"
31 31
32 using extensions::Extension; 32 using extensions::Extension;
33 using extensions::SandboxedUnpacker; 33 using extensions::SandboxedUnpacker;
34 34
35 namespace chromeos { 35 namespace chromeos {
36 36
37 namespace { 37 namespace {
38 38
39 ExtensionService* GetDefaultExtensionService() {
40 Profile* default_profile = ProfileManager::GetDefaultProfile();
41 if (!default_profile)
42 return NULL;
43 return extensions::ExtensionSystem::Get(
44 default_profile)->extension_service();
45 }
46
39 typedef base::Callback<void( 47 typedef base::Callback<void(
40 scoped_refptr<Extension>, 48 scoped_refptr<Extension>,
41 const base::FilePath&)> UnpackCallback; 49 const base::FilePath&)> UnpackCallback;
42 50
43 class ScreensaverUnpackerClient 51 class ScreensaverUnpackerClient
44 : public extensions::SandboxedUnpackerClient { 52 : public extensions::SandboxedUnpackerClient {
45 public: 53 public:
46 ScreensaverUnpackerClient(const base::FilePath& crx_path, 54 ScreensaverUnpackerClient(const base::FilePath& crx_path,
47 const UnpackCallback& unpacker_callback) 55 const UnpackCallback& unpacker_callback)
48 : crx_path_(crx_path), 56 : crx_path_(crx_path),
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 void ScreensaverUnpackerClient::OnUnpackFailure(const string16& error) { 97 void ScreensaverUnpackerClient::OnUnpackFailure(const string16& error) {
90 LOG(ERROR) << "Couldn't unpack screensaver extension. Error: " << error; 98 LOG(ERROR) << "Couldn't unpack screensaver extension. Error: " << error;
91 NotifyAppPackOfDamagedFile(); 99 NotifyAppPackOfDamagedFile();
92 } 100 }
93 101
94 void ScreensaverUnpackerClient::LoadScreensaverExtension( 102 void ScreensaverUnpackerClient::LoadScreensaverExtension(
95 const base::FilePath& extension_base_path, 103 const base::FilePath& extension_base_path,
96 const base::FilePath& screensaver_extension_path) { 104 const base::FilePath& screensaver_extension_path) {
97 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE)); 105 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE));
98 106
107 ExtensionService* service = GetDefaultExtensionService();
108 // TODO(rkc): This is a HACK, please remove this method from extension
109 // service once this code is deprecated. See crbug.com/280363
110 if (service)
111 service->disable_garbage_collection();
112
99 std::string error; 113 std::string error;
100 scoped_refptr<Extension> screensaver_extension = 114 scoped_refptr<Extension> screensaver_extension =
101 extension_file_util::LoadExtension(screensaver_extension_path, 115 extension_file_util::LoadExtension(screensaver_extension_path,
102 extensions::Manifest::COMPONENT, 116 extensions::Manifest::COMPONENT,
103 Extension::NO_FLAGS, 117 Extension::NO_FLAGS,
104 &error); 118 &error);
105 if (!screensaver_extension.get()) { 119 if (!screensaver_extension.get()) {
106 LOG(ERROR) << "Could not load screensaver extension from: " 120 LOG(ERROR) << "Could not load screensaver extension from: "
107 << screensaver_extension_path.value() << " due to: " << error; 121 << screensaver_extension_path.value() << " due to: " << error;
108 NotifyAppPackOfDamagedFile(); 122 NotifyAppPackOfDamagedFile();
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 } else { 160 } else {
147 kiosk_mode_settings->Initialize(base::Bind( 161 kiosk_mode_settings->Initialize(base::Bind(
148 &KioskModeScreensaver::GetScreensaverCrxPath, 162 &KioskModeScreensaver::GetScreensaverCrxPath,
149 weak_ptr_factory_.GetWeakPtr())); 163 weak_ptr_factory_.GetWeakPtr()));
150 } 164 }
151 } 165 }
152 166
153 KioskModeScreensaver::~KioskModeScreensaver() { 167 KioskModeScreensaver::~KioskModeScreensaver() {
154 // If the extension was unpacked. 168 // If the extension was unpacked.
155 if (!extension_base_path_.empty()) { 169 if (!extension_base_path_.empty()) {
170 ExtensionService* service = GetDefaultExtensionService();
171 // TODO(rkc): This is a HACK, please remove this method from extension
172 // service once this code is deprecated. See crbug.com/280363
173 if (service)
174 service->enable_garbage_collection();
175
156 // Delete it. 176 // Delete it.
157 content::BrowserThread::PostTask( 177 content::BrowserThread::PostTask(
158 content::BrowserThread::FILE, 178 content::BrowserThread::FILE,
159 FROM_HERE, 179 FROM_HERE,
160 base::Bind( 180 base::Bind(
161 &extension_file_util::DeleteFile, extension_base_path_, true)); 181 &extension_file_util::DeleteFile, extension_base_path_, true));
162 } 182 }
163 183
164 // In case we're shutting down without ever triggering the active 184 // In case we're shutting down without ever triggering the active
165 // notification and/or logging in. 185 // notification and/or logging in.
(...skipping 10 matching lines...) Expand all
176 } 196 }
177 197
178 void KioskModeScreensaver::ScreensaverPathCallback( 198 void KioskModeScreensaver::ScreensaverPathCallback(
179 const base::FilePath& screensaver_crx) { 199 const base::FilePath& screensaver_crx) {
180 if (screensaver_crx.empty()) 200 if (screensaver_crx.empty())
181 return; 201 return;
182 202
183 Profile* default_profile = ProfileManager::GetDefaultProfile(); 203 Profile* default_profile = ProfileManager::GetDefaultProfile();
184 if (!default_profile) 204 if (!default_profile)
185 return; 205 return;
186 base::FilePath extensions_dir = extensions::ExtensionSystem::Get( 206 base::FilePath extensions_dir =
187 default_profile)->extension_service()->install_directory(); 207 GetDefaultExtensionService()->install_directory();
188 scoped_refptr<SandboxedUnpacker> screensaver_unpacker( 208 scoped_refptr<SandboxedUnpacker> screensaver_unpacker(
189 new SandboxedUnpacker( 209 new SandboxedUnpacker(
190 screensaver_crx, 210 screensaver_crx,
191 extensions::Manifest::COMPONENT, 211 extensions::Manifest::COMPONENT,
192 Extension::NO_FLAGS, 212 Extension::NO_FLAGS,
193 extensions_dir, 213 extensions_dir,
194 content::BrowserThread::GetMessageLoopProxyForThread( 214 content::BrowserThread::GetMessageLoopProxyForThread(
195 content::BrowserThread::FILE).get(), 215 content::BrowserThread::FILE).get(),
196 new ScreensaverUnpackerClient( 216 new ScreensaverUnpackerClient(
197 screensaver_crx, 217 screensaver_crx,
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 295
276 g_kiosk_mode_screensaver = new KioskModeScreensaver(); 296 g_kiosk_mode_screensaver = new KioskModeScreensaver();
277 } 297 }
278 298
279 void ShutdownKioskModeScreensaver() { 299 void ShutdownKioskModeScreensaver() {
280 delete g_kiosk_mode_screensaver; 300 delete g_kiosk_mode_screensaver;
281 g_kiosk_mode_screensaver = NULL; 301 g_kiosk_mode_screensaver = NULL;
282 } 302 }
283 303
284 } // namespace chromeos 304 } // namespace chromeos
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/extensions/extension_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698