OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 // | 4 // |
5 // This file defines functions that integrate Chrome in Windows shell. These | 5 // This file defines functions that integrate Chrome in Windows shell. These |
6 // functions can be used by Chrome as well as Chrome installer. All of the | 6 // functions can be used by Chrome as well as Chrome installer. All of the |
7 // work is done by the local functions defined in anonymous namespace in | 7 // work is done by the local functions defined in anonymous namespace in |
8 // this class. | 8 // this class. |
9 | 9 |
10 #include "chrome/installer/util/shell_util.h" | 10 #include "chrome/installer/util/shell_util.h" |
(...skipping 1829 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 FilePath taskbar_pins_path; |
| 1852 if (!PathService::Get(base::DIR_TASKBAR_PINS, &taskbar_pins_path) || |
| 1853 !file_util::PathExists(taskbar_pins_path)) { |
| 1854 LOG(ERROR) << "Couldn't find path to taskbar pins."; |
| 1855 return; |
| 1856 } |
| 1857 |
| 1858 file_util::FileEnumerator shortcuts_enum( |
| 1859 taskbar_pins_path, false, |
| 1860 file_util::FileEnumerator::FILES, FILE_PATH_LITERAL("*.lnk")); |
| 1861 |
| 1862 FilePath chrome_path(chrome_exe); |
| 1863 InstallUtil::ProgramCompare chrome_compare(chrome_path); |
| 1864 for (FilePath shortcut_path = shortcuts_enum.Next(); !shortcut_path.empty(); |
| 1865 shortcut_path = shortcuts_enum.Next()) { |
| 1866 FilePath read_target; |
| 1867 if (!base::win::ResolveShortcut(shortcut_path, &read_target, NULL)) { |
| 1868 NOTREACHED(); |
| 1869 continue; |
| 1870 } |
| 1871 if (chrome_compare.Evaluate(read_target.value())) { |
| 1872 // Unpin this shortcut if it points to |chrome_exe|. |
| 1873 base::win::TaskbarUnpinShortcutLink(shortcut_path.value().c_str()); |
| 1874 } |
| 1875 } |
| 1876 } |
| 1877 |
1850 void ShellUtil::RemoveChromeStartScreenShortcuts(BrowserDistribution* dist, | 1878 void ShellUtil::RemoveChromeStartScreenShortcuts(BrowserDistribution* dist, |
1851 const string16& chrome_exe) { | 1879 const string16& chrome_exe) { |
1852 if (base::win::GetVersion() < base::win::VERSION_WIN8) | 1880 if (base::win::GetVersion() < base::win::VERSION_WIN8) |
1853 return; | 1881 return; |
1854 | 1882 |
1855 FilePath app_shortcuts_path; | 1883 FilePath app_shortcuts_path; |
1856 if (!PathService::Get(base::DIR_APP_SHORTCUTS, &app_shortcuts_path)) { | 1884 if (!PathService::Get(base::DIR_APP_SHORTCUTS, &app_shortcuts_path)) { |
1857 LOG(ERROR) << "Could not get application shortcuts location to delete" | 1885 LOG(ERROR) << "Could not get application shortcuts location to delete" |
1858 << " start screen shortcuts."; | 1886 << " start screen shortcuts."; |
1859 return; | 1887 return; |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1935 // are any left...). | 1963 // are any left...). |
1936 if (free_bits >= 8 && next_byte_index < size) { | 1964 if (free_bits >= 8 && next_byte_index < size) { |
1937 free_bits -= 8; | 1965 free_bits -= 8; |
1938 bit_stream += bytes[next_byte_index++] << free_bits; | 1966 bit_stream += bytes[next_byte_index++] << free_bits; |
1939 } | 1967 } |
1940 } | 1968 } |
1941 | 1969 |
1942 DCHECK_EQ(ret.length(), encoded_length); | 1970 DCHECK_EQ(ret.length(), encoded_length); |
1943 return ret; | 1971 return ret; |
1944 } | 1972 } |
OLD | NEW |