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 1779 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1790 bool delete_folder = (location == SHORTCUT_LOCATION_START_MENU); | 1790 bool delete_folder = (location == SHORTCUT_LOCATION_START_MENU); |
1791 | 1791 |
1792 FilePath shortcut_folder; | 1792 FilePath shortcut_folder; |
1793 if (!GetShortcutPath(location, dist, level, &shortcut_folder) || | 1793 if (!GetShortcutPath(location, dist, level, &shortcut_folder) || |
1794 shortcut_folder.empty()) { | 1794 shortcut_folder.empty()) { |
1795 NOTREACHED(); | 1795 NOTREACHED(); |
1796 return false; | 1796 return false; |
1797 } | 1797 } |
1798 | 1798 |
1799 string16 shortcut_base_name( | 1799 string16 shortcut_base_name( |
1800 (shortcut_name ? *shortcut_name : dist->GetAppShortCutName()) + | 1800 (shortcut_name ? *shortcut_name : |
1801 installer::kLnkExt); | 1801 dist->GetAppShortCutName()) + installer::kLnkExt); |
1802 FilePath shortcut_path(shortcut_folder.Append(shortcut_base_name)); | 1802 FilePath shortcut_path(shortcut_folder.Append(shortcut_base_name)); |
1803 | 1803 |
1804 if (!file_util::PathExists(shortcut_path)) | 1804 if (!file_util::PathExists(shortcut_path)) |
1805 return true; | 1805 return true; |
1806 | 1806 |
1807 base::win::ScopedComPtr<IShellLink> i_shell_link; | 1807 FilePath read_target; |
1808 base::win::ScopedComPtr<IPersistFile> i_persist_file; | 1808 if (!base::win::ResolveShortcut(shortcut_path, &read_target, NULL)) |
1809 wchar_t read_target[MAX_PATH] = {}; | |
1810 if (FAILED(i_shell_link.CreateInstance(CLSID_ShellLink, NULL, | |
1811 CLSCTX_INPROC_SERVER)) || | |
1812 FAILED(i_persist_file.QueryFrom(i_shell_link)) || | |
1813 FAILED(i_persist_file->Load(shortcut_path.value().c_str(), STGM_READ)) || | |
1814 FAILED(i_shell_link->GetPath(read_target, MAX_PATH, NULL, | |
1815 SLGP_SHORTPATH))) { | |
1816 NOTREACHED(); | |
1817 return false; | 1809 return false; |
1818 } | |
1819 | 1810 |
1820 if (InstallUtil::ProgramCompare(FilePath(target_exe)).Evaluate(read_target)) { | 1811 if (InstallUtil::ProgramCompare( |
| 1812 FilePath(target_exe)).Evaluate(read_target.value())) { |
1821 // Unpin the shortcut if it was ever pinned by the user or the installer. | 1813 // Unpin the shortcut if it was ever pinned by the user or the installer. |
1822 VLOG(1) << "Trying to unpin " << shortcut_path.value(); | 1814 VLOG(1) << "Trying to unpin " << shortcut_path.value(); |
1823 if (!base::win::TaskbarUnpinShortcutLink(shortcut_path.value().c_str())) { | 1815 if (!base::win::TaskbarUnpinShortcutLink(shortcut_path.value().c_str())) { |
1824 VLOG(1) << shortcut_path.value() | 1816 VLOG(1) << shortcut_path.value() |
1825 << " wasn't pinned (or the unpin failed)."; | 1817 << " wasn't pinned (or the unpin failed)."; |
1826 } | 1818 } |
1827 if (delete_folder) | 1819 if (delete_folder) |
1828 return file_util::Delete(shortcut_folder, true); | 1820 return file_util::Delete(shortcut_folder, true); |
1829 else | 1821 else |
1830 return file_util::Delete(shortcut_path, false); | 1822 return file_util::Delete(shortcut_path, false); |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1954 // are any left...). | 1946 // are any left...). |
1955 if (free_bits >= 8 && next_byte_index < size) { | 1947 if (free_bits >= 8 && next_byte_index < size) { |
1956 free_bits -= 8; | 1948 free_bits -= 8; |
1957 bit_stream += bytes[next_byte_index++] << free_bits; | 1949 bit_stream += bytes[next_byte_index++] << free_bits; |
1958 } | 1950 } |
1959 } | 1951 } |
1960 | 1952 |
1961 DCHECK_EQ(ret.length(), encoded_length); | 1953 DCHECK_EQ(ret.length(), encoded_length); |
1962 return ret; | 1954 return ret; |
1963 } | 1955 } |
OLD | NEW |