OLD | NEW |
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 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 // HKLM for system-level installs. | 128 // HKLM for system-level installs. |
129 static bool GetProgIdEntries(BrowserDistribution* dist, | 129 static bool GetProgIdEntries(BrowserDistribution* dist, |
130 const string16& chrome_exe, | 130 const string16& chrome_exe, |
131 const string16& suffix, | 131 const string16& suffix, |
132 std::list<RegistryEntry*>* entries) { | 132 std::list<RegistryEntry*>* entries) { |
133 string16 icon_path(ShellUtil::GetChromeIcon(dist, chrome_exe)); | 133 string16 icon_path(ShellUtil::GetChromeIcon(dist, chrome_exe)); |
134 string16 open_cmd(ShellUtil::GetChromeShellOpenCmd(chrome_exe)); | 134 string16 open_cmd(ShellUtil::GetChromeShellOpenCmd(chrome_exe)); |
135 string16 delegate_command(ShellUtil::GetChromeDelegateCommand(chrome_exe)); | 135 string16 delegate_command(ShellUtil::GetChromeDelegateCommand(chrome_exe)); |
136 // For user-level installs: entries for the app id and DelegateExecute verb | 136 // For user-level installs: entries for the app id and DelegateExecute verb |
137 // handler will be in HKCU; thus we do not need a suffix on those entries. | 137 // handler will be in HKCU; thus we do not need a suffix on those entries. |
138 string16 app_id(dist->GetBrowserAppId()); | 138 string16 app_id(ShellUtil::GetAppId(dist, chrome_exe)); |
139 string16 delegate_guid; | 139 string16 delegate_guid; |
140 // TODO(grt): remove HasDelegateExecuteHandler when the exe is ever-present; | 140 // TODO(grt): remove HasDelegateExecuteHandler when the exe is ever-present; |
141 // see also install_worker.cc's AddDelegateExecuteWorkItems. | 141 // see also install_worker.cc's AddDelegateExecuteWorkItems. |
142 bool set_delegate_execute = | 142 bool set_delegate_execute = |
143 IsChromeMetroSupported() && | 143 IsChromeMetroSupported() && |
144 dist->GetDelegateExecuteHandlerData(&delegate_guid, NULL, NULL, NULL) && | 144 dist->GetDelegateExecuteHandlerData(&delegate_guid, NULL, NULL, NULL) && |
145 InstallUtil::HasDelegateExecuteHandler(dist, chrome_exe); | 145 InstallUtil::HasDelegateExecuteHandler(dist, chrome_exe); |
146 | 146 |
147 // DelegateExecute ProgId. Needed for Chrome Metro in Windows 8. | 147 // DelegateExecute ProgId. Needed for Chrome Metro in Windows 8. |
148 if (set_delegate_execute) { | 148 if (set_delegate_execute) { |
(...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
655 (!InstallUtil::HasDelegateExecuteHandler(dist, chrome_exe) || | 655 (!InstallUtil::HasDelegateExecuteHandler(dist, chrome_exe) || |
656 !IsChromeMetroSupported())) { | 656 !IsChromeMetroSupported())) { |
657 // There's no need to rollback, so forgo the usual work item lists and just | 657 // There's no need to rollback, so forgo the usual work item lists and just |
658 // remove the values from the registry. | 658 // remove the values from the registry. |
659 const HKEY root_key = InstallUtil::IsPerUserInstall(chrome_exe.c_str()) ? | 659 const HKEY root_key = InstallUtil::IsPerUserInstall(chrome_exe.c_str()) ? |
660 HKEY_CURRENT_USER : HKEY_LOCAL_MACHINE; | 660 HKEY_CURRENT_USER : HKEY_LOCAL_MACHINE; |
661 // Use the current installation's suffix, not the about-to-be-installed | 661 // Use the current installation's suffix, not the about-to-be-installed |
662 // suffix. | 662 // suffix. |
663 const string16 installation_suffix( | 663 const string16 installation_suffix( |
664 ShellUtil::GetCurrentInstallationSuffix(dist, chrome_exe)); | 664 ShellUtil::GetCurrentInstallationSuffix(dist, chrome_exe)); |
665 const string16 app_id(dist->GetBrowserAppId()); | 665 const string16 app_id(ShellUtil::GetAppId(dist, chrome_exe)); |
666 | 666 |
667 // <root hkey>\Software\Classes\<app_id> | 667 // <root hkey>\Software\Classes\<app_id> |
668 string16 key(ShellUtil::kRegClasses); | 668 string16 key(ShellUtil::kRegClasses); |
669 key.push_back(FilePath::kSeparators[0]); | 669 key.push_back(FilePath::kSeparators[0]); |
670 key.append(app_id); | 670 key.append(app_id); |
671 InstallUtil::DeleteRegistryKey(root_key, key); | 671 InstallUtil::DeleteRegistryKey(root_key, key); |
672 | 672 |
673 // <root hkey>\Software\Classes\ChromiumHTML[.user]\shell\open\command | 673 // <root hkey>\Software\Classes\ChromiumHTML[.user]\shell\open\command |
674 key = ShellUtil::kRegClasses; | 674 key = ShellUtil::kRegClasses; |
675 key.push_back(FilePath::kSeparators[0]); | 675 key.push_back(FilePath::kSeparators[0]); |
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1066 return tested_suffix; | 1066 return tested_suffix; |
1067 } | 1067 } |
1068 | 1068 |
1069 string16 ShellUtil::GetApplicationName(BrowserDistribution* dist, | 1069 string16 ShellUtil::GetApplicationName(BrowserDistribution* dist, |
1070 const string16& chrome_exe) { | 1070 const string16& chrome_exe) { |
1071 string16 app_name = dist->GetBaseAppName(); | 1071 string16 app_name = dist->GetBaseAppName(); |
1072 app_name += GetCurrentInstallationSuffix(dist, chrome_exe); | 1072 app_name += GetCurrentInstallationSuffix(dist, chrome_exe); |
1073 return app_name; | 1073 return app_name; |
1074 } | 1074 } |
1075 | 1075 |
| 1076 string16 ShellUtil::GetAppId(BrowserDistribution* dist, |
| 1077 const string16& chrome_exe) { |
| 1078 string16 app_id(dist->GetBaseAppId()); |
| 1079 string16 suffix; |
| 1080 if (InstallUtil::IsPerUserInstall(chrome_exe.c_str()) && |
| 1081 !GetUserSpecificRegistrySuffix(&suffix)) { |
| 1082 NOTREACHED(); |
| 1083 } |
| 1084 return app_id.append(suffix); |
| 1085 } |
| 1086 |
1076 bool ShellUtil::MakeChromeDefault(BrowserDistribution* dist, | 1087 bool ShellUtil::MakeChromeDefault(BrowserDistribution* dist, |
1077 int shell_change, | 1088 int shell_change, |
1078 const string16& chrome_exe, | 1089 const string16& chrome_exe, |
1079 bool elevate_if_not_admin) { | 1090 bool elevate_if_not_admin) { |
1080 DCHECK(!(shell_change & ShellUtil::SYSTEM_LEVEL) || IsUserAnAdmin()); | 1091 DCHECK(!(shell_change & ShellUtil::SYSTEM_LEVEL) || IsUserAnAdmin()); |
1081 | 1092 |
1082 if (!dist->CanSetAsDefault()) | 1093 if (!dist->CanSetAsDefault()) |
1083 return false; | 1094 return false; |
1084 | 1095 |
1085 // Windows 8 does not permit making a browser default just like that. | 1096 // Windows 8 does not permit making a browser default just like that. |
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 } |
OLD | NEW |