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

Side by Side Diff: chrome/browser/shell_integration_linux.cc

Issue 447403002: Move file_util_icu to base::i18n namespace (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 months 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
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 #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 8
9 #if defined(USE_GLIB) 9 #if defined(USE_GLIB)
10 #include <glib.h> 10 #include <glib.h>
(...skipping 677 matching lines...) Expand 10 before | Expand all | Expand 10 after
688 } 688 }
689 } 689 }
690 690
691 return false; 691 return false;
692 } 692 }
693 693
694 base::FilePath GetWebShortcutFilename(const GURL& url) { 694 base::FilePath GetWebShortcutFilename(const GURL& url) {
695 // Use a prefix, because xdg-desktop-menu requires it. 695 // Use a prefix, because xdg-desktop-menu requires it.
696 std::string filename = 696 std::string filename =
697 std::string(chrome::kBrowserProcessExecutableName) + "-" + url.spec(); 697 std::string(chrome::kBrowserProcessExecutableName) + "-" + url.spec();
698 file_util::ReplaceIllegalCharactersInPath(&filename, '_'); 698 base::i18n::ReplaceIllegalCharactersInPath(&filename, '_');
699 699
700 base::FilePath desktop_path; 700 base::FilePath desktop_path;
701 if (!PathService::Get(base::DIR_USER_DESKTOP, &desktop_path)) 701 if (!PathService::Get(base::DIR_USER_DESKTOP, &desktop_path))
702 return base::FilePath(); 702 return base::FilePath();
703 703
704 base::FilePath filepath = desktop_path.Append(filename); 704 base::FilePath filepath = desktop_path.Append(filename);
705 base::FilePath alternative_filepath(filepath.value() + ".desktop"); 705 base::FilePath alternative_filepath(filepath.value() + ".desktop");
706 for (size_t i = 1; i < 100; ++i) { 706 for (size_t i = 1; i < 100; ++i) {
707 if (base::PathExists(base::FilePath(alternative_filepath))) { 707 if (base::PathExists(base::FilePath(alternative_filepath))) {
708 alternative_filepath = base::FilePath( 708 alternative_filepath = base::FilePath(
709 filepath.value() + "_" + base::IntToString(i) + ".desktop"); 709 filepath.value() + "_" + base::IntToString(i) + ".desktop");
710 } else { 710 } else {
711 return base::FilePath(alternative_filepath).BaseName(); 711 return base::FilePath(alternative_filepath).BaseName();
712 } 712 }
713 } 713 }
714 714
715 return base::FilePath(); 715 return base::FilePath();
716 } 716 }
717 717
718 base::FilePath GetExtensionShortcutFilename(const base::FilePath& profile_path, 718 base::FilePath GetExtensionShortcutFilename(const base::FilePath& profile_path,
719 const std::string& extension_id) { 719 const std::string& extension_id) {
720 DCHECK(!extension_id.empty()); 720 DCHECK(!extension_id.empty());
721 721
722 // Use a prefix, because xdg-desktop-menu requires it. 722 // Use a prefix, because xdg-desktop-menu requires it.
723 std::string filename(chrome::kBrowserProcessExecutableName); 723 std::string filename(chrome::kBrowserProcessExecutableName);
724 filename.append("-") 724 filename.append("-")
725 .append(extension_id) 725 .append(extension_id)
726 .append("-") 726 .append("-")
727 .append(profile_path.BaseName().value()); 727 .append(profile_path.BaseName().value());
728 file_util::ReplaceIllegalCharactersInPath(&filename, '_'); 728 base::i18n::ReplaceIllegalCharactersInPath(&filename, '_');
729 // Spaces in filenames break xdg-desktop-menu 729 // Spaces in filenames break xdg-desktop-menu
730 // (see https://bugs.freedesktop.org/show_bug.cgi?id=66605). 730 // (see https://bugs.freedesktop.org/show_bug.cgi?id=66605).
731 base::ReplaceChars(filename, " ", "_", &filename); 731 base::ReplaceChars(filename, " ", "_", &filename);
732 return base::FilePath(filename.append(".desktop")); 732 return base::FilePath(filename.append(".desktop"));
733 } 733 }
734 734
735 std::vector<base::FilePath> GetExistingProfileShortcutFilenames( 735 std::vector<base::FilePath> GetExistingProfileShortcutFilenames(
736 const base::FilePath& profile_path, 736 const base::FilePath& profile_path,
737 const base::FilePath& directory) { 737 const base::FilePath& directory) {
738 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 738 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
739 // Use a prefix, because xdg-desktop-menu requires it. 739 // Use a prefix, because xdg-desktop-menu requires it.
740 std::string prefix(chrome::kBrowserProcessExecutableName); 740 std::string prefix(chrome::kBrowserProcessExecutableName);
741 prefix.append("-"); 741 prefix.append("-");
742 std::string suffix("-"); 742 std::string suffix("-");
743 suffix.append(profile_path.BaseName().value()); 743 suffix.append(profile_path.BaseName().value());
744 file_util::ReplaceIllegalCharactersInPath(&suffix, '_'); 744 base::i18n::ReplaceIllegalCharactersInPath(&suffix, '_');
745 // Spaces in filenames break xdg-desktop-menu 745 // Spaces in filenames break xdg-desktop-menu
746 // (see https://bugs.freedesktop.org/show_bug.cgi?id=66605). 746 // (see https://bugs.freedesktop.org/show_bug.cgi?id=66605).
747 base::ReplaceChars(suffix, " ", "_", &suffix); 747 base::ReplaceChars(suffix, " ", "_", &suffix);
748 std::string glob = prefix + "*" + suffix + ".desktop"; 748 std::string glob = prefix + "*" + suffix + ".desktop";
749 749
750 base::FileEnumerator files(directory, false, base::FileEnumerator::FILES, 750 base::FileEnumerator files(directory, false, base::FileEnumerator::FILES,
751 glob); 751 glob);
752 base::FilePath shortcut_file = files.Next(); 752 base::FilePath shortcut_file = files.Next();
753 std::vector<base::FilePath> shortcut_paths; 753 std::vector<base::FilePath> shortcut_paths;
754 while (!shortcut_file.empty()) { 754 while (!shortcut_file.empty()) {
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after
1072 for (std::vector<base::FilePath>::const_iterator it = 1072 for (std::vector<base::FilePath>::const_iterator it =
1073 shortcut_filenames_app_menu.begin(); 1073 shortcut_filenames_app_menu.begin();
1074 it != shortcut_filenames_app_menu.end(); ++it) { 1074 it != shortcut_filenames_app_menu.end(); ++it) {
1075 DeleteShortcutInApplicationsMenu(*it, 1075 DeleteShortcutInApplicationsMenu(*it,
1076 base::FilePath(kDirectoryFilename)); 1076 base::FilePath(kDirectoryFilename));
1077 } 1077 }
1078 } 1078 }
1079 } 1079 }
1080 1080
1081 } // namespace shell_integration_linux 1081 } // namespace shell_integration_linux
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698