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 1317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1328 // This method will abort and return false if |cancel| is non-NULL and gets set | 1328 // This method will abort and return false if |cancel| is non-NULL and gets set |
1329 // at any point during this call. | 1329 // at any point during this call. |
1330 bool BatchShortcutAction( | 1330 bool BatchShortcutAction( |
1331 const ShortcutFilterCallback& shortcut_filter, | 1331 const ShortcutFilterCallback& shortcut_filter, |
1332 const ShortcutOperationCallback& shortcut_operation, | 1332 const ShortcutOperationCallback& shortcut_operation, |
1333 ShellUtil::ShortcutLocation location, | 1333 ShellUtil::ShortcutLocation location, |
1334 BrowserDistribution* dist, | 1334 BrowserDistribution* dist, |
1335 ShellUtil::ShellChange level, | 1335 ShellUtil::ShellChange level, |
1336 const scoped_refptr<ShellUtil::SharedCancellationFlag>& cancel) { | 1336 const scoped_refptr<ShellUtil::SharedCancellationFlag>& cancel) { |
1337 DCHECK(!shortcut_operation.is_null()); | 1337 DCHECK(!shortcut_operation.is_null()); |
| 1338 |
| 1339 // There is no system-level Quick Launch shortcut folder. |
| 1340 if (level == ShellUtil::SYSTEM_LEVEL && |
| 1341 location == ShellUtil::SHORTCUT_LOCATION_QUICK_LAUNCH) { |
| 1342 return true; |
| 1343 } |
| 1344 |
1338 base::FilePath shortcut_folder; | 1345 base::FilePath shortcut_folder; |
1339 if (!ShellUtil::GetShortcutPath(location, dist, level, &shortcut_folder)) { | 1346 if (!ShellUtil::GetShortcutPath(location, dist, level, &shortcut_folder)) { |
1340 LOG(WARNING) << "Cannot find path at location " << location; | 1347 LOG(WARNING) << "Cannot find path at location " << location; |
1341 return false; | 1348 return false; |
1342 } | 1349 } |
1343 | 1350 |
1344 bool success = true; | 1351 bool success = true; |
1345 base::FileEnumerator enumerator( | 1352 base::FileEnumerator enumerator( |
1346 shortcut_folder, false, base::FileEnumerator::FILES, | 1353 shortcut_folder, false, base::FileEnumerator::FILES, |
1347 base::string16(L"*") + installer::kLnkExt); | 1354 base::string16(L"*") + installer::kLnkExt); |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1467 base::FilePath* path) { | 1474 base::FilePath* path) { |
1468 DCHECK(path); | 1475 DCHECK(path); |
1469 int dir_key = -1; | 1476 int dir_key = -1; |
1470 base::string16 folder_to_append; | 1477 base::string16 folder_to_append; |
1471 switch (location) { | 1478 switch (location) { |
1472 case SHORTCUT_LOCATION_DESKTOP: | 1479 case SHORTCUT_LOCATION_DESKTOP: |
1473 dir_key = (level == CURRENT_USER) ? base::DIR_USER_DESKTOP : | 1480 dir_key = (level == CURRENT_USER) ? base::DIR_USER_DESKTOP : |
1474 base::DIR_COMMON_DESKTOP; | 1481 base::DIR_COMMON_DESKTOP; |
1475 break; | 1482 break; |
1476 case SHORTCUT_LOCATION_QUICK_LAUNCH: | 1483 case SHORTCUT_LOCATION_QUICK_LAUNCH: |
1477 dir_key = (level == CURRENT_USER) ? base::DIR_USER_QUICK_LAUNCH : | 1484 // There is no support for a system-level Quick Launch shortcut. |
1478 base::DIR_DEFAULT_USER_QUICK_LAUNCH; | 1485 DCHECK_EQ(level, CURRENT_USER); |
| 1486 dir_key = base::DIR_USER_QUICK_LAUNCH; |
1479 break; | 1487 break; |
1480 case SHORTCUT_LOCATION_START_MENU_ROOT: | 1488 case SHORTCUT_LOCATION_START_MENU_ROOT: |
1481 dir_key = (level == CURRENT_USER) ? base::DIR_START_MENU : | 1489 dir_key = (level == CURRENT_USER) ? base::DIR_START_MENU : |
1482 base::DIR_COMMON_START_MENU; | 1490 base::DIR_COMMON_START_MENU; |
1483 break; | 1491 break; |
1484 case SHORTCUT_LOCATION_START_MENU_CHROME_DIR: | 1492 case SHORTCUT_LOCATION_START_MENU_CHROME_DIR: |
1485 dir_key = (level == CURRENT_USER) ? base::DIR_START_MENU : | 1493 dir_key = (level == CURRENT_USER) ? base::DIR_START_MENU : |
1486 base::DIR_COMMON_START_MENU; | 1494 base::DIR_COMMON_START_MENU; |
1487 folder_to_append = dist->GetStartMenuShortcutSubfolder( | 1495 folder_to_append = dist->GetStartMenuShortcutSubfolder( |
1488 BrowserDistribution::SUBFOLDER_CHROME); | 1496 BrowserDistribution::SUBFOLDER_CHROME); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1532 } | 1540 } |
1533 | 1541 |
1534 DCHECK(dist); | 1542 DCHECK(dist); |
1535 // |pin_to_taskbar| is only acknowledged when first creating the shortcut. | 1543 // |pin_to_taskbar| is only acknowledged when first creating the shortcut. |
1536 DCHECK(!properties.pin_to_taskbar || | 1544 DCHECK(!properties.pin_to_taskbar || |
1537 operation == SHELL_SHORTCUT_CREATE_ALWAYS || | 1545 operation == SHELL_SHORTCUT_CREATE_ALWAYS || |
1538 operation == SHELL_SHORTCUT_CREATE_IF_NO_SYSTEM_LEVEL); | 1546 operation == SHELL_SHORTCUT_CREATE_IF_NO_SYSTEM_LEVEL); |
1539 | 1547 |
1540 base::FilePath user_shortcut_path; | 1548 base::FilePath user_shortcut_path; |
1541 base::FilePath system_shortcut_path; | 1549 base::FilePath system_shortcut_path; |
1542 if (!GetShortcutPath(location, dist, SYSTEM_LEVEL, &system_shortcut_path)) { | 1550 if (location == SHORTCUT_LOCATION_QUICK_LAUNCH) { |
| 1551 // There is no system-level shortcut for Quick Launch. |
| 1552 DCHECK_EQ(properties.level, CURRENT_USER); |
| 1553 } else if (!GetShortcutPath( |
| 1554 location, dist, SYSTEM_LEVEL, &system_shortcut_path)) { |
1543 NOTREACHED(); | 1555 NOTREACHED(); |
1544 return false; | 1556 return false; |
1545 } | 1557 } |
1546 | 1558 |
1547 base::string16 shortcut_name( | 1559 base::string16 shortcut_name( |
1548 ExtractShortcutNameFromProperties(dist, properties)); | 1560 ExtractShortcutNameFromProperties(dist, properties)); |
1549 system_shortcut_path = system_shortcut_path.Append(shortcut_name); | 1561 system_shortcut_path = system_shortcut_path.Append(shortcut_name); |
1550 | 1562 |
1551 base::FilePath* chosen_path; | 1563 base::FilePath* chosen_path; |
1552 bool should_install_shortcut = true; | 1564 bool should_install_shortcut = true; |
1553 if (properties.level == SYSTEM_LEVEL) { | 1565 if (properties.level == SYSTEM_LEVEL) { |
1554 // Install the system-level shortcut if requested. | 1566 // Install the system-level shortcut if requested. |
1555 chosen_path = &system_shortcut_path; | 1567 chosen_path = &system_shortcut_path; |
1556 } else if (operation != SHELL_SHORTCUT_CREATE_IF_NO_SYSTEM_LEVEL || | 1568 } else if (operation != SHELL_SHORTCUT_CREATE_IF_NO_SYSTEM_LEVEL || |
| 1569 system_shortcut_path.empty() || |
1557 !base::PathExists(system_shortcut_path)) { | 1570 !base::PathExists(system_shortcut_path)) { |
1558 // Otherwise install the user-level shortcut, unless the system-level | 1571 // Otherwise install the user-level shortcut, unless the system-level |
1559 // variant of this shortcut is present on the machine and |operation| states | 1572 // variant of this shortcut is present on the machine and |operation| states |
1560 // not to create a user-level shortcut in that case. | 1573 // not to create a user-level shortcut in that case. |
1561 if (!GetShortcutPath(location, dist, CURRENT_USER, &user_shortcut_path)) { | 1574 if (!GetShortcutPath(location, dist, CURRENT_USER, &user_shortcut_path)) { |
1562 NOTREACHED(); | 1575 NOTREACHED(); |
1563 return false; | 1576 return false; |
1564 } | 1577 } |
1565 user_shortcut_path = user_shortcut_path.Append(shortcut_name); | 1578 user_shortcut_path = user_shortcut_path.Append(shortcut_name); |
1566 chosen_path = &user_shortcut_path; | 1579 chosen_path = &user_shortcut_path; |
(...skipping 707 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2274 // are any left...). | 2287 // are any left...). |
2275 if (free_bits >= 8 && next_byte_index < size) { | 2288 if (free_bits >= 8 && next_byte_index < size) { |
2276 free_bits -= 8; | 2289 free_bits -= 8; |
2277 bit_stream += bytes[next_byte_index++] << free_bits; | 2290 bit_stream += bytes[next_byte_index++] << free_bits; |
2278 } | 2291 } |
2279 } | 2292 } |
2280 | 2293 |
2281 DCHECK_EQ(ret.length(), encoded_length); | 2294 DCHECK_EQ(ret.length(), encoded_length); |
2282 return ret; | 2295 return ret; |
2283 } | 2296 } |
OLD | NEW |