Chromium Code Reviews| 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 string16 chrome_html(ShellUtil::GetBrowserProgIdPrefix()); |
| 106 chrome_html.append(suffix); | 106 chrome_html.append(suffix); |
| 107 | 107 |
| 108 // ProgIds cannot be longer than 39 characters. | 108 // ProgIds cannot be longer than 39 characters. |
| 109 // Ref: http://msdn.microsoft.com/en-us/library/aa911706.aspx. | 109 // Ref: http://msdn.microsoft.com/en-us/library/aa911706.aspx. |
| 110 // Make all new registrations comply with this requirement (existing | 110 // Make all new registrations comply with this requirement (existing |
| 111 // registrations must be preserved). | 111 // registrations must be preserved). |
| 112 string16 new_style_suffix; | 112 string16 new_style_suffix; |
| 113 if (ShellUtil::GetUserSpecificRegistrySuffix(&new_style_suffix) && | 113 if (ShellUtil::GetUserSpecificRegistrySuffix(&new_style_suffix) && |
| 114 suffix == new_style_suffix && chrome_html.length() > 39) { | 114 suffix == new_style_suffix && chrome_html.length() > 39) { |
| 115 NOTREACHED(); | 115 NOTREACHED(); |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 282 entries->push_back(new RegistryEntry( | 282 entries->push_back(new RegistryEntry( |
| 283 sub_path, ShellUtil::kRegDelegateExecute, delegate_guid)); | 283 sub_path, ShellUtil::kRegDelegateExecute, delegate_guid)); |
| 284 } | 284 } |
| 285 } | 285 } |
| 286 | 286 |
| 287 // File association ProgId | 287 // File association ProgId |
| 288 string16 chrome_html_prog_id(ShellUtil::kRegClasses); | 288 string16 chrome_html_prog_id(ShellUtil::kRegClasses); |
| 289 chrome_html_prog_id.push_back(base::FilePath::kSeparators[0]); | 289 chrome_html_prog_id.push_back(base::FilePath::kSeparators[0]); |
| 290 chrome_html_prog_id.append(GetBrowserProgId(suffix)); | 290 chrome_html_prog_id.append(GetBrowserProgId(suffix)); |
| 291 entries->push_back(new RegistryEntry( | 291 entries->push_back(new RegistryEntry( |
| 292 chrome_html_prog_id, ShellUtil::kChromeHTMLProgIdDesc)); | 292 chrome_html_prog_id, ShellUtil::GetBrowserProgIdDesc())); |
| 293 entries->push_back(new RegistryEntry( | 293 entries->push_back(new RegistryEntry( |
| 294 chrome_html_prog_id, ShellUtil::kRegUrlProtocol, L"")); | 294 chrome_html_prog_id, ShellUtil::kRegUrlProtocol, L"")); |
| 295 entries->push_back(new RegistryEntry( | 295 entries->push_back(new RegistryEntry( |
| 296 chrome_html_prog_id + ShellUtil::kRegDefaultIcon, icon_path)); | 296 chrome_html_prog_id + ShellUtil::kRegDefaultIcon, icon_path)); |
| 297 entries->push_back(new RegistryEntry( | 297 entries->push_back(new RegistryEntry( |
| 298 chrome_html_prog_id + ShellUtil::kRegShellOpen, open_cmd)); | 298 chrome_html_prog_id + ShellUtil::kRegShellOpen, open_cmd)); |
| 299 if (set_delegate_execute) { | 299 if (set_delegate_execute) { |
| 300 entries->push_back(new RegistryEntry( | 300 entries->push_back(new RegistryEntry( |
| 301 chrome_html_prog_id + ShellUtil::kRegShellOpen, | 301 chrome_html_prog_id + ShellUtil::kRegShellOpen, |
| 302 ShellUtil::kRegDelegateExecute, delegate_guid)); | 302 ShellUtil::kRegDelegateExecute, delegate_guid)); |
| (...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 782 const string16& chrome_exe, | 782 const string16& chrome_exe, |
| 783 const string16& suffix, | 783 const string16& suffix, |
| 784 RegistrationConfirmationLevel confirmation_level) { | 784 RegistrationConfirmationLevel confirmation_level) { |
| 785 // Get the appropriate key to look for based on the level desired. | 785 // Get the appropriate key to look for based on the level desired. |
| 786 string16 reg_key; | 786 string16 reg_key; |
| 787 switch (confirmation_level) { | 787 switch (confirmation_level) { |
| 788 case CONFIRM_PROGID_REGISTRATION: | 788 case CONFIRM_PROGID_REGISTRATION: |
| 789 // Software\Classes\ChromeHTML|suffix| | 789 // Software\Classes\ChromeHTML|suffix| |
| 790 reg_key = ShellUtil::kRegClasses; | 790 reg_key = ShellUtil::kRegClasses; |
| 791 reg_key.push_back(base::FilePath::kSeparators[0]); | 791 reg_key.push_back(base::FilePath::kSeparators[0]); |
| 792 reg_key.append(ShellUtil::kChromeHTMLProgId); | 792 reg_key.append(ShellUtil::GetBrowserProgIdPrefix()); |
| 793 reg_key.append(suffix); | 793 reg_key.append(suffix); |
| 794 break; | 794 break; |
| 795 case CONFIRM_SHELL_REGISTRATION: | 795 case CONFIRM_SHELL_REGISTRATION: |
| 796 case CONFIRM_SHELL_REGISTRATION_IN_HKLM: | 796 case CONFIRM_SHELL_REGISTRATION_IN_HKLM: |
| 797 // Software\Clients\StartMenuInternet\Google Chrome|suffix| | 797 // Software\Clients\StartMenuInternet\Google Chrome|suffix| |
| 798 reg_key = RegistryEntry::GetBrowserClientKey(dist, suffix); | 798 reg_key = RegistryEntry::GetBrowserClientKey(dist, suffix); |
| 799 break; | 799 break; |
| 800 default: | 800 default: |
| 801 NOTREACHED(); | 801 NOTREACHED(); |
| 802 break; | 802 break; |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1051 CLSID_ApplicationAssociationRegistration, NULL, CLSCTX_INPROC); | 1051 CLSID_ApplicationAssociationRegistration, NULL, CLSCTX_INPROC); |
| 1052 if (FAILED(hr)) | 1052 if (FAILED(hr)) |
| 1053 return ShellUtil::UNKNOWN_DEFAULT; | 1053 return ShellUtil::UNKNOWN_DEFAULT; |
| 1054 | 1054 |
| 1055 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); | 1055 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); |
| 1056 base::FilePath chrome_exe; | 1056 base::FilePath chrome_exe; |
| 1057 if (!PathService::Get(base::FILE_EXE, &chrome_exe)) { | 1057 if (!PathService::Get(base::FILE_EXE, &chrome_exe)) { |
| 1058 NOTREACHED(); | 1058 NOTREACHED(); |
| 1059 return ShellUtil::UNKNOWN_DEFAULT; | 1059 return ShellUtil::UNKNOWN_DEFAULT; |
| 1060 } | 1060 } |
| 1061 string16 prog_id(ShellUtil::kChromeHTMLProgId); | 1061 string16 prog_id(ShellUtil::GetBrowserProgIdPrefix()); |
| 1062 prog_id += ShellUtil::GetCurrentInstallationSuffix(dist, chrome_exe.value()); | 1062 prog_id += ShellUtil::GetCurrentInstallationSuffix(dist, chrome_exe.value()); |
| 1063 | 1063 |
| 1064 for (size_t i = 0; i < num_protocols; ++i) { | 1064 for (size_t i = 0; i < num_protocols; ++i) { |
| 1065 base::win::ScopedCoMem<wchar_t> current_app; | 1065 base::win::ScopedCoMem<wchar_t> current_app; |
| 1066 hr = registration->QueryCurrentDefault(protocols[i], AT_URLPROTOCOL, | 1066 hr = registration->QueryCurrentDefault(protocols[i], AT_URLPROTOCOL, |
| 1067 AL_EFFECTIVE, ¤t_app); | 1067 AL_EFFECTIVE, ¤t_app); |
| 1068 if (FAILED(hr) || prog_id.compare(current_app) != 0) | 1068 if (FAILED(hr) || prog_id.compare(current_app) != 0) |
| 1069 return ShellUtil::NOT_DEFAULT; | 1069 return ShellUtil::NOT_DEFAULT; |
| 1070 } | 1070 } |
| 1071 | 1071 |
| (...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1337 const wchar_t* ShellUtil::kRegRegisteredApplications = | 1337 const wchar_t* ShellUtil::kRegRegisteredApplications = |
| 1338 L"Software\\RegisteredApplications"; | 1338 L"Software\\RegisteredApplications"; |
| 1339 const wchar_t* ShellUtil::kRegVistaUrlPrefs = | 1339 const wchar_t* ShellUtil::kRegVistaUrlPrefs = |
| 1340 L"Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\" | 1340 L"Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\" |
| 1341 L"http\\UserChoice"; | 1341 L"http\\UserChoice"; |
| 1342 const wchar_t* ShellUtil::kAppPathsRegistryKey = | 1342 const wchar_t* ShellUtil::kAppPathsRegistryKey = |
| 1343 L"Software\\Microsoft\\Windows\\CurrentVersion\\App Paths"; | 1343 L"Software\\Microsoft\\Windows\\CurrentVersion\\App Paths"; |
| 1344 const wchar_t* ShellUtil::kAppPathsRegistryPathName = L"Path"; | 1344 const wchar_t* ShellUtil::kAppPathsRegistryPathName = L"Path"; |
| 1345 | 1345 |
| 1346 #if defined(GOOGLE_CHROME_BUILD) | 1346 #if defined(GOOGLE_CHROME_BUILD) |
| 1347 const wchar_t* ShellUtil::kChromeHTMLProgId = L"ChromeHTML"; | 1347 const wchar_t* ShellUtil::kChromeStableHTMLProgId = L"ChromeHTML"; |
|
grt (UTC plus 2)
2013/09/04 03:33:36
these constants are no longer public, so move them
zturner
2013/09/05 01:35:29
Done.
| |
| 1348 const wchar_t* ShellUtil::kChromeHTMLProgIdDesc = L"Chrome HTML Document"; | 1348 const wchar_t* ShellUtil::kChromeStableHTMLProgIdDesc = L"Chrome HTML Document"; |
| 1349 const wchar_t* ShellUtil::kChromeSXSHTMLProgId = L"ChromeSSHTM"; | |
| 1350 const wchar_t* ShellUtil::kChromeSXSHTMLProgIdDesc = | |
| 1351 L"Chrome Canary HTML Document"; | |
| 1349 #else | 1352 #else |
| 1350 // This used to be "ChromiumHTML", but was forced to become "ChromiumHTM" | 1353 // This used to be "ChromiumHTML", but was forced to become "ChromiumHTM" |
| 1351 // because of http://crbug.com/153349 as with the '.' and 26 characters suffix | 1354 // because of http://crbug.com/153349 as with the '.' and 26 characters suffix |
| 1352 // added on user-level installs, the generated progid for Chromium was 39 | 1355 // added on user-level installs, the generated progid for Chromium was 39 |
| 1353 // characters long which, according to MSDN ( | 1356 // characters long which, according to MSDN ( |
| 1354 // http://msdn.microsoft.com/library/aa911706.aspx), is the maximum length | 1357 // http://msdn.microsoft.com/library/aa911706.aspx), is the maximum length |
| 1355 // for a progid. It was however determined through experimentation that the 39 | 1358 // for a progid. It was however determined through experimentation that the 39 |
| 1356 // character limit mentioned on MSDN includes the NULL character... | 1359 // character limit mentioned on MSDN includes the NULL character... |
| 1357 const wchar_t* ShellUtil::kChromeHTMLProgId = L"ChromiumHTM"; | 1360 const wchar_t* ShellUtil::kChromiumHTMLProgId = L"ChromiumHTM"; |
| 1358 const wchar_t* ShellUtil::kChromeHTMLProgIdDesc = L"Chromium HTML Document"; | 1361 const wchar_t* ShellUtil::kChromiumHTMLProgIdDesc = L"Chromium HTML Document"; |
| 1359 #endif | 1362 #endif |
| 1360 | 1363 |
| 1361 const wchar_t* ShellUtil::kDefaultFileAssociations[] = {L".htm", L".html", | 1364 const wchar_t* ShellUtil::kDefaultFileAssociations[] = {L".htm", L".html", |
| 1362 L".shtml", L".xht", L".xhtml", NULL}; | 1365 L".shtml", L".xht", L".xhtml", NULL}; |
| 1363 const wchar_t* ShellUtil::kPotentialFileAssociations[] = {L".htm", L".html", | 1366 const wchar_t* ShellUtil::kPotentialFileAssociations[] = {L".htm", L".html", |
| 1364 L".shtml", L".xht", L".xhtml", L".webp", NULL}; | 1367 L".shtml", L".xht", L".xhtml", L".webp", NULL}; |
| 1365 const wchar_t* ShellUtil::kBrowserProtocolAssociations[] = {L"ftp", L"http", | 1368 const wchar_t* ShellUtil::kBrowserProtocolAssociations[] = {L"ftp", L"http", |
| 1366 L"https", NULL}; | 1369 L"https", NULL}; |
| 1367 const wchar_t* ShellUtil::kPotentialProtocolAssociations[] = {L"ftp", L"http", | 1370 const wchar_t* ShellUtil::kPotentialProtocolAssociations[] = {L"ftp", L"http", |
| 1368 L"https", L"irc", L"mailto", L"mms", L"news", L"nntp", L"sms", L"smsto", | 1371 L"https", L"irc", L"mailto", L"mms", L"news", L"nntp", L"sms", L"smsto", |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 1383 const wchar_t* ShellUtil::kRegDelegateExecute = L"DelegateExecute"; | 1386 const wchar_t* ShellUtil::kRegDelegateExecute = L"DelegateExecute"; |
| 1384 const wchar_t* ShellUtil::kRegOpenWithProgids = L"OpenWithProgids"; | 1387 const wchar_t* ShellUtil::kRegOpenWithProgids = L"OpenWithProgids"; |
| 1385 | 1388 |
| 1386 bool ShellUtil::QuickIsChromeRegisteredInHKLM(BrowserDistribution* dist, | 1389 bool ShellUtil::QuickIsChromeRegisteredInHKLM(BrowserDistribution* dist, |
| 1387 const string16& chrome_exe, | 1390 const string16& chrome_exe, |
| 1388 const string16& suffix) { | 1391 const string16& suffix) { |
| 1389 return QuickIsChromeRegistered(dist, chrome_exe, suffix, | 1392 return QuickIsChromeRegistered(dist, chrome_exe, suffix, |
| 1390 CONFIRM_SHELL_REGISTRATION_IN_HKLM); | 1393 CONFIRM_SHELL_REGISTRATION_IN_HKLM); |
| 1391 } | 1394 } |
| 1392 | 1395 |
| 1396 | |
| 1397 string16 ShellUtil::GetBrowserProgIdPrefix() { | |
| 1398 #if defined(GOOGLE_CHROME_BUILD) | |
| 1399 if (InstallUtil::IsChromeSXSProcess()) | |
| 1400 return string16(ShellUtil::kChromeSXSHTMLProgId); | |
| 1401 else | |
| 1402 return string16(ShellUtil::kChromeStableHTMLProgId); | |
| 1403 #else | |
| 1404 return string16(ShellUtil::kChromiumHTMLProgId); | |
| 1405 #endif | |
| 1406 } | |
| 1407 | |
| 1408 string16 ShellUtil::GetBrowserProgIdDesc() { | |
| 1409 #if defined(GOOGLE_CHROME_BUILD) | |
| 1410 if (InstallUtil::IsChromeSXSProcess()) | |
| 1411 return string16(ShellUtil::kChromeSXSHTMLProgIdDesc); | |
| 1412 else | |
| 1413 return string16(ShellUtil::kChromeStableHTMLProgIdDesc); | |
| 1414 #else | |
| 1415 return string16(ShellUtil::kChromiumHTMLProgIdDesc); | |
| 1416 #endif | |
| 1417 } | |
| 1418 | |
| 1393 bool ShellUtil::ShortcutLocationIsSupported( | 1419 bool ShellUtil::ShortcutLocationIsSupported( |
| 1394 ShellUtil::ShortcutLocation location) { | 1420 ShellUtil::ShortcutLocation location) { |
| 1395 switch (location) { | 1421 switch (location) { |
| 1396 case SHORTCUT_LOCATION_DESKTOP: | 1422 case SHORTCUT_LOCATION_DESKTOP: |
| 1397 return true; | 1423 return true; |
| 1398 case SHORTCUT_LOCATION_QUICK_LAUNCH: | 1424 case SHORTCUT_LOCATION_QUICK_LAUNCH: |
| 1399 return true; | 1425 return true; |
| 1400 case SHORTCUT_LOCATION_START_MENU: | 1426 case SHORTCUT_LOCATION_START_MENU: |
| 1401 return true; | 1427 return true; |
| 1402 case SHORTCUT_LOCATION_TASKBAR_PINS: | 1428 case SHORTCUT_LOCATION_TASKBAR_PINS: |
| (...skipping 732 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2135 // are any left...). | 2161 // are any left...). |
| 2136 if (free_bits >= 8 && next_byte_index < size) { | 2162 if (free_bits >= 8 && next_byte_index < size) { |
| 2137 free_bits -= 8; | 2163 free_bits -= 8; |
| 2138 bit_stream += bytes[next_byte_index++] << free_bits; | 2164 bit_stream += bytes[next_byte_index++] << free_bits; |
| 2139 } | 2165 } |
| 2140 } | 2166 } |
| 2141 | 2167 |
| 2142 DCHECK_EQ(ret.length(), encoded_length); | 2168 DCHECK_EQ(ret.length(), encoded_length); |
| 2143 return ret; | 2169 return ret; |
| 2144 } | 2170 } |
| OLD | NEW |