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

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

Issue 101001: For system level install read setup.exe path from HKLM instead of HKCU. (Closed)
Patch Set: Created 11 years, 8 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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 <windows.h> 10 #include <windows.h>
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 std::wstring app_key = L"Software\\Classes\\Applications\\" + exe_name + 68 std::wstring app_key = L"Software\\Classes\\Applications\\" + exe_name +
69 L"\\shell\\open\\command"; 69 L"\\shell\\open\\command";
70 entries.push_front(new RegistryEntry(app_key, open_cmd)); 70 entries.push_front(new RegistryEntry(app_key, open_cmd));
71 for (int i = 0; ShellUtil::kFileAssociations[i] != NULL; i++) { 71 for (int i = 0; ShellUtil::kFileAssociations[i] != NULL; i++) {
72 std::wstring open_with_key(L"Software\\Classes\\"); 72 std::wstring open_with_key(L"Software\\Classes\\");
73 open_with_key.append(ShellUtil::kFileAssociations[i]); 73 open_with_key.append(ShellUtil::kFileAssociations[i]);
74 open_with_key.append(L"\\OpenWithList\\" + exe_name); 74 open_with_key.append(L"\\OpenWithList\\" + exe_name);
75 entries.push_front(new RegistryEntry(open_with_key, std::wstring())); 75 entries.push_front(new RegistryEntry(open_with_key, std::wstring()));
76 } 76 }
77 77
78 // Chrome extension installer 78 // Chrome Extension file handler
79 std::wstring install_cmd = 79 std::wstring install_cmd =
80 ShellUtil::GetChromeInstallExtensionCmd(chrome_exe); 80 ShellUtil::GetChromeInstallExtensionCmd(chrome_exe);
81 std::wstring prog_id = std::wstring(L"Software\\Classes\\") + 81 std::wstring prog_id = std::wstring(L"Software\\Classes\\") +
82 ShellUtil::kChromeExtProgId; 82 ShellUtil::kChromeExtProgId;
83
84 // Extension file handler
85 entries.push_front(new RegistryEntry(prog_id, 83 entries.push_front(new RegistryEntry(prog_id,
86 ShellUtil::kChromeExtProgIdDesc)); 84 ShellUtil::kChromeExtProgIdDesc));
87 entries.push_front(new RegistryEntry( 85 entries.push_front(new RegistryEntry(
88 prog_id + L"\\DefaultIcon", icon_path)); 86 prog_id + ShellUtil::kRegDefaultIcon, icon_path));
89 entries.push_front(new RegistryEntry( 87 entries.push_front(new RegistryEntry(
90 prog_id + L"\\shell\\open\\command", install_cmd)); 88 prog_id + ShellUtil::kRegShellOpen, install_cmd));
91
92 // .crx file type extension
93 std::wstring file_extension_key(L"Software\\Classes\\");
94 file_extension_key.append(L".");
95 file_extension_key.append(chrome::kExtensionFileExtension);
96 entries.push_front(new RegistryEntry(file_extension_key,
97 ShellUtil::kChromeExtProgId));
98 89
99 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); 90 BrowserDistribution* dist = BrowserDistribution::GetDistribution();
100 std::wstring start_menu_entry(ShellUtil::kRegStartMenuInternet); 91 std::wstring start_menu_entry(ShellUtil::kRegStartMenuInternet);
101 start_menu_entry.append(L"\\" + dist->GetApplicationName()); 92 start_menu_entry.append(L"\\" + dist->GetApplicationName());
102 entries.push_front(new RegistryEntry(start_menu_entry, 93 entries.push_front(new RegistryEntry(start_menu_entry,
103 dist->GetApplicationName())); 94 dist->GetApplicationName()));
104 entries.push_front(new RegistryEntry( 95 entries.push_front(new RegistryEntry(
105 start_menu_entry + ShellUtil::kRegShellOpen, quoted_exe_path)); 96 start_menu_entry + ShellUtil::kRegShellOpen, quoted_exe_path));
106 entries.push_front(new RegistryEntry( 97 entries.push_front(new RegistryEntry(
107 start_menu_entry + ShellUtil::kRegDefaultIcon, icon_path)); 98 start_menu_entry + ShellUtil::kRegDefaultIcon, icon_path));
(...skipping 18 matching lines...) Expand all
126 entries.push_front(new RegistryEntry( 117 entries.push_front(new RegistryEntry(
127 capabilities, L"ApplicationName", dist->GetApplicationName())); 118 capabilities, L"ApplicationName", dist->GetApplicationName()));
128 119
129 entries.push_front(new RegistryEntry(capabilities + L"\\StartMenu", 120 entries.push_front(new RegistryEntry(capabilities + L"\\StartMenu",
130 L"StartMenuInternet", dist->GetApplicationName())); 121 L"StartMenuInternet", dist->GetApplicationName()));
131 for (int i = 0; ShellUtil::kFileAssociations[i] != NULL; i++) { 122 for (int i = 0; ShellUtil::kFileAssociations[i] != NULL; i++) {
132 entries.push_front(new RegistryEntry( 123 entries.push_front(new RegistryEntry(
133 capabilities + L"\\FileAssociations", 124 capabilities + L"\\FileAssociations",
134 ShellUtil::kFileAssociations[i], ShellUtil::kChromeHTMLProgId)); 125 ShellUtil::kFileAssociations[i], ShellUtil::kChromeHTMLProgId));
135 } 126 }
127 entries.push_front(new RegistryEntry(
128 capabilities + L"\\FileAssociations",
129 chrome::kExtensionFileExtension, ShellUtil::kChromeExtProgId));
136 for (int i = 0; ShellUtil::kProtocolAssociations[i] != NULL; i++) { 130 for (int i = 0; ShellUtil::kProtocolAssociations[i] != NULL; i++) {
137 entries.push_front(new RegistryEntry( 131 entries.push_front(new RegistryEntry(
138 capabilities + L"\\URLAssociations", 132 capabilities + L"\\URLAssociations",
139 ShellUtil::kProtocolAssociations[i], ShellUtil::kChromeHTMLProgId)); 133 ShellUtil::kProtocolAssociations[i], ShellUtil::kChromeHTMLProgId));
140 } 134 }
141 return entries; 135 return entries;
142 } 136 }
143 137
144 // Generate work_item tasks required to create current registry entry and 138 // Generate work_item tasks required to create current registry entry and
145 // add them to the given work item list. 139 // add them to the given work item list.
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 // file extension associations 231 // file extension associations
238 std::wstring classes_path(ShellUtil::kRegClasses); 232 std::wstring classes_path(ShellUtil::kRegClasses);
239 for (int i = 0; ShellUtil::kFileAssociations[i] != NULL; i++) { 233 for (int i = 0; ShellUtil::kFileAssociations[i] != NULL; i++) {
240 std::wstring key_path = classes_path + L"\\" + 234 std::wstring key_path = classes_path + L"\\" +
241 ShellUtil::kFileAssociations[i]; 235 ShellUtil::kFileAssociations[i];
242 items->AddCreateRegKeyWorkItem(root_key, key_path); 236 items->AddCreateRegKeyWorkItem(root_key, key_path);
243 items->AddSetRegValueWorkItem(root_key, key_path, L"", 237 items->AddSetRegValueWorkItem(root_key, key_path, L"",
244 ShellUtil::kChromeHTMLProgId, true); 238 ShellUtil::kChromeHTMLProgId, true);
245 } 239 }
246 240
241 // .crx file type extension
242 std::wstring file_extension_key = classes_path + L"\\." +
243 chrome::kExtensionFileExtension;
244 items->AddCreateRegKeyWorkItem(root_key, file_extension_key);
245 items->AddSetRegValueWorkItem(root_key, file_extension_key, L"",
246 ShellUtil::kChromeExtProgId, true);
247
248
247 // protocols associations 249 // protocols associations
248 std::wstring chrome_open = ShellUtil::GetChromeShellOpenCmd(chrome_exe); 250 std::wstring chrome_open = ShellUtil::GetChromeShellOpenCmd(chrome_exe);
249 std::wstring chrome_icon(chrome_exe); 251 std::wstring chrome_icon(chrome_exe);
250 ShellUtil::GetChromeIcon(chrome_icon); 252 ShellUtil::GetChromeIcon(chrome_icon);
251 for (int i = 0; ShellUtil::kProtocolAssociations[i] != NULL; i++) { 253 for (int i = 0; ShellUtil::kProtocolAssociations[i] != NULL; i++) {
252 std::wstring key_path = classes_path + L"\\" + 254 std::wstring key_path = classes_path + L"\\" +
253 ShellUtil::kProtocolAssociations[i]; 255 ShellUtil::kProtocolAssociations[i];
254 // <root hkey>\Software\Classes\<protocol>\DefaultIcon 256 // <root hkey>\Software\Classes\<protocol>\DefaultIcon
255 std::wstring icon_path = key_path + ShellUtil::kRegDefaultIcon; 257 std::wstring icon_path = key_path + ShellUtil::kRegDefaultIcon;
256 items->AddCreateRegKeyWorkItem(root_key, icon_path); 258 items->AddCreateRegKeyWorkItem(root_key, icon_path);
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 bool skip_if_not_admin) { 351 bool skip_if_not_admin) {
350 if (IsUserAnAdmin() && 352 if (IsUserAnAdmin() &&
351 SetAccessDefaultRegEntries(HKEY_LOCAL_MACHINE, chrome_exe)) 353 SetAccessDefaultRegEntries(HKEY_LOCAL_MACHINE, chrome_exe))
352 return ShellUtil::SUCCESS; 354 return ShellUtil::SUCCESS;
353 355
354 if (!skip_if_not_admin) { 356 if (!skip_if_not_admin) {
355 std::wstring exe_path(file_util::GetDirectoryFromPath(chrome_exe)); 357 std::wstring exe_path(file_util::GetDirectoryFromPath(chrome_exe));
356 file_util::AppendToPath(&exe_path, installer_util::kSetupExe); 358 file_util::AppendToPath(&exe_path, installer_util::kSetupExe);
357 if (!file_util::PathExists(exe_path)) { 359 if (!file_util::PathExists(exe_path)) {
358 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); 360 BrowserDistribution* dist = BrowserDistribution::GetDistribution();
359 RegKey key(HKEY_CURRENT_USER, dist->GetUninstallRegPath().c_str()); 361 HKEY reg_root = InstallUtil::IsPerUserInstall(chrome_exe.c_str()) ?
362 HKEY_CURRENT_USER : HKEY_LOCAL_MACHINE;
363 RegKey key(reg_root, dist->GetUninstallRegPath().c_str());
360 key.ReadValue(installer_util::kUninstallStringField, &exe_path); 364 key.ReadValue(installer_util::kUninstallStringField, &exe_path);
361 CommandLine command_line(L""); 365 CommandLine command_line(L"");
362 command_line.ParseFromString(exe_path); 366 command_line.ParseFromString(exe_path);
363 exe_path = command_line.program(); 367 exe_path = command_line.program();
364 } 368 }
365 if (file_util::PathExists(exe_path)) { 369 if (file_util::PathExists(exe_path)) {
366 std::wstring params(L"--"); 370 std::wstring params(L"--");
367 params.append(installer_util::switches::kRegisterChromeBrowser); 371 params.append(installer_util::switches::kRegisterChromeBrowser);
368 params.append(L"=\"" + chrome_exe + L"\""); 372 params.append(L"=\"" + chrome_exe + L"\"");
369 DWORD ret_val = ShellUtil::SUCCESS; 373 DWORD ret_val = ShellUtil::SUCCESS;
(...skipping 17 matching lines...) Expand all
387 const wchar_t* ShellUtil::kRegRegisteredApplications = 391 const wchar_t* ShellUtil::kRegRegisteredApplications =
388 L"Software\\RegisteredApplications"; 392 L"Software\\RegisteredApplications";
389 const wchar_t* ShellUtil::kRegVistaUrlPrefs = 393 const wchar_t* ShellUtil::kRegVistaUrlPrefs =
390 L"Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\" 394 L"Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\"
391 L"http\\UserChoice"; 395 L"http\\UserChoice";
392 const wchar_t* ShellUtil::kAppPathsRegistryKey = 396 const wchar_t* ShellUtil::kAppPathsRegistryKey =
393 L"Software\\Microsoft\\Windows\\CurrentVersion\\App Paths"; 397 L"Software\\Microsoft\\Windows\\CurrentVersion\\App Paths";
394 const wchar_t* ShellUtil::kAppPathsRegistryPathName = L"Path"; 398 const wchar_t* ShellUtil::kAppPathsRegistryPathName = L"Path";
395 399
396 #if defined(GOOGLE_CHROME_BUILD) 400 #if defined(GOOGLE_CHROME_BUILD)
401 const wchar_t* ShellUtil::kChromeExtProgId = L"ChromeExt";
397 const wchar_t* ShellUtil::kChromeHTMLProgId = L"ChromeHTML"; 402 const wchar_t* ShellUtil::kChromeHTMLProgId = L"ChromeHTML";
398 const wchar_t* ShellUtil::kChromeHTMLProgIdDesc = L"Chrome HTML"; 403 const wchar_t* ShellUtil::kChromeHTMLProgIdDesc = L"Chrome HTML";
399 #else 404 #else
405 const wchar_t* ShellUtil::kChromeExtProgId = L"ChromiumExt";
400 const wchar_t* ShellUtil::kChromeHTMLProgId = L"ChromiumHTML"; 406 const wchar_t* ShellUtil::kChromeHTMLProgId = L"ChromiumHTML";
401 const wchar_t* ShellUtil::kChromeHTMLProgIdDesc = L"Chromium HTML"; 407 const wchar_t* ShellUtil::kChromeHTMLProgIdDesc = L"Chromium HTML";
402 #endif 408 #endif
403 409
404 const wchar_t* ShellUtil::kFileAssociations[] = {L".htm", L".html", L".shtml", 410 const wchar_t* ShellUtil::kFileAssociations[] = {L".htm", L".html", L".shtml",
405 L".xht", L".xhtml", NULL}; 411 L".xht", L".xhtml", NULL};
406 const wchar_t* ShellUtil::kProtocolAssociations[] = {L"ftp", L"http", L"https", 412 const wchar_t* ShellUtil::kProtocolAssociations[] = {L"ftp", L"http", L"https",
407 NULL}; 413 NULL};
408 const wchar_t* ShellUtil::kRegUrlProtocol = L"URL Protocol"; 414 const wchar_t* ShellUtil::kRegUrlProtocol = L"URL Protocol";
409 415
410 const wchar_t* ShellUtil::kChromeExtProgId = L"ChromeExt";
411 const wchar_t* ShellUtil::kChromeExtProgIdDesc = L"Chrome Extension Installer"; 416 const wchar_t* ShellUtil::kChromeExtProgIdDesc = L"Chrome Extension Installer";
412 417
413 ShellUtil::RegisterStatus ShellUtil::AddChromeToSetAccessDefaults( 418 ShellUtil::RegisterStatus ShellUtil::AddChromeToSetAccessDefaults(
414 const std::wstring& chrome_exe, bool skip_if_not_admin) { 419 const std::wstring& chrome_exe, bool skip_if_not_admin) {
415 if (IsChromeRegistered(chrome_exe)) 420 if (IsChromeRegistered(chrome_exe))
416 return ShellUtil::SUCCESS; 421 return ShellUtil::SUCCESS;
417 422
418 if (win_util::GetWinVersion() >= win_util::WINVERSION_VISTA) 423 if (win_util::GetWinVersion() >= win_util::WINVERSION_VISTA)
419 return RegisterOnVista(chrome_exe, skip_if_not_admin); 424 return RegisterOnVista(chrome_exe, skip_if_not_admin);
420 425
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
695 } else { 700 } else {
696 return file_util::UpdateShortcutLink(chrome_exe.c_str(), // target 701 return file_util::UpdateShortcutLink(chrome_exe.c_str(), // target
697 shortcut.c_str(), // shortcut 702 shortcut.c_str(), // shortcut
698 chrome_path.c_str(), // working dir 703 chrome_path.c_str(), // working dir
699 NULL, // arguments 704 NULL, // arguments
700 description.c_str(), // description 705 description.c_str(), // description
701 chrome_exe.c_str(), // icon file 706 chrome_exe.c_str(), // icon file
702 0); // icon index 707 0); // icon index
703 } 708 }
704 } 709 }
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