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

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

Issue 10837222: Enable EULA dialog to be shown from metro Chrome. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Dear Greg, the third. Created 8 years, 3 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
« no previous file with comments | « chrome/installer/util/shell_util.h ('k') | chrome/installer/util/util_constants.h » ('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) 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 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 // These entries need to be registered in HKLM prior to Win8. 209 // These entries need to be registered in HKLM prior to Win8.
210 static void GetProgIdEntries(BrowserDistribution* dist, 210 static void GetProgIdEntries(BrowserDistribution* dist,
211 const string16& chrome_exe, 211 const string16& chrome_exe,
212 const string16& suffix, 212 const string16& suffix,
213 ScopedVector<RegistryEntry>* entries) { 213 ScopedVector<RegistryEntry>* entries) {
214 string16 icon_path(ShellUtil::GetChromeIcon(dist, chrome_exe)); 214 string16 icon_path(ShellUtil::GetChromeIcon(dist, chrome_exe));
215 string16 open_cmd(ShellUtil::GetChromeShellOpenCmd(chrome_exe)); 215 string16 open_cmd(ShellUtil::GetChromeShellOpenCmd(chrome_exe));
216 string16 delegate_command(ShellUtil::GetChromeDelegateCommand(chrome_exe)); 216 string16 delegate_command(ShellUtil::GetChromeDelegateCommand(chrome_exe));
217 // For user-level installs: entries for the app id and DelegateExecute verb 217 // For user-level installs: entries for the app id and DelegateExecute verb
218 // handler will be in HKCU; thus we do not need a suffix on those entries. 218 // handler will be in HKCU; thus we do not need a suffix on those entries.
219 string16 app_id(ShellUtil::GetBrowserModelId(dist, chrome_exe)); 219 string16 app_id(
220 ShellUtil::GetBrowserModelId(
221 dist, InstallUtil::IsPerUserInstall(chrome_exe.c_str())));
220 string16 delegate_guid; 222 string16 delegate_guid;
221 // TODO(grt): remove HasDelegateExecuteHandler when the exe is ever-present; 223 // TODO(grt): remove HasDelegateExecuteHandler when the exe is ever-present;
222 // see also install_worker.cc's AddDelegateExecuteWorkItems. 224 // see also install_worker.cc's AddDelegateExecuteWorkItems.
223 bool set_delegate_execute = 225 bool set_delegate_execute =
224 IsChromeMetroSupported() && 226 IsChromeMetroSupported() &&
225 dist->GetCommandExecuteImplClsid(&delegate_guid) && 227 dist->GetCommandExecuteImplClsid(&delegate_guid) &&
226 InstallUtil::HasDelegateExecuteHandler(dist, chrome_exe); 228 InstallUtil::HasDelegateExecuteHandler(dist, chrome_exe);
227 229
228 // DelegateExecute ProgId. Needed for Chrome Metro in Windows 8. 230 // DelegateExecute ProgId. Needed for Chrome Metro in Windows 8.
229 if (set_delegate_execute) { 231 if (set_delegate_execute) {
(...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after
745 // also become irrelevant sometime after Windows 8 RC (thus the aforementioned 747 // also become irrelevant sometime after Windows 8 RC (thus the aforementioned
746 // removal date remains correct). 748 // removal date remains correct).
747 void RemoveBadWindows8RegistrationIfNeeded( 749 void RemoveBadWindows8RegistrationIfNeeded(
748 BrowserDistribution* dist, 750 BrowserDistribution* dist,
749 const string16& chrome_exe) { 751 const string16& chrome_exe) {
750 if (dist->GetCommandExecuteImplClsid(NULL) && 752 if (dist->GetCommandExecuteImplClsid(NULL) &&
751 (!InstallUtil::HasDelegateExecuteHandler(dist, chrome_exe) || 753 (!InstallUtil::HasDelegateExecuteHandler(dist, chrome_exe) ||
752 !IsChromeMetroSupported())) { 754 !IsChromeMetroSupported())) {
753 // There's no need to rollback, so forgo the usual work item lists and just 755 // There's no need to rollback, so forgo the usual work item lists and just
754 // remove the values from the registry. 756 // remove the values from the registry.
755 const HKEY root_key = InstallUtil::IsPerUserInstall(chrome_exe.c_str()) ? 757 bool is_per_user_install =
756 HKEY_CURRENT_USER : HKEY_LOCAL_MACHINE; 758 InstallUtil::IsPerUserInstall(chrome_exe.c_str());
759 const HKEY root_key = is_per_user_install ? HKEY_CURRENT_USER :
760 HKEY_LOCAL_MACHINE;
757 // Use the current installation's suffix, not the about-to-be-installed 761 // Use the current installation's suffix, not the about-to-be-installed
758 // suffix. 762 // suffix.
759 const string16 installation_suffix( 763 const string16 installation_suffix(
760 ShellUtil::GetCurrentInstallationSuffix(dist, chrome_exe)); 764 ShellUtil::GetCurrentInstallationSuffix(dist, chrome_exe));
761 const string16 app_id(ShellUtil::GetBrowserModelId(dist, chrome_exe)); 765 const string16 app_id(ShellUtil::GetBrowserModelId(dist,
766 is_per_user_install));
762 767
763 // <root hkey>\Software\Classes\<app_id> 768 // <root hkey>\Software\Classes\<app_id>
764 string16 key(ShellUtil::kRegClasses); 769 string16 key(ShellUtil::kRegClasses);
765 key.push_back(FilePath::kSeparators[0]); 770 key.push_back(FilePath::kSeparators[0]);
766 key.append(app_id); 771 key.append(app_id);
767 InstallUtil::DeleteRegistryKey(root_key, key); 772 InstallUtil::DeleteRegistryKey(root_key, key);
768 773
769 // <root hkey>\Software\Classes\ChromiumHTML[.user]\shell\open\command 774 // <root hkey>\Software\Classes\ChromiumHTML[.user]\shell\open\command
770 key = ShellUtil::kRegClasses; 775 key = ShellUtil::kRegClasses;
771 key.push_back(FilePath::kSeparators[0]); 776 key.push_back(FilePath::kSeparators[0]);
(...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after
1206 } 1211 }
1207 1212
1208 string16 ShellUtil::GetApplicationName(BrowserDistribution* dist, 1213 string16 ShellUtil::GetApplicationName(BrowserDistribution* dist,
1209 const string16& chrome_exe) { 1214 const string16& chrome_exe) {
1210 string16 app_name = dist->GetBaseAppName(); 1215 string16 app_name = dist->GetBaseAppName();
1211 app_name += GetCurrentInstallationSuffix(dist, chrome_exe); 1216 app_name += GetCurrentInstallationSuffix(dist, chrome_exe);
1212 return app_name; 1217 return app_name;
1213 } 1218 }
1214 1219
1215 string16 ShellUtil::GetBrowserModelId(BrowserDistribution* dist, 1220 string16 ShellUtil::GetBrowserModelId(BrowserDistribution* dist,
1216 const string16& chrome_exe) { 1221 bool is_per_user_install) {
1217 string16 app_id(dist->GetBaseAppId()); 1222 string16 app_id(dist->GetBaseAppId());
1218 string16 suffix; 1223 string16 suffix;
1219 if (InstallUtil::IsPerUserInstall(chrome_exe.c_str()) && 1224 if (is_per_user_install && !GetUserSpecificRegistrySuffix(&suffix)) {
1220 !GetUserSpecificRegistrySuffix(&suffix)) {
1221 NOTREACHED(); 1225 NOTREACHED();
1222 } 1226 }
1223 // There is only one component (i.e. the suffixed appid) in this case, but it 1227 // There is only one component (i.e. the suffixed appid) in this case, but it
1224 // is still necessary to go through the appid constructor to make sure the 1228 // is still necessary to go through the appid constructor to make sure the
1225 // returned appid is truncated if necessary. 1229 // returned appid is truncated if necessary.
1226 std::vector<string16> components(1, app_id.append(suffix)); 1230 std::vector<string16> components(1, app_id.append(suffix));
1227 return BuildAppModelId(components); 1231 return BuildAppModelId(components);
1228 } 1232 }
1229 1233
1230 string16 ShellUtil::BuildAppModelId( 1234 string16 ShellUtil::BuildAppModelId(
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after
1625 return; 1629 return;
1626 1630
1627 FilePath app_shortcuts_path; 1631 FilePath app_shortcuts_path;
1628 if (!PathService::Get(base::DIR_APP_SHORTCUTS, &app_shortcuts_path)) { 1632 if (!PathService::Get(base::DIR_APP_SHORTCUTS, &app_shortcuts_path)) {
1629 LOG(ERROR) << "Could not get application shortcuts location to delete" 1633 LOG(ERROR) << "Could not get application shortcuts location to delete"
1630 << " start screen shortcuts."; 1634 << " start screen shortcuts.";
1631 return; 1635 return;
1632 } 1636 }
1633 1637
1634 app_shortcuts_path = app_shortcuts_path.Append( 1638 app_shortcuts_path = app_shortcuts_path.Append(
1635 GetBrowserModelId(dist, chrome_exe)); 1639 GetBrowserModelId(dist,
1640 InstallUtil::IsPerUserInstall(chrome_exe.c_str())));
1636 if (!file_util::DirectoryExists(app_shortcuts_path)) { 1641 if (!file_util::DirectoryExists(app_shortcuts_path)) {
1637 VLOG(1) << "No start screen shortcuts to delete."; 1642 VLOG(1) << "No start screen shortcuts to delete.";
1638 return; 1643 return;
1639 } 1644 }
1640 1645
1641 VLOG(1) << "Removing start screen shortcuts from " 1646 VLOG(1) << "Removing start screen shortcuts from "
1642 << app_shortcuts_path.value(); 1647 << app_shortcuts_path.value();
1643 if (!file_util::Delete(app_shortcuts_path, true)) { 1648 if (!file_util::Delete(app_shortcuts_path, true)) {
1644 LOG(ERROR) << "Failed to remove start screen shortcuts from " 1649 LOG(ERROR) << "Failed to remove start screen shortcuts from "
1645 << app_shortcuts_path.value(); 1650 << app_shortcuts_path.value();
(...skipping 10 matching lines...) Expand all
1656 uint32 options) { 1661 uint32 options) {
1657 const FilePath chrome_path(FilePath(chrome_exe).DirName()); 1662 const FilePath chrome_path(FilePath(chrome_exe).DirName());
1658 1663
1659 installer::MasterPreferences prefs( 1664 installer::MasterPreferences prefs(
1660 chrome_path.AppendASCII(installer::kDefaultMasterPrefs)); 1665 chrome_path.AppendASCII(installer::kDefaultMasterPrefs));
1661 if (FilePath::CompareEqualIgnoreCase(icon_path, chrome_exe)) { 1666 if (FilePath::CompareEqualIgnoreCase(icon_path, chrome_exe)) {
1662 prefs.GetInt(installer::master_preferences::kChromeShortcutIconIndex, 1667 prefs.GetInt(installer::master_preferences::kChromeShortcutIconIndex,
1663 &icon_index); 1668 &icon_index);
1664 } 1669 }
1665 1670
1666 const string16 app_id(GetBrowserModelId(dist, chrome_exe)); 1671 const string16 app_id(
1672 GetBrowserModelId(dist,
1673 InstallUtil::IsPerUserInstall(chrome_exe.c_str())));
1667 const bool is_dual_mode = ((options & ShellUtil::SHORTCUT_DUAL_MODE) != 0); 1674 const bool is_dual_mode = ((options & ShellUtil::SHORTCUT_DUAL_MODE) != 0);
1668 const base::win::ShortcutOperation operation = 1675 const base::win::ShortcutOperation operation =
1669 (options & ShellUtil::SHORTCUT_CREATE_ALWAYS) != 0 ? 1676 (options & ShellUtil::SHORTCUT_CREATE_ALWAYS) != 0 ?
1670 base::win::SHORTCUT_CREATE_ALWAYS : 1677 base::win::SHORTCUT_CREATE_ALWAYS :
1671 base::win::SHORTCUT_UPDATE_EXISTING; 1678 base::win::SHORTCUT_UPDATE_EXISTING;
1672 1679
1673 // TODO(gab): The shell_util interface will also be refactored in an upcoming 1680 // TODO(gab): The shell_util interface will also be refactored in an upcoming
1674 // CL to use a ShortcutProperties like interface for its shortcut methods. 1681 // CL to use a ShortcutProperties like interface for its shortcut methods.
1675 base::win::ShortcutProperties shortcut_properties; 1682 base::win::ShortcutProperties shortcut_properties;
1676 shortcut_properties.set_target(FilePath(chrome_exe)); 1683 shortcut_properties.set_target(FilePath(chrome_exe));
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
1744 // are any left...). 1751 // are any left...).
1745 if (free_bits >= 8 && next_byte_index < size) { 1752 if (free_bits >= 8 && next_byte_index < size) {
1746 free_bits -= 8; 1753 free_bits -= 8;
1747 bit_stream += bytes[next_byte_index++] << free_bits; 1754 bit_stream += bytes[next_byte_index++] << free_bits;
1748 } 1755 }
1749 } 1756 }
1750 1757
1751 DCHECK_EQ(ret.length(), encoded_length); 1758 DCHECK_EQ(ret.length(), encoded_length);
1752 return ret; 1759 return ret;
1753 } 1760 }
OLDNEW
« no previous file with comments | « chrome/installer/util/shell_util.h ('k') | chrome/installer/util/util_constants.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698