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

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

Issue 4366001: base: Move CaseInsensitiveCompare traits into the base namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 10 years, 1 month 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
« no previous file with comments | « chrome/installer/setup/uninstall.cc ('k') | chrome_frame/test_utils.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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"
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 // Checks if the current registry entry exists in HKLM registry and the value 194 // Checks if the current registry entry exists in HKLM registry and the value
195 // is same. 195 // is same.
196 bool ExistsInHKLM() const { 196 bool ExistsInHKLM() const {
197 RegKey key(HKEY_LOCAL_MACHINE, _key_path.c_str(), KEY_READ); 197 RegKey key(HKEY_LOCAL_MACHINE, _key_path.c_str(), KEY_READ);
198 bool found = false; 198 bool found = false;
199 if (_is_string) { 199 if (_is_string) {
200 std::wstring read_value; 200 std::wstring read_value;
201 found = (key.ReadValue(_name.c_str(), &read_value)) && 201 found = (key.ReadValue(_name.c_str(), &read_value)) &&
202 (read_value.size() == _value.size()) && 202 (read_value.size() == _value.size()) &&
203 (std::equal(_value.begin(), _value.end(), read_value.begin(), 203 (std::equal(_value.begin(), _value.end(), read_value.begin(),
204 CaseInsensitiveCompare<wchar_t>())); 204 base::CaseInsensitiveCompare<wchar_t>()));
205 } else { 205 } else {
206 DWORD read_value; 206 DWORD read_value;
207 found = key.ReadValueDW(_name.c_str(), &read_value) && 207 found = key.ReadValueDW(_name.c_str(), &read_value) &&
208 read_value == _int_value; 208 read_value == _int_value;
209 } 209 }
210 key.Close(); 210 key.Close();
211 return found; 211 return found;
212 } 212 }
213 213
214 // Checks if the current registry entry exists in HKLM registry 214 // Checks if the current registry entry exists in HKLM registry
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 std::wstring registry_chrome_exe; 358 std::wstring registry_chrome_exe;
359 if (!key.ReadValue(L"", &registry_chrome_exe) || 359 if (!key.ReadValue(L"", &registry_chrome_exe) ||
360 registry_chrome_exe.length() < 2) 360 registry_chrome_exe.length() < 2)
361 return false; 361 return false;
362 362
363 registry_chrome_exe = registry_chrome_exe.substr(1, 363 registry_chrome_exe = registry_chrome_exe.substr(1,
364 registry_chrome_exe.length() - 2); 364 registry_chrome_exe.length() - 2);
365 if ((registry_chrome_exe.size() == chrome_exe.size()) && 365 if ((registry_chrome_exe.size() == chrome_exe.size()) &&
366 (std::equal(chrome_exe.begin(), chrome_exe.end(), 366 (std::equal(chrome_exe.begin(), chrome_exe.end(),
367 registry_chrome_exe.begin(), 367 registry_chrome_exe.begin(),
368 CaseInsensitiveCompare<wchar_t>()))) 368 base::CaseInsensitiveCompare<wchar_t>()))) {
369 return false; 369 return false;
370 }
370 371
371 std::vector<std::wstring> v1, v2; 372 std::vector<std::wstring> v1, v2;
372 base::SplitString(registry_chrome_exe, L'\\', &v1); 373 base::SplitString(registry_chrome_exe, L'\\', &v1);
373 base::SplitString(chrome_exe, L'\\', &v2); 374 base::SplitString(chrome_exe, L'\\', &v2);
374 if (v1.size() == 0 || v2.size() == 0 || v1.size() != v2.size()) 375 if (v1.size() == 0 || v2.size() == 0 || v1.size() != v2.size())
375 return false; 376 return false;
376 377
377 // Now check that only one of the values within two '\' chars differ. 378 // Now check that only one of the values within two '\' chars differ.
378 std::vector<std::wstring>::iterator itr1 = v1.begin(); 379 std::vector<std::wstring>::iterator itr1 = v1.begin();
379 std::vector<std::wstring>::iterator itr2 = v2.begin(); 380 std::vector<std::wstring>::iterator itr2 = v2.begin();
380 bool one_mismatch = false; 381 bool one_mismatch = false;
381 for ( ; itr1 < v1.end() && itr2 < v2.end(); ++itr1, ++itr2) { 382 for ( ; itr1 < v1.end() && itr2 < v2.end(); ++itr1, ++itr2) {
382 std::wstring s1 = *itr1; 383 std::wstring s1 = *itr1;
383 std::wstring s2 = *itr2; 384 std::wstring s2 = *itr2;
384 if ((s1.size() != s2.size()) || 385 if ((s1.size() != s2.size()) ||
385 (!std::equal(s1.begin(), s1.end(), 386 (!std::equal(s1.begin(), s1.end(),
386 s2.begin(), CaseInsensitiveCompare<wchar_t>()))) { 387 s2.begin(), base::CaseInsensitiveCompare<wchar_t>()))) {
387 if (one_mismatch) 388 if (one_mismatch)
388 return false; 389 return false;
389 else 390 else
390 one_mismatch = true; 391 one_mismatch = true;
391 } 392 }
392 } 393 }
393 return true; 394 return true;
394 } 395 }
395 396
396 } // namespace 397 } // namespace
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after
803 chrome_exe.c_str(), // target 804 chrome_exe.c_str(), // target
804 shortcut.c_str(), // shortcut 805 shortcut.c_str(), // shortcut
805 chrome_path.c_str(), // working dir 806 chrome_path.c_str(), // working dir
806 NULL, // arguments 807 NULL, // arguments
807 description.c_str(), // description 808 description.c_str(), // description
808 chrome_exe.c_str(), // icon file 809 chrome_exe.c_str(), // icon file
809 icon_index, // icon index 810 icon_index, // icon index
810 dist->GetBrowserAppId().c_str()); // app id 811 dist->GetBrowserAppId().c_str()); // app id
811 } 812 }
812 } 813 }
OLDNEW
« no previous file with comments | « chrome/installer/setup/uninstall.cc ('k') | chrome_frame/test_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698