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

Unified Diff: chrome/browser/shell_integration_linux.cc

Issue 12386077: shell_integration_linux: Follow the XDG Base Directory Specification. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Swap /usr/share and /usr/local/share to match the spec. Created 7 years, 10 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
« no previous file with comments | « no previous file | chrome/browser/shell_integration_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/shell_integration_linux.cc
diff --git a/chrome/browser/shell_integration_linux.cc b/chrome/browser/shell_integration_linux.cc
index e7412aeff0f09a63a6101a00455ca726283a20c8..d8f7d7bbe0aa9857d75eee0ee70184c72ca95ca2 100644
--- a/chrome/browser/shell_integration_linux.cc
+++ b/chrome/browser/shell_integration_linux.cc
@@ -463,10 +463,16 @@ bool GetDesktopShortcutTemplate(base::Environment* env,
std::vector<base::FilePath> search_paths;
+ // Search paths as specified in the XDG Base Directory Specification.
+ // http://standards.freedesktop.org/basedir-spec/latest/
std::string xdg_data_home;
+ std::string home;
if (env->GetVar("XDG_DATA_HOME", &xdg_data_home) &&
!xdg_data_home.empty()) {
search_paths.push_back(base::FilePath(xdg_data_home));
+ } else if (env->GetVar("HOME", &home) && !home.empty()) {
+ search_paths.push_back(base::FilePath(home).Append(".local").Append(
+ "share"));
}
std::string xdg_data_dirs;
@@ -476,19 +482,16 @@ bool GetDesktopShortcutTemplate(base::Environment* env,
while (tokenizer.GetNext()) {
base::FilePath data_dir(tokenizer.token());
search_paths.push_back(data_dir);
- search_paths.push_back(data_dir.Append("applications"));
}
+ } else {
+ search_paths.push_back(base::FilePath("/usr/local/share"));
+ search_paths.push_back(base::FilePath("/usr/share"));
}
- // Add some fallback paths for systems which don't have XDG_DATA_DIRS or have
- // it incomplete.
- search_paths.push_back(base::FilePath("/usr/share/applications"));
- search_paths.push_back(base::FilePath("/usr/local/share/applications"));
-
std::string template_filename(GetDesktopName(env));
for (std::vector<base::FilePath>::const_iterator i = search_paths.begin();
i != search_paths.end(); ++i) {
- base::FilePath path = i->Append(template_filename);
+ base::FilePath path = i->Append("applications").Append(template_filename);
VLOG(1) << "Looking for desktop file template in " << path.value();
if (file_util::PathExists(path)) {
VLOG(1) << "Found desktop file template at " << path.value();
« no previous file with comments | « no previous file | chrome/browser/shell_integration_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698