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

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

Issue 120983002: Update some uses of UTF conversions in chrome/browser to use the base:: namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 12 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 #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 718 matching lines...) Expand 10 before | Expand all | Expand 10 after
729 729
730 // See http://standards.freedesktop.org/desktop-entry-spec/latest/ 730 // See http://standards.freedesktop.org/desktop-entry-spec/latest/
731 GKeyFile* key_file = g_key_file_new(); 731 GKeyFile* key_file = g_key_file_new();
732 732
733 // Set keys with fixed values. 733 // Set keys with fixed values.
734 g_key_file_set_string(key_file, kDesktopEntry, "Version", "1.0"); 734 g_key_file_set_string(key_file, kDesktopEntry, "Version", "1.0");
735 g_key_file_set_string(key_file, kDesktopEntry, "Terminal", "false"); 735 g_key_file_set_string(key_file, kDesktopEntry, "Terminal", "false");
736 g_key_file_set_string(key_file, kDesktopEntry, "Type", "Application"); 736 g_key_file_set_string(key_file, kDesktopEntry, "Type", "Application");
737 737
738 // Set the "Name" key. 738 // Set the "Name" key.
739 std::string final_title = UTF16ToUTF8(title); 739 std::string final_title = base::UTF16ToUTF8(title);
740 // Make sure no endline characters can slip in and possibly introduce 740 // Make sure no endline characters can slip in and possibly introduce
741 // additional lines (like Exec, which makes it a security risk). Also 741 // additional lines (like Exec, which makes it a security risk). Also
742 // use the URL as a default when the title is empty. 742 // use the URL as a default when the title is empty.
743 if (final_title.empty() || 743 if (final_title.empty() ||
744 final_title.find("\n") != std::string::npos || 744 final_title.find("\n") != std::string::npos ||
745 final_title.find("\r") != std::string::npos) { 745 final_title.find("\r") != std::string::npos) {
746 final_title = url.spec(); 746 final_title = url.spec();
747 } 747 }
748 g_key_file_set_string(key_file, kDesktopEntry, "Name", final_title.c_str()); 748 g_key_file_set_string(key_file, kDesktopEntry, "Name", final_title.c_str());
749 749
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
799 return output_buffer; 799 return output_buffer;
800 } 800 }
801 801
802 std::string GetDirectoryFileContents(const base::string16& title, 802 std::string GetDirectoryFileContents(const base::string16& title,
803 const std::string& icon_name) { 803 const std::string& icon_name) {
804 // See http://standards.freedesktop.org/desktop-entry-spec/latest/ 804 // See http://standards.freedesktop.org/desktop-entry-spec/latest/
805 GKeyFile* key_file = g_key_file_new(); 805 GKeyFile* key_file = g_key_file_new();
806 806
807 g_key_file_set_string(key_file, kDesktopEntry, "Version", "1.0"); 807 g_key_file_set_string(key_file, kDesktopEntry, "Version", "1.0");
808 g_key_file_set_string(key_file, kDesktopEntry, "Type", "Directory"); 808 g_key_file_set_string(key_file, kDesktopEntry, "Type", "Directory");
809 std::string final_title = UTF16ToUTF8(title); 809 std::string final_title = base::UTF16ToUTF8(title);
810 g_key_file_set_string(key_file, kDesktopEntry, "Name", final_title.c_str()); 810 g_key_file_set_string(key_file, kDesktopEntry, "Name", final_title.c_str());
811 if (!icon_name.empty()) { 811 if (!icon_name.empty()) {
812 g_key_file_set_string(key_file, kDesktopEntry, "Icon", icon_name.c_str()); 812 g_key_file_set_string(key_file, kDesktopEntry, "Icon", icon_name.c_str());
813 } else { 813 } else {
814 g_key_file_set_string(key_file, kDesktopEntry, "Icon", 814 g_key_file_set_string(key_file, kDesktopEntry, "Icon",
815 GetIconName().c_str()); 815 GetIconName().c_str());
816 } 816 }
817 817
818 gsize length = 0; 818 gsize length = 0;
819 gchar* data_dump = g_key_file_to_data(key_file, &length, NULL); 819 gchar* data_dump = g_key_file_to_data(key_file, &length, NULL);
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
968 for (std::vector<base::FilePath>::const_iterator it = 968 for (std::vector<base::FilePath>::const_iterator it =
969 shortcut_filenames_app_menu.begin(); 969 shortcut_filenames_app_menu.begin();
970 it != shortcut_filenames_app_menu.end(); ++it) { 970 it != shortcut_filenames_app_menu.end(); ++it) {
971 DeleteShortcutInApplicationsMenu(*it, 971 DeleteShortcutInApplicationsMenu(*it,
972 base::FilePath(kDirectoryFilename)); 972 base::FilePath(kDirectoryFilename));
973 } 973 }
974 } 974 }
975 } 975 }
976 976
977 } // namespace ShellIntegrationLinux 977 } // namespace ShellIntegrationLinux
OLDNEW
« no previous file with comments | « chrome/browser/sessions/tab_restore_browsertest.cc ('k') | chrome/browser/shell_integration_linux_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698