OLD | NEW |
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/policy/app_pack_updater.h" | 5 #include "chrome/browser/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/location.h" | 10 #include "base/location.h" |
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 if (!file_util::DirectoryExists(dir)) { | 270 if (!file_util::DirectoryExists(dir)) { |
271 // Create it now. | 271 // Create it now. |
272 if (!file_util::CreateDirectory(dir)) | 272 if (!file_util::CreateDirectory(dir)) |
273 LOG(ERROR) << "Failed to create AppPack directory at " << dir.value(); | 273 LOG(ERROR) << "Failed to create AppPack directory at " << dir.value(); |
274 // Nothing else to do. | 274 // Nothing else to do. |
275 return; | 275 return; |
276 } | 276 } |
277 | 277 |
278 // Enumerate all the files in the cache |dir|, including directories | 278 // Enumerate all the files in the cache |dir|, including directories |
279 // and symlinks. Each unrecognized file will be erased. | 279 // and symlinks. Each unrecognized file will be erased. |
280 FileEnumerator::FileType types = static_cast<FileEnumerator::FileType>( | 280 int types = FileEnumerator::FILES | FileEnumerator::DIRECTORIES | |
281 FileEnumerator::FILES | FileEnumerator::DIRECTORIES | | 281 FileEnumerator::SHOW_SYM_LINKS; |
282 FileEnumerator::SHOW_SYM_LINKS); | |
283 FileEnumerator enumerator(dir, false /* recursive */, types); | 282 FileEnumerator enumerator(dir, false /* recursive */, types); |
284 | 283 |
285 for (FilePath path = enumerator.Next(); | 284 for (FilePath path = enumerator.Next(); |
286 !path.empty(); path = enumerator.Next()) { | 285 !path.empty(); path = enumerator.Next()) { |
287 FileEnumerator::FindInfo info; | 286 FileEnumerator::FindInfo info; |
288 enumerator.GetFindInfo(&info); | 287 enumerator.GetFindInfo(&info); |
289 std::string basename = path.BaseName().value(); | 288 std::string basename = path.BaseName().value(); |
290 | 289 |
291 if (FileEnumerator::IsDirectory(info) || FileEnumerator::IsLink(info)) { | 290 if (FileEnumerator::IsDirectory(info) || FileEnumerator::IsLink(info)) { |
292 LOG(ERROR) << "Erasing bad file in AppPack directory: " << basename; | 291 LOG(ERROR) << "Erasing bad file in AppPack directory: " << basename; |
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
587 } | 586 } |
588 } | 587 } |
589 | 588 |
590 void AppPackUpdater::SetUpdateChecked(const std::string& id) { | 589 void AppPackUpdater::SetUpdateChecked(const std::string& id) { |
591 PolicyEntryMap::iterator entry = app_pack_extensions_.find(id); | 590 PolicyEntryMap::iterator entry = app_pack_extensions_.find(id); |
592 if (entry != app_pack_extensions_.end()) | 591 if (entry != app_pack_extensions_.end()) |
593 entry->second.update_checked = true; | 592 entry->second.update_checked = true; |
594 } | 593 } |
595 | 594 |
596 } // namespace policy | 595 } // namespace policy |
OLD | NEW |