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 27 matching lines...) Expand all Loading... |
38 | 38 |
39 // This class represents a single registry entry. The objective is to | 39 // This class represents a single registry entry. The objective is to |
40 // encapsulate all the registry entries required for registering Chrome at one | 40 // encapsulate all the registry entries required for registering Chrome at one |
41 // place. This class can not be instantiated outside the class and the objects | 41 // place. This class can not be instantiated outside the class and the objects |
42 // of this class type can be obtained only by calling a static method of this | 42 // of this class type can be obtained only by calling a static method of this |
43 // class. | 43 // class. |
44 class RegistryEntry { | 44 class RegistryEntry { |
45 public: | 45 public: |
46 // This method returns a list of all the registry entries that are needed | 46 // This method returns a list of all the registry entries that are needed |
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( |
| 49 const std::wstring& chrome_exe) { |
49 std::list<RegistryEntry*> entries; | 50 std::list<RegistryEntry*> entries; |
50 std::wstring icon_path(chrome_exe); | 51 std::wstring icon_path(chrome_exe); |
51 ShellUtil::GetChromeIcon(icon_path); | 52 ShellUtil::GetChromeIcon(icon_path); |
52 std::wstring quoted_exe_path = L"\"" + chrome_exe + L"\""; | 53 std::wstring quoted_exe_path = L"\"" + chrome_exe + L"\""; |
53 std::wstring open_cmd = ShellUtil::GetChromeShellOpenCmd(chrome_exe); | 54 std::wstring open_cmd = ShellUtil::GetChromeShellOpenCmd(chrome_exe); |
54 | 55 |
55 entries.push_front(new RegistryEntry(L"Software\\Classes\\ChromeHTML", | 56 entries.push_front(new RegistryEntry(L"Software\\Classes\\ChromeHTML", |
56 ShellUtil::kChromeHTMLProgIdDesc)); | 57 ShellUtil::kChromeHTMLProgIdDesc)); |
57 entries.push_front(new RegistryEntry( | 58 entries.push_front(new RegistryEntry( |
58 L"Software\\Classes\\ChromeHTML\\DefaultIcon", icon_path)); | 59 L"Software\\Classes\\ChromeHTML\\DefaultIcon", icon_path)); |
(...skipping 30 matching lines...) Expand all Loading... |
89 file_extension_key.append(L"."); | 90 file_extension_key.append(L"."); |
90 file_extension_key.append(chrome::kExtensionFileExtension); | 91 file_extension_key.append(chrome::kExtensionFileExtension); |
91 entries.push_front(new RegistryEntry(file_extension_key, | 92 entries.push_front(new RegistryEntry(file_extension_key, |
92 ShellUtil::kChromeExtProgId)); | 93 ShellUtil::kChromeExtProgId)); |
93 | 94 |
94 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); | 95 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); |
95 entries.push_front(new RegistryEntry( | 96 entries.push_front(new RegistryEntry( |
96 L"Software\\Clients\\StartMenuInternet\\chrome.exe", | 97 L"Software\\Clients\\StartMenuInternet\\chrome.exe", |
97 dist->GetApplicationName())); | 98 dist->GetApplicationName())); |
98 entries.push_front(new RegistryEntry( | 99 entries.push_front(new RegistryEntry( |
99 L"Software\\Clients\\StartMenuInternet\\chrome.exe\\shell\\open\\command
", | 100 L"Software\\Clients\\StartMenuInternet\\chrome.exe\\shell\\open\\" |
| 101 L"command", |
100 quoted_exe_path)); | 102 quoted_exe_path)); |
101 entries.push_front(new RegistryEntry( | 103 entries.push_front(new RegistryEntry( |
102 L"Software\\Clients\\StartMenuInternet\\chrome.exe\\DefaultIcon", | 104 L"Software\\Clients\\StartMenuInternet\\chrome.exe\\DefaultIcon", |
103 icon_path)); | 105 icon_path)); |
104 entries.push_front(new RegistryEntry( | 106 entries.push_front(new RegistryEntry( |
105 L"Software\\Clients\\StartMenuInternet\\chrome.exe\\InstallInfo", | 107 L"Software\\Clients\\StartMenuInternet\\chrome.exe\\InstallInfo", |
106 L"ReinstallCommand", | 108 L"ReinstallCommand", |
107 quoted_exe_path + L" --" + switches::kMakeDefaultBrowser)); | 109 quoted_exe_path + L" --" + switches::kMakeDefaultBrowser)); |
108 entries.push_front(new RegistryEntry( | 110 entries.push_front(new RegistryEntry( |
109 L"Software\\Clients\\StartMenuInternet\\chrome.exe\\InstallInfo", | 111 L"Software\\Clients\\StartMenuInternet\\chrome.exe\\InstallInfo", |
(...skipping 15 matching lines...) Expand all Loading... |
125 L"Software\\Clients\\StartMenuInternet\\chrome.exe\\Capabilities", | 127 L"Software\\Clients\\StartMenuInternet\\chrome.exe\\Capabilities", |
126 L"ApplicationDescription", dist->GetApplicationName())); | 128 L"ApplicationDescription", dist->GetApplicationName())); |
127 entries.push_front(new RegistryEntry( | 129 entries.push_front(new RegistryEntry( |
128 L"Software\\Clients\\StartMenuInternet\\chrome.exe\\Capabilities", | 130 L"Software\\Clients\\StartMenuInternet\\chrome.exe\\Capabilities", |
129 L"ApplicationIcon", icon_path)); | 131 L"ApplicationIcon", icon_path)); |
130 entries.push_front(new RegistryEntry( | 132 entries.push_front(new RegistryEntry( |
131 L"Software\\Clients\\StartMenuInternet\\chrome.exe\\Capabilities", | 133 L"Software\\Clients\\StartMenuInternet\\chrome.exe\\Capabilities", |
132 L"ApplicationName", dist->GetApplicationName())); | 134 L"ApplicationName", dist->GetApplicationName())); |
133 | 135 |
134 entries.push_front(new RegistryEntry( | 136 entries.push_front(new RegistryEntry( |
135 L"Software\\Clients\\StartMenuInternet\\chrome.exe\\Capabilities\\StartM
enu", | 137 L"Software\\Clients\\StartMenuInternet\\chrome.exe\\Capabilities\\" |
| 138 L"StartMenu", |
136 L"StartMenuInternet", L"chrome.exe")); | 139 L"StartMenuInternet", L"chrome.exe")); |
137 for (int i = 0; ShellUtil::kFileAssociations[i] != NULL; i++) { | 140 for (int i = 0; ShellUtil::kFileAssociations[i] != NULL; i++) { |
138 entries.push_front(new RegistryEntry( | 141 entries.push_front(new RegistryEntry( |
139 L"Software\\Clients\\StartMenuInternet\\chrome.exe\\Capabilities\\File
Associations", | 142 L"Software\\Clients\\StartMenuInternet\\chrome.exe\\Capabilities\\" |
| 143 L"FileAssociations", |
140 ShellUtil::kFileAssociations[i], ShellUtil::kChromeHTMLProgId)); | 144 ShellUtil::kFileAssociations[i], ShellUtil::kChromeHTMLProgId)); |
141 } | 145 } |
142 for (int i = 0; ShellUtil::kProtocolAssociations[i] != NULL; i++) { | 146 for (int i = 0; ShellUtil::kProtocolAssociations[i] != NULL; i++) { |
143 entries.push_front(new RegistryEntry( | 147 entries.push_front(new RegistryEntry( |
144 L"Software\\Clients\\StartMenuInternet\\chrome.exe\\Capabilities\\URLA
ssociations", | 148 L"Software\\Clients\\StartMenuInternet\\chrome.exe\\Capabilities\\" |
| 149 L"URLAssociations", |
145 ShellUtil::kProtocolAssociations[i], ShellUtil::kChromeHTMLProgId)); | 150 ShellUtil::kProtocolAssociations[i], ShellUtil::kChromeHTMLProgId)); |
146 } | 151 } |
147 return entries; | 152 return entries; |
148 } | 153 } |
149 | 154 |
150 // Generate work_item tasks required to create current regitry entry and | 155 // Generate work_item tasks required to create current regitry entry and |
151 // add them to the given work item list. | 156 // add them to the given work item list. |
152 void AddToWorkItemList(HKEY root, WorkItemList *items) { | 157 void AddToWorkItemList(HKEY root, WorkItemList *items) { |
153 items->AddCreateRegKeyWorkItem(root, _key_path); | 158 items->AddCreateRegKeyWorkItem(root, _key_path); |
154 if (_is_string) { | 159 if (_is_string) { |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
376 | 381 |
377 const wchar_t* ShellUtil::kRegDefaultIcon = L"\\DefaultIcon"; | 382 const wchar_t* ShellUtil::kRegDefaultIcon = L"\\DefaultIcon"; |
378 const wchar_t* ShellUtil::kRegShellPath = L"\\shell"; | 383 const wchar_t* ShellUtil::kRegShellPath = L"\\shell"; |
379 const wchar_t* ShellUtil::kRegShellOpen = L"\\shell\\open\\command"; | 384 const wchar_t* ShellUtil::kRegShellOpen = L"\\shell\\open\\command"; |
380 const wchar_t* ShellUtil::kRegStartMenuInternet = | 385 const wchar_t* ShellUtil::kRegStartMenuInternet = |
381 L"Software\\Clients\\StartMenuInternet"; | 386 L"Software\\Clients\\StartMenuInternet"; |
382 const wchar_t* ShellUtil::kRegClasses = L"Software\\Classes"; | 387 const wchar_t* ShellUtil::kRegClasses = L"Software\\Classes"; |
383 const wchar_t* ShellUtil::kRegRegisteredApplications = | 388 const wchar_t* ShellUtil::kRegRegisteredApplications = |
384 L"Software\\RegisteredApplications"; | 389 L"Software\\RegisteredApplications"; |
385 const wchar_t* ShellUtil::kRegVistaUrlPrefs = | 390 const wchar_t* ShellUtil::kRegVistaUrlPrefs = |
386 L"Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\http\\
UserChoice"; | 391 L"Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\" |
| 392 L"http\\UserChoice"; |
387 const wchar_t* ShellUtil::kAppPathsRegistryKey = | 393 const wchar_t* ShellUtil::kAppPathsRegistryKey = |
388 L"Software\\Microsoft\\Windows\\CurrentVersion\\App Paths"; | 394 L"Software\\Microsoft\\Windows\\CurrentVersion\\App Paths"; |
389 const wchar_t* ShellUtil::kAppPathsRegistryPathName = L"Path"; | 395 const wchar_t* ShellUtil::kAppPathsRegistryPathName = L"Path"; |
390 | 396 |
391 const wchar_t* ShellUtil::kChromeHTMLProgId = L"ChromeHTML"; | 397 const wchar_t* ShellUtil::kChromeHTMLProgId = L"ChromeHTML"; |
392 const wchar_t* ShellUtil::kChromeHTMLProgIdDesc = L"Chrome HTML"; | 398 const wchar_t* ShellUtil::kChromeHTMLProgIdDesc = L"Chrome HTML"; |
393 const wchar_t* ShellUtil::kFileAssociations[] = {L".htm", L".html", L".shtml", | 399 const wchar_t* ShellUtil::kFileAssociations[] = {L".htm", L".html", L".shtml", |
394 L".xht", L".xhtml", NULL}; | 400 L".xht", L".xhtml", NULL}; |
395 const wchar_t* ShellUtil::kProtocolAssociations[] = {L"ftp", L"http", L"https", | 401 const wchar_t* ShellUtil::kProtocolAssociations[] = {L"ftp", L"http", L"https", |
396 NULL}; | 402 NULL}; |
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
674 return file_util::UpdateShortcutLink(chrome_exe.c_str(), // target | 680 return file_util::UpdateShortcutLink(chrome_exe.c_str(), // target |
675 shortcut.c_str(), // shortcut | 681 shortcut.c_str(), // shortcut |
676 chrome_path.c_str(), // working dir | 682 chrome_path.c_str(), // working dir |
677 NULL, // arguments | 683 NULL, // arguments |
678 description.c_str(), // description | 684 description.c_str(), // description |
679 chrome_exe.c_str(), // icon file | 685 chrome_exe.c_str(), // icon file |
680 0); // icon index | 686 0); // icon index |
681 } | 687 } |
682 } | 688 } |
683 | 689 |
OLD | NEW |