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

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

Issue 11465025: Keep installing all-users Start Menu and Desktop shortcuts on system-level installs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remove TODO Created 8 years 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/setup/install.cc ('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 1260 matching lines...) Expand 10 before | Expand all | Expand 10 after
1271 system_shortcut_path.empty()) { 1271 system_shortcut_path.empty()) {
1272 NOTREACHED(); 1272 NOTREACHED();
1273 return false; 1273 return false;
1274 } 1274 }
1275 1275
1276 string16 shortcut_name(ExtractShortcutNameFromProperties(dist, properties)); 1276 string16 shortcut_name(ExtractShortcutNameFromProperties(dist, properties));
1277 user_shortcut_path = user_shortcut_path.Append(shortcut_name); 1277 user_shortcut_path = user_shortcut_path.Append(shortcut_name);
1278 system_shortcut_path = system_shortcut_path.Append(shortcut_name); 1278 system_shortcut_path = system_shortcut_path.Append(shortcut_name);
1279 1279
1280 FilePath *chosen_path; 1280 FilePath *chosen_path;
1281 bool should_install_shortcut = true;
1281 if (properties.level == SYSTEM_LEVEL) { 1282 if (properties.level == SYSTEM_LEVEL) {
1282 // Install the system-level shortcut if requested. 1283 // Install the system-level shortcut if requested.
1283 chosen_path = &system_shortcut_path; 1284 chosen_path = &system_shortcut_path;
1284 } else if (operation != SHELL_SHORTCUT_CREATE_IF_NO_SYSTEM_LEVEL || 1285 } else if (operation != SHELL_SHORTCUT_CREATE_IF_NO_SYSTEM_LEVEL ||
1285 !file_util::PathExists(system_shortcut_path)){ 1286 !file_util::PathExists(system_shortcut_path)){
1286 // Otherwise install the user-level shortcut, unless the system-level 1287 // Otherwise install the user-level shortcut, unless the system-level
1287 // variant of this shortcut is present on the machine and |operation| states 1288 // variant of this shortcut is present on the machine and |operation| states
1288 // not to create a user-level shortcut in that case. 1289 // not to create a user-level shortcut in that case.
1289 chosen_path = &user_shortcut_path; 1290 chosen_path = &user_shortcut_path;
1290 } else { 1291 } else {
1291 // Do not install anything if we are told to install a user-level shortcut, 1292 // Do not install any shortcut if we are told to install a user-level
1292 // but the system-level variant of that shortcut is present. 1293 // shortcut, but the system-level variant of that shortcut is present.
1293 chosen_path = &FilePath(); 1294 // Other actions (e.g., pinning) can still happen with respect to the
1295 // existing system-level shortcut however.
1296 chosen_path = &system_shortcut_path;
1297 should_install_shortcut = false;
1294 } 1298 }
1295 1299
1296 // No shortcut needs to be created/updated. 1300 if (chosen_path == NULL || chosen_path->empty()) {
1297 if (chosen_path->empty())
1298 return true;
1299
1300 base::win::ShortcutOperation shortcut_operation =
1301 TranslateShortcutOperation(operation);
1302 // Make sure the parent directories exist when creating the shortcut.
1303 if (shortcut_operation == base::win::SHORTCUT_CREATE_ALWAYS &&
1304 !file_util::CreateDirectory(chosen_path->DirName())) {
1305 NOTREACHED(); 1301 NOTREACHED();
1306 return false; 1302 return false;
1307 } 1303 }
1308 1304
1309 base::win::ShortcutProperties shortcut_properties( 1305 base::win::ShortcutOperation shortcut_operation =
1310 TranslateShortcutProperties(properties)); 1306 TranslateShortcutOperation(operation);
1311 bool ret = base::win::CreateOrUpdateShortcutLink( 1307 bool ret = true;
1312 *chosen_path, shortcut_properties, shortcut_operation); 1308 if (should_install_shortcut) {
1309 // Make sure the parent directories exist when creating the shortcut.
1310 if (shortcut_operation == base::win::SHORTCUT_CREATE_ALWAYS &&
1311 !file_util::CreateDirectory(chosen_path->DirName())) {
1312 NOTREACHED();
1313 return false;
1314 }
1315
1316 base::win::ShortcutProperties shortcut_properties(
1317 TranslateShortcutProperties(properties));
1318 ret = base::win::CreateOrUpdateShortcutLink(
1319 *chosen_path, shortcut_properties, shortcut_operation);
1320 }
1313 1321
1314 if (ret && shortcut_operation == base::win::SHORTCUT_CREATE_ALWAYS && 1322 if (ret && shortcut_operation == base::win::SHORTCUT_CREATE_ALWAYS &&
1315 properties.pin_to_taskbar && 1323 properties.pin_to_taskbar &&
1316 base::win::GetVersion() >= base::win::VERSION_WIN7) { 1324 base::win::GetVersion() >= base::win::VERSION_WIN7) {
1317 ret = base::win::TaskbarPinShortcutLink(chosen_path->value().c_str()); 1325 ret = base::win::TaskbarPinShortcutLink(chosen_path->value().c_str());
1318 if (!ret) { 1326 if (!ret) {
1319 LOG(ERROR) << "The shorcut at " << chosen_path->value() 1327 LOG(ERROR) << "Failed to pin " << chosen_path->value();
1320 << " was created, but the taskbar pin failed.";
1321 } 1328 }
1322 } 1329 }
1323 1330
1324 return ret; 1331 return ret;
1325 } 1332 }
1326 1333
1327 string16 ShellUtil::FormatIconLocation(const string16& icon_path, 1334 string16 ShellUtil::FormatIconLocation(const string16& icon_path,
1328 int icon_index) { 1335 int icon_index) {
1329 string16 icon_string(icon_path); 1336 string16 icon_string(icon_path);
1330 icon_string.append(L","); 1337 icon_string.append(L",");
(...skipping 627 matching lines...) Expand 10 before | Expand all | Expand 10 after
1958 // are any left...). 1965 // are any left...).
1959 if (free_bits >= 8 && next_byte_index < size) { 1966 if (free_bits >= 8 && next_byte_index < size) {
1960 free_bits -= 8; 1967 free_bits -= 8;
1961 bit_stream += bytes[next_byte_index++] << free_bits; 1968 bit_stream += bytes[next_byte_index++] << free_bits;
1962 } 1969 }
1963 } 1970 }
1964 1971
1965 DCHECK_EQ(ret.length(), encoded_length); 1972 DCHECK_EQ(ret.length(), encoded_length);
1966 return ret; 1973 return ret;
1967 } 1974 }
OLDNEW
« no previous file with comments | « chrome/installer/setup/install.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698