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

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

Issue 1402243003: [shell_util] Fall Back to Long Paths if Short Is Not Available (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix wrong variable name Created 5 years, 2 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
« no previous file with comments | « no previous file | no next file » | 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) 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 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 1289 matching lines...) Expand 10 before | Expand all | Expand 10 after
1300 1300
1301 return ShellUtil::IS_DEFAULT; 1301 return ShellUtil::IS_DEFAULT;
1302 } 1302 }
1303 1303
1304 // Probe the current commands registered to handle the shell "open" verb for 1304 // Probe the current commands registered to handle the shell "open" verb for
1305 // |protocols| (Windows XP); see ProbeProtocolHandlers. 1305 // |protocols| (Windows XP); see ProbeProtocolHandlers.
1306 ShellUtil::DefaultState ProbeOpenCommandHandlers( 1306 ShellUtil::DefaultState ProbeOpenCommandHandlers(
1307 const base::FilePath& chrome_exe, 1307 const base::FilePath& chrome_exe,
1308 const wchar_t* const* protocols, 1308 const wchar_t* const* protocols,
1309 size_t num_protocols) { 1309 size_t num_protocols) {
1310 // Get its short (8.3) form. 1310 // Get its short (8.3) form if possible.
1311 base::string16 short_app_path; 1311 base::string16 app_path;
1312 if (!ShortNameFromPath(chrome_exe, &short_app_path)) 1312 if (!ShortNameFromPath(chrome_exe, &app_path))
1313 return ShellUtil::UNKNOWN_DEFAULT; 1313 app_path = chrome_exe.value();
gab 2015/10/15 14:21:43 Value is only used inside if{} below, move it inli
Mark P 2015/10/15 16:27:48 I don't know what you mean. It's used in two spot
gab 2015/10/15 18:33:07 What I mean is you only need |short_app_path| in t
Mark P 2015/10/15 19:17:42 I don't understand. Do you mean that new line 133
gab 2015/10/16 19:02:17 I mean you definitely don't need it if you're not
Mark P 2015/10/16 23:02:44 Ah, now I understand.
1314 1314
1315 const HKEY root_key = HKEY_CLASSES_ROOT; 1315 const HKEY root_key = HKEY_CLASSES_ROOT;
1316 base::string16 key_path; 1316 base::string16 key_path;
1317 base::win::RegKey key; 1317 base::win::RegKey key;
1318 base::string16 value; 1318 base::string16 value;
1319 base::CommandLine command_line(base::CommandLine::NO_PROGRAM); 1319 base::CommandLine command_line(base::CommandLine::NO_PROGRAM);
1320 base::string16 short_path; 1320 base::string16 short_path;
1321 1321
1322 for (size_t i = 0; i < num_protocols; ++i) { 1322 for (size_t i = 0; i < num_protocols; ++i) {
1323 // Get the command line from HKCU\<protocol>\shell\open\command. 1323 // Get the command line from HKCU\<protocol>\shell\open\command.
1324 key_path.assign(protocols[i]).append(ShellUtil::kRegShellOpen); 1324 key_path.assign(protocols[i]).append(ShellUtil::kRegShellOpen);
1325 if ((key.Open(root_key, key_path.c_str(), 1325 if ((key.Open(root_key, key_path.c_str(),
1326 KEY_QUERY_VALUE) != ERROR_SUCCESS) || 1326 KEY_QUERY_VALUE) != ERROR_SUCCESS) ||
1327 (key.ReadValue(L"", &value) != ERROR_SUCCESS)) { 1327 (key.ReadValue(L"", &value) != ERROR_SUCCESS)) {
1328 return ShellUtil::NOT_DEFAULT; 1328 return ShellUtil::NOT_DEFAULT;
1329 } 1329 }
1330 1330
1331 // Need to normalize path in case it's been munged. 1331 // Need to normalize path in case it's been munged.
1332 command_line = base::CommandLine::FromString(value); 1332 command_line = base::CommandLine::FromString(value);
1333 if (!ShortNameFromPath(command_line.GetProgram(), &short_path)) 1333 if (ShortNameFromPath(command_line.GetProgram(), &short_path)) {
1334 return ShellUtil::UNKNOWN_DEFAULT; 1334 if (!base::FilePath::CompareEqualIgnoreCase(short_path, app_path))
gab 2015/10/15 14:21:43 Actually, @grt: shouldn't this entire method use P
grt (UTC plus 2) 2015/10/19 19:30:39 Might be a good idea, although the condition leadi
1335 1335 return ShellUtil::NOT_DEFAULT;
1336 if (!base::FilePath::CompareEqualIgnoreCase(short_path, short_app_path)) 1336 } else {
1337 return ShellUtil::NOT_DEFAULT; 1337 if (!base::FilePath::CompareEqualIgnoreCase(
1338 command_line.GetProgram().value(), app_path))
1339 return ShellUtil::NOT_DEFAULT;
1340 }
1338 } 1341 }
1339 1342
1340 return ShellUtil::IS_DEFAULT; 1343 return ShellUtil::IS_DEFAULT;
1341 } 1344 }
1342 1345
1343 // A helper function that probes default protocol handler registration (in a 1346 // A helper function that probes default protocol handler registration (in a
1344 // manner appropriate for the current version of Windows) to determine if 1347 // manner appropriate for the current version of Windows) to determine if
1345 // Chrome is the default handler for |protocols|. Returns IS_DEFAULT 1348 // Chrome is the default handler for |protocols|. Returns IS_DEFAULT
1346 // only if Chrome is the default for all specified protocols. 1349 // only if Chrome is the default for all specified protocols.
1347 ShellUtil::DefaultState ProbeProtocolHandlers( 1350 ShellUtil::DefaultState ProbeProtocolHandlers(
(...skipping 1217 matching lines...) Expand 10 before | Expand all | Expand 10 after
2565 base::string16 key_path(ShellUtil::kRegClasses); 2568 base::string16 key_path(ShellUtil::kRegClasses);
2566 key_path.push_back(base::FilePath::kSeparators[0]); 2569 key_path.push_back(base::FilePath::kSeparators[0]);
2567 key_path.append(prog_id); 2570 key_path.append(prog_id);
2568 return InstallUtil::DeleteRegistryKey( 2571 return InstallUtil::DeleteRegistryKey(
2569 HKEY_CURRENT_USER, key_path, WorkItem::kWow64Default); 2572 HKEY_CURRENT_USER, key_path, WorkItem::kWow64Default);
2570 2573
2571 // TODO(mgiuca): Remove the extension association entries. This requires that 2574 // TODO(mgiuca): Remove the extension association entries. This requires that
2572 // the extensions associated with a particular prog_id are stored in that 2575 // the extensions associated with a particular prog_id are stored in that
2573 // prog_id's key. 2576 // prog_id's key.
2574 } 2577 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698