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

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

Issue 21477: Remove code that adds "Url Protocol" key to registry entry... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 10 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/setup/main.cc ('k') | 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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 // to register Chrome. 47 // to register Chrome.
48 static std::list<RegistryEntry*> GetAllEntries(const std::wstring& chrome_exe) { 48 static std::list<RegistryEntry*> GetAllEntries(const std::wstring& chrome_exe) {
49 std::list<RegistryEntry*> entries; 49 std::list<RegistryEntry*> entries;
50 std::wstring icon_path(chrome_exe); 50 std::wstring icon_path(chrome_exe);
51 ShellUtil::GetChromeIcon(icon_path); 51 ShellUtil::GetChromeIcon(icon_path);
52 std::wstring quoted_exe_path = L"\"" + chrome_exe + L"\""; 52 std::wstring quoted_exe_path = L"\"" + chrome_exe + L"\"";
53 std::wstring open_cmd = ShellUtil::GetChromeShellOpenCmd(chrome_exe); 53 std::wstring open_cmd = ShellUtil::GetChromeShellOpenCmd(chrome_exe);
54 54
55 entries.push_front(new RegistryEntry(L"Software\\Classes\\ChromeHTML", 55 entries.push_front(new RegistryEntry(L"Software\\Classes\\ChromeHTML",
56 ShellUtil::kChromeHTMLProgIdDesc)); 56 ShellUtil::kChromeHTMLProgIdDesc));
57 entries.push_front(new RegistryEntry(L"Software\\Classes\\ChromeHTML",
58 ShellUtil::kRegUrlProtocol, L""));
59 entries.push_front(new RegistryEntry( 57 entries.push_front(new RegistryEntry(
60 L"Software\\Classes\\ChromeHTML\\DefaultIcon", icon_path)); 58 L"Software\\Classes\\ChromeHTML\\DefaultIcon", icon_path));
61 entries.push_front(new RegistryEntry( 59 entries.push_front(new RegistryEntry(
62 L"Software\\Classes\\ChromeHTML\\shell\\open\\command", open_cmd)); 60 L"Software\\Classes\\ChromeHTML\\shell\\open\\command", open_cmd));
63 61
64 std::wstring exe_name = file_util::GetFilenameFromPath(chrome_exe); 62 std::wstring exe_name = file_util::GetFilenameFromPath(chrome_exe);
65 std::wstring app_key = L"Software\\Classes\\Applications\\" + exe_name + 63 std::wstring app_key = L"Software\\Classes\\Applications\\" + exe_name +
66 L"\\shell\\open\\command"; 64 L"\\shell\\open\\command";
67 entries.push_front(new RegistryEntry(app_key, open_cmd)); 65 entries.push_front(new RegistryEntry(app_key, open_cmd));
68 for (int i = 0; ShellUtil::kFileAssociations[i] != NULL; i++) { 66 for (int i = 0; ShellUtil::kFileAssociations[i] != NULL; i++) {
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 // they exist in HKLM. Returns true if all the entries exist, otherwise false. 207 // they exist in HKLM. Returns true if all the entries exist, otherwise false.
210 bool IsChromeRegistered(const std::wstring& chrome_exe) { 208 bool IsChromeRegistered(const std::wstring& chrome_exe) {
211 bool registered = true; 209 bool registered = true;
212 std::list<RegistryEntry*> entries = RegistryEntry::GetAllEntries(chrome_exe); 210 std::list<RegistryEntry*> entries = RegistryEntry::GetAllEntries(chrome_exe);
213 for (std::list<RegistryEntry*>::iterator itr = entries.begin(); 211 for (std::list<RegistryEntry*>::iterator itr = entries.begin();
214 itr != entries.end(); ++itr) { 212 itr != entries.end(); ++itr) {
215 if (registered && !(*itr)->ExistsInHKLM()) 213 if (registered && !(*itr)->ExistsInHKLM())
216 registered = false; 214 registered = false;
217 delete (*itr); 215 delete (*itr);
218 } 216 }
219 LOG(INFO) << "Check for Chrome registeration returned " << registered; 217 LOG(INFO) << "Check for Chrome registration returned " << registered;
220 return registered; 218 return registered;
221 } 219 }
222 220
223 bool BindChromeAssociations(HKEY root_key, const std::wstring& chrome_exe) { 221 bool BindChromeAssociations(HKEY root_key, const std::wstring& chrome_exe) {
224 // Create a list of registry entries to create so that we can rollback 222 // Create a list of registry entries to create so that we can rollback
225 // in case of problem. 223 // in case of problem.
226 scoped_ptr<WorkItemList> items(WorkItem::CreateWorkItemList()); 224 scoped_ptr<WorkItemList> items(WorkItem::CreateWorkItemList());
227 225
228 // file extension associations 226 // file extension associations
229 std::wstring classes_path(ShellUtil::kRegClasses); 227 std::wstring classes_path(ShellUtil::kRegClasses);
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 params.append(L"=\"" + chrome_exe + L"\""); 357 params.append(L"=\"" + chrome_exe + L"\"");
360 DWORD ret_val = ShellUtil::SUCCESS; 358 DWORD ret_val = ShellUtil::SUCCESS;
361 InstallUtil::ExecuteExeAsAdmin(exe_path, params, &ret_val); 359 InstallUtil::ExecuteExeAsAdmin(exe_path, params, &ret_val);
362 if (ret_val == ShellUtil::SUCCESS) 360 if (ret_val == ShellUtil::SUCCESS)
363 return ShellUtil::SUCCESS; 361 return ShellUtil::SUCCESS;
364 } 362 }
365 } 363 }
366 return ShellUtil::FAILURE; 364 return ShellUtil::FAILURE;
367 } 365 }
368 366
367 // Remove unnecessary "URL Protocol" entry from shell registration. This value
368 // was written by older installers so ignoring error conditions.
369 void RemoveUrlProtocol(HKEY root) {
370 RegKey key(root, L"Software\\Classes\\ChromeHTML", KEY_ALL_ACCESS);
371 key.DeleteValue(ShellUtil::kRegUrlProtocol);
372 }
373
369 } // namespace 374 } // namespace
370 375
371 376
372 const wchar_t* ShellUtil::kRegDefaultIcon = L"\\DefaultIcon"; 377 const wchar_t* ShellUtil::kRegDefaultIcon = L"\\DefaultIcon";
373 const wchar_t* ShellUtil::kRegShellPath = L"\\shell"; 378 const wchar_t* ShellUtil::kRegShellPath = L"\\shell";
374 const wchar_t* ShellUtil::kRegShellOpen = L"\\shell\\open\\command"; 379 const wchar_t* ShellUtil::kRegShellOpen = L"\\shell\\open\\command";
375 const wchar_t* ShellUtil::kRegStartMenuInternet = 380 const wchar_t* ShellUtil::kRegStartMenuInternet =
376 L"Software\\Clients\\StartMenuInternet"; 381 L"Software\\Clients\\StartMenuInternet";
377 const wchar_t* ShellUtil::kRegClasses = L"Software\\Classes"; 382 const wchar_t* ShellUtil::kRegClasses = L"Software\\Classes";
378 const wchar_t* ShellUtil::kRegRegisteredApplications = 383 const wchar_t* ShellUtil::kRegRegisteredApplications =
(...skipping 10 matching lines...) Expand all
389 L".xht", L".xhtml", NULL}; 394 L".xht", L".xhtml", NULL};
390 const wchar_t* ShellUtil::kProtocolAssociations[] = {L"ftp", L"http", L"https", 395 const wchar_t* ShellUtil::kProtocolAssociations[] = {L"ftp", L"http", L"https",
391 NULL}; 396 NULL};
392 const wchar_t* ShellUtil::kRegUrlProtocol = L"URL Protocol"; 397 const wchar_t* ShellUtil::kRegUrlProtocol = L"URL Protocol";
393 398
394 const wchar_t* ShellUtil::kChromeExtProgId = L"ChromeExt"; 399 const wchar_t* ShellUtil::kChromeExtProgId = L"ChromeExt";
395 const wchar_t* ShellUtil::kChromeExtProgIdDesc = L"Chrome Extension Installer"; 400 const wchar_t* ShellUtil::kChromeExtProgIdDesc = L"Chrome Extension Installer";
396 401
397 ShellUtil::RegisterStatus ShellUtil::AddChromeToSetAccessDefaults( 402 ShellUtil::RegisterStatus ShellUtil::AddChromeToSetAccessDefaults(
398 const std::wstring& chrome_exe, bool skip_if_not_admin) { 403 const std::wstring& chrome_exe, bool skip_if_not_admin) {
404 RemoveUrlProtocol(HKEY_LOCAL_MACHINE);
405 RemoveUrlProtocol(HKEY_CURRENT_USER);
406
399 if (IsChromeRegistered(chrome_exe)) 407 if (IsChromeRegistered(chrome_exe))
400 return ShellUtil::SUCCESS; 408 return ShellUtil::SUCCESS;
401 409
402 if (win_util::GetWinVersion() == win_util::WINVERSION_VISTA) 410 if (win_util::GetWinVersion() == win_util::WINVERSION_VISTA)
403 return RegisterOnVista(chrome_exe, skip_if_not_admin); 411 return RegisterOnVista(chrome_exe, skip_if_not_admin);
404 412
405 // Try adding these entries to HKLM first and if that fails try adding 413 // Try adding these entries to HKLM first and if that fails try adding
406 // to HKCU. 414 // to HKCU.
407 if (SetAccessDefaultRegEntries(HKEY_LOCAL_MACHINE, chrome_exe)) 415 if (SetAccessDefaultRegEntries(HKEY_LOCAL_MACHINE, chrome_exe))
408 return ShellUtil::SUCCESS; 416 return ShellUtil::SUCCESS;
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
663 return file_util::UpdateShortcutLink(chrome_exe.c_str(), // target 671 return file_util::UpdateShortcutLink(chrome_exe.c_str(), // target
664 shortcut.c_str(), // shortcut 672 shortcut.c_str(), // shortcut
665 chrome_path.c_str(), // working dir 673 chrome_path.c_str(), // working dir
666 NULL, // arguments 674 NULL, // arguments
667 NULL, // description 675 NULL, // description
668 chrome_exe.c_str(), // icon file 676 chrome_exe.c_str(), // icon file
669 0); // icon index 677 0); // icon index
670 } 678 }
671 } 679 }
672 680
OLDNEW
« no previous file with comments | « chrome/installer/setup/main.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698