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

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

Issue 10542031: Suffix Chrome's appid on user-level installs (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix shell integration test Created 8 years, 6 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) 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 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 // HKLM for system-level installs. 129 // HKLM for system-level installs.
130 static bool GetProgIdEntries(BrowserDistribution* dist, 130 static bool GetProgIdEntries(BrowserDistribution* dist,
131 const string16& chrome_exe, 131 const string16& chrome_exe,
132 const string16& suffix, 132 const string16& suffix,
133 std::list<RegistryEntry*>* entries) { 133 std::list<RegistryEntry*>* entries) {
134 string16 icon_path(ShellUtil::GetChromeIcon(dist, chrome_exe)); 134 string16 icon_path(ShellUtil::GetChromeIcon(dist, chrome_exe));
135 string16 open_cmd(ShellUtil::GetChromeShellOpenCmd(chrome_exe)); 135 string16 open_cmd(ShellUtil::GetChromeShellOpenCmd(chrome_exe));
136 string16 delegate_command(ShellUtil::GetChromeDelegateCommand(chrome_exe)); 136 string16 delegate_command(ShellUtil::GetChromeDelegateCommand(chrome_exe));
137 // For user-level installs: entries for the app id and DelegateExecute verb 137 // For user-level installs: entries for the app id and DelegateExecute verb
138 // handler will be in HKCU; thus we do not need a suffix on those entries. 138 // handler will be in HKCU; thus we do not need a suffix on those entries.
139 string16 app_id(dist->GetBrowserAppId()); 139 string16 app_id(ShellUtil::GetAppId(dist, chrome_exe));
140 string16 delegate_guid; 140 string16 delegate_guid;
141 // TODO(grt): remove HasDelegateExecuteHandler when the exe is ever-present; 141 // TODO(grt): remove HasDelegateExecuteHandler when the exe is ever-present;
142 // see also install_worker.cc's AddDelegateExecuteWorkItems. 142 // see also install_worker.cc's AddDelegateExecuteWorkItems.
143 bool set_delegate_execute = 143 bool set_delegate_execute =
144 IsChromeMetroSupported() && 144 IsChromeMetroSupported() &&
145 dist->GetDelegateExecuteHandlerData(&delegate_guid, NULL, NULL, NULL) && 145 dist->GetDelegateExecuteHandlerData(&delegate_guid, NULL, NULL, NULL) &&
146 InstallUtil::HasDelegateExecuteHandler(dist, chrome_exe); 146 InstallUtil::HasDelegateExecuteHandler(dist, chrome_exe);
147 147
148 // DelegateExecute ProgId. Needed for Chrome Metro in Windows 8. 148 // DelegateExecute ProgId. Needed for Chrome Metro in Windows 8.
149 if (set_delegate_execute) { 149 if (set_delegate_execute) {
(...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after
656 (!InstallUtil::HasDelegateExecuteHandler(dist, chrome_exe) || 656 (!InstallUtil::HasDelegateExecuteHandler(dist, chrome_exe) ||
657 !IsChromeMetroSupported())) { 657 !IsChromeMetroSupported())) {
658 // There's no need to rollback, so forgo the usual work item lists and just 658 // There's no need to rollback, so forgo the usual work item lists and just
659 // remove the values from the registry. 659 // remove the values from the registry.
660 const HKEY root_key = InstallUtil::IsPerUserInstall(chrome_exe.c_str()) ? 660 const HKEY root_key = InstallUtil::IsPerUserInstall(chrome_exe.c_str()) ?
661 HKEY_CURRENT_USER : HKEY_LOCAL_MACHINE; 661 HKEY_CURRENT_USER : HKEY_LOCAL_MACHINE;
662 // Use the current installation's suffix, not the about-to-be-installed 662 // Use the current installation's suffix, not the about-to-be-installed
663 // suffix. 663 // suffix.
664 const string16 installation_suffix( 664 const string16 installation_suffix(
665 ShellUtil::GetCurrentInstallationSuffix(dist, chrome_exe)); 665 ShellUtil::GetCurrentInstallationSuffix(dist, chrome_exe));
666 const string16 app_id(dist->GetBrowserAppId()); 666 const string16 app_id(ShellUtil::GetAppId(dist, chrome_exe));
667 667
668 // <root hkey>\Software\Classes\<app_id> 668 // <root hkey>\Software\Classes\<app_id>
669 string16 key(ShellUtil::kRegClasses); 669 string16 key(ShellUtil::kRegClasses);
670 key.push_back(FilePath::kSeparators[0]); 670 key.push_back(FilePath::kSeparators[0]);
671 key.append(app_id); 671 key.append(app_id);
672 InstallUtil::DeleteRegistryKey(root_key, key); 672 InstallUtil::DeleteRegistryKey(root_key, key);
673 673
674 // <root hkey>\Software\Classes\ChromiumHTML[.user]\shell\open\command 674 // <root hkey>\Software\Classes\ChromiumHTML[.user]\shell\open\command
675 key = ShellUtil::kRegClasses; 675 key = ShellUtil::kRegClasses;
676 key.push_back(FilePath::kSeparators[0]); 676 key.push_back(FilePath::kSeparators[0]);
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after
1067 return tested_suffix; 1067 return tested_suffix;
1068 } 1068 }
1069 1069
1070 string16 ShellUtil::GetApplicationName(BrowserDistribution* dist, 1070 string16 ShellUtil::GetApplicationName(BrowserDistribution* dist,
1071 const string16& chrome_exe) { 1071 const string16& chrome_exe) {
1072 string16 app_name = dist->GetBaseAppName(); 1072 string16 app_name = dist->GetBaseAppName();
1073 app_name += GetCurrentInstallationSuffix(dist, chrome_exe); 1073 app_name += GetCurrentInstallationSuffix(dist, chrome_exe);
1074 return app_name; 1074 return app_name;
1075 } 1075 }
1076 1076
1077 string16 ShellUtil::GetAppId(BrowserDistribution* dist,
1078 const string16& chrome_exe) {
1079 string16 app_id(dist->GetBaseAppId());
1080 string16 suffix;
1081 if (InstallUtil::IsPerUserInstall(chrome_exe.c_str()) &&
1082 !GetUserSpecificRegistrySuffix(&suffix)) {
1083 NOTREACHED();
1084 }
1085 return app_id.append(suffix);
1086 }
1087
1077 bool ShellUtil::MakeChromeDefault(BrowserDistribution* dist, 1088 bool ShellUtil::MakeChromeDefault(BrowserDistribution* dist,
1078 int shell_change, 1089 int shell_change,
1079 const string16& chrome_exe, 1090 const string16& chrome_exe,
1080 bool elevate_if_not_admin) { 1091 bool elevate_if_not_admin) {
1081 DCHECK(!(shell_change & ShellUtil::SYSTEM_LEVEL) || IsUserAnAdmin()); 1092 DCHECK(!(shell_change & ShellUtil::SYSTEM_LEVEL) || IsUserAnAdmin());
1082 1093
1083 if (!dist->CanSetAsDefault()) 1094 if (!dist->CanSetAsDefault())
1084 return false; 1095 return false;
1085 1096
1086 // Windows 8 does not permit making a browser default just like that. 1097 // Windows 8 does not permit making a browser default just like that.
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after
1425 } 1436 }
1426 1437
1427 bool ShellUtil::UpdateChromeShortcut(BrowserDistribution* dist, 1438 bool ShellUtil::UpdateChromeShortcut(BrowserDistribution* dist,
1428 const string16& chrome_exe, 1439 const string16& chrome_exe,
1429 const string16& shortcut, 1440 const string16& shortcut,
1430 const string16& arguments, 1441 const string16& arguments,
1431 const string16& description, 1442 const string16& description,
1432 const string16& icon_path, 1443 const string16& icon_path,
1433 int icon_index, 1444 int icon_index,
1434 uint32 options) { 1445 uint32 options) {
1435 string16 chrome_path = FilePath(chrome_exe).DirName().value(); 1446 const FilePath chrome_path(FilePath(chrome_exe).DirName());
1436 1447
1437 FilePath prefs_path(chrome_path); 1448 installer::MasterPreferences prefs(
1438 prefs_path = prefs_path.AppendASCII(installer::kDefaultMasterPrefs); 1449 chrome_path.AppendASCII(installer::kDefaultMasterPrefs));
1439 installer::MasterPreferences prefs(prefs_path);
1440 if (FilePath::CompareEqualIgnoreCase(icon_path, chrome_exe)) { 1450 if (FilePath::CompareEqualIgnoreCase(icon_path, chrome_exe)) {
1441 prefs.GetInt(installer::master_preferences::kChromeShortcutIconIndex, 1451 prefs.GetInt(installer::master_preferences::kChromeShortcutIconIndex,
1442 &icon_index); 1452 &icon_index);
1443 } 1453 }
1444 1454
1455 const string16 app_id(GetAppId(dist, chrome_exe));
1456
1445 return file_util::CreateOrUpdateShortcutLink( 1457 return file_util::CreateOrUpdateShortcutLink(
1446 chrome_exe.c_str(), 1458 chrome_exe.c_str(),
1447 shortcut.c_str(), 1459 shortcut.c_str(),
1448 chrome_path.c_str(), 1460 chrome_path.value().c_str(),
1449 arguments.c_str(), 1461 arguments.c_str(),
1450 description.c_str(), 1462 description.c_str(),
1451 icon_path.c_str(), 1463 icon_path.c_str(),
1452 icon_index, 1464 icon_index,
1453 dist->GetBrowserAppId().c_str(), 1465 app_id.c_str(),
1454 ConvertShellUtilShortcutOptionsToFileUtil(options)); 1466 ConvertShellUtilShortcutOptionsToFileUtil(options));
1455 } 1467 }
OLDNEW
« chrome/browser/shell_integration_unittest.cc ('K') | « chrome/installer/util/shell_util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698