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

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

Issue 23093020: Set the WM_CLASS property of X11 windows in Linux Aura build. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Respond to reviews. Created 7 years, 3 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
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 527 matching lines...) Expand 10 before | Expand all | Expand 10 after
538 search_paths.push_back(data_dir); 538 search_paths.push_back(data_dir);
539 } 539 }
540 } else { 540 } else {
541 search_paths.push_back(base::FilePath("/usr/local/share")); 541 search_paths.push_back(base::FilePath("/usr/local/share"));
542 search_paths.push_back(base::FilePath("/usr/share")); 542 search_paths.push_back(base::FilePath("/usr/share"));
543 } 543 }
544 544
545 return search_paths; 545 return search_paths;
546 } 546 }
547 547
548 std::string GetProgramClassName() {
549 DCHECK(CommandLine::InitializedForCurrentProcess());
550 // Get the res_name component from argv[0].
551 const CommandLine* command_line = CommandLine::ForCurrentProcess();
552 std::string class_name = command_line->GetProgram().BaseName().value();
553 if (!class_name.empty())
554 class_name[0] = base::ToUpperASCII(class_name[0]);
555 return class_name;
556 }
557
548 std::string GetDesktopName(base::Environment* env) { 558 std::string GetDesktopName(base::Environment* env) {
549 #if defined(GOOGLE_CHROME_BUILD) 559 #if defined(GOOGLE_CHROME_BUILD)
550 return "google-chrome.desktop"; 560 return "google-chrome.desktop";
551 #else // CHROMIUM_BUILD 561 #else // CHROMIUM_BUILD
552 // Allow $CHROME_DESKTOP to override the built-in value, so that development 562 // Allow $CHROME_DESKTOP to override the built-in value, so that development
553 // versions can set themselves as the default without interfering with 563 // versions can set themselves as the default without interfering with
554 // non-official, packaged versions using the built-in value. 564 // non-official, packaged versions using the built-in value.
555 std::string name; 565 std::string name;
556 if (env->GetVar("CHROME_DESKTOP", &name) && !name.empty()) 566 if (env->GetVar("CHROME_DESKTOP", &name) && !name.empty())
557 return name; 567 return name;
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
754 g_key_file_set_string(key_file, kDesktopEntry, "Icon", icon_name.c_str()); 764 g_key_file_set_string(key_file, kDesktopEntry, "Icon", icon_name.c_str());
755 } else { 765 } else {
756 g_key_file_set_string(key_file, kDesktopEntry, "Icon", 766 g_key_file_set_string(key_file, kDesktopEntry, "Icon",
757 GetIconName().c_str()); 767 GetIconName().c_str());
758 } 768 }
759 769
760 // Set the "NoDisplay" key. 770 // Set the "NoDisplay" key.
761 if (no_display) 771 if (no_display)
762 g_key_file_set_string(key_file, kDesktopEntry, "NoDisplay", "true"); 772 g_key_file_set_string(key_file, kDesktopEntry, "NoDisplay", "true");
763 773
764 #if defined(TOOLKIT_GTK)
765 std::string wmclass = web_app::GetWMClassFromAppName(app_name); 774 std::string wmclass = web_app::GetWMClassFromAppName(app_name);
766 g_key_file_set_string(key_file, kDesktopEntry, "StartupWMClass", 775 g_key_file_set_string(key_file, kDesktopEntry, "StartupWMClass",
767 wmclass.c_str()); 776 wmclass.c_str());
768 #endif
769 777
770 gsize length = 0; 778 gsize length = 0;
771 gchar* data_dump = g_key_file_to_data(key_file, &length, NULL); 779 gchar* data_dump = g_key_file_to_data(key_file, &length, NULL);
772 if (data_dump) { 780 if (data_dump) {
773 // If strlen(data_dump[0]) == 0, this check will fail. 781 // If strlen(data_dump[0]) == 0, this check will fail.
774 if (data_dump[0] == '\n') { 782 if (data_dump[0] == '\n') {
775 // Older versions of glib produce a leading newline. If this is the case, 783 // Older versions of glib produce a leading newline. If this is the case,
776 // remove it to avoid double-newline after the shebang. 784 // remove it to avoid double-newline after the shebang.
777 output_buffer += (data_dump + 1); 785 output_buffer += (data_dump + 1);
778 } else { 786 } else {
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
942 for (std::vector<base::FilePath>::const_iterator it = 950 for (std::vector<base::FilePath>::const_iterator it =
943 shortcut_filenames_app_menu.begin(); 951 shortcut_filenames_app_menu.begin();
944 it != shortcut_filenames_app_menu.end(); ++it) { 952 it != shortcut_filenames_app_menu.end(); ++it) {
945 DeleteShortcutInApplicationsMenu(*it, 953 DeleteShortcutInApplicationsMenu(*it,
946 base::FilePath(kDirectoryFilename)); 954 base::FilePath(kDirectoryFilename));
947 } 955 }
948 } 956 }
949 } 957 }
950 958
951 } // namespace ShellIntegrationLinux 959 } // namespace ShellIntegrationLinux
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698