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 #include "chrome/browser/shell_integration_linux.h" | 5 #include "chrome/browser/shell_integration_linux.h" |
6 | 6 |
7 #include <fcntl.h> | 7 #include <fcntl.h> |
8 #include <glib.h> | 8 #include <glib.h> |
9 #include <stdlib.h> | 9 #include <stdlib.h> |
10 #include <sys/stat.h> | 10 #include <sys/stat.h> |
(...skipping 662 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
673 | 673 |
674 // Use a prefix, because xdg-desktop-menu requires it. | 674 // Use a prefix, because xdg-desktop-menu requires it. |
675 std::string filename(chrome::kBrowserProcessExecutableName); | 675 std::string filename(chrome::kBrowserProcessExecutableName); |
676 filename.append("-") | 676 filename.append("-") |
677 .append(extension_id) | 677 .append(extension_id) |
678 .append("-") | 678 .append("-") |
679 .append(profile_path.BaseName().value()); | 679 .append(profile_path.BaseName().value()); |
680 file_util::ReplaceIllegalCharactersInPath(&filename, '_'); | 680 file_util::ReplaceIllegalCharactersInPath(&filename, '_'); |
681 // Spaces in filenames break xdg-desktop-menu | 681 // Spaces in filenames break xdg-desktop-menu |
682 // (see https://bugs.freedesktop.org/show_bug.cgi?id=66605). | 682 // (see https://bugs.freedesktop.org/show_bug.cgi?id=66605). |
683 ReplaceChars(filename, " ", "_", &filename); | 683 base::ReplaceChars(filename, " ", "_", &filename); |
684 return base::FilePath(filename.append(".desktop")); | 684 return base::FilePath(filename.append(".desktop")); |
685 } | 685 } |
686 | 686 |
687 std::vector<base::FilePath> GetExistingProfileShortcutFilenames( | 687 std::vector<base::FilePath> GetExistingProfileShortcutFilenames( |
688 const base::FilePath& profile_path, | 688 const base::FilePath& profile_path, |
689 const base::FilePath& directory) { | 689 const base::FilePath& directory) { |
690 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 690 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
691 // Use a prefix, because xdg-desktop-menu requires it. | 691 // Use a prefix, because xdg-desktop-menu requires it. |
692 std::string prefix(chrome::kBrowserProcessExecutableName); | 692 std::string prefix(chrome::kBrowserProcessExecutableName); |
693 prefix.append("-"); | 693 prefix.append("-"); |
694 std::string suffix("-"); | 694 std::string suffix("-"); |
695 suffix.append(profile_path.BaseName().value()); | 695 suffix.append(profile_path.BaseName().value()); |
696 file_util::ReplaceIllegalCharactersInPath(&suffix, '_'); | 696 file_util::ReplaceIllegalCharactersInPath(&suffix, '_'); |
697 // Spaces in filenames break xdg-desktop-menu | 697 // Spaces in filenames break xdg-desktop-menu |
698 // (see https://bugs.freedesktop.org/show_bug.cgi?id=66605). | 698 // (see https://bugs.freedesktop.org/show_bug.cgi?id=66605). |
699 ReplaceChars(suffix, " ", "_", &suffix); | 699 base::ReplaceChars(suffix, " ", "_", &suffix); |
700 std::string glob = prefix + "*" + suffix + ".desktop"; | 700 std::string glob = prefix + "*" + suffix + ".desktop"; |
701 | 701 |
702 base::FileEnumerator files(directory, false, base::FileEnumerator::FILES, | 702 base::FileEnumerator files(directory, false, base::FileEnumerator::FILES, |
703 glob); | 703 glob); |
704 base::FilePath shortcut_file = files.Next(); | 704 base::FilePath shortcut_file = files.Next(); |
705 std::vector<base::FilePath> shortcut_paths; | 705 std::vector<base::FilePath> shortcut_paths; |
706 while (!shortcut_file.empty()) { | 706 while (!shortcut_file.empty()) { |
707 shortcut_paths.push_back(shortcut_file.BaseName()); | 707 shortcut_paths.push_back(shortcut_file.BaseName()); |
708 shortcut_file = files.Next(); | 708 shortcut_file = files.Next(); |
709 } | 709 } |
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
953 for (std::vector<base::FilePath>::const_iterator it = | 953 for (std::vector<base::FilePath>::const_iterator it = |
954 shortcut_filenames_app_menu.begin(); | 954 shortcut_filenames_app_menu.begin(); |
955 it != shortcut_filenames_app_menu.end(); ++it) { | 955 it != shortcut_filenames_app_menu.end(); ++it) { |
956 DeleteShortcutInApplicationsMenu(*it, | 956 DeleteShortcutInApplicationsMenu(*it, |
957 base::FilePath(kDirectoryFilename)); | 957 base::FilePath(kDirectoryFilename)); |
958 } | 958 } |
959 } | 959 } |
960 } | 960 } |
961 | 961 |
962 } // namespace ShellIntegrationLinux | 962 } // namespace ShellIntegrationLinux |
OLD | NEW |