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

Side by Side Diff: chrome/installer/util/shell_util.cc

Issue 13165005: Move FileEnumerator to its own file, do some refactoring. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merge, fixes 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 // This file defines functions that integrate Chrome in Windows shell. These 5 // This file defines functions that integrate Chrome in Windows shell. These
6 // functions can be used by Chrome as well as Chrome installer. All of the 6 // functions can be used by Chrome as well as Chrome installer. All of the
7 // work is done by the local functions defined in anonymous namespace in 7 // work is done by the local functions defined in anonymous namespace in
8 // this class. 8 // this class.
9 9
10 #include "chrome/installer/util/shell_util.h" 10 #include "chrome/installer/util/shell_util.h"
11 11
12 #include <windows.h> 12 #include <windows.h>
13 #include <shlobj.h> 13 #include <shlobj.h>
14 14
15 #include <limits> 15 #include <limits>
16 #include <string> 16 #include <string>
17 17
18 #include "base/bind.h" 18 #include "base/bind.h"
19 #include "base/command_line.h" 19 #include "base/command_line.h"
20 #include "base/file_util.h" 20 #include "base/file_util.h"
21 #include "base/files/file_enumerator.h"
21 #include "base/files/file_path.h" 22 #include "base/files/file_path.h"
22 #include "base/lazy_instance.h" 23 #include "base/lazy_instance.h"
23 #include "base/logging.h" 24 #include "base/logging.h"
24 #include "base/md5.h" 25 #include "base/md5.h"
25 #include "base/memory/scoped_ptr.h" 26 #include "base/memory/scoped_ptr.h"
26 #include "base/memory/scoped_vector.h" 27 #include "base/memory/scoped_vector.h"
27 #include "base/path_service.h" 28 #include "base/path_service.h"
28 #include "base/string16.h" 29 #include "base/string16.h"
29 #include "base/string_util.h" 30 #include "base/string_util.h"
30 #include "base/strings/string_number_conversions.h" 31 #include "base/strings/string_number_conversions.h"
(...skipping 1193 matching lines...) Expand 10 before | Expand all | Expand 10 after
1224 const base::FilePath& target_exe) { 1225 const base::FilePath& target_exe) {
1225 DCHECK(!shortcut_operation.is_null()); 1226 DCHECK(!shortcut_operation.is_null());
1226 base::FilePath shortcut_folder; 1227 base::FilePath shortcut_folder;
1227 if (!ShellUtil::GetShortcutPath(location, dist, level, &shortcut_folder)) { 1228 if (!ShellUtil::GetShortcutPath(location, dist, level, &shortcut_folder)) {
1228 LOG(WARNING) << "Cannot find path at location " << location; 1229 LOG(WARNING) << "Cannot find path at location " << location;
1229 return false; 1230 return false;
1230 } 1231 }
1231 1232
1232 bool success = true; 1233 bool success = true;
1233 InstallUtil::ProgramCompare target_compare(target_exe); 1234 InstallUtil::ProgramCompare target_compare(target_exe);
1234 file_util::FileEnumerator enumerator( 1235 base::FileEnumerator enumerator(
1235 shortcut_folder, false, file_util::FileEnumerator::FILES, 1236 shortcut_folder, false, base::FileEnumerator::FILES,
1236 string16(L"*") + installer::kLnkExt); 1237 string16(L"*") + installer::kLnkExt);
1237 base::FilePath target_path; 1238 base::FilePath target_path;
1238 for (base::FilePath shortcut_path = enumerator.Next(); 1239 for (base::FilePath shortcut_path = enumerator.Next();
1239 !shortcut_path.empty(); 1240 !shortcut_path.empty();
1240 shortcut_path = enumerator.Next()) { 1241 shortcut_path = enumerator.Next()) {
1241 if (base::win::ResolveShortcut(shortcut_path, &target_path, NULL)) { 1242 if (base::win::ResolveShortcut(shortcut_path, &target_path, NULL)) {
1242 if (target_compare.EvaluatePath(target_path) && 1243 if (target_compare.EvaluatePath(target_path) &&
1243 !shortcut_operation.Run(shortcut_path)) { 1244 !shortcut_operation.Run(shortcut_path)) {
1244 success = false; 1245 success = false;
1245 } 1246 }
(...skipping 834 matching lines...) Expand 10 before | Expand all | Expand 10 after
2080 // are any left...). 2081 // are any left...).
2081 if (free_bits >= 8 && next_byte_index < size) { 2082 if (free_bits >= 8 && next_byte_index < size) {
2082 free_bits -= 8; 2083 free_bits -= 8;
2083 bit_stream += bytes[next_byte_index++] << free_bits; 2084 bit_stream += bytes[next_byte_index++] << free_bits;
2084 } 2085 }
2085 } 2086 }
2086 2087
2087 DCHECK_EQ(ret.length(), encoded_length); 2088 DCHECK_EQ(ret.length(), encoded_length);
2088 return ret; 2089 return ret;
2089 } 2090 }
OLDNEW
« no previous file with comments | « chrome/installer/util/installer_state_unittest.cc ('k') | chrome/installer/util/shell_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698