OLD | NEW |
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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 DWORD type_mask = VER_MAJORVERSION | VER_MINORVERSION | VER_BUILDNUMBER | | 95 DWORD type_mask = VER_MAJORVERSION | VER_MINORVERSION | VER_BUILDNUMBER | |
96 VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR; | 96 VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR; |
97 | 97 |
98 return VerifyVersionInfo(&min_version_info, type_mask, condition_mask) != 0; | 98 return VerifyVersionInfo(&min_version_info, type_mask, condition_mask) != 0; |
99 } | 99 } |
100 | 100 |
101 // Returns the current (or installed) browser's ProgId (e.g. | 101 // Returns the current (or installed) browser's ProgId (e.g. |
102 // "ChromeHTML|suffix|"). | 102 // "ChromeHTML|suffix|"). |
103 // |suffix| can be the empty string. | 103 // |suffix| can be the empty string. |
104 string16 GetBrowserProgId(const string16& suffix) { | 104 string16 GetBrowserProgId(const string16& suffix) { |
105 string16 chrome_html(ShellUtil::kChromeHTMLProgId); | 105 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); |
| 106 string16 chrome_html(dist->GetBrowserProgIdPrefix()); |
106 chrome_html.append(suffix); | 107 chrome_html.append(suffix); |
107 | 108 |
108 // ProgIds cannot be longer than 39 characters. | 109 // ProgIds cannot be longer than 39 characters. |
109 // Ref: http://msdn.microsoft.com/en-us/library/aa911706.aspx. | 110 // Ref: http://msdn.microsoft.com/en-us/library/aa911706.aspx. |
110 // Make all new registrations comply with this requirement (existing | 111 // Make all new registrations comply with this requirement (existing |
111 // registrations must be preserved). | 112 // registrations must be preserved). |
112 string16 new_style_suffix; | 113 string16 new_style_suffix; |
113 if (ShellUtil::GetUserSpecificRegistrySuffix(&new_style_suffix) && | 114 if (ShellUtil::GetUserSpecificRegistrySuffix(&new_style_suffix) && |
114 suffix == new_style_suffix && chrome_html.length() > 39) { | 115 suffix == new_style_suffix && chrome_html.length() > 39) { |
115 NOTREACHED(); | 116 NOTREACHED(); |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
282 entries->push_back(new RegistryEntry( | 283 entries->push_back(new RegistryEntry( |
283 sub_path, ShellUtil::kRegDelegateExecute, delegate_guid)); | 284 sub_path, ShellUtil::kRegDelegateExecute, delegate_guid)); |
284 } | 285 } |
285 } | 286 } |
286 | 287 |
287 // File association ProgId | 288 // File association ProgId |
288 string16 chrome_html_prog_id(ShellUtil::kRegClasses); | 289 string16 chrome_html_prog_id(ShellUtil::kRegClasses); |
289 chrome_html_prog_id.push_back(base::FilePath::kSeparators[0]); | 290 chrome_html_prog_id.push_back(base::FilePath::kSeparators[0]); |
290 chrome_html_prog_id.append(GetBrowserProgId(suffix)); | 291 chrome_html_prog_id.append(GetBrowserProgId(suffix)); |
291 entries->push_back(new RegistryEntry( | 292 entries->push_back(new RegistryEntry( |
292 chrome_html_prog_id, ShellUtil::kChromeHTMLProgIdDesc)); | 293 chrome_html_prog_id, dist->GetBrowserProgIdDesc())); |
293 entries->push_back(new RegistryEntry( | 294 entries->push_back(new RegistryEntry( |
294 chrome_html_prog_id, ShellUtil::kRegUrlProtocol, L"")); | 295 chrome_html_prog_id, ShellUtil::kRegUrlProtocol, L"")); |
295 entries->push_back(new RegistryEntry( | 296 entries->push_back(new RegistryEntry( |
296 chrome_html_prog_id + ShellUtil::kRegDefaultIcon, icon_path)); | 297 chrome_html_prog_id + ShellUtil::kRegDefaultIcon, icon_path)); |
297 entries->push_back(new RegistryEntry( | 298 entries->push_back(new RegistryEntry( |
298 chrome_html_prog_id + ShellUtil::kRegShellOpen, open_cmd)); | 299 chrome_html_prog_id + ShellUtil::kRegShellOpen, open_cmd)); |
299 if (set_delegate_execute) { | 300 if (set_delegate_execute) { |
300 entries->push_back(new RegistryEntry( | 301 entries->push_back(new RegistryEntry( |
301 chrome_html_prog_id + ShellUtil::kRegShellOpen, | 302 chrome_html_prog_id + ShellUtil::kRegShellOpen, |
302 ShellUtil::kRegDelegateExecute, delegate_guid)); | 303 ShellUtil::kRegDelegateExecute, delegate_guid)); |
(...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
782 const string16& chrome_exe, | 783 const string16& chrome_exe, |
783 const string16& suffix, | 784 const string16& suffix, |
784 RegistrationConfirmationLevel confirmation_level) { | 785 RegistrationConfirmationLevel confirmation_level) { |
785 // Get the appropriate key to look for based on the level desired. | 786 // Get the appropriate key to look for based on the level desired. |
786 string16 reg_key; | 787 string16 reg_key; |
787 switch (confirmation_level) { | 788 switch (confirmation_level) { |
788 case CONFIRM_PROGID_REGISTRATION: | 789 case CONFIRM_PROGID_REGISTRATION: |
789 // Software\Classes\ChromeHTML|suffix| | 790 // Software\Classes\ChromeHTML|suffix| |
790 reg_key = ShellUtil::kRegClasses; | 791 reg_key = ShellUtil::kRegClasses; |
791 reg_key.push_back(base::FilePath::kSeparators[0]); | 792 reg_key.push_back(base::FilePath::kSeparators[0]); |
792 reg_key.append(ShellUtil::kChromeHTMLProgId); | 793 reg_key.append(dist->GetBrowserProgIdPrefix()); |
793 reg_key.append(suffix); | 794 reg_key.append(suffix); |
794 break; | 795 break; |
795 case CONFIRM_SHELL_REGISTRATION: | 796 case CONFIRM_SHELL_REGISTRATION: |
796 case CONFIRM_SHELL_REGISTRATION_IN_HKLM: | 797 case CONFIRM_SHELL_REGISTRATION_IN_HKLM: |
797 // Software\Clients\StartMenuInternet\Google Chrome|suffix| | 798 // Software\Clients\StartMenuInternet\Google Chrome|suffix| |
798 reg_key = RegistryEntry::GetBrowserClientKey(dist, suffix); | 799 reg_key = RegistryEntry::GetBrowserClientKey(dist, suffix); |
799 break; | 800 break; |
800 default: | 801 default: |
801 NOTREACHED(); | 802 NOTREACHED(); |
802 break; | 803 break; |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1051 CLSID_ApplicationAssociationRegistration, NULL, CLSCTX_INPROC); | 1052 CLSID_ApplicationAssociationRegistration, NULL, CLSCTX_INPROC); |
1052 if (FAILED(hr)) | 1053 if (FAILED(hr)) |
1053 return ShellUtil::UNKNOWN_DEFAULT; | 1054 return ShellUtil::UNKNOWN_DEFAULT; |
1054 | 1055 |
1055 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); | 1056 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); |
1056 base::FilePath chrome_exe; | 1057 base::FilePath chrome_exe; |
1057 if (!PathService::Get(base::FILE_EXE, &chrome_exe)) { | 1058 if (!PathService::Get(base::FILE_EXE, &chrome_exe)) { |
1058 NOTREACHED(); | 1059 NOTREACHED(); |
1059 return ShellUtil::UNKNOWN_DEFAULT; | 1060 return ShellUtil::UNKNOWN_DEFAULT; |
1060 } | 1061 } |
1061 string16 prog_id(ShellUtil::kChromeHTMLProgId); | 1062 string16 prog_id(dist->GetBrowserProgIdPrefix()); |
1062 prog_id += ShellUtil::GetCurrentInstallationSuffix(dist, chrome_exe.value()); | 1063 prog_id += ShellUtil::GetCurrentInstallationSuffix(dist, chrome_exe.value()); |
1063 | 1064 |
1064 for (size_t i = 0; i < num_protocols; ++i) { | 1065 for (size_t i = 0; i < num_protocols; ++i) { |
1065 base::win::ScopedCoMem<wchar_t> current_app; | 1066 base::win::ScopedCoMem<wchar_t> current_app; |
1066 hr = registration->QueryCurrentDefault(protocols[i], AT_URLPROTOCOL, | 1067 hr = registration->QueryCurrentDefault(protocols[i], AT_URLPROTOCOL, |
1067 AL_EFFECTIVE, ¤t_app); | 1068 AL_EFFECTIVE, ¤t_app); |
1068 if (FAILED(hr) || prog_id.compare(current_app) != 0) | 1069 if (FAILED(hr) || prog_id.compare(current_app) != 0) |
1069 return ShellUtil::NOT_DEFAULT; | 1070 return ShellUtil::NOT_DEFAULT; |
1070 } | 1071 } |
1071 | 1072 |
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1346 const wchar_t* ShellUtil::kRegClasses = L"Software\\Classes"; | 1347 const wchar_t* ShellUtil::kRegClasses = L"Software\\Classes"; |
1347 const wchar_t* ShellUtil::kRegRegisteredApplications = | 1348 const wchar_t* ShellUtil::kRegRegisteredApplications = |
1348 L"Software\\RegisteredApplications"; | 1349 L"Software\\RegisteredApplications"; |
1349 const wchar_t* ShellUtil::kRegVistaUrlPrefs = | 1350 const wchar_t* ShellUtil::kRegVistaUrlPrefs = |
1350 L"Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\" | 1351 L"Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\" |
1351 L"http\\UserChoice"; | 1352 L"http\\UserChoice"; |
1352 const wchar_t* ShellUtil::kAppPathsRegistryKey = | 1353 const wchar_t* ShellUtil::kAppPathsRegistryKey = |
1353 L"Software\\Microsoft\\Windows\\CurrentVersion\\App Paths"; | 1354 L"Software\\Microsoft\\Windows\\CurrentVersion\\App Paths"; |
1354 const wchar_t* ShellUtil::kAppPathsRegistryPathName = L"Path"; | 1355 const wchar_t* ShellUtil::kAppPathsRegistryPathName = L"Path"; |
1355 | 1356 |
1356 #if defined(GOOGLE_CHROME_BUILD) | |
1357 const wchar_t* ShellUtil::kChromeHTMLProgId = L"ChromeHTML"; | |
1358 const wchar_t* ShellUtil::kChromeHTMLProgIdDesc = L"Chrome HTML Document"; | |
1359 #else | |
1360 // This used to be "ChromiumHTML", but was forced to become "ChromiumHTM" | |
1361 // because of http://crbug.com/153349 as with the '.' and 26 characters suffix | |
1362 // added on user-level installs, the generated progid for Chromium was 39 | |
1363 // characters long which, according to MSDN ( | |
1364 // http://msdn.microsoft.com/library/aa911706.aspx), is the maximum length | |
1365 // for a progid. It was however determined through experimentation that the 39 | |
1366 // character limit mentioned on MSDN includes the NULL character... | |
1367 const wchar_t* ShellUtil::kChromeHTMLProgId = L"ChromiumHTM"; | |
1368 const wchar_t* ShellUtil::kChromeHTMLProgIdDesc = L"Chromium HTML Document"; | |
1369 #endif | |
1370 | |
1371 const wchar_t* ShellUtil::kDefaultFileAssociations[] = {L".htm", L".html", | 1357 const wchar_t* ShellUtil::kDefaultFileAssociations[] = {L".htm", L".html", |
1372 L".shtml", L".xht", L".xhtml", NULL}; | 1358 L".shtml", L".xht", L".xhtml", NULL}; |
1373 const wchar_t* ShellUtil::kPotentialFileAssociations[] = {L".htm", L".html", | 1359 const wchar_t* ShellUtil::kPotentialFileAssociations[] = {L".htm", L".html", |
1374 L".shtml", L".xht", L".xhtml", L".webp", NULL}; | 1360 L".shtml", L".xht", L".xhtml", L".webp", NULL}; |
1375 const wchar_t* ShellUtil::kBrowserProtocolAssociations[] = {L"ftp", L"http", | 1361 const wchar_t* ShellUtil::kBrowserProtocolAssociations[] = {L"ftp", L"http", |
1376 L"https", NULL}; | 1362 L"https", NULL}; |
1377 const wchar_t* ShellUtil::kPotentialProtocolAssociations[] = {L"ftp", L"http", | 1363 const wchar_t* ShellUtil::kPotentialProtocolAssociations[] = {L"ftp", L"http", |
1378 L"https", L"irc", L"mailto", L"mms", L"news", L"nntp", L"sms", L"smsto", | 1364 L"https", L"irc", L"mailto", L"mms", L"news", L"nntp", L"sms", L"smsto", |
1379 L"tel", L"urn", L"webcal", NULL}; | 1365 L"tel", L"urn", L"webcal", NULL}; |
1380 const wchar_t* ShellUtil::kRegUrlProtocol = L"URL Protocol"; | 1366 const wchar_t* ShellUtil::kRegUrlProtocol = L"URL Protocol"; |
(...skipping 765 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2146 // are any left...). | 2132 // are any left...). |
2147 if (free_bits >= 8 && next_byte_index < size) { | 2133 if (free_bits >= 8 && next_byte_index < size) { |
2148 free_bits -= 8; | 2134 free_bits -= 8; |
2149 bit_stream += bytes[next_byte_index++] << free_bits; | 2135 bit_stream += bytes[next_byte_index++] << free_bits; |
2150 } | 2136 } |
2151 } | 2137 } |
2152 | 2138 |
2153 DCHECK_EQ(ret.length(), encoded_length); | 2139 DCHECK_EQ(ret.length(), encoded_length); |
2154 return ret; | 2140 return ret; |
2155 } | 2141 } |
OLD | NEW |