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

Side by Side Diff: chrome/browser/enumerate_modules_model_win.cc

Issue 6386009: Remove app/win/win_util.h,cc etc. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge with NSApp changes in r73581 Created 9 years, 10 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #include "chrome/browser/enumerate_modules_model_win.h" 5 #include "chrome/browser/enumerate_modules_model_win.h"
6 6
7 #include <Tlhelp32.h> 7 #include <Tlhelp32.h>
8 #include <wintrust.h> 8 #include <wintrust.h>
9 9
10 #include "app/win/win_util.h"
11 #include "base/command_line.h" 10 #include "base/command_line.h"
12 #include "base/environment.h" 11 #include "base/environment.h"
13 #include "base/file_path.h" 12 #include "base/file_path.h"
14 #include "base/file_version_info_win.h" 13 #include "base/file_version_info_win.h"
15 #include "base/metrics/histogram.h" 14 #include "base/metrics/histogram.h"
16 #include "base/sha2.h" 15 #include "base/sha2.h"
17 #include "base/string_number_conversions.h" 16 #include "base/string_number_conversions.h"
18 #include "base/string_util.h" 17 #include "base/string_util.h"
19 #include "base/time.h" 18 #include "base/time.h"
20 #include "base/utf_string_conversions.h" 19 #include "base/utf_string_conversions.h"
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 explicit FindModule(const ModuleEnumerator::Module& x) 67 explicit FindModule(const ModuleEnumerator::Module& x)
69 : module(x) {} 68 : module(x) {}
70 bool operator()(const ModuleEnumerator::Module& module_in) const { 69 bool operator()(const ModuleEnumerator::Module& module_in) const {
71 return (module.location == module_in.location) && 70 return (module.location == module_in.location) &&
72 (module.name == module_in.name); 71 (module.name == module_in.name);
73 } 72 }
74 73
75 const ModuleEnumerator::Module& module; 74 const ModuleEnumerator::Module& module;
76 }; 75 };
77 76
77 // Returns the long path name given a short path name. A short path name is a
78 // path that follows the 8.3 convention and has ~x in it. If the path is already
79 // a long path name, the function returns the current path without modification.
80 bool ConvertToLongPath(const string16& short_path, string16* long_path) {
81 wchar_t long_path_buf[MAX_PATH];
82 DWORD return_value = GetLongPathName(short_path.c_str(), long_path_buf,
83 MAX_PATH);
84 if (return_value != 0 && return_value < MAX_PATH) {
85 *long_path = long_path_buf;
86 return true;
87 }
88
89 return false;
78 } 90 }
79 91
92 } // namespace
93
80 // The browser process module blacklist. This lists modules that are known 94 // The browser process module blacklist. This lists modules that are known
81 // to cause compatibility issues within the browser process. When adding to this 95 // to cause compatibility issues within the browser process. When adding to this
82 // list, make sure that all paths are lower-case, in long pathname form, end 96 // list, make sure that all paths are lower-case, in long pathname form, end
83 // with a slash and use environments variables (or just look at one of the 97 // with a slash and use environments variables (or just look at one of the
84 // comments below and keep it consistent with that). When adding an entry with 98 // comments below and keep it consistent with that). When adding an entry with
85 // an environment variable not currently used in the list below, make sure to 99 // an environment variable not currently used in the list below, make sure to
86 // update the list in PreparePathMappings. Filename, Description/Signer, and 100 // update the list in PreparePathMappings. Filename, Description/Signer, and
87 // Location must be entered as hashes (see GenerateHash). Filename is mandatory. 101 // Location must be entered as hashes (see GenerateHash). Filename is mandatory.
88 // Entries without any Description, Signer info, or Location will never be 102 // Entries without any Description, Signer info, or Location will never be
89 // marked as confirmed bad (only as suspicious). 103 // marked as confirmed bad (only as suspicious).
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 uint8 hash[4]; 227 uint8 hash[4];
214 base::SHA256HashString(input, hash, sizeof(hash)); 228 base::SHA256HashString(input, hash, sizeof(hash));
215 *output = StringToLowerASCII(base::HexEncode(hash, sizeof(hash))); 229 *output = StringToLowerASCII(base::HexEncode(hash, sizeof(hash)));
216 } 230 }
217 231
218 // ----------------------------------------------------------------------------- 232 // -----------------------------------------------------------------------------
219 233
220 // static 234 // static
221 void ModuleEnumerator::NormalizeModule(Module* module) { 235 void ModuleEnumerator::NormalizeModule(Module* module) {
222 string16 path = module->location; 236 string16 path = module->location;
223 if (!app::win::ConvertToLongPath(path, &module->location)) 237 if (!ConvertToLongPath(path, &module->location))
224 module->location = path; 238 module->location = path;
225 239
226 module->location = l10n_util::ToLower(module->location); 240 module->location = l10n_util::ToLower(module->location);
227 241
228 // Location contains the filename, so the last slash is where the path 242 // Location contains the filename, so the last slash is where the path
229 // ends. 243 // ends.
230 size_t last_slash = module->location.find_last_of(L"\\"); 244 size_t last_slash = module->location.find_last_of(L"\\");
231 if (last_slash != string16::npos) { 245 if (last_slash != string16::npos) {
232 module->name = module->location.substr(last_slash + 1); 246 module->name = module->location.substr(last_slash + 1);
233 module->location = module->location.substr(0, last_slash + 1); 247 module->location = module->location.substr(0, last_slash + 1);
(...skipping 645 matching lines...) Expand 10 before | Expand all | Expand 10 after
879 GenerateHash(WideToUTF8(module.name), &filename); 893 GenerateHash(WideToUTF8(module.name), &filename);
880 GenerateHash(WideToUTF8(module.location), &location); 894 GenerateHash(WideToUTF8(module.location), &location);
881 GenerateHash(WideToUTF8(module.description), &description); 895 GenerateHash(WideToUTF8(module.description), &description);
882 GenerateHash(WideToUTF8(module.digital_signer), &signer); 896 GenerateHash(WideToUTF8(module.digital_signer), &signer);
883 897
884 string16 url = l10n_util::GetStringFUTF16(IDS_HELP_CENTER_VIEW_CONFLICTS, 898 string16 url = l10n_util::GetStringFUTF16(IDS_HELP_CENTER_VIEW_CONFLICTS,
885 ASCIIToUTF16(filename), ASCIIToUTF16(location), 899 ASCIIToUTF16(filename), ASCIIToUTF16(location),
886 ASCIIToUTF16(description), ASCIIToUTF16(signer)); 900 ASCIIToUTF16(description), ASCIIToUTF16(signer));
887 return GURL(UTF16ToUTF8(url)); 901 return GURL(UTF16ToUTF8(url));
888 } 902 }
OLDNEW
« no previous file with comments | « chrome/browser/download/download_util.cc ('k') | chrome/browser/extensions/extensions_startup.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698