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 // This file declares util functions for setup project. | 5 // This file declares util functions for setup project. |
6 | 6 |
7 #include "chrome/installer/setup/setup_util.h" | 7 #include "chrome/installer/setup/setup_util.h" |
8 | 8 |
9 #include <windows.h> | 9 #include <windows.h> |
10 | 10 |
11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
12 #include "base/file_util.h" | 12 #include "base/file_util.h" |
| 13 #include "base/files/file_enumerator.h" |
13 #include "base/files/file_path.h" | 14 #include "base/files/file_path.h" |
14 #include "base/logging.h" | 15 #include "base/logging.h" |
15 #include "base/process_util.h" | 16 #include "base/process_util.h" |
16 #include "base/string_util.h" | 17 #include "base/string_util.h" |
17 #include "base/version.h" | 18 #include "base/version.h" |
18 #include "chrome/installer/util/copy_tree_work_item.h" | 19 #include "chrome/installer/util/copy_tree_work_item.h" |
19 #include "chrome/installer/util/installation_state.h" | 20 #include "chrome/installer/util/installation_state.h" |
20 #include "chrome/installer/util/installer_state.h" | 21 #include "chrome/installer/util/installer_state.h" |
21 #include "chrome/installer/util/master_preferences.h" | 22 #include "chrome/installer/util/master_preferences.h" |
22 #include "chrome/installer/util/util_constants.h" | 23 #include "chrome/installer/util/util_constants.h" |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 if (installer_state != NULL) | 118 if (installer_state != NULL) |
118 installer_state->UpdateStage(installer::BINARY_PATCHING); | 119 installer_state->UpdateStage(installer::BINARY_PATCHING); |
119 | 120 |
120 return ApplyBinaryPatch(src.value().c_str(), patch.value().c_str(), | 121 return ApplyBinaryPatch(src.value().c_str(), patch.value().c_str(), |
121 dest.value().c_str()); | 122 dest.value().c_str()); |
122 } | 123 } |
123 | 124 |
124 Version* GetMaxVersionFromArchiveDir(const base::FilePath& chrome_path) { | 125 Version* GetMaxVersionFromArchiveDir(const base::FilePath& chrome_path) { |
125 VLOG(1) << "Looking for Chrome version folder under " << chrome_path.value(); | 126 VLOG(1) << "Looking for Chrome version folder under " << chrome_path.value(); |
126 Version* version = NULL; | 127 Version* version = NULL; |
127 file_util::FileEnumerator version_enum(chrome_path, false, | 128 base::FileEnumerator version_enum(chrome_path, false, |
128 file_util::FileEnumerator::DIRECTORIES); | 129 base::FileEnumerator::DIRECTORIES); |
129 // TODO(tommi): The version directory really should match the version of | 130 // TODO(tommi): The version directory really should match the version of |
130 // setup.exe. To begin with, we should at least DCHECK that that's true. | 131 // setup.exe. To begin with, we should at least DCHECK that that's true. |
131 | 132 |
132 scoped_ptr<Version> max_version(new Version("0.0.0.0")); | 133 scoped_ptr<Version> max_version(new Version("0.0.0.0")); |
133 bool version_found = false; | 134 bool version_found = false; |
134 | 135 |
135 while (!version_enum.Next().empty()) { | 136 while (!version_enum.Next().empty()) { |
136 file_util::FileEnumerator::FindInfo find_data = {0}; | 137 base::FileEnumerator::FileInfo find_data = version_enum.GetInfo(); |
137 version_enum.GetFindInfo(&find_data); | 138 VLOG(1) << "directory found: " << find_data.GetName().value(); |
138 VLOG(1) << "directory found: " << find_data.cFileName; | |
139 | 139 |
140 scoped_ptr<Version> found_version( | 140 scoped_ptr<Version> found_version( |
141 new Version(WideToASCII(find_data.cFileName))); | 141 new Version(WideToASCII(find_data.GetName().value()))); |
142 if (found_version->IsValid() && | 142 if (found_version->IsValid() && |
143 found_version->CompareTo(*max_version.get()) > 0) { | 143 found_version->CompareTo(*max_version.get()) > 0) { |
144 max_version.reset(found_version.release()); | 144 max_version.reset(found_version.release()); |
145 version_found = true; | 145 version_found = true; |
146 } | 146 } |
147 } | 147 } |
148 | 148 |
149 return (version_found ? max_version.release() : NULL); | 149 return (version_found ? max_version.release() : NULL); |
150 } | 150 } |
151 | 151 |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
345 } | 345 } |
346 | 346 |
347 ScopedTokenPrivilege::~ScopedTokenPrivilege() { | 347 ScopedTokenPrivilege::~ScopedTokenPrivilege() { |
348 if (is_enabled_ && previous_privileges_.PrivilegeCount != 0) { | 348 if (is_enabled_ && previous_privileges_.PrivilegeCount != 0) { |
349 ::AdjustTokenPrivileges(token_, FALSE, &previous_privileges_, | 349 ::AdjustTokenPrivileges(token_, FALSE, &previous_privileges_, |
350 sizeof(TOKEN_PRIVILEGES), NULL, NULL); | 350 sizeof(TOKEN_PRIVILEGES), NULL, NULL); |
351 } | 351 } |
352 } | 352 } |
353 | 353 |
354 } // namespace installer | 354 } // namespace installer |
OLD | NEW |