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

Side by Side Diff: trunk/src/chrome/browser/chromeos/policy/app_pack_updater.cc

Issue 14824006: Revert 198820 "Move FileEnumerator to its own file, do some refa..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 7 years, 7 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
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/policy/app_pack_updater.h" 5 #include "chrome/browser/chromeos/policy/app_pack_updater.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/files/file_enumerator.h"
11 #include "base/location.h" 10 #include "base/location.h"
12 #include "base/stl_util.h" 11 #include "base/stl_util.h"
13 #include "base/string_util.h" 12 #include "base/string_util.h"
14 #include "base/values.h" 13 #include "base/values.h"
15 #include "base/version.h" 14 #include "base/version.h"
16 #include "chrome/browser/browser_process.h" 15 #include "chrome/browser/browser_process.h"
17 #include "chrome/browser/chromeos/policy/enterprise_install_attributes.h" 16 #include "chrome/browser/chromeos/policy/enterprise_install_attributes.h"
18 #include "chrome/browser/chromeos/settings/cros_settings.h" 17 #include "chrome/browser/chromeos/settings/cros_settings.h"
19 #include "chrome/browser/chromeos/settings/cros_settings_names.h" 18 #include "chrome/browser/chromeos/settings/cros_settings_names.h"
20 #include "chrome/browser/extensions/crx_installer.h" 19 #include "chrome/browser/extensions/crx_installer.h"
21 #include "chrome/browser/extensions/external_loader.h" 20 #include "chrome/browser/extensions/external_loader.h"
22 #include "chrome/browser/extensions/external_provider_impl.h" 21 #include "chrome/browser/extensions/external_provider_impl.h"
23 #include "chrome/browser/extensions/updater/extension_downloader.h" 22 #include "chrome/browser/extensions/updater/extension_downloader.h"
24 #include "chrome/common/chrome_notification_types.h" 23 #include "chrome/common/chrome_notification_types.h"
25 #include "chrome/common/extensions/extension.h" 24 #include "chrome/common/extensions/extension.h"
26 #include "chrome/common/extensions/extension_constants.h" 25 #include "chrome/common/extensions/extension_constants.h"
27 #include "content/public/browser/browser_thread.h" 26 #include "content/public/browser/browser_thread.h"
28 #include "content/public/browser/notification_details.h" 27 #include "content/public/browser/notification_details.h"
29 #include "content/public/browser/notification_service.h" 28 #include "content/public/browser/notification_service.h"
30 #include "content/public/browser/notification_source.h" 29 #include "content/public/browser/notification_source.h"
31 30
32 using content::BrowserThread; 31 using content::BrowserThread;
32 using file_util::FileEnumerator;
33 33
34 namespace policy { 34 namespace policy {
35 35
36 namespace { 36 namespace {
37 37
38 // Directory where the AppPack extensions are cached. 38 // Directory where the AppPack extensions are cached.
39 const char kAppPackCacheDir[] = "/var/cache/app_pack"; 39 const char kAppPackCacheDir[] = "/var/cache/app_pack";
40 40
41 // File name extension for CRX files (not case sensitive). 41 // File name extension for CRX files (not case sensitive).
42 const char kCRXFileExtension[] = ".crx"; 42 const char kCRXFileExtension[] = ".crx";
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 if (!file_util::DirectoryExists(dir)) { 243 if (!file_util::DirectoryExists(dir)) {
244 // Create it now. 244 // Create it now.
245 if (!file_util::CreateDirectory(dir)) 245 if (!file_util::CreateDirectory(dir))
246 LOG(ERROR) << "Failed to create AppPack directory at " << dir.value(); 246 LOG(ERROR) << "Failed to create AppPack directory at " << dir.value();
247 // Nothing else to do. 247 // Nothing else to do.
248 return; 248 return;
249 } 249 }
250 250
251 // Enumerate all the files in the cache |dir|, including directories 251 // Enumerate all the files in the cache |dir|, including directories
252 // and symlinks. Each unrecognized file will be erased. 252 // and symlinks. Each unrecognized file will be erased.
253 int types = base::FileEnumerator::FILES | base::FileEnumerator::DIRECTORIES | 253 int types = FileEnumerator::FILES | FileEnumerator::DIRECTORIES |
254 base::FileEnumerator::SHOW_SYM_LINKS; 254 FileEnumerator::SHOW_SYM_LINKS;
255 base::FileEnumerator enumerator(dir, false /* recursive */, types); 255 FileEnumerator enumerator(dir, false /* recursive */, types);
256 256
257 for (base::FilePath path = enumerator.Next(); 257 for (base::FilePath path = enumerator.Next();
258 !path.empty(); path = enumerator.Next()) { 258 !path.empty(); path = enumerator.Next()) {
259 base::FileEnumerator::FileInfo info = enumerator.GetInfo(); 259 FileEnumerator::FindInfo info;
260 enumerator.GetFindInfo(&info);
260 std::string basename = path.BaseName().value(); 261 std::string basename = path.BaseName().value();
261 262
262 if (info.IsDirectory() || file_util::IsLink(info.GetName())) { 263 if (FileEnumerator::IsDirectory(info) ||
264 file_util::IsLink(FileEnumerator::GetFilename(info))) {
263 LOG(ERROR) << "Erasing bad file in AppPack directory: " << basename; 265 LOG(ERROR) << "Erasing bad file in AppPack directory: " << basename;
264 file_util::Delete(path, true /* recursive */); 266 file_util::Delete(path, true /* recursive */);
265 continue; 267 continue;
266 } 268 }
267 269
268 // crx files in the cache are named <extension-id>-<version>.crx. 270 // crx files in the cache are named <extension-id>-<version>.crx.
269 std::string id; 271 std::string id;
270 std::string version; 272 std::string version;
271 273
272 if (EndsWith(basename, kCRXFileExtension, false /* case-sensitive */)) { 274 if (EndsWith(basename, kCRXFileExtension, false /* case-sensitive */)) {
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
558 void AppPackUpdater::SetScreenSaverPath(const base::FilePath& path) { 560 void AppPackUpdater::SetScreenSaverPath(const base::FilePath& path) {
559 // Don't invoke the callback if the path isn't changing. 561 // Don't invoke the callback if the path isn't changing.
560 if (path != screen_saver_path_) { 562 if (path != screen_saver_path_) {
561 screen_saver_path_ = path; 563 screen_saver_path_ = path;
562 if (!screen_saver_update_callback_.is_null()) 564 if (!screen_saver_update_callback_.is_null())
563 screen_saver_update_callback_.Run(screen_saver_path_); 565 screen_saver_update_callback_.Run(screen_saver_path_);
564 } 566 }
565 } 567 }
566 568
567 } // namespace policy 569 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698