OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 529 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
540 cleanup_needed = (*itr)->NameExistsInHKLM(); | 540 cleanup_needed = (*itr)->NameExistsInHKLM(); |
541 } | 541 } |
542 return cleanup_needed; | 542 return cleanup_needed; |
543 } | 543 } |
544 | 544 |
545 bool ShellUtil::CreateChromeDesktopShortcut(BrowserDistribution* dist, | 545 bool ShellUtil::CreateChromeDesktopShortcut(BrowserDistribution* dist, |
546 const std::wstring& chrome_exe, | 546 const std::wstring& chrome_exe, |
547 const std::wstring& description, | 547 const std::wstring& description, |
548 const std::wstring& appended_name, | 548 const std::wstring& appended_name, |
549 const std::wstring& arguments, | 549 const std::wstring& arguments, |
550 const std::wstring& icon_path, | |
551 int icon_index, | |
550 ShellChange shell_change, | 552 ShellChange shell_change, |
551 bool alternate, | 553 bool alternate, |
552 bool create_new) { | 554 bool create_new) { |
553 std::wstring shortcut_name; | 555 std::wstring shortcut_name; |
554 if (!ShellUtil::GetChromeShortcutName(dist, alternate, appended_name, | 556 if (!ShellUtil::GetChromeShortcutName(dist, alternate, appended_name, |
555 &shortcut_name)) | 557 &shortcut_name)) |
556 return false; | 558 return false; |
557 | 559 |
558 bool ret = false; | 560 bool ret = false; |
559 if (shell_change == ShellUtil::CURRENT_USER) { | 561 if (shell_change == ShellUtil::CURRENT_USER) { |
560 FilePath shortcut_path; | 562 FilePath shortcut_path; |
561 // We do not want to create a desktop shortcut to Chrome in the current | 563 // We do not want to create a desktop shortcut to Chrome in the current |
562 // user's desktop folder if there is already one in the "All Users" | 564 // user's desktop folder if there is already one in the "All Users" |
563 // desktop folder. | 565 // desktop folder. |
564 bool got_system_desktop = ShellUtil::GetDesktopPath(true, &shortcut_path); | 566 bool got_system_desktop = ShellUtil::GetDesktopPath(true, &shortcut_path); |
565 FilePath shortcut = shortcut_path.Append(shortcut_name); | 567 FilePath shortcut = shortcut_path.Append(shortcut_name); |
566 if (!got_system_desktop || !file_util::PathExists(shortcut)) { | 568 if (!got_system_desktop || !file_util::PathExists(shortcut)) { |
567 // Either we couldn't query the "All Users" Desktop folder or there's | 569 // Either we couldn't query the "All Users" Desktop folder or there's |
568 // nothing in it, so let's continue. | 570 // nothing in it, so let's continue. |
569 if (ShellUtil::GetDesktopPath(false, &shortcut_path)) { | 571 if (ShellUtil::GetDesktopPath(false, &shortcut_path)) { |
570 shortcut = shortcut_path.Append(shortcut_name); | 572 shortcut = shortcut_path.Append(shortcut_name); |
571 ret = ShellUtil::UpdateChromeShortcut(dist, | 573 ret = ShellUtil::UpdateChromeShortcut(dist, |
572 chrome_exe, | 574 chrome_exe, |
573 shortcut.value(), | 575 shortcut.value(), |
574 arguments, | 576 arguments, |
575 description, | 577 description, |
578 icon_path, | |
579 dist->GetIconIndex(), | |
grt (UTC plus 2)
2011/12/03 04:14:00
this should be icon_index, no?
SteveT
2011/12/03 05:07:09
Yup, thanks for catching that.
| |
576 create_new); | 580 create_new); |
577 } | 581 } |
578 } | 582 } |
579 } else if (shell_change == ShellUtil::SYSTEM_LEVEL) { | 583 } else if (shell_change == ShellUtil::SYSTEM_LEVEL) { |
580 FilePath shortcut_path; | 584 FilePath shortcut_path; |
581 if (ShellUtil::GetDesktopPath(true, &shortcut_path)) { | 585 if (ShellUtil::GetDesktopPath(true, &shortcut_path)) { |
582 FilePath shortcut = shortcut_path.Append(shortcut_name); | 586 FilePath shortcut = shortcut_path.Append(shortcut_name); |
583 ret = ShellUtil::UpdateChromeShortcut(dist, | 587 ret = ShellUtil::UpdateChromeShortcut(dist, |
584 chrome_exe, | 588 chrome_exe, |
585 shortcut.value(), | 589 shortcut.value(), |
586 arguments, | 590 arguments, |
587 description, | 591 description, |
592 icon_path, | |
593 dist->GetIconIndex(), | |
grt (UTC plus 2)
2011/12/03 04:14:00
same
SteveT
2011/12/03 05:07:09
Done.
| |
588 create_new); | 594 create_new); |
589 } | 595 } |
590 } else { | 596 } else { |
591 NOTREACHED(); | 597 NOTREACHED(); |
592 } | 598 } |
593 return ret; | 599 return ret; |
594 } | 600 } |
595 | 601 |
596 bool ShellUtil::CreateChromeQuickLaunchShortcut(BrowserDistribution* dist, | 602 bool ShellUtil::CreateChromeQuickLaunchShortcut(BrowserDistribution* dist, |
597 const std::wstring& chrome_exe, | 603 const std::wstring& chrome_exe, |
598 int shell_change, | 604 int shell_change, |
599 bool create_new) { | 605 bool create_new) { |
600 std::wstring shortcut_name; | 606 std::wstring shortcut_name; |
601 if (!ShellUtil::GetChromeShortcutName(dist, false, L"", &shortcut_name)) | 607 if (!ShellUtil::GetChromeShortcutName(dist, false, L"", &shortcut_name)) |
602 return false; | 608 return false; |
603 | 609 |
604 bool ret = true; | 610 bool ret = true; |
605 // First create shortcut for the current user. | 611 // First create shortcut for the current user. |
606 if (shell_change & ShellUtil::CURRENT_USER) { | 612 if (shell_change & ShellUtil::CURRENT_USER) { |
607 std::wstring user_ql_path; | 613 std::wstring user_ql_path; |
608 if (ShellUtil::GetQuickLaunchPath(false, &user_ql_path)) { | 614 if (ShellUtil::GetQuickLaunchPath(false, &user_ql_path)) { |
609 file_util::AppendToPath(&user_ql_path, shortcut_name); | 615 file_util::AppendToPath(&user_ql_path, shortcut_name); |
610 ret = ShellUtil::UpdateChromeShortcut(dist, chrome_exe, user_ql_path, | 616 ret = ShellUtil::UpdateChromeShortcut(dist, chrome_exe, user_ql_path, |
611 L"", L"", create_new); | 617 L"", L"", chrome_exe, |
618 dist->GetIconIndex(), | |
619 create_new); | |
612 } else { | 620 } else { |
613 ret = false; | 621 ret = false; |
614 } | 622 } |
615 } | 623 } |
616 | 624 |
617 // Add a shortcut to Default User's profile so that all new user profiles | 625 // Add a shortcut to Default User's profile so that all new user profiles |
618 // get it. | 626 // get it. |
619 if (shell_change & ShellUtil::SYSTEM_LEVEL) { | 627 if (shell_change & ShellUtil::SYSTEM_LEVEL) { |
620 std::wstring default_ql_path; | 628 std::wstring default_ql_path; |
621 if (ShellUtil::GetQuickLaunchPath(true, &default_ql_path)) { | 629 if (ShellUtil::GetQuickLaunchPath(true, &default_ql_path)) { |
622 file_util::AppendToPath(&default_ql_path, shortcut_name); | 630 file_util::AppendToPath(&default_ql_path, shortcut_name); |
623 ret = ShellUtil::UpdateChromeShortcut(dist, chrome_exe, default_ql_path, | 631 ret = ShellUtil::UpdateChromeShortcut(dist, chrome_exe, default_ql_path, |
624 L"", L"", create_new) && ret; | 632 L"", L"", chrome_exe, |
633 dist->GetIconIndex(), | |
634 create_new) && ret; | |
625 } else { | 635 } else { |
626 ret = false; | 636 ret = false; |
627 } | 637 } |
628 } | 638 } |
629 | 639 |
630 return ret; | 640 return ret; |
631 } | 641 } |
632 | 642 |
633 std::wstring ShellUtil::GetChromeIcon(BrowserDistribution* dist, | 643 std::wstring ShellUtil::GetChromeIcon(BrowserDistribution* dist, |
634 const std::wstring& chrome_exe) { | 644 const std::wstring& chrome_exe) { |
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1045 } | 1055 } |
1046 | 1056 |
1047 return ret; | 1057 return ret; |
1048 } | 1058 } |
1049 | 1059 |
1050 bool ShellUtil::UpdateChromeShortcut(BrowserDistribution* dist, | 1060 bool ShellUtil::UpdateChromeShortcut(BrowserDistribution* dist, |
1051 const std::wstring& chrome_exe, | 1061 const std::wstring& chrome_exe, |
1052 const std::wstring& shortcut, | 1062 const std::wstring& shortcut, |
1053 const std::wstring& arguments, | 1063 const std::wstring& arguments, |
1054 const std::wstring& description, | 1064 const std::wstring& description, |
1065 const std::wstring& icon_path, | |
1066 int icon_index, | |
1055 bool create_new) { | 1067 bool create_new) { |
1056 std::wstring chrome_path = FilePath(chrome_exe).DirName().value(); | 1068 std::wstring chrome_path = FilePath(chrome_exe).DirName().value(); |
1057 | 1069 |
1058 FilePath prefs_path(chrome_path); | 1070 FilePath prefs_path(chrome_path); |
1059 prefs_path = prefs_path.AppendASCII(installer::kDefaultMasterPrefs); | 1071 prefs_path = prefs_path.AppendASCII(installer::kDefaultMasterPrefs); |
1060 installer::MasterPreferences prefs(prefs_path); | 1072 installer::MasterPreferences prefs(prefs_path); |
1061 int icon_index = dist->GetIconIndex(); | |
1062 prefs.GetInt(installer::master_preferences::kChromeShortcutIconIndex, | 1073 prefs.GetInt(installer::master_preferences::kChromeShortcutIconIndex, |
grt (UTC plus 2)
2011/12/03 04:14:00
should this pref only do anything if FilePath::Com
SteveT
2011/12/03 05:09:53
Yup, that makes sense. I am going to check FilePat
| |
1063 &icon_index); | 1074 &icon_index); |
1064 if (create_new) { | 1075 if (create_new) { |
1065 return file_util::CreateShortcutLink( | 1076 return file_util::CreateShortcutLink( |
1066 chrome_exe.c_str(), // target | 1077 chrome_exe.c_str(), // target |
1067 shortcut.c_str(), // shortcut | 1078 shortcut.c_str(), // shortcut |
1068 chrome_path.c_str(), // working dir | 1079 chrome_path.c_str(), // working dir |
1069 arguments.c_str(), // arguments | 1080 arguments.c_str(), // arguments |
1070 description.c_str(), // description | 1081 description.c_str(), // description |
1071 chrome_exe.c_str(), // icon file | 1082 icon_path.c_str(), // icon file |
1072 icon_index, // icon index | 1083 icon_index, // icon index |
1073 dist->GetBrowserAppId().c_str()); // app id | 1084 dist->GetBrowserAppId().c_str()); // app id |
1074 } else { | 1085 } else { |
1075 return file_util::UpdateShortcutLink( | 1086 return file_util::UpdateShortcutLink( |
1076 chrome_exe.c_str(), // target | 1087 chrome_exe.c_str(), // target |
1077 shortcut.c_str(), // shortcut | 1088 shortcut.c_str(), // shortcut |
1078 chrome_path.c_str(), // working dir | 1089 chrome_path.c_str(), // working dir |
1079 arguments.c_str(), // arguments | 1090 arguments.c_str(), // arguments |
1080 description.c_str(), // description | 1091 description.c_str(), // description |
1081 chrome_exe.c_str(), // icon file | 1092 icon_path.c_str(), // icon file |
1082 icon_index, // icon index | 1093 icon_index, // icon index |
1083 dist->GetBrowserAppId().c_str()); // app id | 1094 dist->GetBrowserAppId().c_str()); // app id |
1084 } | 1095 } |
1085 } | 1096 } |
OLD | NEW |