| OLD | NEW |
| 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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 prog_id + L"\\shell\\open\\command", install_cmd)); | 86 prog_id + L"\\shell\\open\\command", install_cmd)); |
| 87 | 87 |
| 88 // .crx file type extension | 88 // .crx file type extension |
| 89 std::wstring file_extension_key(L"Software\\Classes\\"); | 89 std::wstring file_extension_key(L"Software\\Classes\\"); |
| 90 file_extension_key.append(L"."); | 90 file_extension_key.append(L"."); |
| 91 file_extension_key.append(chrome::kExtensionFileExtension); | 91 file_extension_key.append(chrome::kExtensionFileExtension); |
| 92 entries.push_front(new RegistryEntry(file_extension_key, | 92 entries.push_front(new RegistryEntry(file_extension_key, |
| 93 ShellUtil::kChromeExtProgId)); | 93 ShellUtil::kChromeExtProgId)); |
| 94 | 94 |
| 95 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); | 95 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); |
| 96 std::wstring start_menu_entry(ShellUtil::kRegStartMenuInternet); |
| 97 start_menu_entry.append(L"\\" + dist->GetApplicationName()); |
| 98 entries.push_front(new RegistryEntry(start_menu_entry, |
| 99 dist->GetApplicationName())); |
| 96 entries.push_front(new RegistryEntry( | 100 entries.push_front(new RegistryEntry( |
| 97 L"Software\\Clients\\StartMenuInternet\\chrome.exe", | 101 start_menu_entry + ShellUtil::kRegShellOpen, quoted_exe_path)); |
| 98 dist->GetApplicationName())); | |
| 99 entries.push_front(new RegistryEntry( | 102 entries.push_front(new RegistryEntry( |
| 100 L"Software\\Clients\\StartMenuInternet\\chrome.exe\\shell\\open\\" | 103 start_menu_entry + ShellUtil::kRegDefaultIcon, icon_path)); |
| 101 L"command", | 104 |
| 102 quoted_exe_path)); | 105 std::wstring install_info(start_menu_entry + L"\\InstallInfo"); |
| 106 entries.push_front(new RegistryEntry(install_info, L"ReinstallCommand", |
| 107 quoted_exe_path + L" --" + switches::kMakeDefaultBrowser)); |
| 108 entries.push_front(new RegistryEntry(install_info, L"HideIconsCommand", |
| 109 quoted_exe_path + L" --" + switches::kHideIcons)); |
| 110 entries.push_front(new RegistryEntry(install_info, L"ShowIconsCommand", |
| 111 quoted_exe_path + L" --" + switches::kShowIcons)); |
| 112 entries.push_front(new RegistryEntry(install_info, L"IconsVisible", 1)); |
| 113 |
| 114 std::wstring capabilities(start_menu_entry + L"\\Capabilities"); |
| 115 entries.push_front(new RegistryEntry(ShellUtil::kRegRegisteredApplications, |
| 116 dist->GetApplicationName(), |
| 117 capabilities)); |
| 103 entries.push_front(new RegistryEntry( | 118 entries.push_front(new RegistryEntry( |
| 104 L"Software\\Clients\\StartMenuInternet\\chrome.exe\\DefaultIcon", | 119 capabilities, L"ApplicationDescription", dist->GetApplicationName())); |
| 105 icon_path)); | |
| 106 entries.push_front(new RegistryEntry( | 120 entries.push_front(new RegistryEntry( |
| 107 L"Software\\Clients\\StartMenuInternet\\chrome.exe\\InstallInfo", | 121 capabilities, L"ApplicationIcon", icon_path)); |
| 108 L"ReinstallCommand", | |
| 109 quoted_exe_path + L" --" + switches::kMakeDefaultBrowser)); | |
| 110 entries.push_front(new RegistryEntry( | 122 entries.push_front(new RegistryEntry( |
| 111 L"Software\\Clients\\StartMenuInternet\\chrome.exe\\InstallInfo", | 123 capabilities, L"ApplicationName", dist->GetApplicationName())); |
| 112 L"HideIconsCommand", | |
| 113 quoted_exe_path + L" --" + switches::kHideIcons)); | |
| 114 entries.push_front(new RegistryEntry( | |
| 115 L"Software\\Clients\\StartMenuInternet\\chrome.exe\\InstallInfo", | |
| 116 L"ShowIconsCommand", | |
| 117 quoted_exe_path + L" --" + switches::kShowIcons)); | |
| 118 entries.push_front(new RegistryEntry( | |
| 119 L"Software\\Clients\\StartMenuInternet\\chrome.exe\\InstallInfo", | |
| 120 L"IconsVisible", 1)); | |
| 121 | 124 |
| 122 entries.push_front(new RegistryEntry( | 125 entries.push_front(new RegistryEntry(capabilities + L"\\StartMenu", |
| 123 ShellUtil::kRegRegisteredApplications, | 126 L"StartMenuInternet", dist->GetApplicationName())); |
| 124 dist->GetApplicationName(), | |
| 125 L"Software\\Clients\\StartMenuInternet\\chrome.exe\\Capabilities")); | |
| 126 entries.push_front(new RegistryEntry( | |
| 127 L"Software\\Clients\\StartMenuInternet\\chrome.exe\\Capabilities", | |
| 128 L"ApplicationDescription", dist->GetApplicationName())); | |
| 129 entries.push_front(new RegistryEntry( | |
| 130 L"Software\\Clients\\StartMenuInternet\\chrome.exe\\Capabilities", | |
| 131 L"ApplicationIcon", icon_path)); | |
| 132 entries.push_front(new RegistryEntry( | |
| 133 L"Software\\Clients\\StartMenuInternet\\chrome.exe\\Capabilities", | |
| 134 L"ApplicationName", dist->GetApplicationName())); | |
| 135 | |
| 136 entries.push_front(new RegistryEntry( | |
| 137 L"Software\\Clients\\StartMenuInternet\\chrome.exe\\Capabilities\\" | |
| 138 L"StartMenu", | |
| 139 L"StartMenuInternet", L"chrome.exe")); | |
| 140 for (int i = 0; ShellUtil::kFileAssociations[i] != NULL; i++) { | 127 for (int i = 0; ShellUtil::kFileAssociations[i] != NULL; i++) { |
| 141 entries.push_front(new RegistryEntry( | 128 entries.push_front(new RegistryEntry( |
| 142 L"Software\\Clients\\StartMenuInternet\\chrome.exe\\Capabilities\\" | 129 capabilities + L"\\FileAssociations", |
| 143 L"FileAssociations", | |
| 144 ShellUtil::kFileAssociations[i], ShellUtil::kChromeHTMLProgId)); | 130 ShellUtil::kFileAssociations[i], ShellUtil::kChromeHTMLProgId)); |
| 145 } | 131 } |
| 146 for (int i = 0; ShellUtil::kProtocolAssociations[i] != NULL; i++) { | 132 for (int i = 0; ShellUtil::kProtocolAssociations[i] != NULL; i++) { |
| 147 entries.push_front(new RegistryEntry( | 133 entries.push_front(new RegistryEntry( |
| 148 L"Software\\Clients\\StartMenuInternet\\chrome.exe\\Capabilities\\" | 134 capabilities + L"\\URLAssociations", |
| 149 L"URLAssociations", | |
| 150 ShellUtil::kProtocolAssociations[i], ShellUtil::kChromeHTMLProgId)); | 135 ShellUtil::kProtocolAssociations[i], ShellUtil::kChromeHTMLProgId)); |
| 151 } | 136 } |
| 152 return entries; | 137 return entries; |
| 153 } | 138 } |
| 154 | 139 |
| 155 // Generate work_item tasks required to create current regitry entry and | 140 // Generate work_item tasks required to create current regitry entry and |
| 156 // add them to the given work item list. | 141 // add them to the given work item list. |
| 157 void AddToWorkItemList(HKEY root, WorkItemList *items) { | 142 void AddToWorkItemList(HKEY root, WorkItemList *items) { |
| 158 items->AddCreateRegKeyWorkItem(root, _key_path); | 143 items->AddCreateRegKeyWorkItem(root, _key_path); |
| 159 if (_is_string) { | 144 if (_is_string) { |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 std::wstring dde_path = key_path + L"\\shell\\open\\ddeexec"; | 244 std::wstring dde_path = key_path + L"\\shell\\open\\ddeexec"; |
| 260 items->AddCreateRegKeyWorkItem(root_key, dde_path); | 245 items->AddCreateRegKeyWorkItem(root_key, dde_path); |
| 261 items->AddSetRegValueWorkItem(root_key, dde_path, L"", L"", true); | 246 items->AddSetRegValueWorkItem(root_key, dde_path, L"", L"", true); |
| 262 // <root hkey>\Software\Classes\<protocol>\shell\@ | 247 // <root hkey>\Software\Classes\<protocol>\shell\@ |
| 263 std::wstring protocol_shell_path = key_path + ShellUtil::kRegShellPath; | 248 std::wstring protocol_shell_path = key_path + ShellUtil::kRegShellPath; |
| 264 items->AddSetRegValueWorkItem(root_key, protocol_shell_path, L"", | 249 items->AddSetRegValueWorkItem(root_key, protocol_shell_path, L"", |
| 265 L"open", true); | 250 L"open", true); |
| 266 } | 251 } |
| 267 | 252 |
| 268 // start->Internet shortcut. | 253 // start->Internet shortcut. |
| 269 std::wstring exe_name = file_util::GetFilenameFromPath(chrome_exe); | |
| 270 std::wstring start_internet(ShellUtil::kRegStartMenuInternet); | 254 std::wstring start_internet(ShellUtil::kRegStartMenuInternet); |
| 271 items->AddCreateRegKeyWorkItem(root_key, start_internet); | 255 items->AddCreateRegKeyWorkItem(root_key, start_internet); |
| 256 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); |
| 272 items->AddSetRegValueWorkItem(root_key, start_internet, L"", | 257 items->AddSetRegValueWorkItem(root_key, start_internet, L"", |
| 273 exe_name, true); | 258 dist->GetApplicationName(), true); |
| 274 | 259 |
| 275 // Apply all the registry changes and if there is a problem, rollback | 260 // Apply all the registry changes and if there is a problem, rollback |
| 276 if (!items->Do()) { | 261 if (!items->Do()) { |
| 277 LOG(ERROR) << "Error while registering Chrome as default browser"; | 262 LOG(ERROR) << "Error while registering Chrome as default browser"; |
| 278 items->Rollback(); | 263 items->Rollback(); |
| 279 return false; | 264 return false; |
| 280 } | 265 } |
| 281 return true; | 266 return true; |
| 282 } | 267 } |
| 283 | 268 |
| (...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 680 } else { | 665 } else { |
| 681 return file_util::UpdateShortcutLink(chrome_exe.c_str(), // target | 666 return file_util::UpdateShortcutLink(chrome_exe.c_str(), // target |
| 682 shortcut.c_str(), // shortcut | 667 shortcut.c_str(), // shortcut |
| 683 chrome_path.c_str(), // working dir | 668 chrome_path.c_str(), // working dir |
| 684 NULL, // arguments | 669 NULL, // arguments |
| 685 description.c_str(), // description | 670 description.c_str(), // description |
| 686 chrome_exe.c_str(), // icon file | 671 chrome_exe.c_str(), // icon file |
| 687 0); // icon index | 672 0); // icon index |
| 688 } | 673 } |
| 689 } | 674 } |
| OLD | NEW |