Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1111)

Unified Diff: chrome/installer/setup/update_shortcuts.cc

Issue 1780693002: Fix the path of Chrome shortcuts from the installer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/installer/setup/update_shortcuts.cc
diff --git a/chrome/installer/setup/update_shortcuts.cc b/chrome/installer/setup/update_shortcuts.cc
new file mode 100644
index 0000000000000000000000000000000000000000..db6ab2d6a0225514d62d734b3d44c137249be650
--- /dev/null
+++ b/chrome/installer/setup/update_shortcuts.cc
@@ -0,0 +1,55 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/installer/setup/update_shortcuts.h"
+
+#include "base/command_line.h"
+#include "base/files/file_enumerator.h"
+#include "base/files/file_path.h"
+#include "base/logging.h"
+#include "base/strings/string16.h"
+#include "base/strings/string_util.h"
+#include "base/win/shortcut.h"
+#include "chrome/common/chrome_switches.h"
+
+namespace installer {
+
+void UpdateShortcuts(const ShellUtil::ShortcutLocation shortcut_location,
+ const ShellUtil::ShellChange shortcut_level,
+ BrowserDistribution* dist,
+ const base::FilePath& old_target_path_prefix,
+ const base::FilePath& old_target_path_suffix,
+ const base::FilePath& new_target_path) {
+ base::FilePath shortcut_path;
+ const bool get_shortcut_path_return = ShellUtil::GetShortcutPath(
+ shortcut_location, dist, shortcut_level, &shortcut_path);
+ DCHECK(get_shortcut_path_return);
+
+ base::FileEnumerator shortcuts_enum(shortcut_path, true, // recursive
gab 2016/03/09 20:10:44 Blind recursion here is potentially dangerous (i.e
fdoray 2016/03/09 22:13:03 ok, I now use recursion only for taskbar pins.
+ base::FileEnumerator::FILES);
+
+ base::FilePath existing_target_path;
+ base::string16 existing_args_unused;
gab 2016/03/09 20:10:44 ResolveShortcut() supports null arguments, so no n
fdoray 2016/03/09 22:13:03 Done.
+ for (base::FilePath shortcut = shortcuts_enum.Next(); !shortcut.empty();
+ shortcut = shortcuts_enum.Next()) {
+ if (!base::win::ResolveShortcut(shortcut, &existing_target_path,
+ &existing_args_unused) ||
+ !base::StartsWith(existing_target_path.value(),
+ old_target_path_prefix.value(),
+ base::CompareCase::INSENSITIVE_ASCII) ||
+ !base::EndsWith(existing_target_path.value(),
+ old_target_path_suffix.value(),
+ base::CompareCase::INSENSITIVE_ASCII)) {
+ continue;
+ }
+
+ base::win::ShortcutProperties updated_properties;
+ updated_properties.set_target(new_target_path);
+
+ base::win::CreateOrUpdateShortcutLink(shortcut, updated_properties,
+ base::win::SHORTCUT_UPDATE_EXISTING);
+ }
+}
+
+} // namespace installer
« chrome/installer/setup/update_shortcuts.h ('K') | « chrome/installer/setup/update_shortcuts.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698