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 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
289 } | 289 } |
290 } | 290 } |
291 | 291 |
292 // File association ProgId | 292 // File association ProgId |
293 base::string16 chrome_html_prog_id(ShellUtil::kRegClasses); | 293 base::string16 chrome_html_prog_id(ShellUtil::kRegClasses); |
294 chrome_html_prog_id.push_back(base::FilePath::kSeparators[0]); | 294 chrome_html_prog_id.push_back(base::FilePath::kSeparators[0]); |
295 chrome_html_prog_id.append(GetBrowserProgId(suffix)); | 295 chrome_html_prog_id.append(GetBrowserProgId(suffix)); |
296 entries->push_back(new RegistryEntry( | 296 entries->push_back(new RegistryEntry( |
297 chrome_html_prog_id, dist->GetBrowserProgIdDesc())); | 297 chrome_html_prog_id, dist->GetBrowserProgIdDesc())); |
298 entries->push_back(new RegistryEntry( | 298 entries->push_back(new RegistryEntry( |
299 chrome_html_prog_id, ShellUtil::kRegUrlProtocol, L"")); | 299 chrome_html_prog_id, ShellUtil::kRegUrlProtocol, base::string16())); |
300 entries->push_back(new RegistryEntry( | 300 entries->push_back(new RegistryEntry( |
301 chrome_html_prog_id + ShellUtil::kRegDefaultIcon, icon_path)); | 301 chrome_html_prog_id + ShellUtil::kRegDefaultIcon, icon_path)); |
302 entries->push_back(new RegistryEntry( | 302 entries->push_back(new RegistryEntry( |
303 chrome_html_prog_id + ShellUtil::kRegShellOpen, open_cmd)); | 303 chrome_html_prog_id + ShellUtil::kRegShellOpen, open_cmd)); |
304 if (set_delegate_execute) { | 304 if (set_delegate_execute) { |
305 entries->push_back(new RegistryEntry( | 305 entries->push_back(new RegistryEntry( |
306 chrome_html_prog_id + ShellUtil::kRegShellOpen, | 306 chrome_html_prog_id + ShellUtil::kRegShellOpen, |
307 ShellUtil::kRegDelegateExecute, delegate_guid)); | 307 ShellUtil::kRegDelegateExecute, delegate_guid)); |
308 } | 308 } |
309 | 309 |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
466 ScopedVector<RegistryEntry>* entries) { | 466 ScopedVector<RegistryEntry>* entries) { |
467 // Protocols associations. | 467 // Protocols associations. |
468 base::string16 url_key(ShellUtil::kRegClasses); | 468 base::string16 url_key(ShellUtil::kRegClasses); |
469 url_key.push_back(base::FilePath::kSeparators[0]); | 469 url_key.push_back(base::FilePath::kSeparators[0]); |
470 url_key.append(protocol); | 470 url_key.append(protocol); |
471 | 471 |
472 // This registry value tells Windows that this 'class' is a URL scheme | 472 // This registry value tells Windows that this 'class' is a URL scheme |
473 // so IE, explorer and other apps will route it to our handler. | 473 // so IE, explorer and other apps will route it to our handler. |
474 // <root hkey>\Software\Classes\<protocol>\URL Protocol | 474 // <root hkey>\Software\Classes\<protocol>\URL Protocol |
475 entries->push_back(new RegistryEntry(url_key, | 475 entries->push_back(new RegistryEntry(url_key, |
476 ShellUtil::kRegUrlProtocol, L"")); | 476 ShellUtil::kRegUrlProtocol, base::string16())); |
477 | 477 |
478 // <root hkey>\Software\Classes\<protocol>\DefaultIcon | 478 // <root hkey>\Software\Classes\<protocol>\DefaultIcon |
479 base::string16 icon_key = url_key + ShellUtil::kRegDefaultIcon; | 479 base::string16 icon_key = url_key + ShellUtil::kRegDefaultIcon; |
480 entries->push_back(new RegistryEntry(icon_key, chrome_icon)); | 480 entries->push_back(new RegistryEntry(icon_key, chrome_icon)); |
481 | 481 |
482 // <root hkey>\Software\Classes\<protocol>\shell\open\command | 482 // <root hkey>\Software\Classes\<protocol>\shell\open\command |
483 base::string16 shell_key = url_key + ShellUtil::kRegShellOpen; | 483 base::string16 shell_key = url_key + ShellUtil::kRegShellOpen; |
484 entries->push_back(new RegistryEntry(shell_key, chrome_open)); | 484 entries->push_back(new RegistryEntry(shell_key, chrome_open)); |
485 | 485 |
486 // <root hkey>\Software\Classes\<protocol>\shell\open\ddeexec | 486 // <root hkey>\Software\Classes\<protocol>\shell\open\ddeexec |
487 base::string16 dde_key = url_key + L"\\shell\\open\\ddeexec"; | 487 base::string16 dde_key = url_key + L"\\shell\\open\\ddeexec"; |
488 entries->push_back(new RegistryEntry(dde_key, L"")); | 488 entries->push_back(new RegistryEntry(dde_key, base::string16())); |
489 | 489 |
490 // <root hkey>\Software\Classes\<protocol>\shell\@ | 490 // <root hkey>\Software\Classes\<protocol>\shell\@ |
491 base::string16 protocol_shell_key = url_key + ShellUtil::kRegShellPath; | 491 base::string16 protocol_shell_key = url_key + ShellUtil::kRegShellPath; |
492 entries->push_back(new RegistryEntry(protocol_shell_key, L"open")); | 492 entries->push_back(new RegistryEntry(protocol_shell_key, L"open")); |
493 } | 493 } |
494 | 494 |
495 // This method returns a list of all the user level registry entries that | 495 // This method returns a list of all the user level registry entries that |
496 // are needed to make Chromium default browser on XP. | 496 // are needed to make Chromium default browser on XP. |
497 // Some of these entries are irrelevant in recent versions of Windows, but | 497 // Some of these entries are irrelevant in recent versions of Windows, but |
498 // we register them anyways as some legacy apps are hardcoded to lookup those | 498 // we register them anyways as some legacy apps are hardcoded to lookup those |
(...skipping 1247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1746 // at the beginning or end for things like usernames and paths). | 1746 // at the beginning or end for things like usernames and paths). |
1747 app_id.append(component.c_str(), 0, max_component_length / 2); | 1747 app_id.append(component.c_str(), 0, max_component_length / 2); |
1748 app_id.append(component.c_str(), | 1748 app_id.append(component.c_str(), |
1749 component.length() - ((max_component_length + 1) / 2), | 1749 component.length() - ((max_component_length + 1) / 2), |
1750 base::string16::npos); | 1750 base::string16::npos); |
1751 } else { | 1751 } else { |
1752 app_id.append(component); | 1752 app_id.append(component); |
1753 } | 1753 } |
1754 } | 1754 } |
1755 // No spaces are allowed in the AppUserModelId according to MSDN. | 1755 // No spaces are allowed in the AppUserModelId according to MSDN. |
1756 base::ReplaceChars(app_id, L" ", L"_", &app_id); | 1756 base::ReplaceChars(app_id, base::ASCIIToUTF16(" "), base::ASCIIToUTF16("_"), |
| 1757 &app_id); |
1757 return app_id; | 1758 return app_id; |
1758 } | 1759 } |
1759 | 1760 |
1760 ShellUtil::DefaultState ShellUtil::GetChromeDefaultState() { | 1761 ShellUtil::DefaultState ShellUtil::GetChromeDefaultState() { |
1761 base::FilePath app_path; | 1762 base::FilePath app_path; |
1762 if (!PathService::Get(base::FILE_EXE, &app_path)) { | 1763 if (!PathService::Get(base::FILE_EXE, &app_path)) { |
1763 NOTREACHED(); | 1764 NOTREACHED(); |
1764 return ShellUtil::UNKNOWN_DEFAULT; | 1765 return ShellUtil::UNKNOWN_DEFAULT; |
1765 } | 1766 } |
1766 | 1767 |
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2044 ScopedVector<RegistryEntry> shell_entries; | 2045 ScopedVector<RegistryEntry> shell_entries; |
2045 RegistryEntry::GetProgIdEntries(dist, chrome_exe, suffix, | 2046 RegistryEntry::GetProgIdEntries(dist, chrome_exe, suffix, |
2046 &progid_and_appreg_entries); | 2047 &progid_and_appreg_entries); |
2047 RegistryEntry::GetAppRegistrationEntries(chrome_exe, suffix, | 2048 RegistryEntry::GetAppRegistrationEntries(chrome_exe, suffix, |
2048 &progid_and_appreg_entries); | 2049 &progid_and_appreg_entries); |
2049 RegistryEntry::GetShellIntegrationEntries( | 2050 RegistryEntry::GetShellIntegrationEntries( |
2050 dist, chrome_exe, suffix, &shell_entries); | 2051 dist, chrome_exe, suffix, &shell_entries); |
2051 result = (AddRegistryEntries(root, progid_and_appreg_entries) && | 2052 result = (AddRegistryEntries(root, progid_and_appreg_entries) && |
2052 AddRegistryEntries(root, shell_entries)); | 2053 AddRegistryEntries(root, shell_entries)); |
2053 } else if (elevate_if_not_admin && | 2054 } else if (elevate_if_not_admin && |
2054 base::win::GetVersion() >= base::win::VERSION_VISTA && | 2055 base::win::GetVersion() >= base::win::VERSION_VISTA && |
2055 ElevateAndRegisterChrome(dist, chrome_exe, suffix, L"")) { | 2056 ElevateAndRegisterChrome(dist, chrome_exe, suffix, base::string16())) { |
2056 // If the user is not an admin and OS is between Vista and Windows 7 | 2057 // If the user is not an admin and OS is between Vista and Windows 7 |
2057 // inclusively, try to elevate and register. This is only intended for | 2058 // inclusively, try to elevate and register. This is only intended for |
2058 // user-level installs as system-level installs should always be run with | 2059 // user-level installs as system-level installs should always be run with |
2059 // admin rights. | 2060 // admin rights. |
2060 result = true; | 2061 result = true; |
2061 } else { | 2062 } else { |
2062 // If we got to this point then all we can do is create ProgId and basic app | 2063 // If we got to this point then all we can do is create ProgId and basic app |
2063 // registrations under HKCU. | 2064 // registrations under HKCU. |
2064 ScopedVector<RegistryEntry> entries; | 2065 ScopedVector<RegistryEntry> entries; |
2065 RegistryEntry::GetProgIdEntries( | 2066 RegistryEntry::GetProgIdEntries( |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2264 // are any left...). | 2265 // are any left...). |
2265 if (free_bits >= 8 && next_byte_index < size) { | 2266 if (free_bits >= 8 && next_byte_index < size) { |
2266 free_bits -= 8; | 2267 free_bits -= 8; |
2267 bit_stream += bytes[next_byte_index++] << free_bits; | 2268 bit_stream += bytes[next_byte_index++] << free_bits; |
2268 } | 2269 } |
2269 } | 2270 } |
2270 | 2271 |
2271 DCHECK_EQ(ret.length(), encoded_length); | 2272 DCHECK_EQ(ret.length(), encoded_length); |
2272 return ret; | 2273 return ret; |
2273 } | 2274 } |
OLD | NEW |