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

Side by Side Diff: chrome/installer/util/shell_util.cc

Issue 11275333: Merge 166285 - Re-commit: Introduce RemoveChromeTaskbarShortcuts() to delete all pinned-to-taskbar … (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1312/src/
Patch Set: Created 8 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/installer/util/shell_util.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 // 4 //
5 // This file defines functions that integrate Chrome in Windows shell. These 5 // This file defines functions that integrate Chrome in Windows shell. These
6 // functions can be used by Chrome as well as Chrome installer. All of the 6 // functions can be used by Chrome as well as Chrome installer. All of the
7 // work is done by the local functions defined in anonymous namespace in 7 // work is done by the local functions defined in anonymous namespace in
8 // this class. 8 // this class.
9 9
10 #include "chrome/installer/util/shell_util.h" 10 #include "chrome/installer/util/shell_util.h"
(...skipping 1829 matching lines...) Expand 10 before | Expand all | Expand 10 after
1840 return file_util::Delete(shortcut_folder, true); 1840 return file_util::Delete(shortcut_folder, true);
1841 else 1841 else
1842 return file_util::Delete(shortcut_path, false); 1842 return file_util::Delete(shortcut_path, false);
1843 } 1843 }
1844 1844
1845 // The shortcut at |shortcut_path| doesn't point to |chrome_exe|, act as if 1845 // The shortcut at |shortcut_path| doesn't point to |chrome_exe|, act as if
1846 // our shortcut had been deleted. 1846 // our shortcut had been deleted.
1847 return true; 1847 return true;
1848 } 1848 }
1849 1849
1850 void ShellUtil::RemoveChromeTaskbarShortcuts(const string16& chrome_exe) {
1851 if (base::win::GetVersion() < base::win::VERSION_WIN7)
1852 return;
1853
1854 FilePath taskbar_pins_path;
1855 if (!PathService::Get(base::DIR_TASKBAR_PINS, &taskbar_pins_path) ||
1856 !file_util::PathExists(taskbar_pins_path)) {
1857 LOG(ERROR) << "Couldn't find path to taskbar pins.";
1858 return;
1859 }
1860
1861 file_util::FileEnumerator shortcuts_enum(
1862 taskbar_pins_path, false,
1863 file_util::FileEnumerator::FILES, FILE_PATH_LITERAL("*.lnk"));
1864
1865 FilePath chrome_path(chrome_exe);
1866 InstallUtil::ProgramCompare chrome_compare(chrome_path);
1867 for (FilePath shortcut_path = shortcuts_enum.Next(); !shortcut_path.empty();
1868 shortcut_path = shortcuts_enum.Next()) {
1869 FilePath read_target;
1870 if (!base::win::ResolveShortcut(shortcut_path, &read_target, NULL)) {
1871 LOG(ERROR) << "Couldn't resolve shortcut at " << shortcut_path.value();
1872 continue;
1873 }
1874 if (chrome_compare.Evaluate(read_target.value())) {
1875 // Unpin this shortcut if it points to |chrome_exe|.
1876 base::win::TaskbarUnpinShortcutLink(shortcut_path.value().c_str());
1877 }
1878 }
1879 }
1880
1850 void ShellUtil::RemoveChromeStartScreenShortcuts(BrowserDistribution* dist, 1881 void ShellUtil::RemoveChromeStartScreenShortcuts(BrowserDistribution* dist,
1851 const string16& chrome_exe) { 1882 const string16& chrome_exe) {
1852 if (base::win::GetVersion() < base::win::VERSION_WIN8) 1883 if (base::win::GetVersion() < base::win::VERSION_WIN8)
1853 return; 1884 return;
1854 1885
1855 FilePath app_shortcuts_path; 1886 FilePath app_shortcuts_path;
1856 if (!PathService::Get(base::DIR_APP_SHORTCUTS, &app_shortcuts_path)) { 1887 if (!PathService::Get(base::DIR_APP_SHORTCUTS, &app_shortcuts_path)) {
1857 LOG(ERROR) << "Could not get application shortcuts location to delete" 1888 LOG(ERROR) << "Could not get application shortcuts location to delete"
1858 << " start screen shortcuts."; 1889 << " start screen shortcuts.";
1859 return; 1890 return;
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
1935 // are any left...). 1966 // are any left...).
1936 if (free_bits >= 8 && next_byte_index < size) { 1967 if (free_bits >= 8 && next_byte_index < size) {
1937 free_bits -= 8; 1968 free_bits -= 8;
1938 bit_stream += bytes[next_byte_index++] << free_bits; 1969 bit_stream += bytes[next_byte_index++] << free_bits;
1939 } 1970 }
1940 } 1971 }
1941 1972
1942 DCHECK_EQ(ret.length(), encoded_length); 1973 DCHECK_EQ(ret.length(), encoded_length);
1943 return ret; 1974 return ret;
1944 } 1975 }
OLDNEW
« no previous file with comments | « chrome/installer/util/shell_util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698