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