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 #include <stddef.h> | 10 #include <stddef.h> |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 return exit_code; | 96 return exit_code; |
97 } | 97 } |
98 | 98 |
99 Version* GetMaxVersionFromArchiveDir(const base::FilePath& chrome_path) { | 99 Version* GetMaxVersionFromArchiveDir(const base::FilePath& chrome_path) { |
100 VLOG(1) << "Looking for Chrome version folder under " << chrome_path.value(); | 100 VLOG(1) << "Looking for Chrome version folder under " << chrome_path.value(); |
101 base::FileEnumerator version_enum(chrome_path, false, | 101 base::FileEnumerator version_enum(chrome_path, false, |
102 base::FileEnumerator::DIRECTORIES); | 102 base::FileEnumerator::DIRECTORIES); |
103 // TODO(tommi): The version directory really should match the version of | 103 // TODO(tommi): The version directory really should match the version of |
104 // setup.exe. To begin with, we should at least DCHECK that that's true. | 104 // setup.exe. To begin with, we should at least DCHECK that that's true. |
105 | 105 |
106 scoped_ptr<Version> max_version(new Version("0.0.0.0")); | 106 std::unique_ptr<Version> max_version(new Version("0.0.0.0")); |
107 bool version_found = false; | 107 bool version_found = false; |
108 | 108 |
109 while (!version_enum.Next().empty()) { | 109 while (!version_enum.Next().empty()) { |
110 base::FileEnumerator::FileInfo find_data = version_enum.GetInfo(); | 110 base::FileEnumerator::FileInfo find_data = version_enum.GetInfo(); |
111 VLOG(1) << "directory found: " << find_data.GetName().value(); | 111 VLOG(1) << "directory found: " << find_data.GetName().value(); |
112 | 112 |
113 scoped_ptr<Version> found_version( | 113 std::unique_ptr<Version> found_version( |
114 new Version(base::UTF16ToASCII(find_data.GetName().value()))); | 114 new Version(base::UTF16ToASCII(find_data.GetName().value()))); |
115 if (found_version->IsValid() && | 115 if (found_version->IsValid() && |
116 found_version->CompareTo(*max_version.get()) > 0) { | 116 found_version->CompareTo(*max_version.get()) > 0) { |
117 max_version.reset(found_version.release()); | 117 max_version.reset(found_version.release()); |
118 version_found = true; | 118 version_found = true; |
119 } | 119 } |
120 } | 120 } |
121 | 121 |
122 return (version_found ? max_version.release() : NULL); | 122 return (version_found ? max_version.release() : NULL); |
123 } | 123 } |
(...skipping 13 matching lines...) Expand all Loading... |
137 base::FilePath patch_source; | 137 base::FilePath patch_source; |
138 const ProductState* product = | 138 const ProductState* product = |
139 original_state.GetProductState(installer_state.system_install(), | 139 original_state.GetProductState(installer_state.system_install(), |
140 installer_state.state_type()); | 140 installer_state.state_type()); |
141 if (product) { | 141 if (product) { |
142 patch_source = installer_state.GetInstallerDirectory(product->version()) | 142 patch_source = installer_state.GetInstallerDirectory(product->version()) |
143 .Append(installer::kChromeArchive); | 143 .Append(installer::kChromeArchive); |
144 if (base::PathExists(patch_source)) | 144 if (base::PathExists(patch_source)) |
145 return patch_source; | 145 return patch_source; |
146 } | 146 } |
147 scoped_ptr<Version> version( | 147 std::unique_ptr<Version> version( |
148 installer::GetMaxVersionFromArchiveDir(installer_state.target_path())); | 148 installer::GetMaxVersionFromArchiveDir(installer_state.target_path())); |
149 if (version) { | 149 if (version) { |
150 patch_source = installer_state.GetInstallerDirectory(*version) | 150 patch_source = installer_state.GetInstallerDirectory(*version) |
151 .Append(installer::kChromeArchive); | 151 .Append(installer::kChromeArchive); |
152 if (base::PathExists(patch_source)) | 152 if (base::PathExists(patch_source)) |
153 return patch_source; | 153 return patch_source; |
154 } | 154 } |
155 return base::FilePath(); | 155 return base::FilePath(); |
156 } | 156 } |
157 | 157 |
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
575 } | 575 } |
576 | 576 |
577 ScopedTokenPrivilege::~ScopedTokenPrivilege() { | 577 ScopedTokenPrivilege::~ScopedTokenPrivilege() { |
578 if (is_enabled_ && previous_privileges_.PrivilegeCount != 0) { | 578 if (is_enabled_ && previous_privileges_.PrivilegeCount != 0) { |
579 ::AdjustTokenPrivileges(token_.Get(), FALSE, &previous_privileges_, | 579 ::AdjustTokenPrivileges(token_.Get(), FALSE, &previous_privileges_, |
580 sizeof(TOKEN_PRIVILEGES), NULL, NULL); | 580 sizeof(TOKEN_PRIVILEGES), NULL, NULL); |
581 } | 581 } |
582 } | 582 } |
583 | 583 |
584 } // namespace installer | 584 } // namespace installer |
OLD | NEW |