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

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

Issue 1220653002: Fix some case-insensitive cases for StartsWith (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: grt's review comments, Mac fix Created 5 years, 5 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
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 // See the corresponding header file for description of the functions in this 5 // See the corresponding header file for description of the functions in this
6 // file. 6 // file.
7 7
8 #include "chrome/installer/util/install_util.h" 8 #include "chrome/installer/util/install_util.h"
9 9
10 #include <shellapi.h> 10 #include <shellapi.h>
11 #include <shlobj.h> 11 #include <shlobj.h>
12 #include <shlwapi.h> 12 #include <shlwapi.h>
13 13
14 #include <algorithm> 14 #include <algorithm>
15 15
16 #include "base/command_line.h" 16 #include "base/command_line.h"
17 #include "base/environment.h" 17 #include "base/environment.h"
18 #include "base/files/file_util.h" 18 #include "base/files/file_util.h"
19 #include "base/logging.h" 19 #include "base/logging.h"
20 #include "base/memory/scoped_ptr.h" 20 #include "base/memory/scoped_ptr.h"
21 #include "base/numerics/safe_conversions.h"
21 #include "base/path_service.h" 22 #include "base/path_service.h"
22 #include "base/process/launch.h" 23 #include "base/process/launch.h"
23 #include "base/strings/string_util.h" 24 #include "base/strings/string_util.h"
24 #include "base/strings/utf_string_conversions.h" 25 #include "base/strings/utf_string_conversions.h"
25 #include "base/sys_info.h" 26 #include "base/sys_info.h"
26 #include "base/values.h" 27 #include "base/values.h"
27 #include "base/version.h" 28 #include "base/version.h"
28 #include "base/win/metro.h" 29 #include "base/win/metro.h"
29 #include "base/win/registry.h" 30 #include "base/win/registry.h"
30 #include "base/win/windows_version.h" 31 #include "base/win/windows_version.h"
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 #else 387 #else
387 base::DIR_PROGRAM_FILES; 388 base::DIR_PROGRAM_FILES;
388 #endif 389 #endif
389 if (!PathService::Get(kProgramFilesKey, &program_files_path)) { 390 if (!PathService::Get(kProgramFilesKey, &program_files_path)) {
390 NOTREACHED(); 391 NOTREACHED();
391 return true; 392 return true;
392 } 393 }
393 env->SetVar(kEnvProgramFilesPath, 394 env->SetVar(kEnvProgramFilesPath,
394 base::WideToUTF8(program_files_path.value())); 395 base::WideToUTF8(program_files_path.value()));
395 } 396 }
396 return !base::StartsWith(exe_path.value(), program_files_path.value(), false); 397
398 // Return true if the program files path is not a case-insensitive prefix of
399 // the exe path.
400 if (exe_path.value().size() < program_files_path.value().size())
401 return true;
402 DWORD prefix_len =
403 base::saturated_cast<DWORD>(program_files_path.value().size());
404 return ::CompareString(LOCALE_USER_DEFAULT, NORM_IGNORECASE,
405 exe_path.value().data(), prefix_len,
406 program_files_path.value().data(), prefix_len) !=
407 CSTR_EQUAL;
397 } 408 }
398 409
399 bool InstallUtil::IsMultiInstall(BrowserDistribution* dist, 410 bool InstallUtil::IsMultiInstall(BrowserDistribution* dist,
400 bool system_install) { 411 bool system_install) {
401 DCHECK(dist); 412 DCHECK(dist);
402 ProductState state; 413 ProductState state;
403 return state.Initialize(system_install, dist) && state.is_multi_install(); 414 return state.Initialize(system_install, dist) && state.is_multi_install();
404 } 415 }
405 416
406 bool CheckIsChromeSxSProcess() { 417 bool CheckIsChromeSxSProcess() {
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
665 // Open the program and see if it references the expected file. 676 // Open the program and see if it references the expected file.
666 base::File file; 677 base::File file;
667 BY_HANDLE_FILE_INFORMATION info = {}; 678 BY_HANDLE_FILE_INFORMATION info = {};
668 679
669 return (OpenForInfo(path, &file) && 680 return (OpenForInfo(path, &file) &&
670 GetInfo(file, &info) && 681 GetInfo(file, &info) &&
671 info.dwVolumeSerialNumber == file_info_.dwVolumeSerialNumber && 682 info.dwVolumeSerialNumber == file_info_.dwVolumeSerialNumber &&
672 info.nFileIndexHigh == file_info_.nFileIndexHigh && 683 info.nFileIndexHigh == file_info_.nFileIndexHigh &&
673 info.nFileIndexLow == file_info_.nFileIndexLow); 684 info.nFileIndexLow == file_info_.nFileIndexLow);
674 } 685 }
OLDNEW
« no previous file with comments | « chrome/installer/util/delete_after_reboot_helper.cc ('k') | chrome/installer/util/shell_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698