blob: 06dbc42d025ac612636b61e19ce233ebdeec3f5f [file] [log] [blame]
[email protected]b6b72222012-02-11 02:04:131// Copyright (c) 2012 The Chromium Authors. All rights reserved.
[email protected]d24c4012009-07-28 01:57:312// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
pmonette32a5cfb42016-04-11 22:04:445#include "chrome/browser/shell_integration_win.h"
[email protected]d24c4012009-07-28 01:57:316
7#include <windows.h>
robliaoa872e992017-05-18 06:36:198#include <objbase.h>
[email protected]caa05352014-03-01 00:43:059#include <shlwapi.h>
[email protected]d24c4012009-07-28 01:57:3110#include <shobjidl.h>
thestig18dfb7a52014-08-26 10:44:0411#include <propkey.h> // Needs to come after shobjidl.h.
avi664c07b2015-12-26 02:18:3112#include <stddef.h>
13#include <stdint.h>
[email protected]d24c4012009-07-28 01:57:3114
pmonettea98315242016-11-23 21:39:1815#include <memory>
16#include <utility>
pmonette32a5cfb42016-04-11 22:04:4417#include <vector>
18
[email protected]3a3e72c2011-11-29 02:59:3819#include "base/bind.h"
pmonette32a5cfb42016-04-11 22:04:4420#include "base/callback.h"
[email protected]d24c4012009-07-28 01:57:3121#include "base/command_line.h"
[email protected]25a4c1c2013-06-08 04:53:3622#include "base/files/file_enumerator.h"
thestig18dfb7a52014-08-26 10:44:0423#include "base/files/file_util.h"
avi664c07b2015-12-26 02:18:3124#include "base/macros.h"
dcheng4af48582016-04-19 00:29:3525#include "base/memory/ptr_util.h"
pmonette32a5cfb42016-04-11 22:04:4426#include "base/memory/weak_ptr.h"
[email protected]fa1e0e12013-07-18 00:10:1427#include "base/message_loop/message_loop.h"
pmonette32a5cfb42016-04-11 22:04:4428#include "base/metrics/histogram_macros.h"
grtc291eea2016-05-26 15:38:4829#include "base/metrics/user_metrics.h"
30#include "base/metrics/user_metrics_action.h"
[email protected]d24c4012009-07-28 01:57:3131#include "base/path_service.h"
[email protected]24a555b62013-06-10 22:01:1732#include "base/strings/string_util.h"
33#include "base/strings/stringprintf.h"
[email protected]e309f312013-06-07 21:50:0834#include "base/strings/utf_string_conversions.h"
pmonette32a5cfb42016-04-11 22:04:4435#include "base/time/time.h"
36#include "base/timer/timer.h"
[email protected]2d6503982010-10-17 04:41:5437#include "base/win/registry.h"
[email protected]8ee65ba2011-04-12 20:53:2338#include "base/win/scoped_comptr.h"
[email protected]07983302013-01-21 19:41:4439#include "base/win/scoped_propvariant.h"
[email protected]f1024e22012-09-12 07:14:5540#include "base/win/shortcut.h"
[email protected]935aa542010-10-15 01:59:1541#include "base/win/windows_version.h"
[email protected]89d43832013-06-29 20:25:2042#include "chrome/browser/policy/policy_path_parser.h"
pmonette32a5cfb42016-04-11 22:04:4443#include "chrome/browser/shell_integration.h"
[email protected]c9bb06f42010-01-13 23:53:4844#include "chrome/browser/web_applications/web_app.h"
grtc291eea2016-05-26 15:38:4845#include "chrome/browser/win/settings_app_monitor.h"
[email protected]d24c4012009-07-28 01:57:3146#include "chrome/common/chrome_constants.h"
[email protected]12f520c2010-01-06 18:11:1547#include "chrome/common/chrome_paths_internal.h"
[email protected]c9bb06f42010-01-13 23:53:4848#include "chrome/common/chrome_switches.h"
pmonette5057ca3b2016-07-04 16:48:4049#include "chrome/common/shell_handler_win.mojom.h"
50#include "chrome/grit/generated_resources.h"
grtc98803462017-03-08 10:05:0851#include "chrome/install_static/install_util.h"
[email protected]d24c4012009-07-28 01:57:3152#include "chrome/installer/util/browser_distribution.h"
[email protected]3f69d6e612012-08-03 18:52:2753#include "chrome/installer/util/install_util.h"
pmonette0c40087a2016-04-21 00:05:1654#include "chrome/installer/util/scoped_user_protocol_entry.h"
[email protected]d24c4012009-07-28 01:57:3155#include "chrome/installer/util/shell_util.h"
pmonette2b1dbee2016-01-08 20:18:5856#include "components/variations/variations_associated_data.h"
[email protected]c38831a12011-10-28 12:44:4957#include "content/public/browser/browser_thread.h"
pmonette5057ca3b2016-07-04 16:48:4058#include "content/public/browser/utility_process_mojo_client.h"
59#include "ui/base/l10n/l10n_util.h"
[email protected]d24c4012009-07-28 01:57:3160
[email protected]631bb742011-11-02 11:29:3961using content::BrowserThread;
62
pmonette9fa59e882016-02-10 00:12:1963namespace shell_integration {
64
[email protected]12f520c2010-01-06 18:11:1565namespace {
66
pmonette9fa59e882016-02-10 00:12:1967// Helper function for GetAppId to generates profile id
[email protected]2f1c09d2011-01-14 14:58:1468// from profile path. "profile_id" is composed of sanitized basenames of
[email protected]12f520c2010-01-06 18:11:1569// user data dir and profile dir joined by a ".".
[email protected]6a72a632013-12-12 22:22:0070base::string16 GetProfileIdFromPath(const base::FilePath& profile_path) {
[email protected]12f520c2010-01-06 18:11:1571 // Return empty string if profile_path is empty
72 if (profile_path.empty())
[email protected]0085863a2013-12-06 21:19:0373 return base::string16();
[email protected]12f520c2010-01-06 18:11:1574
[email protected]650b2d52013-02-10 03:41:4575 base::FilePath default_user_data_dir;
[email protected]12f520c2010-01-06 18:11:1576 // Return empty string if profile_path is in default user data
77 // dir and is the default profile.
78 if (chrome::GetDefaultUserDataDirectory(&default_user_data_dir) &&
79 profile_path.DirName() == default_user_data_dir &&
[email protected]162b5992011-03-15 19:40:4880 profile_path.BaseName().value() ==
[email protected]f911df52013-12-24 23:24:2381 base::ASCIIToUTF16(chrome::kInitialProfile)) {
[email protected]0085863a2013-12-06 21:19:0382 return base::string16();
[email protected]162b5992011-03-15 19:40:4883 }
[email protected]12f520c2010-01-06 18:11:1584
85 // Get joined basenames of user data dir and profile.
[email protected]0085863a2013-12-06 21:19:0386 base::string16 basenames = profile_path.DirName().BaseName().value() +
[email protected]12f520c2010-01-06 18:11:1587 L"." + profile_path.BaseName().value();
88
[email protected]0085863a2013-12-06 21:19:0389 base::string16 profile_id;
[email protected]12f520c2010-01-06 18:11:1590 profile_id.reserve(basenames.size());
91
92 // Generate profile_id from sanitized basenames.
93 for (size_t i = 0; i < basenames.length(); ++i) {
brettwb3413062015-06-24 00:39:0294 if (base::IsAsciiAlpha(basenames[i]) ||
95 base::IsAsciiDigit(basenames[i]) ||
[email protected]12f520c2010-01-06 18:11:1596 basenames[i] == L'.')
97 profile_id += basenames[i];
98 }
99
100 return profile_id;
101}
102
taptedc2c690ab2016-05-25 02:49:03103base::string16 GetAppListAppName() {
104 static const base::char16 kAppListAppNameSuffix[] = L"AppList";
grtc98803462017-03-08 10:05:08105 base::string16 app_name(install_static::GetBaseAppId());
taptedc2c690ab2016-05-25 02:49:03106 app_name.append(kAppListAppNameSuffix);
107 return app_name;
108}
109
[email protected]8ea8f1ef2013-01-06 18:39:03110// Gets expected app id for given Chrome (based on |command_line| and
111// |is_per_user_install|).
avi556c05022014-12-22 23:31:43112base::string16 GetExpectedAppId(const base::CommandLine& command_line,
[email protected]6a72a632013-12-12 22:22:00113 bool is_per_user_install) {
[email protected]b39e32e2013-04-24 08:55:54114 base::FilePath user_data_dir;
115 if (command_line.HasSwitch(switches::kUserDataDir))
116 user_data_dir = command_line.GetSwitchValuePath(switches::kUserDataDir);
117 else
118 chrome::GetDefaultUserDataDirectory(&user_data_dir);
[email protected]89d43832013-06-29 20:25:20119 // Adjust with any policy that overrides any other way to set the path.
120 policy::path_parser::CheckUserDataDirPolicy(&user_data_dir);
[email protected]b39e32e2013-04-24 08:55:54121 DCHECK(!user_data_dir.empty());
[email protected]c9bb06f42010-01-13 23:53:48122
[email protected]b39e32e2013-04-24 08:55:54123 base::FilePath profile_subdir;
124 if (command_line.HasSwitch(switches::kProfileDirectory)) {
125 profile_subdir =
126 command_line.GetSwitchValuePath(switches::kProfileDirectory);
127 } else {
[email protected]f911df52013-12-24 23:24:23128 profile_subdir =
129 base::FilePath(base::ASCIIToUTF16(chrome::kInitialProfile));
[email protected]b39e32e2013-04-24 08:55:54130 }
131 DCHECK(!profile_subdir.empty());
132
133 base::FilePath profile_path = user_data_dir.Append(profile_subdir);
[email protected]0085863a2013-12-06 21:19:03134 base::string16 app_name;
[email protected]c9bb06f42010-01-13 23:53:48135 if (command_line.HasSwitch(switches::kApp)) {
[email protected]f911df52013-12-24 23:24:23136 app_name = base::UTF8ToUTF16(web_app::GenerateApplicationNameFromURL(
[email protected]57ecc4b2010-08-11 03:02:51137 GURL(command_line.GetSwitchValueASCII(switches::kApp))));
[email protected]2f1c09d2011-01-14 14:58:14138 } else if (command_line.HasSwitch(switches::kAppId)) {
[email protected]f911df52013-12-24 23:24:23139 app_name = base::UTF8ToUTF16(
140 web_app::GenerateApplicationNameFromExtensionId(
141 command_line.GetSwitchValueASCII(switches::kAppId)));
taptedc2c690ab2016-05-25 02:49:03142 } else if (command_line.HasSwitch(switches::kShowAppList)) {
143 app_name = GetAppListAppName();
[email protected]c9bb06f42010-01-13 23:53:48144 } else {
grtc98803462017-03-08 10:05:08145 app_name = ShellUtil::GetBrowserModelId(is_per_user_install);
[email protected]c9bb06f42010-01-13 23:53:48146 }
[email protected]b39e32e2013-04-24 08:55:54147 DCHECK(!app_name.empty());
[email protected]c9bb06f42010-01-13 23:53:48148
pmonette9e4c1a82016-04-14 18:15:30149 return win::GetAppModelIdForProfile(app_name, profile_path);
[email protected]c9bb06f42010-01-13 23:53:48150}
151
gab88257b62016-01-15 03:19:19152void MigrateTaskbarPinsCallback() {
[email protected]3a3e72c2011-11-29 02:59:38153 // This should run on the file thread.
thestig00844cea2015-09-08 21:44:52154 DCHECK_CURRENTLY_ON(BrowserThread::FILE);
[email protected]3a3e72c2011-11-29 02:59:38155
156 // Get full path of chrome.
[email protected]650b2d52013-02-10 03:41:45157 base::FilePath chrome_exe;
[email protected]3a3e72c2011-11-29 02:59:38158 if (!PathService::Get(base::FILE_EXE, &chrome_exe))
159 return;
160
gab88257b62016-01-15 03:19:19161 base::FilePath pins_path;
162 if (!PathService::Get(base::DIR_TASKBAR_PINS, &pins_path)) {
163 NOTREACHED();
164 return;
[email protected]3a3e72c2011-11-29 02:59:38165 }
gab88257b62016-01-15 03:19:19166
pmonette9e4c1a82016-04-14 18:15:30167 win::MigrateShortcutsInPathInternal(chrome_exe, pins_path);
[email protected]3a3e72c2011-11-29 02:59:38168}
169
[email protected]caa05352014-03-01 00:43:05170// Windows 8 introduced a new protocol->executable binding system which cannot
171// be retrieved in the HKCR registry subkey method implemented below. We call
172// AssocQueryString with the new Win8-only flag ASSOCF_IS_PROTOCOL instead.
173base::string16 GetAppForProtocolUsingAssocQuery(const GURL& url) {
thestig11bf74d2014-11-24 20:14:42174 base::string16 url_scheme = base::ASCIIToUTF16(url.scheme());
[email protected]caa05352014-03-01 00:43:05175 // Don't attempt to query protocol association on an empty string.
[email protected]6e84d372014-05-29 23:36:39176 if (url_scheme.empty())
[email protected]caa05352014-03-01 00:43:05177 return base::string16();
178
[email protected]caa05352014-03-01 00:43:05179 // Query AssocQueryString for a human-readable description of the program
180 // that will be invoked given the provided URL spec. This is used only to
181 // populate the external protocol dialog box the user sees when invoking
182 // an unknown external protocol.
183 wchar_t out_buffer[1024];
184 DWORD buffer_size = arraysize(out_buffer);
185 HRESULT hr = AssocQueryString(ASSOCF_IS_PROTOCOL,
186 ASSOCSTR_FRIENDLYAPPNAME,
[email protected]6e84d372014-05-29 23:36:39187 url_scheme.c_str(),
[email protected]caa05352014-03-01 00:43:05188 NULL,
189 out_buffer,
190 &buffer_size);
191 if (FAILED(hr)) {
192 DLOG(WARNING) << "AssocQueryString failed!";
193 return base::string16();
194 }
195 return base::string16(out_buffer);
196}
197
198base::string16 GetAppForProtocolUsingRegistry(const GURL& url) {
dominickn0c9a5062016-10-06 20:49:00199 base::string16 command_to_launch;
200
201 // First, try and extract the application's display name.
202 base::string16 cmd_key_path = base::ASCIIToUTF16(url.scheme());
203 base::win::RegKey cmd_key_name(HKEY_CLASSES_ROOT, cmd_key_path.c_str(),
204 KEY_READ);
205 if (cmd_key_name.ReadValue(NULL, &command_to_launch) == ERROR_SUCCESS &&
206 !command_to_launch.empty()) {
207 return command_to_launch;
[email protected]caa05352014-03-01 00:43:05208 }
dominickn0c9a5062016-10-06 20:49:00209
210 // Otherwise, parse the command line in the registry, and return the basename
211 // of the program path if it exists.
212 cmd_key_path = base::ASCIIToUTF16(url.scheme() + "\\shell\\open\\command");
213 base::win::RegKey cmd_key_exe(HKEY_CLASSES_ROOT, cmd_key_path.c_str(),
214 KEY_READ);
215 if (cmd_key_exe.ReadValue(NULL, &command_to_launch) == ERROR_SUCCESS) {
216 base::CommandLine command_line(
217 base::CommandLine::FromString(command_to_launch));
218 return command_line.GetProgram().BaseName().value();
219 }
220
[email protected]caa05352014-03-01 00:43:05221 return base::string16();
222}
223
pmonette9fa59e882016-02-10 00:12:19224DefaultWebClientState GetDefaultWebClientStateFromShellUtilDefaultState(
225 ShellUtil::DefaultState default_state) {
[email protected]eb63da72012-10-15 20:39:48226 switch (default_state) {
227 case ShellUtil::NOT_DEFAULT:
pmonette9fa59e882016-02-10 00:12:19228 return DefaultWebClientState::NOT_DEFAULT;
[email protected]eb63da72012-10-15 20:39:48229 case ShellUtil::IS_DEFAULT:
pmonette9fa59e882016-02-10 00:12:19230 return DefaultWebClientState::IS_DEFAULT;
[email protected]eb63da72012-10-15 20:39:48231 default:
232 DCHECK_EQ(ShellUtil::UNKNOWN_DEFAULT, default_state);
pmonette9fa59e882016-02-10 00:12:19233 return DefaultWebClientState::UNKNOWN_DEFAULT;
[email protected]eb63da72012-10-15 20:39:48234 }
235}
236
grtc291eea2016-05-26 15:38:48237// A recorder of user actions in the Windows Settings app.
238class DefaultBrowserActionRecorder : public win::SettingsAppMonitor::Delegate {
239 public:
240 // Creates the recorder and the monitor that drives it. |continuation| will be
241 // run once the monitor's initialization completes (regardless of success or
242 // failure).
243 explicit DefaultBrowserActionRecorder(base::Closure continuation)
244 : continuation_(std::move(continuation)), settings_app_monitor_(this) {}
245
246 private:
247 // win::SettingsAppMonitor::Delegate:
248 void OnInitialized(HRESULT result) override {
249 UMA_HISTOGRAM_BOOLEAN("SettingsAppMonitor.InitializationResult",
250 SUCCEEDED(result));
251 if (SUCCEEDED(result)) {
252 base::RecordAction(
253 base::UserMetricsAction("SettingsAppMonitor.Initialized"));
254 }
255 continuation_.Run();
256 continuation_ = base::Closure();
257 }
258
259 void OnAppFocused() override {
260 base::RecordAction(
261 base::UserMetricsAction("SettingsAppMonitor.AppFocused"));
262 }
263
264 void OnChooserInvoked() override {
265 base::RecordAction(
266 base::UserMetricsAction("SettingsAppMonitor.ChooserInvoked"));
267 }
268
269 void OnBrowserChosen(const base::string16& browser_name) override {
270 if (browser_name ==
271 BrowserDistribution::GetDistribution()->GetDisplayName()) {
272 base::RecordAction(
273 base::UserMetricsAction("SettingsAppMonitor.ChromeBrowserChosen"));
274 } else {
275 base::RecordAction(
276 base::UserMetricsAction("SettingsAppMonitor.OtherBrowserChosen"));
277 }
278 }
279
pmonetteb66514b42016-12-07 20:28:39280 void OnPromoFocused() override {
281 base::RecordAction(
282 base::UserMetricsAction("SettingsAppMonitor.PromoFocused"));
283 }
284
285 void OnPromoChoiceMade(bool accept_promo) override {
286 if (accept_promo) {
287 base::RecordAction(
288 base::UserMetricsAction("SettingsAppMonitor.CheckItOut"));
289 } else {
290 base::RecordAction(
291 base::UserMetricsAction("SettingsAppMonitor.SwitchAnyway"));
292 }
293 }
294
grtc291eea2016-05-26 15:38:48295 // A closure to be run once initialization completes.
296 base::Closure continuation_;
297
298 // Monitors user interaction with the Windows Settings app for the sake of
299 // reporting user actions.
300 win::SettingsAppMonitor settings_app_monitor_;
301
302 DISALLOW_COPY_AND_ASSIGN(DefaultBrowserActionRecorder);
303};
304
305// A function bound up in a callback with a DefaultBrowserActionRecorder and
306// a closure to keep the former alive until the time comes to run the latter.
307void OnSettingsAppFinished(
308 std::unique_ptr<DefaultBrowserActionRecorder> recorder,
309 const base::Closure& on_finished_callback) {
310 recorder.reset();
311 on_finished_callback.Run();
312}
313
pmonette32a5cfb42016-04-11 22:04:44314// There is no way to make sure the user is done with the system settings, but a
315// signal that the interaction is finished is needed for UMA. A timer of 2
316// minutes is used as a substitute. The registry keys for the protocol
317// association with an app are also monitored to signal the end of the
318// interaction early when it is clear that the user made a choice (e.g. http
319// and https for default browser).
320//
321// This helper class manages both the timer and the registry watchers and makes
322// sure the callback for the end of the settings interaction is only run once.
323// This class also manages its own lifetime.
324class OpenSystemSettingsHelper {
325 public:
326 // Begin the monitoring and will call |on_finished_callback| when done.
327 // Takes in a null-terminated array of |protocols| whose registry keys must be
pmonette0c40087a2016-04-21 00:05:16328 // watched. The array must contain at least one element.
pmonette32a5cfb42016-04-11 22:04:44329 static void Begin(const wchar_t* const protocols[],
330 const base::Closure& on_finished_callback) {
pmonettec541d942016-06-15 22:08:32331 DCHECK_CURRENTLY_ON(BrowserThread::FILE);
332
333 delete instance_;
334 instance_ = new OpenSystemSettingsHelper(protocols, on_finished_callback);
pmonette32a5cfb42016-04-11 22:04:44335 }
336
337 private:
338 // The reason the settings interaction concluded. Do not modify the ordering
339 // because it is used for UMA.
340 enum ConcludeReason { REGISTRY_WATCHER, TIMEOUT, NUM_CONCLUDE_REASON_TYPES };
341
342 OpenSystemSettingsHelper(const wchar_t* const protocols[],
343 const base::Closure& on_finished_callback)
pmonette0c40087a2016-04-21 00:05:16344 : scoped_user_protocol_entry_(protocols[0]),
345 on_finished_callback_(on_finished_callback),
346 weak_ptr_factory_(this) {
pmonette32a5cfb42016-04-11 22:04:44347 static const wchar_t kUrlAssociationFormat[] =
348 L"SOFTWARE\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\"
349 L"%ls\\UserChoice";
350
351 // Remember the start time.
352 start_time_ = base::TimeTicks::Now();
353
354 for (const wchar_t* const* scan = &protocols[0]; *scan != nullptr; ++scan) {
355 AddRegistryKeyWatcher(
356 base::StringPrintf(kUrlAssociationFormat, *scan).c_str());
357 }
358 // Only the watchers that were succesfully initialized are counted.
359 registry_watcher_count_ = registry_key_watchers_.size();
360
361 timer_.Start(
362 FROM_HERE, base::TimeDelta::FromMinutes(2),
363 base::Bind(&OpenSystemSettingsHelper::ConcludeInteraction,
364 weak_ptr_factory_.GetWeakPtr(), ConcludeReason::TIMEOUT));
365 }
366
367 // Called when a change is detected on one of the registry keys being watched.
368 // Note: All types of modification to the registry key will trigger this
369 // function even if the value change is the only one that matters. This
370 // is good enough for now.
371 void OnRegistryKeyChanged() {
372 DCHECK_CURRENTLY_ON(BrowserThread::FILE);
373
374 // Make sure all the registry watchers have fired.
375 if (--registry_watcher_count_ == 0) {
376 UMA_HISTOGRAM_MEDIUM_TIMES(
377 "DefaultBrowser.SettingsInteraction.RegistryWatcherDuration",
378 base::TimeTicks::Now() - start_time_);
379
380 ConcludeInteraction(ConcludeReason::REGISTRY_WATCHER);
381 }
382 }
383
384 // Ends the monitoring with the system settings. Will call
385 // |on_finished_callback_| and then dispose of this class instance to make
386 // sure the callback won't get called subsequently.
387 void ConcludeInteraction(ConcludeReason conclude_reason) {
388 DCHECK_CURRENTLY_ON(BrowserThread::FILE);
389
390 UMA_HISTOGRAM_ENUMERATION(
391 "DefaultBrowser.SettingsInteraction.ConcludeReason", conclude_reason,
392 NUM_CONCLUDE_REASON_TYPES);
393 on_finished_callback_.Run();
pmonettec541d942016-06-15 22:08:32394 delete instance_;
395 instance_ = nullptr;
pmonette32a5cfb42016-04-11 22:04:44396 }
397
398 // Helper function to create a registry watcher for a given |key_path|. Do
399 // nothing on initialization failure.
400 void AddRegistryKeyWatcher(const wchar_t* key_path) {
ricea86fa1dd2016-09-13 05:59:45401 auto reg_key = base::MakeUnique<base::win::RegKey>(HKEY_CURRENT_USER,
402 key_path, KEY_NOTIFY);
pmonette32a5cfb42016-04-11 22:04:44403
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
pmonettec541d942016-06-15 22:08:32412 // Used to make sure only one instance is alive at the same time.
413 static OpenSystemSettingsHelper* instance_;
414
pmonette0c40087a2016-04-21 00:05:16415 // 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
pmonette32a5cfb42016-04-11 22:04:44419 // 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.
dcheng4af48582016-04-19 00:29:35429 std::vector<std::unique_ptr<base::win::RegKey>> registry_key_watchers_;
pmonette32a5cfb42016-04-11 22:04:44430
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
436 // Weak ptrs are used to bind this class to the callbacks of the timer and the
437 // registry watcher. This makes it possible to self-delete after one of the
438 // callbacks is executed to cancel the remaining ones.
439 base::WeakPtrFactory<OpenSystemSettingsHelper> weak_ptr_factory_;
440
441 DISALLOW_COPY_AND_ASSIGN(OpenSystemSettingsHelper);
442};
443
pmonettec541d942016-06-15 22:08:32444OpenSystemSettingsHelper* OpenSystemSettingsHelper::instance_ = nullptr;
445
pmonettea98315242016-11-23 21:39:18446// Helper class to determine if Chrome is pinned to the taskbar. Hides the
447// complexity of managing the lifetime of a UtilityProcessMojoClient.
448class IsPinnedToTaskbarHelper {
449 public:
450 using ResultCallback = win::IsPinnedToTaskbarCallback;
451 using ErrorCallback = win::ConnectionErrorCallback;
452 static void GetState(const ErrorCallback& error_callback,
453 const ResultCallback& result_callback);
454
455 private:
456 IsPinnedToTaskbarHelper(const ErrorCallback& error_callback,
457 const ResultCallback& result_callback);
458
459 void OnConnectionError();
460 void OnIsPinnedToTaskbarResult(bool succeeded, bool is_pinned_to_taskbar);
461
462 content::UtilityProcessMojoClient<chrome::mojom::ShellHandler> shell_handler_;
463
464 ErrorCallback error_callback_;
465 ResultCallback result_callback_;
466
467 DISALLOW_COPY_AND_ASSIGN(IsPinnedToTaskbarHelper);
468};
469
470// static
471void IsPinnedToTaskbarHelper::GetState(const ErrorCallback& error_callback,
472 const ResultCallback& result_callback) {
473 // Self-deleting when the ShellHandler completes.
474 new IsPinnedToTaskbarHelper(error_callback, result_callback);
pmonette5057ca3b2016-07-04 16:48:40475}
476
pmonettea98315242016-11-23 21:39:18477IsPinnedToTaskbarHelper::IsPinnedToTaskbarHelper(
478 const ErrorCallback& error_callback,
479 const ResultCallback& result_callback)
480 : shell_handler_(
481 l10n_util::GetStringUTF16(IDS_UTILITY_PROCESS_SHELL_HANDLER_NAME)),
482 error_callback_(error_callback),
483 result_callback_(result_callback) {
pmonette83edc1e2016-12-15 17:36:44484 DCHECK(error_callback_);
485 DCHECK(result_callback_);
486
pmonettea98315242016-11-23 21:39:18487 // |shell_handler_| owns the callbacks and is guaranteed to be destroyed
488 // before |this|, therefore making base::Unretained() safe to use.
489 shell_handler_.set_error_callback(base::Bind(
490 &IsPinnedToTaskbarHelper::OnConnectionError, base::Unretained(this)));
491 shell_handler_.set_disable_sandbox();
492 shell_handler_.Start();
493
494 shell_handler_.service()->IsPinnedToTaskbar(
495 base::Bind(&IsPinnedToTaskbarHelper::OnIsPinnedToTaskbarResult,
496 base::Unretained(this)));
497}
498
499void IsPinnedToTaskbarHelper::OnConnectionError() {
500 error_callback_.Run();
501 delete this;
502}
503
504void IsPinnedToTaskbarHelper::OnIsPinnedToTaskbarResult(
pmonette5057ca3b2016-07-04 16:48:40505 bool succeeded,
506 bool is_pinned_to_taskbar) {
pmonettea98315242016-11-23 21:39:18507 result_callback_.Run(succeeded, is_pinned_to_taskbar);
508 delete this;
pmonette5057ca3b2016-07-04 16:48:40509}
510
[email protected]3a3e72c2011-11-29 02:59:38511} // namespace
[email protected]12f520c2010-01-06 18:11:15512
pmonette9fa59e882016-02-10 00:12:19513bool SetAsDefaultBrowser() {
[email protected]650b2d52013-02-10 03:41:45514 base::FilePath chrome_exe;
[email protected]d24c4012009-07-28 01:57:31515 if (!PathService::Get(base::FILE_EXE, &chrome_exe)) {
516 LOG(ERROR) << "Error getting app exe path";
517 return false;
518 }
519
520 // From UI currently we only allow setting default browser for current user.
[email protected]bf6117c7e2010-12-01 06:00:25521 BrowserDistribution* dist = BrowserDistribution::GetDistribution();
grte76ca2852014-12-05 16:42:10522 if (!ShellUtil::MakeChromeDefault(dist, ShellUtil::CURRENT_USER, chrome_exe,
523 true /* elevate_if_not_admin */)) {
[email protected]d24c4012009-07-28 01:57:31524 LOG(ERROR) << "Chrome could not be set as default browser.";
525 return false;
526 }
527
[email protected]8e96e502010-10-21 20:57:12528 VLOG(1) << "Chrome registered as default browser.";
[email protected]d24c4012009-07-28 01:57:31529 return true;
530}
531
pmonette9fa59e882016-02-10 00:12:19532bool SetAsDefaultProtocolClient(const std::string& protocol) {
[email protected]4468a5b2011-05-26 07:48:02533 if (protocol.empty())
534 return false;
535
[email protected]650b2d52013-02-10 03:41:45536 base::FilePath chrome_exe;
[email protected]4468a5b2011-05-26 07:48:02537 if (!PathService::Get(base::FILE_EXE, &chrome_exe)) {
538 LOG(ERROR) << "Error getting app exe path";
539 return false;
540 }
541
[email protected]f911df52013-12-24 23:24:23542 base::string16 wprotocol(base::UTF8ToUTF16(protocol));
[email protected]4468a5b2011-05-26 07:48:02543 BrowserDistribution* dist = BrowserDistribution::GetDistribution();
grte76ca2852014-12-05 16:42:10544 if (!ShellUtil::MakeChromeDefaultProtocolClient(dist, chrome_exe,
545 wprotocol)) {
[email protected]4468a5b2011-05-26 07:48:02546 LOG(ERROR) << "Chrome could not be set as default handler for "
547 << protocol << ".";
548 return false;
549 }
550
551 VLOG(1) << "Chrome registered as default handler for " << protocol << ".";
552 return true;
553}
554
pmonette32a5cfb42016-04-11 22:04:44555DefaultWebClientSetPermission GetDefaultWebClientSetPermission() {
grt509bc942017-03-25 08:43:21556 if (!install_static::SupportsSetAsDefaultBrowser())
pmonette034a03d92015-10-02 21:04:27557 return SET_DEFAULT_NOT_ALLOWED;
pmonette034a03d92015-10-02 21:04:27558 if (ShellUtil::CanMakeChromeDefaultUnattended())
559 return SET_DEFAULT_UNATTENDED;
pmonette32a5cfb42016-04-11 22:04:44560 // Windows 8 and 10 both introduced a new way to set the default web client
561 // which require user interaction.
pmonettef89ac7c72015-10-06 03:22:01562 return SET_DEFAULT_INTERACTIVE;
pmonette034a03d92015-10-02 21:04:27563}
564
pmonette9fa59e882016-02-10 00:12:19565bool IsElevationNeededForSettingDefaultProtocolClient() {
pmonette868ca642015-09-02 14:34:02566 return base::win::GetVersion() < base::win::VERSION_WIN8;
567}
568
pmonette9fa59e882016-02-10 00:12:19569base::string16 GetApplicationNameForProtocol(const GURL& url) {
benwellsd0c67aa2016-07-28 02:57:20570 base::string16 application_name;
571 // Windows 8 or above has a new protocol association query.
572 if (base::win::GetVersion() >= base::win::VERSION_WIN8) {
573 application_name = GetAppForProtocolUsingAssocQuery(url);
574 if (!application_name.empty())
575 return application_name;
576 }
577
578 return GetAppForProtocolUsingRegistry(url);
[email protected]42dc9402013-01-30 07:54:20579}
580
pmonette9fa59e882016-02-10 00:12:19581DefaultWebClientState GetDefaultBrowser() {
pmonette034a03d92015-10-02 21:04:27582 return GetDefaultWebClientStateFromShellUtilDefaultState(
583 ShellUtil::GetChromeDefaultState());
584}
585
[email protected]d24c4012009-07-28 01:57:31586// There is no reliable way to say which browser is default on a machine (each
587// browser can have some of the protocols/shortcuts). So we look for only HTTP
588// protocol handler. Even this handler is located at different places in
589// registry on XP and Vista:
590// - HKCR\http\shell\open\command (XP)
591// - HKCU\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\
592// http\UserChoice (Vista)
thakise4a02ff32016-09-20 17:00:42593// This method checks if Firefox is default browser by checking these
[email protected]d24c4012009-07-28 01:57:31594// locations and returns true if Firefox traces are found there. In case of
595// error (or if Firefox is not found)it returns the default value which
596// is false.
pmonette9fa59e882016-02-10 00:12:19597bool IsFirefoxDefaultBrowser() {
[email protected]d24c4012009-07-28 01:57:31598 bool ff_default = false;
[email protected]935aa542010-10-15 01:59:15599 if (base::win::GetVersion() >= base::win::VERSION_VISTA) {
[email protected]0085863a2013-12-06 21:19:03600 base::string16 app_cmd;
[email protected]2d6503982010-10-17 04:41:54601 base::win::RegKey key(HKEY_CURRENT_USER,
602 ShellUtil::kRegVistaUrlPrefs, KEY_READ);
[email protected]e06f4d52011-01-19 07:28:46603 if (key.Valid() && (key.ReadValue(L"Progid", &app_cmd) == ERROR_SUCCESS) &&
[email protected]d24c4012009-07-28 01:57:31604 app_cmd == L"FirefoxURL")
605 ff_default = true;
606 } else {
[email protected]0085863a2013-12-06 21:19:03607 base::string16 key_path(L"http");
[email protected]d24c4012009-07-28 01:57:31608 key_path.append(ShellUtil::kRegShellOpen);
[email protected]2d6503982010-10-17 04:41:54609 base::win::RegKey key(HKEY_CLASSES_ROOT, key_path.c_str(), KEY_READ);
[email protected]0085863a2013-12-06 21:19:03610 base::string16 app_cmd;
[email protected]e06f4d52011-01-19 07:28:46611 if (key.Valid() && (key.ReadValue(L"", &app_cmd) == ERROR_SUCCESS) &&
[email protected]cb1f4ac2014-08-07 16:55:42612 base::string16::npos !=
brettwfce8d192015-08-10 19:07:51613 base::ToLowerASCII(app_cmd).find(L"firefox"))
[email protected]d24c4012009-07-28 01:57:31614 ff_default = true;
615 }
616 return ff_default;
617}
[email protected]12f520c2010-01-06 18:11:15618
pmonette9fa59e882016-02-10 00:12:19619DefaultWebClientState IsDefaultProtocolClient(const std::string& protocol) {
pmonette034a03d92015-10-02 21:04:27620 return GetDefaultWebClientStateFromShellUtilDefaultState(
621 ShellUtil::GetChromeDefaultProtocolClientState(
622 base::UTF8ToUTF16(protocol)));
623}
624
pmonette9e4c1a82016-04-14 18:15:30625namespace win {
626
627bool SetAsDefaultBrowserUsingIntentPicker() {
628 base::FilePath chrome_exe;
629 if (!PathService::Get(base::FILE_EXE, &chrome_exe)) {
630 NOTREACHED() << "Error getting app exe path";
631 return false;
632 }
633
634 BrowserDistribution* dist = BrowserDistribution::GetDistribution();
635 if (!ShellUtil::ShowMakeChromeDefaultSystemUI(dist, chrome_exe)) {
636 LOG(ERROR) << "Failed to launch the set-default-browser Windows UI.";
637 return false;
638 }
639
640 VLOG(1) << "Set-default-browser Windows UI completed.";
641 return true;
642}
643
644void SetAsDefaultBrowserUsingSystemSettings(
645 const base::Closure& on_finished_callback) {
646 DCHECK_CURRENTLY_ON(BrowserThread::FILE);
647
648 base::FilePath chrome_exe;
649 if (!PathService::Get(base::FILE_EXE, &chrome_exe)) {
650 NOTREACHED() << "Error getting app exe path";
651 on_finished_callback.Run();
652 return;
653 }
654
grtc291eea2016-05-26 15:38:48655 // Create an action recorder that will open the settings app once it has
656 // initialized.
657 std::unique_ptr<DefaultBrowserActionRecorder> recorder(
658 new DefaultBrowserActionRecorder(base::Bind(
659 base::IgnoreResult(&ShellUtil::ShowMakeChromeDefaultSystemUI),
660 base::Unretained(BrowserDistribution::GetDistribution()),
661 chrome_exe)));
pmonette9e4c1a82016-04-14 18:15:30662
grtc291eea2016-05-26 15:38:48663 // The helper manages its own lifetime. Bind the action recorder
664 // into the finished callback to keep it alive throughout the
665 // interaction.
666 static const wchar_t* const kProtocols[] = {L"http", L"https", nullptr};
667 OpenSystemSettingsHelper::Begin(
668 kProtocols, base::Bind(&OnSettingsAppFinished, base::Passed(&recorder),
669 on_finished_callback));
pmonette9e4c1a82016-04-14 18:15:30670}
671
672bool SetAsDefaultProtocolClientUsingIntentPicker(const std::string& protocol) {
673 base::FilePath chrome_exe;
674 if (!PathService::Get(base::FILE_EXE, &chrome_exe)) {
675 NOTREACHED() << "Error getting app exe path";
676 return false;
677 }
678
679 BrowserDistribution* dist = BrowserDistribution::GetDistribution();
680 base::string16 wprotocol(base::UTF8ToUTF16(protocol));
681 if (!ShellUtil::ShowMakeChromeDefaultProtocolClientSystemUI(dist, chrome_exe,
682 wprotocol)) {
683 LOG(ERROR) << "Failed to launch the set-default-client Windows UI.";
684 return false;
685 }
686
687 VLOG(1) << "Set-default-client Windows UI completed.";
688 return true;
689}
690
pmonette0c40087a2016-04-21 00:05:16691void SetAsDefaultProtocolClientUsingSystemSettings(
692 const std::string& protocol,
693 const base::Closure& on_finished_callback) {
694 DCHECK_CURRENTLY_ON(BrowserThread::FILE);
695
696 base::FilePath chrome_exe;
697 if (!PathService::Get(base::FILE_EXE, &chrome_exe)) {
698 NOTREACHED() << "Error getting app exe path";
699 on_finished_callback.Run();
700 return;
701 }
702
703 // The helper manages its own lifetime.
704 base::string16 wprotocol(base::UTF8ToUTF16(protocol));
705 const wchar_t* const kProtocols[] = {wprotocol.c_str(), nullptr};
706 OpenSystemSettingsHelper::Begin(kProtocols, on_finished_callback);
707
708 BrowserDistribution* dist = BrowserDistribution::GetDistribution();
709 ShellUtil::ShowMakeChromeDefaultProtocolClientSystemUI(dist, chrome_exe,
710 wprotocol);
711}
712
pmonette9fa59e882016-02-10 00:12:19713base::string16 GetAppModelIdForProfile(const base::string16& app_name,
714 const base::FilePath& profile_path) {
[email protected]d2065e062013-12-12 23:49:52715 std::vector<base::string16> components;
[email protected]a0448002012-06-19 04:32:10716 components.push_back(app_name);
[email protected]0085863a2013-12-06 21:19:03717 const base::string16 profile_id(GetProfileIdFromPath(profile_path));
[email protected]a0448002012-06-19 04:32:10718 if (!profile_id.empty())
719 components.push_back(profile_id);
720 return ShellUtil::BuildAppModelId(components);
[email protected]12f520c2010-01-06 18:11:15721}
722
pmonette9fa59e882016-02-10 00:12:19723base::string16 GetChromiumModelIdForProfile(
[email protected]650b2d52013-02-10 03:41:45724 const base::FilePath& profile_path) {
[email protected]a0448002012-06-19 04:32:10725 return GetAppModelIdForProfile(
grtc98803462017-03-08 10:05:08726 ShellUtil::GetBrowserModelId(InstallUtil::IsPerUserInstall()),
[email protected]786799692012-09-26 14:16:48727 profile_path);
[email protected]12f520c2010-01-06 18:11:15728}
[email protected]c9bb06f42010-01-13 23:53:48729
pmonette9fa59e882016-02-10 00:12:19730void MigrateTaskbarPins() {
[email protected]935aa542010-10-15 01:59:15731 if (base::win::GetVersion() < base::win::VERSION_WIN7)
[email protected]c9bb06f42010-01-13 23:53:48732 return;
733
[email protected]81fcf952012-11-26 22:25:14734 // This needs to happen eventually (e.g. so that the appid is fixed and the
735 // run-time Chrome icon is merged with the taskbar shortcut), but this is not
736 // urgent and shouldn't delay Chrome startup.
gab88257b62016-01-15 03:19:19737 static const int64_t kMigrateTaskbarPinsDelaySeconds = 15;
[email protected]81fcf952012-11-26 22:25:14738 BrowserThread::PostDelayedTask(
[email protected]3a3e72c2011-11-29 02:59:38739 BrowserThread::FILE, FROM_HERE,
gab88257b62016-01-15 03:19:19740 base::Bind(&MigrateTaskbarPinsCallback),
741 base::TimeDelta::FromSeconds(kMigrateTaskbarPinsDelaySeconds));
[email protected]c9bb06f42010-01-13 23:53:48742}
[email protected]43903b82012-06-01 05:26:23743
pmonettea98315242016-11-23 21:39:18744void GetIsPinnedToTaskbarState(
745 const ConnectionErrorCallback& on_error_callback,
746 const IsPinnedToTaskbarCallback& result_callback) {
747 IsPinnedToTaskbarHelper::GetState(on_error_callback, result_callback);
pmonette5057ca3b2016-07-04 16:48:40748}
749
pmonette9fa59e882016-02-10 00:12:19750int MigrateShortcutsInPathInternal(const base::FilePath& chrome_exe,
751 const base::FilePath& path) {
[email protected]8ea8f1ef2013-01-06 18:39:03752 DCHECK(base::win::GetVersion() >= base::win::VERSION_WIN7);
753
754 // Enumerate all pinned shortcuts in the given path directly.
[email protected]25a4c1c2013-06-08 04:53:36755 base::FileEnumerator shortcuts_enum(
[email protected]8ea8f1ef2013-01-06 18:39:03756 path, false, // not recursive
[email protected]25a4c1c2013-06-08 04:53:36757 base::FileEnumerator::FILES, FILE_PATH_LITERAL("*.lnk"));
[email protected]8ea8f1ef2013-01-06 18:39:03758
grt973412f2017-02-25 08:04:21759 bool is_per_user_install = InstallUtil::IsPerUserInstall();
[email protected]8ea8f1ef2013-01-06 18:39:03760
761 int shortcuts_migrated = 0;
[email protected]650b2d52013-02-10 03:41:45762 base::FilePath target_path;
[email protected]0085863a2013-12-06 21:19:03763 base::string16 arguments;
[email protected]07983302013-01-21 19:41:44764 base::win::ScopedPropVariant propvariant;
[email protected]650b2d52013-02-10 03:41:45765 for (base::FilePath shortcut = shortcuts_enum.Next(); !shortcut.empty();
[email protected]8ea8f1ef2013-01-06 18:39:03766 shortcut = shortcuts_enum.Next()) {
767 // TODO(gab): Use ProgramCompare instead of comparing FilePaths below once
768 // it is fixed to work with FilePaths with spaces.
769 if (!base::win::ResolveShortcut(shortcut, &target_path, &arguments) ||
770 chrome_exe != target_path) {
771 continue;
772 }
avi556c05022014-12-22 23:31:43773 base::CommandLine command_line(
774 base::CommandLine::FromString(base::StringPrintf(
775 L"\"%ls\" %ls", target_path.value().c_str(), arguments.c_str())));
[email protected]8ea8f1ef2013-01-06 18:39:03776
777 // Get the expected AppId for this Chrome shortcut.
[email protected]0085863a2013-12-06 21:19:03778 base::string16 expected_app_id(
[email protected]8ea8f1ef2013-01-06 18:39:03779 GetExpectedAppId(command_line, is_per_user_install));
780 if (expected_app_id.empty())
781 continue;
782
783 // Load the shortcut.
784 base::win::ScopedComPtr<IShellLink> shell_link;
785 base::win::ScopedComPtr<IPersistFile> persist_file;
robliaoa872e992017-05-18 06:36:19786 if (FAILED(::CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER,
787 IID_PPV_ARGS(&shell_link))) ||
robliaoa7956aa2017-05-17 19:10:54788 FAILED(shell_link.CopyTo(persist_file.GetAddressOf())) ||
[email protected]8ea8f1ef2013-01-06 18:39:03789 FAILED(persist_file->Load(shortcut.value().c_str(), STGM_READ))) {
790 DLOG(WARNING) << "Failed loading shortcut at " << shortcut.value();
791 continue;
792 }
793
794 // Any properties that need to be updated on the shortcut will be stored in
795 // |updated_properties|.
796 base::win::ShortcutProperties updated_properties;
797
798 // Validate the existing app id for the shortcut.
799 base::win::ScopedComPtr<IPropertyStore> property_store;
[email protected]07983302013-01-21 19:41:44800 propvariant.Reset();
robliaoa7956aa2017-05-17 19:10:54801 if (FAILED(shell_link.CopyTo(property_store.GetAddressOf())) ||
dcheng81762e02014-11-21 21:22:28802 property_store->GetValue(PKEY_AppUserModel_ID, propvariant.Receive()) !=
803 S_OK) {
[email protected]8ea8f1ef2013-01-06 18:39:03804 // When in doubt, prefer not updating the shortcut.
805 NOTREACHED();
806 continue;
[email protected]8ea8f1ef2013-01-06 18:39:03807 } else {
[email protected]07983302013-01-21 19:41:44808 switch (propvariant.get().vt) {
809 case VT_EMPTY:
810 // If there is no app_id set, set our app_id if one is expected.
811 if (!expected_app_id.empty())
812 updated_properties.set_app_id(expected_app_id);
813 break;
814 case VT_LPWSTR:
[email protected]0085863a2013-12-06 21:19:03815 if (expected_app_id != base::string16(propvariant.get().pwszVal))
[email protected]07983302013-01-21 19:41:44816 updated_properties.set_app_id(expected_app_id);
817 break;
818 default:
819 NOTREACHED();
820 continue;
[email protected]8ea8f1ef2013-01-06 18:39:03821 }
822 }
823
gab88257b62016-01-15 03:19:19824 // Clear dual_mode property from any shortcuts that previously had it (it
825 // was only ever installed on shortcuts with the
826 // |default_chromium_model_id|).
[email protected]0085863a2013-12-06 21:19:03827 base::string16 default_chromium_model_id(
grtc98803462017-03-08 10:05:08828 ShellUtil::GetBrowserModelId(is_per_user_install));
gab88257b62016-01-15 03:19:19829 if (expected_app_id == default_chromium_model_id) {
[email protected]07983302013-01-21 19:41:44830 propvariant.Reset();
[email protected]8ea8f1ef2013-01-06 18:39:03831 if (property_store->GetValue(PKEY_AppUserModel_IsDualMode,
[email protected]07983302013-01-21 19:41:44832 propvariant.Receive()) != S_OK) {
[email protected]8ea8f1ef2013-01-06 18:39:03833 // When in doubt, prefer to not update the shortcut.
834 NOTREACHED();
835 continue;
gab38d242d4d2016-01-14 20:38:12836 }
837 if (propvariant.get().vt == VT_BOOL &&
838 !!propvariant.get().boolVal) {
839 updated_properties.set_dual_mode(false);
[email protected]8ea8f1ef2013-01-06 18:39:03840 }
841 }
842
robliao9212cb42017-04-06 17:43:39843 persist_file.Reset();
844 shell_link.Reset();
[email protected]8ea8f1ef2013-01-06 18:39:03845
846 // Update the shortcut if some of its properties need to be updated.
847 if (updated_properties.options &&
848 base::win::CreateOrUpdateShortcutLink(
849 shortcut, updated_properties,
850 base::win::SHORTCUT_UPDATE_EXISTING)) {
851 ++shortcuts_migrated;
852 }
853 }
854 return shortcuts_migrated;
855}
856
pmonette32a5cfb42016-04-11 22:04:44857} // namespace win
858
pmonette9fa59e882016-02-10 00:12:19859} // namespace shell_integration