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 "base/win/windows_version.h" | 19 #include "base/win/windows_version.h" |
19 #include "chrome/installer/util/copy_tree_work_item.h" | 20 #include "chrome/installer/util/copy_tree_work_item.h" |
20 #include "chrome/installer/util/installation_state.h" | 21 #include "chrome/installer/util/installation_state.h" |
21 #include "chrome/installer/util/installer_state.h" | 22 #include "chrome/installer/util/installer_state.h" |
22 #include "chrome/installer/util/master_preferences.h" | 23 #include "chrome/installer/util/master_preferences.h" |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 if (installer_state != NULL) | 119 if (installer_state != NULL) |
119 installer_state->UpdateStage(installer::BINARY_PATCHING); | 120 installer_state->UpdateStage(installer::BINARY_PATCHING); |
120 | 121 |
121 return ApplyBinaryPatch(src.value().c_str(), patch.value().c_str(), | 122 return ApplyBinaryPatch(src.value().c_str(), patch.value().c_str(), |
122 dest.value().c_str()); | 123 dest.value().c_str()); |
123 } | 124 } |
124 | 125 |
125 Version* GetMaxVersionFromArchiveDir(const base::FilePath& chrome_path) { | 126 Version* GetMaxVersionFromArchiveDir(const base::FilePath& chrome_path) { |
126 VLOG(1) << "Looking for Chrome version folder under " << chrome_path.value(); | 127 VLOG(1) << "Looking for Chrome version folder under " << chrome_path.value(); |
127 Version* version = NULL; | 128 Version* version = NULL; |
128 file_util::FileEnumerator version_enum(chrome_path, false, | 129 base::FileEnumerator version_enum(chrome_path, false, |
129 file_util::FileEnumerator::DIRECTORIES); | 130 base::FileEnumerator::DIRECTORIES); |
130 // TODO(tommi): The version directory really should match the version of | 131 // TODO(tommi): The version directory really should match the version of |
131 // setup.exe. To begin with, we should at least DCHECK that that's true. | 132 // setup.exe. To begin with, we should at least DCHECK that that's true. |
132 | 133 |
133 scoped_ptr<Version> max_version(new Version("0.0.0.0")); | 134 scoped_ptr<Version> max_version(new Version("0.0.0.0")); |
134 bool version_found = false; | 135 bool version_found = false; |
135 | 136 |
136 while (!version_enum.Next().empty()) { | 137 while (!version_enum.Next().empty()) { |
137 file_util::FileEnumerator::FindInfo find_data = {0}; | 138 base::FileEnumerator::FileInfo find_data = version_enum.GetInfo(); |
138 version_enum.GetFindInfo(&find_data); | 139 VLOG(1) << "directory found: " << find_data.GetName().value(); |
139 VLOG(1) << "directory found: " << find_data.cFileName; | |
140 | 140 |
141 scoped_ptr<Version> found_version( | 141 scoped_ptr<Version> found_version( |
142 new Version(WideToASCII(find_data.cFileName))); | 142 new Version(WideToASCII(find_data.GetName().value()))); |
143 if (found_version->IsValid() && | 143 if (found_version->IsValid() && |
144 found_version->CompareTo(*max_version.get()) > 0) { | 144 found_version->CompareTo(*max_version.get()) > 0) { |
145 max_version.reset(found_version.release()); | 145 max_version.reset(found_version.release()); |
146 version_found = true; | 146 version_found = true; |
147 } | 147 } |
148 } | 148 } |
149 | 149 |
150 return (version_found ? max_version.release() : NULL); | 150 return (version_found ? max_version.release() : NULL); |
151 } | 151 } |
152 | 152 |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
362 } | 362 } |
363 | 363 |
364 ScopedTokenPrivilege::~ScopedTokenPrivilege() { | 364 ScopedTokenPrivilege::~ScopedTokenPrivilege() { |
365 if (is_enabled_ && previous_privileges_.PrivilegeCount != 0) { | 365 if (is_enabled_ && previous_privileges_.PrivilegeCount != 0) { |
366 ::AdjustTokenPrivileges(token_, FALSE, &previous_privileges_, | 366 ::AdjustTokenPrivileges(token_, FALSE, &previous_privileges_, |
367 sizeof(TOKEN_PRIVILEGES), NULL, NULL); | 367 sizeof(TOKEN_PRIVILEGES), NULL, NULL); |
368 } | 368 } |
369 } | 369 } |
370 | 370 |
371 } // namespace installer | 371 } // namespace installer |
OLD | NEW |