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

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

Issue 276673002: Fix build by adding a guard to exclude glib code. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Updated patch Created 6 years, 7 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
9 #if defined(USE_GLIB)
8 #include <glib.h> 10 #include <glib.h>
11 #endif
12
9 #include <stdlib.h> 13 #include <stdlib.h>
10 #include <sys/stat.h> 14 #include <sys/stat.h>
11 #include <sys/types.h> 15 #include <sys/types.h>
12 #include <unistd.h> 16 #include <unistd.h>
13 17
14 #include <string> 18 #include <string>
15 #include <vector> 19 #include <vector>
16 20
17 #include "base/base_paths.h" 21 #include "base/base_paths.h"
18 #include "base/command_line.h" 22 #include "base/command_line.h"
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 441
438 // Allow any reply that starts with "yes". 442 // Allow any reply that starts with "yes".
439 return (reply.find("yes") == 0) ? ShellIntegration::IS_DEFAULT : 443 return (reply.find("yes") == 0) ? ShellIntegration::IS_DEFAULT :
440 ShellIntegration::NOT_DEFAULT; 444 ShellIntegration::NOT_DEFAULT;
441 #endif 445 #endif
442 } 446 }
443 447
444 // Get the value of NoDisplay from the [Desktop Entry] section of a .desktop 448 // Get the value of NoDisplay from the [Desktop Entry] section of a .desktop
445 // file, given in |shortcut_contents|. If the key is not found, returns false. 449 // file, given in |shortcut_contents|. If the key is not found, returns false.
446 bool GetNoDisplayFromDesktopFile(const std::string& shortcut_contents) { 450 bool GetNoDisplayFromDesktopFile(const std::string& shortcut_contents) {
451 #if defined(USE_GLIB)
447 // An empty file causes a crash with glib <= 2.32, so special case here. 452 // An empty file causes a crash with glib <= 2.32, so special case here.
448 if (shortcut_contents.empty()) 453 if (shortcut_contents.empty())
449 return false; 454 return false;
450 455
451 GKeyFile* key_file = g_key_file_new(); 456 GKeyFile* key_file = g_key_file_new();
452 GError* err = NULL; 457 GError* err = NULL;
453 if (!g_key_file_load_from_data(key_file, shortcut_contents.c_str(), 458 if (!g_key_file_load_from_data(key_file, shortcut_contents.c_str(),
454 shortcut_contents.size(), G_KEY_FILE_NONE, 459 shortcut_contents.size(), G_KEY_FILE_NONE,
455 &err)) { 460 &err)) {
456 LOG(WARNING) << "Unable to read desktop file template: " << err->message; 461 LOG(WARNING) << "Unable to read desktop file template: " << err->message;
457 g_error_free(err); 462 g_error_free(err);
458 g_key_file_free(key_file); 463 g_key_file_free(key_file);
459 return false; 464 return false;
460 } 465 }
461 466
462 bool nodisplay = false; 467 bool nodisplay = false;
463 char* nodisplay_c_string = g_key_file_get_string(key_file, kDesktopEntry, 468 char* nodisplay_c_string = g_key_file_get_string(key_file, kDesktopEntry,
464 "NoDisplay", &err); 469 "NoDisplay", &err);
465 if (nodisplay_c_string) { 470 if (nodisplay_c_string) {
466 if (!g_strcmp0(nodisplay_c_string, "true")) 471 if (!g_strcmp0(nodisplay_c_string, "true"))
467 nodisplay = true; 472 nodisplay = true;
468 g_free(nodisplay_c_string); 473 g_free(nodisplay_c_string);
469 } else { 474 } else {
470 g_error_free(err); 475 g_error_free(err);
471 } 476 }
472 477
473 g_key_file_free(key_file); 478 g_key_file_free(key_file);
474 return nodisplay; 479 return nodisplay;
480 #else
481 NOTIMPLEMENTED();
482 return false;
483 #endif
475 } 484 }
476 485
477 // Gets the path to the Chrome executable or wrapper script. 486 // Gets the path to the Chrome executable or wrapper script.
478 // Returns an empty path if the executable path could not be found. 487 // Returns an empty path if the executable path could not be found.
479 base::FilePath GetChromeExePath() { 488 base::FilePath GetChromeExePath() {
480 // Try to get the name of the wrapper script that launched Chrome. 489 // Try to get the name of the wrapper script that launched Chrome.
481 scoped_ptr<base::Environment> environment(base::Environment::Create()); 490 scoped_ptr<base::Environment> environment(base::Environment::Create());
482 std::string wrapper_script; 491 std::string wrapper_script;
483 if (environment->GetVar("CHROME_WRAPPER", &wrapper_script)) { 492 if (environment->GetVar("CHROME_WRAPPER", &wrapper_script)) {
484 return base::FilePath(wrapper_script); 493 return base::FilePath(wrapper_script);
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
771 } 780 }
772 781
773 std::string GetDesktopFileContentsForCommand( 782 std::string GetDesktopFileContentsForCommand(
774 const CommandLine& command_line, 783 const CommandLine& command_line,
775 const std::string& app_name, 784 const std::string& app_name,
776 const GURL& url, 785 const GURL& url,
777 const base::string16& title, 786 const base::string16& title,
778 const std::string& icon_name, 787 const std::string& icon_name,
779 const std::string& categories, 788 const std::string& categories,
780 bool no_display) { 789 bool no_display) {
790 #if defined(USE_GLIB)
781 // Although not required by the spec, Nautilus on Ubuntu Karmic creates its 791 // Although not required by the spec, Nautilus on Ubuntu Karmic creates its
782 // launchers with an xdg-open shebang. Follow that convention. 792 // launchers with an xdg-open shebang. Follow that convention.
783 std::string output_buffer = std::string(kXdgOpenShebang) + "\n"; 793 std::string output_buffer = std::string(kXdgOpenShebang) + "\n";
784 794
785 // See http://standards.freedesktop.org/desktop-entry-spec/latest/ 795 // See http://standards.freedesktop.org/desktop-entry-spec/latest/
786 GKeyFile* key_file = g_key_file_new(); 796 GKeyFile* key_file = g_key_file_new();
787 797
788 // Set keys with fixed values. 798 // Set keys with fixed values.
789 g_key_file_set_string(key_file, kDesktopEntry, "Version", "1.0"); 799 g_key_file_set_string(key_file, kDesktopEntry, "Version", "1.0");
790 g_key_file_set_string(key_file, kDesktopEntry, "Terminal", "false"); 800 g_key_file_set_string(key_file, kDesktopEntry, "Terminal", "false");
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
837 // remove it to avoid double-newline after the shebang. 847 // remove it to avoid double-newline after the shebang.
838 output_buffer += (data_dump + 1); 848 output_buffer += (data_dump + 1);
839 } else { 849 } else {
840 output_buffer += data_dump; 850 output_buffer += data_dump;
841 } 851 }
842 g_free(data_dump); 852 g_free(data_dump);
843 } 853 }
844 854
845 g_key_file_free(key_file); 855 g_key_file_free(key_file);
846 return output_buffer; 856 return output_buffer;
857 #else
858 NOTIMPLEMENTED();
859 return std::string("");
Lei Zhang 2014/05/23 08:48:22 nit: std::string()
860 #endif
847 } 861 }
848 862
849 std::string GetDirectoryFileContents(const base::string16& title, 863 std::string GetDirectoryFileContents(const base::string16& title,
850 const std::string& icon_name) { 864 const std::string& icon_name) {
865 #if defined(USE_GLIB)
851 // See http://standards.freedesktop.org/desktop-entry-spec/latest/ 866 // See http://standards.freedesktop.org/desktop-entry-spec/latest/
852 GKeyFile* key_file = g_key_file_new(); 867 GKeyFile* key_file = g_key_file_new();
853 868
854 g_key_file_set_string(key_file, kDesktopEntry, "Version", "1.0"); 869 g_key_file_set_string(key_file, kDesktopEntry, "Version", "1.0");
855 g_key_file_set_string(key_file, kDesktopEntry, "Type", "Directory"); 870 g_key_file_set_string(key_file, kDesktopEntry, "Type", "Directory");
856 std::string final_title = base::UTF16ToUTF8(title); 871 std::string final_title = base::UTF16ToUTF8(title);
857 g_key_file_set_string(key_file, kDesktopEntry, "Name", final_title.c_str()); 872 g_key_file_set_string(key_file, kDesktopEntry, "Name", final_title.c_str());
858 if (!icon_name.empty()) { 873 if (!icon_name.empty()) {
859 g_key_file_set_string(key_file, kDesktopEntry, "Icon", icon_name.c_str()); 874 g_key_file_set_string(key_file, kDesktopEntry, "Icon", icon_name.c_str());
860 } else { 875 } else {
(...skipping 11 matching lines...) Expand all
872 // remove it to avoid double-newline after the shebang. 887 // remove it to avoid double-newline after the shebang.
873 output_buffer += (data_dump + 1); 888 output_buffer += (data_dump + 1);
874 } else { 889 } else {
875 output_buffer += data_dump; 890 output_buffer += data_dump;
876 } 891 }
877 g_free(data_dump); 892 g_free(data_dump);
878 } 893 }
879 894
880 g_key_file_free(key_file); 895 g_key_file_free(key_file);
881 return output_buffer; 896 return output_buffer;
897 #else
898 NOTIMPLEMENTED();
899 return std::string("");
900 #endif
882 } 901 }
883 902
884 bool CreateDesktopShortcut( 903 bool CreateDesktopShortcut(
885 const web_app::ShortcutInfo& shortcut_info, 904 const web_app::ShortcutInfo& shortcut_info,
886 const web_app::ShortcutLocations& creation_locations) { 905 const web_app::ShortcutLocations& creation_locations) {
887 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 906 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
888 907
889 base::FilePath shortcut_filename; 908 base::FilePath shortcut_filename;
890 if (!shortcut_info.extension_id.empty()) { 909 if (!shortcut_info.extension_id.empty()) {
891 shortcut_filename = GetExtensionShortcutFilename( 910 shortcut_filename = GetExtensionShortcutFilename(
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
1056 for (std::vector<base::FilePath>::const_iterator it = 1075 for (std::vector<base::FilePath>::const_iterator it =
1057 shortcut_filenames_app_menu.begin(); 1076 shortcut_filenames_app_menu.begin();
1058 it != shortcut_filenames_app_menu.end(); ++it) { 1077 it != shortcut_filenames_app_menu.end(); ++it) {
1059 DeleteShortcutInApplicationsMenu(*it, 1078 DeleteShortcutInApplicationsMenu(*it,
1060 base::FilePath(kDirectoryFilename)); 1079 base::FilePath(kDirectoryFilename));
1061 } 1080 }
1062 } 1081 }
1063 } 1082 }
1064 1083
1065 } // namespace ShellIntegrationLinux 1084 } // namespace ShellIntegrationLinux
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698