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 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 293 entries->push_back(new RegistryEntry( | 293 entries->push_back(new RegistryEntry( |
| 294 prog_id_path + ShellUtil::kRegDefaultIcon, | 294 prog_id_path + ShellUtil::kRegDefaultIcon, |
| 295 ShellUtil::FormatIconLocation(app_info.file_type_icon_path, | 295 ShellUtil::FormatIconLocation(app_info.file_type_icon_path, |
| 296 app_info.file_type_icon_index))); | 296 app_info.file_type_icon_index))); |
| 297 entries->push_back(new RegistryEntry(prog_id_path + ShellUtil::kRegShellOpen, | 297 entries->push_back(new RegistryEntry(prog_id_path + ShellUtil::kRegShellOpen, |
| 298 app_info.command_line)); | 298 app_info.command_line)); |
| 299 if (!app_info.delegate_clsid.empty()) { | 299 if (!app_info.delegate_clsid.empty()) { |
| 300 entries->push_back(new RegistryEntry( | 300 entries->push_back(new RegistryEntry( |
| 301 prog_id_path + ShellUtil::kRegShellOpen, ShellUtil::kRegDelegateExecute, | 301 prog_id_path + ShellUtil::kRegShellOpen, ShellUtil::kRegDelegateExecute, |
| 302 app_info.delegate_clsid)); | 302 app_info.delegate_clsid)); |
| 303 // TODO(scottmg): Simplify after Metro removal. https://crbug.com/558054. | |
| 303 entries->back()->set_removal_flag(RegistryEntry::RemovalFlag::VALUE); | 304 entries->back()->set_removal_flag(RegistryEntry::RemovalFlag::VALUE); |
| 304 } | 305 } |
| 305 | 306 |
| 306 // The following entries are required as of Windows 8, but do not | 307 // The following entries are required as of Windows 8, but do not |
| 307 // depend on the DelegateExecute verb handler being set. | 308 // depend on the DelegateExecute verb handler being set. |
| 308 if (base::win::GetVersion() >= base::win::VERSION_WIN8) { | 309 if (base::win::GetVersion() >= base::win::VERSION_WIN8) { |
| 309 if (!app_info.app_id.empty()) { | 310 if (!app_info.app_id.empty()) { |
| 310 entries->push_back(new RegistryEntry( | 311 entries->push_back(new RegistryEntry( |
| 311 prog_id_path, ShellUtil::kRegAppUserModelId, app_info.app_id)); | 312 prog_id_path, ShellUtil::kRegAppUserModelId, app_info.app_id)); |
| 312 } | 313 } |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 373 | 374 |
| 374 app_info.delegate_clsid = dist->GetCommandExecuteImplClsid(); | 375 app_info.delegate_clsid = dist->GetCommandExecuteImplClsid(); |
| 375 | 376 |
| 376 GetProgIdEntries(app_info, entries); | 377 GetProgIdEntries(app_info, entries); |
| 377 | 378 |
| 378 if (!app_info.delegate_clsid.empty()) { | 379 if (!app_info.delegate_clsid.empty()) { |
| 379 ScopedVector<RegistryEntry> delegate_execute_entries = | 380 ScopedVector<RegistryEntry> delegate_execute_entries = |
| 380 GetChromeDelegateExecuteEntries(chrome_exe, app_info); | 381 GetChromeDelegateExecuteEntries(chrome_exe, app_info); |
| 381 // Remove the keys (not only their values) so that Windows will continue | 382 // Remove the keys (not only their values) so that Windows will continue |
| 382 // to launch Chrome without a pesky association error. | 383 // to launch Chrome without a pesky association error. |
| 384 // TODO(scottmg): Simplify after Metro removal. https://crbug.com/558054. | |
| 383 for (RegistryEntry* entry : delegate_execute_entries) | 385 for (RegistryEntry* entry : delegate_execute_entries) |
| 384 entry->set_removal_flag(RegistryEntry::RemovalFlag::KEY); | 386 entry->set_removal_flag(RegistryEntry::RemovalFlag::KEY); |
| 385 // Move |delegate_execute_entries| to |entries|. | 387 // Move |delegate_execute_entries| to |entries|. |
| 386 entries->insert(entries->end(), delegate_execute_entries.begin(), | 388 entries->insert(entries->end(), delegate_execute_entries.begin(), |
| 387 delegate_execute_entries.end()); | 389 delegate_execute_entries.end()); |
| 388 delegate_execute_entries.weak_clear(); | 390 delegate_execute_entries.weak_clear(); |
| 389 } | 391 } |
| 390 } | 392 } |
| 391 | 393 |
| 392 // This method returns a list of the registry entries needed to declare a | 394 // This method returns a list of the registry entries needed to declare a |
| (...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 940 default: | 942 default: |
| 941 NOTREACHED(); | 943 NOTREACHED(); |
| 942 return base::win::SHORTCUT_REPLACE_EXISTING; | 944 return base::win::SHORTCUT_REPLACE_EXISTING; |
| 943 } | 945 } |
| 944 } | 946 } |
| 945 | 947 |
| 946 // Returns a base::win::ShortcutProperties struct containing the properties | 948 // Returns a base::win::ShortcutProperties struct containing the properties |
| 947 // to set on the shortcut based on the provided ShellUtil::ShortcutProperties. | 949 // to set on the shortcut based on the provided ShellUtil::ShortcutProperties. |
| 948 base::win::ShortcutProperties TranslateShortcutProperties( | 950 base::win::ShortcutProperties TranslateShortcutProperties( |
| 949 const ShellUtil::ShortcutProperties& properties) { | 951 const ShellUtil::ShortcutProperties& properties) { |
| 950 base::win::ShortcutProperties shortcut_properties; | 952 base::win::ShortcutProperties shortcut_properties; |
|
gab
2016/01/14 03:22:17
Also add a TODO on base::win::ShortcutProperties's
gab
2016/01/14 17:08:24
Actually nvm, looking at what's involved here this
| |
| 951 | 953 |
| 952 if (properties.has_target()) { | 954 if (properties.has_target()) { |
| 953 shortcut_properties.set_target(properties.target); | 955 shortcut_properties.set_target(properties.target); |
| 954 DCHECK(!properties.target.DirName().empty()); | 956 DCHECK(!properties.target.DirName().empty()); |
| 955 shortcut_properties.set_working_dir(properties.target.DirName()); | 957 shortcut_properties.set_working_dir(properties.target.DirName()); |
| 956 } | 958 } |
| 957 | 959 |
| 958 if (properties.has_arguments()) | 960 if (properties.has_arguments()) |
| 959 shortcut_properties.set_arguments(properties.arguments); | 961 shortcut_properties.set_arguments(properties.arguments); |
| 960 | 962 |
| 961 if (properties.has_description()) | 963 if (properties.has_description()) |
| 962 shortcut_properties.set_description(properties.description); | 964 shortcut_properties.set_description(properties.description); |
| 963 | 965 |
| 964 if (properties.has_icon()) | 966 if (properties.has_icon()) |
| 965 shortcut_properties.set_icon(properties.icon, properties.icon_index); | 967 shortcut_properties.set_icon(properties.icon, properties.icon_index); |
| 966 | 968 |
| 967 if (properties.has_app_id()) | 969 if (properties.has_app_id()) |
| 968 shortcut_properties.set_app_id(properties.app_id); | 970 shortcut_properties.set_app_id(properties.app_id); |
| 969 | 971 |
| 970 if (properties.has_dual_mode()) | |
| 971 shortcut_properties.set_dual_mode(properties.dual_mode); | |
| 972 | |
| 973 return shortcut_properties; | 972 return shortcut_properties; |
| 974 } | 973 } |
| 975 | 974 |
| 976 // Cleans up an old verb (run) we used to register in | 975 // Cleans up an old verb (run) we used to register in |
| 977 // <root>\Software\Classes\Chrome<.suffix>\.exe\shell\run on Windows 8. | 976 // <root>\Software\Classes\Chrome<.suffix>\.exe\shell\run on Windows 8. |
| 978 void RemoveRunVerbOnWindows8(BrowserDistribution* dist, | 977 void RemoveRunVerbOnWindows8(BrowserDistribution* dist, |
| 979 const base::FilePath& chrome_exe) { | 978 const base::FilePath& chrome_exe) { |
| 980 if (base::win::GetVersion() >= base::win::VERSION_WIN8) { | 979 if (base::win::GetVersion() >= base::win::VERSION_WIN8) { |
| 981 bool is_per_user_install = InstallUtil::IsPerUserInstall(chrome_exe); | 980 bool is_per_user_install = InstallUtil::IsPerUserInstall(chrome_exe); |
| 982 HKEY root_key = DetermineRegistrationRoot(is_per_user_install); | 981 HKEY root_key = DetermineRegistrationRoot(is_per_user_install); |
| (...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1372 const wchar_t* ShellUtil::kRegVerbOpen = L"open"; | 1371 const wchar_t* ShellUtil::kRegVerbOpen = L"open"; |
| 1373 const wchar_t* ShellUtil::kRegVerbOpenNewWindow = L"opennewwindow"; | 1372 const wchar_t* ShellUtil::kRegVerbOpenNewWindow = L"opennewwindow"; |
| 1374 const wchar_t* ShellUtil::kRegVerbRun = L"run"; | 1373 const wchar_t* ShellUtil::kRegVerbRun = L"run"; |
| 1375 const wchar_t* ShellUtil::kRegCommand = L"command"; | 1374 const wchar_t* ShellUtil::kRegCommand = L"command"; |
| 1376 const wchar_t* ShellUtil::kRegDelegateExecute = L"DelegateExecute"; | 1375 const wchar_t* ShellUtil::kRegDelegateExecute = L"DelegateExecute"; |
| 1377 const wchar_t* ShellUtil::kRegOpenWithProgids = L"OpenWithProgids"; | 1376 const wchar_t* ShellUtil::kRegOpenWithProgids = L"OpenWithProgids"; |
| 1378 | 1377 |
| 1379 ShellUtil::ShortcutProperties::ShortcutProperties(ShellChange level_in) | 1378 ShellUtil::ShortcutProperties::ShortcutProperties(ShellChange level_in) |
| 1380 : level(level_in), | 1379 : level(level_in), |
| 1381 icon_index(0), | 1380 icon_index(0), |
| 1382 dual_mode(false), | |
| 1383 pin_to_taskbar(false), | 1381 pin_to_taskbar(false), |
| 1384 options(0U) {} | 1382 options(0U) {} |
| 1385 | 1383 |
| 1386 ShellUtil::ShortcutProperties::~ShortcutProperties() { | 1384 ShellUtil::ShortcutProperties::~ShortcutProperties() { |
| 1387 } | 1385 } |
| 1388 | 1386 |
| 1389 bool ShellUtil::QuickIsChromeRegisteredInHKLM(BrowserDistribution* dist, | 1387 bool ShellUtil::QuickIsChromeRegisteredInHKLM(BrowserDistribution* dist, |
| 1390 const base::FilePath& chrome_exe, | 1388 const base::FilePath& chrome_exe, |
| 1391 const base::string16& suffix) { | 1389 const base::string16& suffix) { |
| 1392 return QuickIsChromeRegistered(dist, chrome_exe, suffix, | 1390 return QuickIsChromeRegistered(dist, chrome_exe, suffix, |
| (...skipping 939 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2332 itr != entries.end(); ++itr) | 2330 itr != entries.end(); ++itr) |
| 2333 (*itr)->AddToWorkItemList(root, items.get()); | 2331 (*itr)->AddToWorkItemList(root, items.get()); |
| 2334 | 2332 |
| 2335 // Apply all the registry changes and if there is a problem, rollback | 2333 // Apply all the registry changes and if there is a problem, rollback |
| 2336 if (!items->Do()) { | 2334 if (!items->Do()) { |
| 2337 items->Rollback(); | 2335 items->Rollback(); |
| 2338 return false; | 2336 return false; |
| 2339 } | 2337 } |
| 2340 return true; | 2338 return true; |
| 2341 } | 2339 } |
| OLD | NEW |