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

Unified Diff: chrome/browser/shell_integration_linux.cc

Issue 2186813002: Linux: Support the --class argument (Reland) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/shell_integration_linux.cc
diff --git a/chrome/browser/shell_integration_linux.cc b/chrome/browser/shell_integration_linux.cc
index 7e63e1dd943f06c7071f0bbffa990b6a4699728b..1d11e3ea682a859801a3b335fca911c89d63a7cf 100644
--- a/chrome/browser/shell_integration_linux.cc
+++ b/chrome/browser/shell_integration_linux.cc
@@ -208,6 +208,15 @@ DefaultWebClientState GetIsDefaultWebClient(const std::string& protocol) {
#endif
}
+std::string GetDesktopBaseName() {
sky 2016/07/27 15:17:00 Please add comment.
Tom (Use chromium acct) 2016/07/27 19:33:09 Done.
+ std::unique_ptr<base::Environment> env(base::Environment::Create());
+ std::string desktop_file(shell_integration_linux::GetDesktopName(env.get()));
+ std::size_t last = desktop_file.find(".desktop");
+ if (last != std::string::npos)
+ return desktop_file.substr(0, last);
+ return desktop_file;
+}
+
} // namespace
bool SetAsDefaultBrowser() {
@@ -577,12 +586,32 @@ std::vector<base::FilePath> GetDataSearchLocations(base::Environment* env) {
}
std::string GetProgramClassName() {
- std::unique_ptr<base::Environment> env(base::Environment::Create());
- std::string desktop_file(GetDesktopName(env.get()));
- std::size_t last = desktop_file.find(".desktop");
- if (last != std::string::npos)
- return desktop_file.substr(0, last);
- return desktop_file;
+ std::string class_name = shell_integration::GetDesktopBaseName();
+ const base::CommandLine& command_line =
+ *base::CommandLine::ForCurrentProcess();
+ if (command_line.HasSwitch(switches::kUserDataDir)) {
+ // Set the class name to e.g. "Chrome (/tmp/my-user-data)". The
+ // class name will show up in the alt-tab list in gnome-shell if
+ // you're running a binary that doesn't have a matching .desktop
+ // file.
+ const std::string user_data_dir =
+ command_line.GetSwitchValueNative(switches::kUserDataDir);
+ class_name += " (" + user_data_dir + ")";
+ }
+ return class_name;
+}
+
+std::string GetProgramClassClass() {
+ const base::CommandLine& command_line =
+ *base::CommandLine::ForCurrentProcess();
+ if (command_line.HasSwitch(switches::kWmClass))
+ return command_line.GetSwitchValueASCII(switches::kWmClass);
+ std::string class_class = shell_integration::GetDesktopBaseName();
+ if (!class_class.empty()) {
+ // Capitalize the first character like gtk does.
+ class_class[0] = base::ToUpperASCII(class_class[0]);
+ }
+ return class_class;
}
std::string GetDesktopName(base::Environment* env) {

Powered by Google App Engine
This is Rietveld 408576698