[email protected] | b6b7222 | 2012-02-11 02:04:13 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
[email protected] | d24c401 | 2009-07-28 01:57:31 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
pmonette | 32a5cfb4 | 2016-04-11 22:04:44 | [diff] [blame] | 5 | #include "chrome/browser/shell_integration_win.h" |
[email protected] | d24c401 | 2009-07-28 01:57:31 | [diff] [blame] | 6 | |
| 7 | #include <windows.h> |
robliao | a872e99 | 2017-05-18 06:36:19 | [diff] [blame] | 8 | #include <objbase.h> |
[email protected] | d24c401 | 2009-07-28 01:57:31 | [diff] [blame] | 9 | #include <shobjidl.h> |
thestig | 18dfb7a5 | 2014-08-26 10:44:04 | [diff] [blame] | 10 | #include <propkey.h> // Needs to come after shobjidl.h. |
avi | 664c07b | 2015-12-26 02:18:31 | [diff] [blame] | 11 | #include <stddef.h> |
| 12 | #include <stdint.h> |
Robert Liao | b2bc703d | 2017-10-17 20:52:35 | [diff] [blame] | 13 | #include <wrl/client.h> |
[email protected] | d24c401 | 2009-07-28 01:57:31 | [diff] [blame] | 14 | |
pmonette | a9831524 | 2016-11-23 21:39:18 | [diff] [blame] | 15 | #include <memory> |
| 16 | #include <utility> |
pmonette | 32a5cfb4 | 2016-04-11 22:04:44 | [diff] [blame] | 17 | #include <vector> |
| 18 | |
[email protected] | 3a3e72c | 2011-11-29 02:59:38 | [diff] [blame] | 19 | #include "base/bind.h" |
pmonette | 32a5cfb4 | 2016-04-11 22:04:44 | [diff] [blame] | 20 | #include "base/callback.h" |
[email protected] | d24c401 | 2009-07-28 01:57:31 | [diff] [blame] | 21 | #include "base/command_line.h" |
[email protected] | 25a4c1c | 2013-06-08 04:53:36 | [diff] [blame] | 22 | #include "base/files/file_enumerator.h" |
thestig | 18dfb7a5 | 2014-08-26 10:44:04 | [diff] [blame] | 23 | #include "base/files/file_util.h" |
avi | 664c07b | 2015-12-26 02:18:31 | [diff] [blame] | 24 | #include "base/macros.h" |
pmonette | 32a5cfb4 | 2016-04-11 22:04:44 | [diff] [blame] | 25 | #include "base/memory/weak_ptr.h" |
pmonette | 32a5cfb4 | 2016-04-11 22:04:44 | [diff] [blame] | 26 | #include "base/metrics/histogram_macros.h" |
grt | c291eea | 2016-05-26 15:38:48 | [diff] [blame] | 27 | #include "base/metrics/user_metrics.h" |
| 28 | #include "base/metrics/user_metrics_action.h" |
[email protected] | d24c401 | 2009-07-28 01:57:31 | [diff] [blame] | 29 | #include "base/path_service.h" |
[email protected] | 24a555b6 | 2013-06-10 22:01:17 | [diff] [blame] | 30 | #include "base/strings/string_util.h" |
| 31 | #include "base/strings/stringprintf.h" |
[email protected] | e309f31 | 2013-06-07 21:50:08 | [diff] [blame] | 32 | #include "base/strings/utf_string_conversions.h" |
Gabriel Charette | 44db142 | 2018-08-06 11:19:33 | [diff] [blame] | 33 | #include "base/task/post_task.h" |
pmonette | 32a5cfb4 | 2016-04-11 22:04:44 | [diff] [blame] | 34 | #include "base/time/time.h" |
| 35 | #include "base/timer/timer.h" |
[email protected] | 2d650398 | 2010-10-17 04:41:54 | [diff] [blame] | 36 | #include "base/win/registry.h" |
[email protected] | 0798330 | 2013-01-21 19:41:44 | [diff] [blame] | 37 | #include "base/win/scoped_propvariant.h" |
Danil Chapovalov | 3518f36 | 2018-08-11 16:13:43 | [diff] [blame] | 38 | #include "base/win/shlwapi.h" |
[email protected] | f1024e2 | 2012-09-12 07:14:55 | [diff] [blame] | 39 | #include "base/win/shortcut.h" |
[email protected] | 935aa54 | 2010-10-15 01:59:15 | [diff] [blame] | 40 | #include "base/win/windows_version.h" |
[email protected] | 89d4383 | 2013-06-29 20:25:20 | [diff] [blame] | 41 | #include "chrome/browser/policy/policy_path_parser.h" |
pmonette | 32a5cfb4 | 2016-04-11 22:04:44 | [diff] [blame] | 42 | #include "chrome/browser/shell_integration.h" |
Alexey Baskakov | 2f8bf816 | 2018-07-17 01:06:11 | [diff] [blame] | 43 | #include "chrome/browser/web_applications/components/web_app_helpers.h" |
grt | c291eea | 2016-05-26 15:38:48 | [diff] [blame] | 44 | #include "chrome/browser/win/settings_app_monitor.h" |
[email protected] | d24c401 | 2009-07-28 01:57:31 | [diff] [blame] | 45 | #include "chrome/common/chrome_constants.h" |
[email protected] | 12f520c | 2010-01-06 18:11:15 | [diff] [blame] | 46 | #include "chrome/common/chrome_paths_internal.h" |
[email protected] | c9bb06f4 | 2010-01-13 23:53:48 | [diff] [blame] | 47 | #include "chrome/common/chrome_switches.h" |
grt | c9880346 | 2017-03-08 10:05:08 | [diff] [blame] | 48 | #include "chrome/install_static/install_util.h" |
[email protected] | 3f69d6e61 | 2012-08-03 18:52:27 | [diff] [blame] | 49 | #include "chrome/installer/util/install_util.h" |
pmonette | 0c40087a | 2016-04-21 00:05:16 | [diff] [blame] | 50 | #include "chrome/installer/util/scoped_user_protocol_entry.h" |
[email protected] | d24c401 | 2009-07-28 01:57:31 | [diff] [blame] | 51 | #include "chrome/installer/util/shell_util.h" |
Ken Rockot | c74e379 | 2018-02-10 16:31:30 | [diff] [blame] | 52 | #include "chrome/services/util_win/public/mojom/constants.mojom.h" |
| 53 | #include "chrome/services/util_win/public/mojom/shell_util_win.mojom.h" |
pmonette | 2b1dbee | 2016-01-08 20:18:58 | [diff] [blame] | 54 | #include "components/variations/variations_associated_data.h" |
Jay Civelli | d4b8905 | 2017-10-31 17:48:25 | [diff] [blame] | 55 | #include "content/public/common/service_manager_connection.h" |
| 56 | #include "services/service_manager/public/cpp/connector.h" |
[email protected] | d24c401 | 2009-07-28 01:57:31 | [diff] [blame] | 57 | |
pmonette | 9fa59e88 | 2016-02-10 00:12:19 | [diff] [blame] | 58 | namespace shell_integration { |
| 59 | |
[email protected] | 12f520c | 2010-01-06 18:11:15 | [diff] [blame] | 60 | namespace { |
| 61 | |
pmonette | 9fa59e88 | 2016-02-10 00:12:19 | [diff] [blame] | 62 | // Helper function for GetAppId to generates profile id |
[email protected] | 2f1c09d | 2011-01-14 14:58:14 | [diff] [blame] | 63 | // from profile path. "profile_id" is composed of sanitized basenames of |
[email protected] | 12f520c | 2010-01-06 18:11:15 | [diff] [blame] | 64 | // user data dir and profile dir joined by a ".". |
[email protected] | 6a72a63 | 2013-12-12 22:22:00 | [diff] [blame] | 65 | base::string16 GetProfileIdFromPath(const base::FilePath& profile_path) { |
[email protected] | 12f520c | 2010-01-06 18:11:15 | [diff] [blame] | 66 | // Return empty string if profile_path is empty |
| 67 | if (profile_path.empty()) |
[email protected] | 0085863a | 2013-12-06 21:19:03 | [diff] [blame] | 68 | return base::string16(); |
[email protected] | 12f520c | 2010-01-06 18:11:15 | [diff] [blame] | 69 | |
[email protected] | 650b2d5 | 2013-02-10 03:41:45 | [diff] [blame] | 70 | base::FilePath default_user_data_dir; |
[email protected] | 12f520c | 2010-01-06 18:11:15 | [diff] [blame] | 71 | // Return empty string if profile_path is in default user data |
| 72 | // dir and is the default profile. |
| 73 | if (chrome::GetDefaultUserDataDirectory(&default_user_data_dir) && |
| 74 | profile_path.DirName() == default_user_data_dir && |
[email protected] | 162b599 | 2011-03-15 19:40:48 | [diff] [blame] | 75 | profile_path.BaseName().value() == |
[email protected] | f911df5 | 2013-12-24 23:24:23 | [diff] [blame] | 76 | base::ASCIIToUTF16(chrome::kInitialProfile)) { |
[email protected] | 0085863a | 2013-12-06 21:19:03 | [diff] [blame] | 77 | return base::string16(); |
[email protected] | 162b599 | 2011-03-15 19:40:48 | [diff] [blame] | 78 | } |
[email protected] | 12f520c | 2010-01-06 18:11:15 | [diff] [blame] | 79 | |
| 80 | // Get joined basenames of user data dir and profile. |
[email protected] | 0085863a | 2013-12-06 21:19:03 | [diff] [blame] | 81 | base::string16 basenames = profile_path.DirName().BaseName().value() + |
[email protected] | 12f520c | 2010-01-06 18:11:15 | [diff] [blame] | 82 | L"." + profile_path.BaseName().value(); |
| 83 | |
[email protected] | 0085863a | 2013-12-06 21:19:03 | [diff] [blame] | 84 | base::string16 profile_id; |
[email protected] | 12f520c | 2010-01-06 18:11:15 | [diff] [blame] | 85 | profile_id.reserve(basenames.size()); |
| 86 | |
| 87 | // Generate profile_id from sanitized basenames. |
| 88 | for (size_t i = 0; i < basenames.length(); ++i) { |
brettw | b341306 | 2015-06-24 00:39:02 | [diff] [blame] | 89 | if (base::IsAsciiAlpha(basenames[i]) || |
| 90 | base::IsAsciiDigit(basenames[i]) || |
[email protected] | 12f520c | 2010-01-06 18:11:15 | [diff] [blame] | 91 | basenames[i] == L'.') |
| 92 | profile_id += basenames[i]; |
| 93 | } |
| 94 | |
| 95 | return profile_id; |
| 96 | } |
| 97 | |
tapted | c2c690ab | 2016-05-25 02:49:03 | [diff] [blame] | 98 | base::string16 GetAppListAppName() { |
| 99 | static const base::char16 kAppListAppNameSuffix[] = L"AppList"; |
grt | c9880346 | 2017-03-08 10:05:08 | [diff] [blame] | 100 | base::string16 app_name(install_static::GetBaseAppId()); |
tapted | c2c690ab | 2016-05-25 02:49:03 | [diff] [blame] | 101 | app_name.append(kAppListAppNameSuffix); |
| 102 | return app_name; |
| 103 | } |
| 104 | |
[email protected] | 8ea8f1ef | 2013-01-06 18:39:03 | [diff] [blame] | 105 | // Gets expected app id for given Chrome (based on |command_line| and |
| 106 | // |is_per_user_install|). |
avi | 556c0502 | 2014-12-22 23:31:43 | [diff] [blame] | 107 | base::string16 GetExpectedAppId(const base::CommandLine& command_line, |
[email protected] | 6a72a63 | 2013-12-12 22:22:00 | [diff] [blame] | 108 | bool is_per_user_install) { |
[email protected] | b39e32e | 2013-04-24 08:55:54 | [diff] [blame] | 109 | base::FilePath user_data_dir; |
| 110 | if (command_line.HasSwitch(switches::kUserDataDir)) |
| 111 | user_data_dir = command_line.GetSwitchValuePath(switches::kUserDataDir); |
| 112 | else |
| 113 | chrome::GetDefaultUserDataDirectory(&user_data_dir); |
[email protected] | 89d4383 | 2013-06-29 20:25:20 | [diff] [blame] | 114 | // Adjust with any policy that overrides any other way to set the path. |
| 115 | policy::path_parser::CheckUserDataDirPolicy(&user_data_dir); |
[email protected] | b39e32e | 2013-04-24 08:55:54 | [diff] [blame] | 116 | DCHECK(!user_data_dir.empty()); |
[email protected] | c9bb06f4 | 2010-01-13 23:53:48 | [diff] [blame] | 117 | |
[email protected] | b39e32e | 2013-04-24 08:55:54 | [diff] [blame] | 118 | base::FilePath profile_subdir; |
| 119 | if (command_line.HasSwitch(switches::kProfileDirectory)) { |
| 120 | profile_subdir = |
| 121 | command_line.GetSwitchValuePath(switches::kProfileDirectory); |
| 122 | } else { |
[email protected] | f911df5 | 2013-12-24 23:24:23 | [diff] [blame] | 123 | profile_subdir = |
| 124 | base::FilePath(base::ASCIIToUTF16(chrome::kInitialProfile)); |
[email protected] | b39e32e | 2013-04-24 08:55:54 | [diff] [blame] | 125 | } |
| 126 | DCHECK(!profile_subdir.empty()); |
| 127 | |
| 128 | base::FilePath profile_path = user_data_dir.Append(profile_subdir); |
[email protected] | 0085863a | 2013-12-06 21:19:03 | [diff] [blame] | 129 | base::string16 app_name; |
[email protected] | c9bb06f4 | 2010-01-13 23:53:48 | [diff] [blame] | 130 | if (command_line.HasSwitch(switches::kApp)) { |
[email protected] | f911df5 | 2013-12-24 23:24:23 | [diff] [blame] | 131 | app_name = base::UTF8ToUTF16(web_app::GenerateApplicationNameFromURL( |
[email protected] | 57ecc4b | 2010-08-11 03:02:51 | [diff] [blame] | 132 | GURL(command_line.GetSwitchValueASCII(switches::kApp)))); |
[email protected] | 2f1c09d | 2011-01-14 14:58:14 | [diff] [blame] | 133 | } else if (command_line.HasSwitch(switches::kAppId)) { |
Alexey Baskakov | 2ce2ffc84 | 2018-08-06 02:57:15 | [diff] [blame] | 134 | app_name = base::UTF8ToUTF16(web_app::GenerateApplicationNameFromAppId( |
| 135 | command_line.GetSwitchValueASCII(switches::kAppId))); |
tapted | c2c690ab | 2016-05-25 02:49:03 | [diff] [blame] | 136 | } else if (command_line.HasSwitch(switches::kShowAppList)) { |
| 137 | app_name = GetAppListAppName(); |
[email protected] | c9bb06f4 | 2010-01-13 23:53:48 | [diff] [blame] | 138 | } else { |
grt | c9880346 | 2017-03-08 10:05:08 | [diff] [blame] | 139 | app_name = ShellUtil::GetBrowserModelId(is_per_user_install); |
[email protected] | c9bb06f4 | 2010-01-13 23:53:48 | [diff] [blame] | 140 | } |
[email protected] | b39e32e | 2013-04-24 08:55:54 | [diff] [blame] | 141 | DCHECK(!app_name.empty()); |
[email protected] | c9bb06f4 | 2010-01-13 23:53:48 | [diff] [blame] | 142 | |
pmonette | 9e4c1a8 | 2016-04-14 18:15:30 | [diff] [blame] | 143 | return win::GetAppModelIdForProfile(app_name, profile_path); |
[email protected] | c9bb06f4 | 2010-01-13 23:53:48 | [diff] [blame] | 144 | } |
| 145 | |
gab | 88257b6 | 2016-01-15 03:19:19 | [diff] [blame] | 146 | void MigrateTaskbarPinsCallback() { |
Francois Doray | 66bdfd8 | 2017-10-20 13:50:37 | [diff] [blame] | 147 | base::AssertBlockingAllowed(); |
[email protected] | 3a3e72c | 2011-11-29 02:59:38 | [diff] [blame] | 148 | |
| 149 | // Get full path of chrome. |
[email protected] | 650b2d5 | 2013-02-10 03:41:45 | [diff] [blame] | 150 | base::FilePath chrome_exe; |
Avi Drissman | 9098f900 | 2018-05-04 00:11:52 | [diff] [blame] | 151 | if (!base::PathService::Get(base::FILE_EXE, &chrome_exe)) |
[email protected] | 3a3e72c | 2011-11-29 02:59:38 | [diff] [blame] | 152 | return; |
| 153 | |
gab | 88257b6 | 2016-01-15 03:19:19 | [diff] [blame] | 154 | base::FilePath pins_path; |
Avi Drissman | 9098f900 | 2018-05-04 00:11:52 | [diff] [blame] | 155 | if (!base::PathService::Get(base::DIR_TASKBAR_PINS, &pins_path)) { |
gab | 88257b6 | 2016-01-15 03:19:19 | [diff] [blame] | 156 | NOTREACHED(); |
| 157 | return; |
[email protected] | 3a3e72c | 2011-11-29 02:59:38 | [diff] [blame] | 158 | } |
gab | 88257b6 | 2016-01-15 03:19:19 | [diff] [blame] | 159 | |
pmonette | 9e4c1a8 | 2016-04-14 18:15:30 | [diff] [blame] | 160 | win::MigrateShortcutsInPathInternal(chrome_exe, pins_path); |
[email protected] | 3a3e72c | 2011-11-29 02:59:38 | [diff] [blame] | 161 | } |
| 162 | |
[email protected] | caa0535 | 2014-03-01 00:43:05 | [diff] [blame] | 163 | // Windows 8 introduced a new protocol->executable binding system which cannot |
| 164 | // be retrieved in the HKCR registry subkey method implemented below. We call |
| 165 | // AssocQueryString with the new Win8-only flag ASSOCF_IS_PROTOCOL instead. |
| 166 | base::string16 GetAppForProtocolUsingAssocQuery(const GURL& url) { |
thestig | 11bf74d | 2014-11-24 20:14:42 | [diff] [blame] | 167 | base::string16 url_scheme = base::ASCIIToUTF16(url.scheme()); |
[email protected] | caa0535 | 2014-03-01 00:43:05 | [diff] [blame] | 168 | // Don't attempt to query protocol association on an empty string. |
[email protected] | 6e84d37 | 2014-05-29 23:36:39 | [diff] [blame] | 169 | if (url_scheme.empty()) |
[email protected] | caa0535 | 2014-03-01 00:43:05 | [diff] [blame] | 170 | return base::string16(); |
| 171 | |
[email protected] | caa0535 | 2014-03-01 00:43:05 | [diff] [blame] | 172 | // Query AssocQueryString for a human-readable description of the program |
| 173 | // that will be invoked given the provided URL spec. This is used only to |
| 174 | // populate the external protocol dialog box the user sees when invoking |
| 175 | // an unknown external protocol. |
| 176 | wchar_t out_buffer[1024]; |
| 177 | DWORD buffer_size = arraysize(out_buffer); |
| 178 | HRESULT hr = AssocQueryString(ASSOCF_IS_PROTOCOL, |
| 179 | ASSOCSTR_FRIENDLYAPPNAME, |
[email protected] | 6e84d37 | 2014-05-29 23:36:39 | [diff] [blame] | 180 | url_scheme.c_str(), |
[email protected] | caa0535 | 2014-03-01 00:43:05 | [diff] [blame] | 181 | NULL, |
| 182 | out_buffer, |
| 183 | &buffer_size); |
| 184 | if (FAILED(hr)) { |
| 185 | DLOG(WARNING) << "AssocQueryString failed!"; |
| 186 | return base::string16(); |
| 187 | } |
| 188 | return base::string16(out_buffer); |
| 189 | } |
| 190 | |
| 191 | base::string16 GetAppForProtocolUsingRegistry(const GURL& url) { |
dominickn | 0c9a506 | 2016-10-06 20:49:00 | [diff] [blame] | 192 | base::string16 command_to_launch; |
| 193 | |
| 194 | // First, try and extract the application's display name. |
| 195 | base::string16 cmd_key_path = base::ASCIIToUTF16(url.scheme()); |
| 196 | base::win::RegKey cmd_key_name(HKEY_CLASSES_ROOT, cmd_key_path.c_str(), |
| 197 | KEY_READ); |
| 198 | if (cmd_key_name.ReadValue(NULL, &command_to_launch) == ERROR_SUCCESS && |
| 199 | !command_to_launch.empty()) { |
| 200 | return command_to_launch; |
[email protected] | caa0535 | 2014-03-01 00:43:05 | [diff] [blame] | 201 | } |
dominickn | 0c9a506 | 2016-10-06 20:49:00 | [diff] [blame] | 202 | |
| 203 | // Otherwise, parse the command line in the registry, and return the basename |
| 204 | // of the program path if it exists. |
| 205 | cmd_key_path = base::ASCIIToUTF16(url.scheme() + "\\shell\\open\\command"); |
| 206 | base::win::RegKey cmd_key_exe(HKEY_CLASSES_ROOT, cmd_key_path.c_str(), |
| 207 | KEY_READ); |
| 208 | if (cmd_key_exe.ReadValue(NULL, &command_to_launch) == ERROR_SUCCESS) { |
| 209 | base::CommandLine command_line( |
| 210 | base::CommandLine::FromString(command_to_launch)); |
| 211 | return command_line.GetProgram().BaseName().value(); |
| 212 | } |
| 213 | |
[email protected] | caa0535 | 2014-03-01 00:43:05 | [diff] [blame] | 214 | return base::string16(); |
| 215 | } |
| 216 | |
pmonette | 9fa59e88 | 2016-02-10 00:12:19 | [diff] [blame] | 217 | DefaultWebClientState GetDefaultWebClientStateFromShellUtilDefaultState( |
| 218 | ShellUtil::DefaultState default_state) { |
[email protected] | eb63da7 | 2012-10-15 20:39:48 | [diff] [blame] | 219 | switch (default_state) { |
Greg Thompson | 75b1c8e | 2017-08-16 13:36:28 | [diff] [blame] | 220 | case ShellUtil::UNKNOWN_DEFAULT: |
| 221 | return DefaultWebClientState::UNKNOWN_DEFAULT; |
[email protected] | eb63da7 | 2012-10-15 20:39:48 | [diff] [blame] | 222 | case ShellUtil::NOT_DEFAULT: |
pmonette | 9fa59e88 | 2016-02-10 00:12:19 | [diff] [blame] | 223 | return DefaultWebClientState::NOT_DEFAULT; |
[email protected] | eb63da7 | 2012-10-15 20:39:48 | [diff] [blame] | 224 | case ShellUtil::IS_DEFAULT: |
pmonette | 9fa59e88 | 2016-02-10 00:12:19 | [diff] [blame] | 225 | return DefaultWebClientState::IS_DEFAULT; |
Greg Thompson | 75b1c8e | 2017-08-16 13:36:28 | [diff] [blame] | 226 | case ShellUtil::OTHER_MODE_IS_DEFAULT: |
| 227 | return DefaultWebClientState::OTHER_MODE_IS_DEFAULT; |
[email protected] | eb63da7 | 2012-10-15 20:39:48 | [diff] [blame] | 228 | } |
Greg Thompson | 75b1c8e | 2017-08-16 13:36:28 | [diff] [blame] | 229 | NOTREACHED(); |
| 230 | return DefaultWebClientState::UNKNOWN_DEFAULT; |
[email protected] | eb63da7 | 2012-10-15 20:39:48 | [diff] [blame] | 231 | } |
| 232 | |
grt | c291eea | 2016-05-26 15:38:48 | [diff] [blame] | 233 | // A recorder of user actions in the Windows Settings app. |
Patrick Monette | 7ff99e0 | 2018-02-19 17:30:12 | [diff] [blame] | 234 | class DefaultBrowserActionRecorder : public SettingsAppMonitor::Delegate { |
grt | c291eea | 2016-05-26 15:38:48 | [diff] [blame] | 235 | public: |
| 236 | // Creates the recorder and the monitor that drives it. |continuation| will be |
| 237 | // run once the monitor's initialization completes (regardless of success or |
| 238 | // failure). |
| 239 | explicit DefaultBrowserActionRecorder(base::Closure continuation) |
| 240 | : continuation_(std::move(continuation)), settings_app_monitor_(this) {} |
| 241 | |
| 242 | private: |
| 243 | // win::SettingsAppMonitor::Delegate: |
| 244 | void OnInitialized(HRESULT result) override { |
| 245 | UMA_HISTOGRAM_BOOLEAN("SettingsAppMonitor.InitializationResult", |
| 246 | SUCCEEDED(result)); |
| 247 | if (SUCCEEDED(result)) { |
| 248 | base::RecordAction( |
| 249 | base::UserMetricsAction("SettingsAppMonitor.Initialized")); |
| 250 | } |
| 251 | continuation_.Run(); |
| 252 | continuation_ = base::Closure(); |
| 253 | } |
| 254 | |
| 255 | void OnAppFocused() override { |
| 256 | base::RecordAction( |
| 257 | base::UserMetricsAction("SettingsAppMonitor.AppFocused")); |
| 258 | } |
| 259 | |
| 260 | void OnChooserInvoked() override { |
| 261 | base::RecordAction( |
| 262 | base::UserMetricsAction("SettingsAppMonitor.ChooserInvoked")); |
| 263 | } |
| 264 | |
| 265 | void OnBrowserChosen(const base::string16& browser_name) override { |
Greg Thompson | 005a710c | 2018-09-06 06:54:38 | [diff] [blame] | 266 | if (browser_name == InstallUtil::GetDisplayName()) { |
grt | c291eea | 2016-05-26 15:38:48 | [diff] [blame] | 267 | base::RecordAction( |
| 268 | base::UserMetricsAction("SettingsAppMonitor.ChromeBrowserChosen")); |
| 269 | } else { |
| 270 | base::RecordAction( |
| 271 | base::UserMetricsAction("SettingsAppMonitor.OtherBrowserChosen")); |
| 272 | } |
| 273 | } |
| 274 | |
pmonette | b66514b4 | 2016-12-07 20:28:39 | [diff] [blame] | 275 | void OnPromoFocused() override { |
| 276 | base::RecordAction( |
| 277 | base::UserMetricsAction("SettingsAppMonitor.PromoFocused")); |
| 278 | } |
| 279 | |
| 280 | void OnPromoChoiceMade(bool accept_promo) override { |
| 281 | if (accept_promo) { |
| 282 | base::RecordAction( |
| 283 | base::UserMetricsAction("SettingsAppMonitor.CheckItOut")); |
| 284 | } else { |
| 285 | base::RecordAction( |
| 286 | base::UserMetricsAction("SettingsAppMonitor.SwitchAnyway")); |
| 287 | } |
| 288 | } |
| 289 | |
grt | c291eea | 2016-05-26 15:38:48 | [diff] [blame] | 290 | // A closure to be run once initialization completes. |
| 291 | base::Closure continuation_; |
| 292 | |
| 293 | // Monitors user interaction with the Windows Settings app for the sake of |
| 294 | // reporting user actions. |
Patrick Monette | 7ff99e0 | 2018-02-19 17:30:12 | [diff] [blame] | 295 | SettingsAppMonitor settings_app_monitor_; |
grt | c291eea | 2016-05-26 15:38:48 | [diff] [blame] | 296 | |
| 297 | DISALLOW_COPY_AND_ASSIGN(DefaultBrowserActionRecorder); |
| 298 | }; |
| 299 | |
| 300 | // A function bound up in a callback with a DefaultBrowserActionRecorder and |
| 301 | // a closure to keep the former alive until the time comes to run the latter. |
| 302 | void OnSettingsAppFinished( |
| 303 | std::unique_ptr<DefaultBrowserActionRecorder> recorder, |
| 304 | const base::Closure& on_finished_callback) { |
| 305 | recorder.reset(); |
| 306 | on_finished_callback.Run(); |
| 307 | } |
| 308 | |
pmonette | 32a5cfb4 | 2016-04-11 22:04:44 | [diff] [blame] | 309 | // There is no way to make sure the user is done with the system settings, but a |
| 310 | // signal that the interaction is finished is needed for UMA. A timer of 2 |
| 311 | // minutes is used as a substitute. The registry keys for the protocol |
| 312 | // association with an app are also monitored to signal the end of the |
| 313 | // interaction early when it is clear that the user made a choice (e.g. http |
| 314 | // and https for default browser). |
| 315 | // |
| 316 | // This helper class manages both the timer and the registry watchers and makes |
| 317 | // sure the callback for the end of the settings interaction is only run once. |
| 318 | // This class also manages its own lifetime. |
| 319 | class OpenSystemSettingsHelper { |
| 320 | public: |
| 321 | // Begin the monitoring and will call |on_finished_callback| when done. |
| 322 | // Takes in a null-terminated array of |protocols| whose registry keys must be |
pmonette | 0c40087a | 2016-04-21 00:05:16 | [diff] [blame] | 323 | // watched. The array must contain at least one element. |
pmonette | 32a5cfb4 | 2016-04-11 22:04:44 | [diff] [blame] | 324 | static void Begin(const wchar_t* const protocols[], |
| 325 | const base::Closure& on_finished_callback) { |
Francois Doray | 66bdfd8 | 2017-10-20 13:50:37 | [diff] [blame] | 326 | base::AssertBlockingAllowed(); |
pmonette | c541d94 | 2016-06-15 22:08:32 | [diff] [blame] | 327 | |
| 328 | delete instance_; |
| 329 | instance_ = new OpenSystemSettingsHelper(protocols, on_finished_callback); |
pmonette | 32a5cfb4 | 2016-04-11 22:04:44 | [diff] [blame] | 330 | } |
| 331 | |
| 332 | private: |
| 333 | // The reason the settings interaction concluded. Do not modify the ordering |
| 334 | // because it is used for UMA. |
| 335 | enum ConcludeReason { REGISTRY_WATCHER, TIMEOUT, NUM_CONCLUDE_REASON_TYPES }; |
| 336 | |
| 337 | OpenSystemSettingsHelper(const wchar_t* const protocols[], |
| 338 | const base::Closure& on_finished_callback) |
pmonette | 0c40087a | 2016-04-21 00:05:16 | [diff] [blame] | 339 | : scoped_user_protocol_entry_(protocols[0]), |
| 340 | on_finished_callback_(on_finished_callback), |
| 341 | weak_ptr_factory_(this) { |
pmonette | 32a5cfb4 | 2016-04-11 22:04:44 | [diff] [blame] | 342 | static const wchar_t kUrlAssociationFormat[] = |
| 343 | L"SOFTWARE\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\" |
| 344 | L"%ls\\UserChoice"; |
| 345 | |
| 346 | // Remember the start time. |
| 347 | start_time_ = base::TimeTicks::Now(); |
| 348 | |
| 349 | for (const wchar_t* const* scan = &protocols[0]; *scan != nullptr; ++scan) { |
| 350 | AddRegistryKeyWatcher( |
| 351 | base::StringPrintf(kUrlAssociationFormat, *scan).c_str()); |
| 352 | } |
| 353 | // Only the watchers that were succesfully initialized are counted. |
| 354 | registry_watcher_count_ = registry_key_watchers_.size(); |
| 355 | |
| 356 | timer_.Start( |
| 357 | FROM_HERE, base::TimeDelta::FromMinutes(2), |
| 358 | base::Bind(&OpenSystemSettingsHelper::ConcludeInteraction, |
| 359 | weak_ptr_factory_.GetWeakPtr(), ConcludeReason::TIMEOUT)); |
| 360 | } |
| 361 | |
pmonette | b18379f | 2017-06-01 01:18:44 | [diff] [blame] | 362 | ~OpenSystemSettingsHelper() { |
| 363 | DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); |
| 364 | } |
| 365 | |
pmonette | 32a5cfb4 | 2016-04-11 22:04:44 | [diff] [blame] | 366 | // Called when a change is detected on one of the registry keys being watched. |
| 367 | // Note: All types of modification to the registry key will trigger this |
| 368 | // function even if the value change is the only one that matters. This |
| 369 | // is good enough for now. |
| 370 | void OnRegistryKeyChanged() { |
pmonette | b18379f | 2017-06-01 01:18:44 | [diff] [blame] | 371 | DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); |
pmonette | 32a5cfb4 | 2016-04-11 22:04:44 | [diff] [blame] | 372 | // Make sure all the registry watchers have fired. |
| 373 | if (--registry_watcher_count_ == 0) { |
| 374 | UMA_HISTOGRAM_MEDIUM_TIMES( |
| 375 | "DefaultBrowser.SettingsInteraction.RegistryWatcherDuration", |
| 376 | base::TimeTicks::Now() - start_time_); |
| 377 | |
| 378 | ConcludeInteraction(ConcludeReason::REGISTRY_WATCHER); |
| 379 | } |
| 380 | } |
| 381 | |
| 382 | // Ends the monitoring with the system settings. Will call |
| 383 | // |on_finished_callback_| and then dispose of this class instance to make |
| 384 | // sure the callback won't get called subsequently. |
| 385 | void ConcludeInteraction(ConcludeReason conclude_reason) { |
pmonette | b18379f | 2017-06-01 01:18:44 | [diff] [blame] | 386 | DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); |
pmonette | 32a5cfb4 | 2016-04-11 22:04:44 | [diff] [blame] | 387 | |
| 388 | UMA_HISTOGRAM_ENUMERATION( |
| 389 | "DefaultBrowser.SettingsInteraction.ConcludeReason", conclude_reason, |
| 390 | NUM_CONCLUDE_REASON_TYPES); |
| 391 | on_finished_callback_.Run(); |
pmonette | c541d94 | 2016-06-15 22:08:32 | [diff] [blame] | 392 | delete instance_; |
| 393 | instance_ = nullptr; |
pmonette | 32a5cfb4 | 2016-04-11 22:04:44 | [diff] [blame] | 394 | } |
| 395 | |
| 396 | // Helper function to create a registry watcher for a given |key_path|. Do |
| 397 | // nothing on initialization failure. |
| 398 | void AddRegistryKeyWatcher(const wchar_t* key_path) { |
pmonette | b18379f | 2017-06-01 01:18:44 | [diff] [blame] | 399 | DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); |
| 400 | |
Jeremy Roman | ec48d7a | 2018-03-01 17:35:09 | [diff] [blame] | 401 | auto reg_key = std::make_unique<base::win::RegKey>(HKEY_CURRENT_USER, |
ricea | 86fa1dd | 2016-09-13 05:59:45 | [diff] [blame] | 402 | key_path, KEY_NOTIFY); |
pmonette | 32a5cfb4 | 2016-04-11 22:04:44 | [diff] [blame] | 403 | |
| 404 | if (reg_key->Valid() && |
| 405 | reg_key->StartWatching( |
| 406 | base::Bind(&OpenSystemSettingsHelper::OnRegistryKeyChanged, |
| 407 | weak_ptr_factory_.GetWeakPtr()))) { |
| 408 | registry_key_watchers_.push_back(std::move(reg_key)); |
| 409 | } |
| 410 | } |
| 411 | |
pmonette | c541d94 | 2016-06-15 22:08:32 | [diff] [blame] | 412 | // Used to make sure only one instance is alive at the same time. |
| 413 | static OpenSystemSettingsHelper* instance_; |
| 414 | |
pmonette | 0c40087a | 2016-04-21 00:05:16 | [diff] [blame] | 415 | // This is needed to make sure that Windows displays an entry for the protocol |
| 416 | // inside the "Choose default apps by protocol" settings page. |
| 417 | ScopedUserProtocolEntry scoped_user_protocol_entry_; |
| 418 | |
pmonette | 32a5cfb4 | 2016-04-11 22:04:44 | [diff] [blame] | 419 | // The function to call when the interaction with the system settings is |
| 420 | // finished. |
| 421 | base::Closure on_finished_callback_; |
| 422 | |
| 423 | // The number of time the registry key watchers must fire. |
| 424 | int registry_watcher_count_ = 0; |
| 425 | |
| 426 | // There can be multiple registry key watchers as some settings modify |
| 427 | // multiple protocol associations. e.g. Changing the default browser modifies |
| 428 | // the http and https associations. |
dcheng | 4af4858 | 2016-04-19 00:29:35 | [diff] [blame] | 429 | std::vector<std::unique_ptr<base::win::RegKey>> registry_key_watchers_; |
pmonette | 32a5cfb4 | 2016-04-11 22:04:44 | [diff] [blame] | 430 | |
| 431 | base::OneShotTimer timer_; |
| 432 | |
| 433 | // Records the time it takes for the final registry watcher to get signaled. |
| 434 | base::TimeTicks start_time_; |
| 435 | |
pmonette | b18379f | 2017-06-01 01:18:44 | [diff] [blame] | 436 | SEQUENCE_CHECKER(sequence_checker_); |
| 437 | |
pmonette | 32a5cfb4 | 2016-04-11 22:04:44 | [diff] [blame] | 438 | // Weak ptrs are used to bind this class to the callbacks of the timer and the |
| 439 | // registry watcher. This makes it possible to self-delete after one of the |
| 440 | // callbacks is executed to cancel the remaining ones. |
| 441 | base::WeakPtrFactory<OpenSystemSettingsHelper> weak_ptr_factory_; |
| 442 | |
| 443 | DISALLOW_COPY_AND_ASSIGN(OpenSystemSettingsHelper); |
| 444 | }; |
| 445 | |
pmonette | c541d94 | 2016-06-15 22:08:32 | [diff] [blame] | 446 | OpenSystemSettingsHelper* OpenSystemSettingsHelper::instance_ = nullptr; |
| 447 | |
pmonette | a9831524 | 2016-11-23 21:39:18 | [diff] [blame] | 448 | // Helper class to determine if Chrome is pinned to the taskbar. Hides the |
Jay Civelli | d4b8905 | 2017-10-31 17:48:25 | [diff] [blame] | 449 | // complexity of managing the lifetime of the connection to the ChromeWinUtil |
| 450 | // service. |
pmonette | a9831524 | 2016-11-23 21:39:18 | [diff] [blame] | 451 | class IsPinnedToTaskbarHelper { |
| 452 | public: |
| 453 | using ResultCallback = win::IsPinnedToTaskbarCallback; |
| 454 | using ErrorCallback = win::ConnectionErrorCallback; |
Jay Civelli | d4b8905 | 2017-10-31 17:48:25 | [diff] [blame] | 455 | static void GetState(std::unique_ptr<service_manager::Connector> connector, |
| 456 | const ErrorCallback& error_callback, |
pmonette | a9831524 | 2016-11-23 21:39:18 | [diff] [blame] | 457 | const ResultCallback& result_callback); |
| 458 | |
| 459 | private: |
Jay Civelli | d4b8905 | 2017-10-31 17:48:25 | [diff] [blame] | 460 | IsPinnedToTaskbarHelper(std::unique_ptr<service_manager::Connector> connector, |
| 461 | const ErrorCallback& error_callback, |
pmonette | a9831524 | 2016-11-23 21:39:18 | [diff] [blame] | 462 | const ResultCallback& result_callback); |
| 463 | |
| 464 | void OnConnectionError(); |
| 465 | void OnIsPinnedToTaskbarResult(bool succeeded, bool is_pinned_to_taskbar); |
| 466 | |
Jay Civelli | d4b8905 | 2017-10-31 17:48:25 | [diff] [blame] | 467 | chrome::mojom::ShellUtilWinPtr shell_util_win_ptr_; |
| 468 | // The connector used to retrieve the Patch service. We can't simply use |
| 469 | // content::ServiceManagerConnection::GetForProcess()->GetConnector() as this |
| 470 | // is called on a background thread. |
| 471 | std::unique_ptr<service_manager::Connector> connector_; |
pmonette | a9831524 | 2016-11-23 21:39:18 | [diff] [blame] | 472 | |
| 473 | ErrorCallback error_callback_; |
| 474 | ResultCallback result_callback_; |
| 475 | |
pmonette | b18379f | 2017-06-01 01:18:44 | [diff] [blame] | 476 | SEQUENCE_CHECKER(sequence_checker_); |
| 477 | |
pmonette | a9831524 | 2016-11-23 21:39:18 | [diff] [blame] | 478 | DISALLOW_COPY_AND_ASSIGN(IsPinnedToTaskbarHelper); |
| 479 | }; |
| 480 | |
| 481 | // static |
Jay Civelli | d4b8905 | 2017-10-31 17:48:25 | [diff] [blame] | 482 | void IsPinnedToTaskbarHelper::GetState( |
| 483 | std::unique_ptr<service_manager::Connector> connector, |
| 484 | const ErrorCallback& error_callback, |
| 485 | const ResultCallback& result_callback) { |
pmonette | a9831524 | 2016-11-23 21:39:18 | [diff] [blame] | 486 | // Self-deleting when the ShellHandler completes. |
Jay Civelli | d4b8905 | 2017-10-31 17:48:25 | [diff] [blame] | 487 | new IsPinnedToTaskbarHelper(std::move(connector), error_callback, |
| 488 | result_callback); |
pmonette | 5057ca3b | 2016-07-04 16:48:40 | [diff] [blame] | 489 | } |
| 490 | |
pmonette | a9831524 | 2016-11-23 21:39:18 | [diff] [blame] | 491 | IsPinnedToTaskbarHelper::IsPinnedToTaskbarHelper( |
Jay Civelli | d4b8905 | 2017-10-31 17:48:25 | [diff] [blame] | 492 | std::unique_ptr<service_manager::Connector> connector, |
pmonette | a9831524 | 2016-11-23 21:39:18 | [diff] [blame] | 493 | const ErrorCallback& error_callback, |
| 494 | const ResultCallback& result_callback) |
Jay Civelli | d4b8905 | 2017-10-31 17:48:25 | [diff] [blame] | 495 | : connector_(std::move(connector)), |
pmonette | a9831524 | 2016-11-23 21:39:18 | [diff] [blame] | 496 | error_callback_(error_callback), |
| 497 | result_callback_(result_callback) { |
pmonette | 83edc1e | 2016-12-15 17:36:44 | [diff] [blame] | 498 | DCHECK(error_callback_); |
| 499 | DCHECK(result_callback_); |
| 500 | |
Jay Civelli | d4b8905 | 2017-10-31 17:48:25 | [diff] [blame] | 501 | connector_->BindInterface(chrome::mojom::kUtilWinServiceName, |
| 502 | &shell_util_win_ptr_); |
| 503 | // |shell_util_win_ptr_| owns the callbacks and is guaranteed to be destroyed |
pmonette | a9831524 | 2016-11-23 21:39:18 | [diff] [blame] | 504 | // before |this|, therefore making base::Unretained() safe to use. |
Jay Civelli | d4b8905 | 2017-10-31 17:48:25 | [diff] [blame] | 505 | shell_util_win_ptr_.set_connection_error_handler(base::Bind( |
pmonette | a9831524 | 2016-11-23 21:39:18 | [diff] [blame] | 506 | &IsPinnedToTaskbarHelper::OnConnectionError, base::Unretained(this))); |
Jay Civelli | d4b8905 | 2017-10-31 17:48:25 | [diff] [blame] | 507 | shell_util_win_ptr_->IsPinnedToTaskbar( |
pmonette | a9831524 | 2016-11-23 21:39:18 | [diff] [blame] | 508 | base::Bind(&IsPinnedToTaskbarHelper::OnIsPinnedToTaskbarResult, |
| 509 | base::Unretained(this))); |
| 510 | } |
| 511 | |
| 512 | void IsPinnedToTaskbarHelper::OnConnectionError() { |
pmonette | b18379f | 2017-06-01 01:18:44 | [diff] [blame] | 513 | DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); |
pmonette | a9831524 | 2016-11-23 21:39:18 | [diff] [blame] | 514 | error_callback_.Run(); |
| 515 | delete this; |
| 516 | } |
| 517 | |
| 518 | void IsPinnedToTaskbarHelper::OnIsPinnedToTaskbarResult( |
pmonette | 5057ca3b | 2016-07-04 16:48:40 | [diff] [blame] | 519 | bool succeeded, |
| 520 | bool is_pinned_to_taskbar) { |
pmonette | b18379f | 2017-06-01 01:18:44 | [diff] [blame] | 521 | DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); |
| 522 | |
pmonette | a9831524 | 2016-11-23 21:39:18 | [diff] [blame] | 523 | result_callback_.Run(succeeded, is_pinned_to_taskbar); |
| 524 | delete this; |
pmonette | 5057ca3b | 2016-07-04 16:48:40 | [diff] [blame] | 525 | } |
| 526 | |
[email protected] | 3a3e72c | 2011-11-29 02:59:38 | [diff] [blame] | 527 | } // namespace |
[email protected] | 12f520c | 2010-01-06 18:11:15 | [diff] [blame] | 528 | |
pmonette | 9fa59e88 | 2016-02-10 00:12:19 | [diff] [blame] | 529 | bool SetAsDefaultBrowser() { |
Francois Doray | 66bdfd8 | 2017-10-20 13:50:37 | [diff] [blame] | 530 | base::AssertBlockingAllowed(); |
pmonette | b18379f | 2017-06-01 01:18:44 | [diff] [blame] | 531 | |
[email protected] | 650b2d5 | 2013-02-10 03:41:45 | [diff] [blame] | 532 | base::FilePath chrome_exe; |
Avi Drissman | 9098f900 | 2018-05-04 00:11:52 | [diff] [blame] | 533 | if (!base::PathService::Get(base::FILE_EXE, &chrome_exe)) { |
[email protected] | d24c401 | 2009-07-28 01:57:31 | [diff] [blame] | 534 | LOG(ERROR) << "Error getting app exe path"; |
| 535 | return false; |
| 536 | } |
| 537 | |
| 538 | // From UI currently we only allow setting default browser for current user. |
Greg Thompson | 8fc94ef | 2018-09-10 16:53:12 | [diff] [blame^] | 539 | if (!ShellUtil::MakeChromeDefault(ShellUtil::CURRENT_USER, chrome_exe, |
grt | e76ca285 | 2014-12-05 16:42:10 | [diff] [blame] | 540 | true /* elevate_if_not_admin */)) { |
[email protected] | d24c401 | 2009-07-28 01:57:31 | [diff] [blame] | 541 | LOG(ERROR) << "Chrome could not be set as default browser."; |
| 542 | return false; |
| 543 | } |
| 544 | |
[email protected] | 8e96e50 | 2010-10-21 20:57:12 | [diff] [blame] | 545 | VLOG(1) << "Chrome registered as default browser."; |
[email protected] | d24c401 | 2009-07-28 01:57:31 | [diff] [blame] | 546 | return true; |
| 547 | } |
| 548 | |
pmonette | 9fa59e88 | 2016-02-10 00:12:19 | [diff] [blame] | 549 | bool SetAsDefaultProtocolClient(const std::string& protocol) { |
Francois Doray | 66bdfd8 | 2017-10-20 13:50:37 | [diff] [blame] | 550 | base::AssertBlockingAllowed(); |
pmonette | b18379f | 2017-06-01 01:18:44 | [diff] [blame] | 551 | |
[email protected] | 4468a5b | 2011-05-26 07:48:02 | [diff] [blame] | 552 | if (protocol.empty()) |
| 553 | return false; |
| 554 | |
[email protected] | 650b2d5 | 2013-02-10 03:41:45 | [diff] [blame] | 555 | base::FilePath chrome_exe; |
Avi Drissman | 9098f900 | 2018-05-04 00:11:52 | [diff] [blame] | 556 | if (!base::PathService::Get(base::FILE_EXE, &chrome_exe)) { |
[email protected] | 4468a5b | 2011-05-26 07:48:02 | [diff] [blame] | 557 | LOG(ERROR) << "Error getting app exe path"; |
| 558 | return false; |
| 559 | } |
| 560 | |
[email protected] | f911df5 | 2013-12-24 23:24:23 | [diff] [blame] | 561 | base::string16 wprotocol(base::UTF8ToUTF16(protocol)); |
Greg Thompson | 8fc94ef | 2018-09-10 16:53:12 | [diff] [blame^] | 562 | if (!ShellUtil::MakeChromeDefaultProtocolClient(chrome_exe, wprotocol)) { |
[email protected] | 4468a5b | 2011-05-26 07:48:02 | [diff] [blame] | 563 | LOG(ERROR) << "Chrome could not be set as default handler for " |
| 564 | << protocol << "."; |
| 565 | return false; |
| 566 | } |
| 567 | |
| 568 | VLOG(1) << "Chrome registered as default handler for " << protocol << "."; |
| 569 | return true; |
| 570 | } |
| 571 | |
pmonette | 32a5cfb4 | 2016-04-11 22:04:44 | [diff] [blame] | 572 | DefaultWebClientSetPermission GetDefaultWebClientSetPermission() { |
grt | 509bc94 | 2017-03-25 08:43:21 | [diff] [blame] | 573 | if (!install_static::SupportsSetAsDefaultBrowser()) |
pmonette | 034a03d9 | 2015-10-02 21:04:27 | [diff] [blame] | 574 | return SET_DEFAULT_NOT_ALLOWED; |
pmonette | 034a03d9 | 2015-10-02 21:04:27 | [diff] [blame] | 575 | if (ShellUtil::CanMakeChromeDefaultUnattended()) |
| 576 | return SET_DEFAULT_UNATTENDED; |
pmonette | 32a5cfb4 | 2016-04-11 22:04:44 | [diff] [blame] | 577 | // Windows 8 and 10 both introduced a new way to set the default web client |
| 578 | // which require user interaction. |
pmonette | f89ac7c7 | 2015-10-06 03:22:01 | [diff] [blame] | 579 | return SET_DEFAULT_INTERACTIVE; |
pmonette | 034a03d9 | 2015-10-02 21:04:27 | [diff] [blame] | 580 | } |
| 581 | |
pmonette | 9fa59e88 | 2016-02-10 00:12:19 | [diff] [blame] | 582 | bool IsElevationNeededForSettingDefaultProtocolClient() { |
pmonette | 868ca64 | 2015-09-02 14:34:02 | [diff] [blame] | 583 | return base::win::GetVersion() < base::win::VERSION_WIN8; |
| 584 | } |
| 585 | |
pmonette | 9fa59e88 | 2016-02-10 00:12:19 | [diff] [blame] | 586 | base::string16 GetApplicationNameForProtocol(const GURL& url) { |
benwells | d0c67aa | 2016-07-28 02:57:20 | [diff] [blame] | 587 | base::string16 application_name; |
| 588 | // Windows 8 or above has a new protocol association query. |
| 589 | if (base::win::GetVersion() >= base::win::VERSION_WIN8) { |
| 590 | application_name = GetAppForProtocolUsingAssocQuery(url); |
| 591 | if (!application_name.empty()) |
| 592 | return application_name; |
| 593 | } |
| 594 | |
| 595 | return GetAppForProtocolUsingRegistry(url); |
[email protected] | 42dc940 | 2013-01-30 07:54:20 | [diff] [blame] | 596 | } |
| 597 | |
pmonette | 9fa59e88 | 2016-02-10 00:12:19 | [diff] [blame] | 598 | DefaultWebClientState GetDefaultBrowser() { |
pmonette | 034a03d9 | 2015-10-02 21:04:27 | [diff] [blame] | 599 | return GetDefaultWebClientStateFromShellUtilDefaultState( |
| 600 | ShellUtil::GetChromeDefaultState()); |
| 601 | } |
| 602 | |
[email protected] | d24c401 | 2009-07-28 01:57:31 | [diff] [blame] | 603 | // There is no reliable way to say which browser is default on a machine (each |
| 604 | // browser can have some of the protocols/shortcuts). So we look for only HTTP |
| 605 | // protocol handler. Even this handler is located at different places in |
| 606 | // registry on XP and Vista: |
| 607 | // - HKCR\http\shell\open\command (XP) |
| 608 | // - HKCU\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\ |
| 609 | // http\UserChoice (Vista) |
thakis | e4a02ff3 | 2016-09-20 17:00:42 | [diff] [blame] | 610 | // This method checks if Firefox is default browser by checking these |
[email protected] | d24c401 | 2009-07-28 01:57:31 | [diff] [blame] | 611 | // locations and returns true if Firefox traces are found there. In case of |
| 612 | // error (or if Firefox is not found)it returns the default value which |
| 613 | // is false. |
pmonette | 9fa59e88 | 2016-02-10 00:12:19 | [diff] [blame] | 614 | bool IsFirefoxDefaultBrowser() { |
Patrick Monette | ab240ec | 2017-07-13 22:49:14 | [diff] [blame] | 615 | base::string16 app_cmd; |
| 616 | base::win::RegKey key(HKEY_CURRENT_USER, ShellUtil::kRegVistaUrlPrefs, |
| 617 | KEY_READ); |
| 618 | return key.Valid() && key.ReadValue(L"Progid", &app_cmd) == ERROR_SUCCESS && |
| 619 | app_cmd == L"FirefoxURL"; |
[email protected] | d24c401 | 2009-07-28 01:57:31 | [diff] [blame] | 620 | } |
[email protected] | 12f520c | 2010-01-06 18:11:15 | [diff] [blame] | 621 | |
pmonette | 9fa59e88 | 2016-02-10 00:12:19 | [diff] [blame] | 622 | DefaultWebClientState IsDefaultProtocolClient(const std::string& protocol) { |
pmonette | 034a03d9 | 2015-10-02 21:04:27 | [diff] [blame] | 623 | return GetDefaultWebClientStateFromShellUtilDefaultState( |
| 624 | ShellUtil::GetChromeDefaultProtocolClientState( |
| 625 | base::UTF8ToUTF16(protocol))); |
| 626 | } |
| 627 | |
pmonette | 9e4c1a8 | 2016-04-14 18:15:30 | [diff] [blame] | 628 | namespace win { |
| 629 | |
| 630 | bool SetAsDefaultBrowserUsingIntentPicker() { |
Francois Doray | 66bdfd8 | 2017-10-20 13:50:37 | [diff] [blame] | 631 | base::AssertBlockingAllowed(); |
pmonette | b18379f | 2017-06-01 01:18:44 | [diff] [blame] | 632 | |
pmonette | 9e4c1a8 | 2016-04-14 18:15:30 | [diff] [blame] | 633 | base::FilePath chrome_exe; |
Avi Drissman | 9098f900 | 2018-05-04 00:11:52 | [diff] [blame] | 634 | if (!base::PathService::Get(base::FILE_EXE, &chrome_exe)) { |
pmonette | 9e4c1a8 | 2016-04-14 18:15:30 | [diff] [blame] | 635 | NOTREACHED() << "Error getting app exe path"; |
| 636 | return false; |
| 637 | } |
| 638 | |
Greg Thompson | 8fc94ef | 2018-09-10 16:53:12 | [diff] [blame^] | 639 | if (!ShellUtil::ShowMakeChromeDefaultSystemUI(chrome_exe)) { |
pmonette | 9e4c1a8 | 2016-04-14 18:15:30 | [diff] [blame] | 640 | LOG(ERROR) << "Failed to launch the set-default-browser Windows UI."; |
| 641 | return false; |
| 642 | } |
| 643 | |
| 644 | VLOG(1) << "Set-default-browser Windows UI completed."; |
| 645 | return true; |
| 646 | } |
| 647 | |
| 648 | void SetAsDefaultBrowserUsingSystemSettings( |
| 649 | const base::Closure& on_finished_callback) { |
Francois Doray | 66bdfd8 | 2017-10-20 13:50:37 | [diff] [blame] | 650 | base::AssertBlockingAllowed(); |
pmonette | 9e4c1a8 | 2016-04-14 18:15:30 | [diff] [blame] | 651 | |
| 652 | base::FilePath chrome_exe; |
Avi Drissman | 9098f900 | 2018-05-04 00:11:52 | [diff] [blame] | 653 | if (!base::PathService::Get(base::FILE_EXE, &chrome_exe)) { |
pmonette | 9e4c1a8 | 2016-04-14 18:15:30 | [diff] [blame] | 654 | NOTREACHED() << "Error getting app exe path"; |
| 655 | on_finished_callback.Run(); |
| 656 | return; |
| 657 | } |
| 658 | |
grt | c291eea | 2016-05-26 15:38:48 | [diff] [blame] | 659 | // Create an action recorder that will open the settings app once it has |
| 660 | // initialized. |
| 661 | std::unique_ptr<DefaultBrowserActionRecorder> recorder( |
| 662 | new DefaultBrowserActionRecorder(base::Bind( |
| 663 | base::IgnoreResult(&ShellUtil::ShowMakeChromeDefaultSystemUI), |
grt | c291eea | 2016-05-26 15:38:48 | [diff] [blame] | 664 | chrome_exe))); |
pmonette | 9e4c1a8 | 2016-04-14 18:15:30 | [diff] [blame] | 665 | |
grt | c291eea | 2016-05-26 15:38:48 | [diff] [blame] | 666 | // The helper manages its own lifetime. Bind the action recorder |
| 667 | // into the finished callback to keep it alive throughout the |
| 668 | // interaction. |
| 669 | static const wchar_t* const kProtocols[] = {L"http", L"https", nullptr}; |
| 670 | OpenSystemSettingsHelper::Begin( |
| 671 | kProtocols, base::Bind(&OnSettingsAppFinished, base::Passed(&recorder), |
| 672 | on_finished_callback)); |
pmonette | 9e4c1a8 | 2016-04-14 18:15:30 | [diff] [blame] | 673 | } |
| 674 | |
| 675 | bool SetAsDefaultProtocolClientUsingIntentPicker(const std::string& protocol) { |
Francois Doray | 66bdfd8 | 2017-10-20 13:50:37 | [diff] [blame] | 676 | base::AssertBlockingAllowed(); |
pmonette | b18379f | 2017-06-01 01:18:44 | [diff] [blame] | 677 | |
pmonette | 9e4c1a8 | 2016-04-14 18:15:30 | [diff] [blame] | 678 | base::FilePath chrome_exe; |
Avi Drissman | 9098f900 | 2018-05-04 00:11:52 | [diff] [blame] | 679 | if (!base::PathService::Get(base::FILE_EXE, &chrome_exe)) { |
pmonette | 9e4c1a8 | 2016-04-14 18:15:30 | [diff] [blame] | 680 | NOTREACHED() << "Error getting app exe path"; |
| 681 | return false; |
| 682 | } |
| 683 | |
pmonette | 9e4c1a8 | 2016-04-14 18:15:30 | [diff] [blame] | 684 | base::string16 wprotocol(base::UTF8ToUTF16(protocol)); |
Greg Thompson | 8fc94ef | 2018-09-10 16:53:12 | [diff] [blame^] | 685 | if (!ShellUtil::ShowMakeChromeDefaultProtocolClientSystemUI(chrome_exe, |
pmonette | 9e4c1a8 | 2016-04-14 18:15:30 | [diff] [blame] | 686 | wprotocol)) { |
| 687 | LOG(ERROR) << "Failed to launch the set-default-client Windows UI."; |
| 688 | return false; |
| 689 | } |
| 690 | |
| 691 | VLOG(1) << "Set-default-client Windows UI completed."; |
| 692 | return true; |
| 693 | } |
| 694 | |
pmonette | 0c40087a | 2016-04-21 00:05:16 | [diff] [blame] | 695 | void SetAsDefaultProtocolClientUsingSystemSettings( |
| 696 | const std::string& protocol, |
| 697 | const base::Closure& on_finished_callback) { |
Francois Doray | 66bdfd8 | 2017-10-20 13:50:37 | [diff] [blame] | 698 | base::AssertBlockingAllowed(); |
pmonette | 0c40087a | 2016-04-21 00:05:16 | [diff] [blame] | 699 | |
| 700 | base::FilePath chrome_exe; |
Avi Drissman | 9098f900 | 2018-05-04 00:11:52 | [diff] [blame] | 701 | if (!base::PathService::Get(base::FILE_EXE, &chrome_exe)) { |
pmonette | 0c40087a | 2016-04-21 00:05:16 | [diff] [blame] | 702 | NOTREACHED() << "Error getting app exe path"; |
| 703 | on_finished_callback.Run(); |
| 704 | return; |
| 705 | } |
| 706 | |
| 707 | // The helper manages its own lifetime. |
| 708 | base::string16 wprotocol(base::UTF8ToUTF16(protocol)); |
| 709 | const wchar_t* const kProtocols[] = {wprotocol.c_str(), nullptr}; |
| 710 | OpenSystemSettingsHelper::Begin(kProtocols, on_finished_callback); |
| 711 | |
Greg Thompson | 8fc94ef | 2018-09-10 16:53:12 | [diff] [blame^] | 712 | ShellUtil::ShowMakeChromeDefaultProtocolClientSystemUI(chrome_exe, wprotocol); |
pmonette | 0c40087a | 2016-04-21 00:05:16 | [diff] [blame] | 713 | } |
| 714 | |
pmonette | 9fa59e88 | 2016-02-10 00:12:19 | [diff] [blame] | 715 | base::string16 GetAppModelIdForProfile(const base::string16& app_name, |
| 716 | const base::FilePath& profile_path) { |
[email protected] | d2065e06 | 2013-12-12 23:49:52 | [diff] [blame] | 717 | std::vector<base::string16> components; |
[email protected] | a044800 | 2012-06-19 04:32:10 | [diff] [blame] | 718 | components.push_back(app_name); |
[email protected] | 0085863a | 2013-12-06 21:19:03 | [diff] [blame] | 719 | const base::string16 profile_id(GetProfileIdFromPath(profile_path)); |
[email protected] | a044800 | 2012-06-19 04:32:10 | [diff] [blame] | 720 | if (!profile_id.empty()) |
| 721 | components.push_back(profile_id); |
| 722 | return ShellUtil::BuildAppModelId(components); |
[email protected] | 12f520c | 2010-01-06 18:11:15 | [diff] [blame] | 723 | } |
| 724 | |
pmonette | 9fa59e88 | 2016-02-10 00:12:19 | [diff] [blame] | 725 | base::string16 GetChromiumModelIdForProfile( |
[email protected] | 650b2d5 | 2013-02-10 03:41:45 | [diff] [blame] | 726 | const base::FilePath& profile_path) { |
[email protected] | a044800 | 2012-06-19 04:32:10 | [diff] [blame] | 727 | return GetAppModelIdForProfile( |
grt | c9880346 | 2017-03-08 10:05:08 | [diff] [blame] | 728 | ShellUtil::GetBrowserModelId(InstallUtil::IsPerUserInstall()), |
[email protected] | 78679969 | 2012-09-26 14:16:48 | [diff] [blame] | 729 | profile_path); |
[email protected] | 12f520c | 2010-01-06 18:11:15 | [diff] [blame] | 730 | } |
[email protected] | c9bb06f4 | 2010-01-13 23:53:48 | [diff] [blame] | 731 | |
pmonette | 9fa59e88 | 2016-02-10 00:12:19 | [diff] [blame] | 732 | void MigrateTaskbarPins() { |
pmonette | b18379f | 2017-06-01 01:18:44 | [diff] [blame] | 733 | // This needs to happen (e.g. so that the appid is fixed and the |
| 734 | // run-time Chrome icon is merged with the taskbar shortcut), but it is not an |
| 735 | // urgent task. |
Robert Liao | e9450f8c | 2017-06-15 17:23:57 | [diff] [blame] | 736 | base::CreateCOMSTATaskRunnerWithTraits( |
Gabriel Charette | b10aeebc | 2018-07-26 20:15:00 | [diff] [blame] | 737 | {base::MayBlock(), base::TaskPriority::BEST_EFFORT}) |
Robert Liao | e9450f8c | 2017-06-15 17:23:57 | [diff] [blame] | 738 | ->PostTask(FROM_HERE, base::Bind(&MigrateTaskbarPinsCallback)); |
[email protected] | c9bb06f4 | 2010-01-13 23:53:48 | [diff] [blame] | 739 | } |
[email protected] | 43903b8 | 2012-06-01 05:26:23 | [diff] [blame] | 740 | |
pmonette | a9831524 | 2016-11-23 21:39:18 | [diff] [blame] | 741 | void GetIsPinnedToTaskbarState( |
Jay Civelli | d4b8905 | 2017-10-31 17:48:25 | [diff] [blame] | 742 | std::unique_ptr<service_manager::Connector> connector, |
pmonette | a9831524 | 2016-11-23 21:39:18 | [diff] [blame] | 743 | const ConnectionErrorCallback& on_error_callback, |
| 744 | const IsPinnedToTaskbarCallback& result_callback) { |
Jay Civelli | d4b8905 | 2017-10-31 17:48:25 | [diff] [blame] | 745 | IsPinnedToTaskbarHelper::GetState(std::move(connector), on_error_callback, |
| 746 | result_callback); |
pmonette | 5057ca3b | 2016-07-04 16:48:40 | [diff] [blame] | 747 | } |
| 748 | |
pmonette | 9fa59e88 | 2016-02-10 00:12:19 | [diff] [blame] | 749 | int MigrateShortcutsInPathInternal(const base::FilePath& chrome_exe, |
| 750 | const base::FilePath& path) { |
[email protected] | 8ea8f1ef | 2013-01-06 18:39:03 | [diff] [blame] | 751 | // Enumerate all pinned shortcuts in the given path directly. |
[email protected] | 25a4c1c | 2013-06-08 04:53:36 | [diff] [blame] | 752 | base::FileEnumerator shortcuts_enum( |
[email protected] | 8ea8f1ef | 2013-01-06 18:39:03 | [diff] [blame] | 753 | path, false, // not recursive |
[email protected] | 25a4c1c | 2013-06-08 04:53:36 | [diff] [blame] | 754 | base::FileEnumerator::FILES, FILE_PATH_LITERAL("*.lnk")); |
[email protected] | 8ea8f1ef | 2013-01-06 18:39:03 | [diff] [blame] | 755 | |
grt | 973412f | 2017-02-25 08:04:21 | [diff] [blame] | 756 | bool is_per_user_install = InstallUtil::IsPerUserInstall(); |
[email protected] | 8ea8f1ef | 2013-01-06 18:39:03 | [diff] [blame] | 757 | |
| 758 | int shortcuts_migrated = 0; |
[email protected] | 650b2d5 | 2013-02-10 03:41:45 | [diff] [blame] | 759 | base::FilePath target_path; |
[email protected] | 0085863a | 2013-12-06 21:19:03 | [diff] [blame] | 760 | base::string16 arguments; |
[email protected] | 0798330 | 2013-01-21 19:41:44 | [diff] [blame] | 761 | base::win::ScopedPropVariant propvariant; |
[email protected] | 650b2d5 | 2013-02-10 03:41:45 | [diff] [blame] | 762 | for (base::FilePath shortcut = shortcuts_enum.Next(); !shortcut.empty(); |
[email protected] | 8ea8f1ef | 2013-01-06 18:39:03 | [diff] [blame] | 763 | shortcut = shortcuts_enum.Next()) { |
| 764 | // TODO(gab): Use ProgramCompare instead of comparing FilePaths below once |
| 765 | // it is fixed to work with FilePaths with spaces. |
| 766 | if (!base::win::ResolveShortcut(shortcut, &target_path, &arguments) || |
| 767 | chrome_exe != target_path) { |
| 768 | continue; |
| 769 | } |
avi | 556c0502 | 2014-12-22 23:31:43 | [diff] [blame] | 770 | base::CommandLine command_line( |
| 771 | base::CommandLine::FromString(base::StringPrintf( |
| 772 | L"\"%ls\" %ls", target_path.value().c_str(), arguments.c_str()))); |
[email protected] | 8ea8f1ef | 2013-01-06 18:39:03 | [diff] [blame] | 773 | |
| 774 | // Get the expected AppId for this Chrome shortcut. |
[email protected] | 0085863a | 2013-12-06 21:19:03 | [diff] [blame] | 775 | base::string16 expected_app_id( |
[email protected] | 8ea8f1ef | 2013-01-06 18:39:03 | [diff] [blame] | 776 | GetExpectedAppId(command_line, is_per_user_install)); |
| 777 | if (expected_app_id.empty()) |
| 778 | continue; |
| 779 | |
| 780 | // Load the shortcut. |
Robert Liao | b2bc703d | 2017-10-17 20:52:35 | [diff] [blame] | 781 | Microsoft::WRL::ComPtr<IShellLink> shell_link; |
| 782 | Microsoft::WRL::ComPtr<IPersistFile> persist_file; |
robliao | a872e99 | 2017-05-18 06:36:19 | [diff] [blame] | 783 | if (FAILED(::CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, |
| 784 | IID_PPV_ARGS(&shell_link))) || |
robliao | a7956aa | 2017-05-17 19:10:54 | [diff] [blame] | 785 | FAILED(shell_link.CopyTo(persist_file.GetAddressOf())) || |
[email protected] | 8ea8f1ef | 2013-01-06 18:39:03 | [diff] [blame] | 786 | FAILED(persist_file->Load(shortcut.value().c_str(), STGM_READ))) { |
| 787 | DLOG(WARNING) << "Failed loading shortcut at " << shortcut.value(); |
| 788 | continue; |
| 789 | } |
| 790 | |
| 791 | // Any properties that need to be updated on the shortcut will be stored in |
| 792 | // |updated_properties|. |
| 793 | base::win::ShortcutProperties updated_properties; |
| 794 | |
| 795 | // Validate the existing app id for the shortcut. |
Robert Liao | b2bc703d | 2017-10-17 20:52:35 | [diff] [blame] | 796 | Microsoft::WRL::ComPtr<IPropertyStore> property_store; |
[email protected] | 0798330 | 2013-01-21 19:41:44 | [diff] [blame] | 797 | propvariant.Reset(); |
robliao | a7956aa | 2017-05-17 19:10:54 | [diff] [blame] | 798 | if (FAILED(shell_link.CopyTo(property_store.GetAddressOf())) || |
dcheng | 81762e0 | 2014-11-21 21:22:28 | [diff] [blame] | 799 | property_store->GetValue(PKEY_AppUserModel_ID, propvariant.Receive()) != |
| 800 | S_OK) { |
[email protected] | 8ea8f1ef | 2013-01-06 18:39:03 | [diff] [blame] | 801 | // When in doubt, prefer not updating the shortcut. |
| 802 | NOTREACHED(); |
| 803 | continue; |
[email protected] | 8ea8f1ef | 2013-01-06 18:39:03 | [diff] [blame] | 804 | } else { |
[email protected] | 0798330 | 2013-01-21 19:41:44 | [diff] [blame] | 805 | switch (propvariant.get().vt) { |
| 806 | case VT_EMPTY: |
| 807 | // If there is no app_id set, set our app_id if one is expected. |
| 808 | if (!expected_app_id.empty()) |
| 809 | updated_properties.set_app_id(expected_app_id); |
| 810 | break; |
| 811 | case VT_LPWSTR: |
[email protected] | 0085863a | 2013-12-06 21:19:03 | [diff] [blame] | 812 | if (expected_app_id != base::string16(propvariant.get().pwszVal)) |
[email protected] | 0798330 | 2013-01-21 19:41:44 | [diff] [blame] | 813 | updated_properties.set_app_id(expected_app_id); |
| 814 | break; |
| 815 | default: |
| 816 | NOTREACHED(); |
| 817 | continue; |
[email protected] | 8ea8f1ef | 2013-01-06 18:39:03 | [diff] [blame] | 818 | } |
| 819 | } |
| 820 | |
gab | 88257b6 | 2016-01-15 03:19:19 | [diff] [blame] | 821 | // Clear dual_mode property from any shortcuts that previously had it (it |
| 822 | // was only ever installed on shortcuts with the |
| 823 | // |default_chromium_model_id|). |
[email protected] | 0085863a | 2013-12-06 21:19:03 | [diff] [blame] | 824 | base::string16 default_chromium_model_id( |
grt | c9880346 | 2017-03-08 10:05:08 | [diff] [blame] | 825 | ShellUtil::GetBrowserModelId(is_per_user_install)); |
gab | 88257b6 | 2016-01-15 03:19:19 | [diff] [blame] | 826 | if (expected_app_id == default_chromium_model_id) { |
[email protected] | 0798330 | 2013-01-21 19:41:44 | [diff] [blame] | 827 | propvariant.Reset(); |
[email protected] | 8ea8f1ef | 2013-01-06 18:39:03 | [diff] [blame] | 828 | if (property_store->GetValue(PKEY_AppUserModel_IsDualMode, |
[email protected] | 0798330 | 2013-01-21 19:41:44 | [diff] [blame] | 829 | propvariant.Receive()) != S_OK) { |
[email protected] | 8ea8f1ef | 2013-01-06 18:39:03 | [diff] [blame] | 830 | // When in doubt, prefer to not update the shortcut. |
| 831 | NOTREACHED(); |
| 832 | continue; |
gab | 38d242d4d | 2016-01-14 20:38:12 | [diff] [blame] | 833 | } |
| 834 | if (propvariant.get().vt == VT_BOOL && |
| 835 | !!propvariant.get().boolVal) { |
| 836 | updated_properties.set_dual_mode(false); |
[email protected] | 8ea8f1ef | 2013-01-06 18:39:03 | [diff] [blame] | 837 | } |
| 838 | } |
| 839 | |
robliao | 9212cb4 | 2017-04-06 17:43:39 | [diff] [blame] | 840 | persist_file.Reset(); |
| 841 | shell_link.Reset(); |
[email protected] | 8ea8f1ef | 2013-01-06 18:39:03 | [diff] [blame] | 842 | |
| 843 | // Update the shortcut if some of its properties need to be updated. |
| 844 | if (updated_properties.options && |
| 845 | base::win::CreateOrUpdateShortcutLink( |
| 846 | shortcut, updated_properties, |
| 847 | base::win::SHORTCUT_UPDATE_EXISTING)) { |
| 848 | ++shortcuts_migrated; |
| 849 | } |
| 850 | } |
| 851 | return shortcuts_migrated; |
| 852 | } |
| 853 | |
pmonette | 32a5cfb4 | 2016-04-11 22:04:44 | [diff] [blame] | 854 | } // namespace win |
| 855 | |
pmonette | 9fa59e88 | 2016-02-10 00:12:19 | [diff] [blame] | 856 | } // namespace shell_integration |