Skip to content
Snippets Groups Projects
Commit fd928963 authored by phajdan.jr@chromium.org's avatar phajdan.jr@chromium.org
Browse files

More reliably find the .desktop file for the browser.

Also search in "applications" subdirectory of each of XDG_DATA_DIRS.

TEST=See bug.
BUG=21995

Review URL: http://codereview.chromium.org/214010

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@26590 0039d316-1c4b-4281-b951-d872f2087c98
parent 5895c5bb
No related merge requests found
......@@ -77,25 +77,27 @@ bool LaunchXdgUtility(const std::vector<std::string>& argv) {
}
bool GetDesktopShortcutTemplate(std::string* output) {
std::vector<std::string> search_paths;
std::vector<FilePath> search_paths;
const char* xdg_data_home = getenv("XDG_DATA_HOME");
if (xdg_data_home)
search_paths.push_back(xdg_data_home);
search_paths.push_back(FilePath(xdg_data_home));
const char* xdg_data_dirs = getenv("XDG_DATA_DIRS");
if (xdg_data_dirs) {
CStringTokenizer tokenizer(xdg_data_dirs,
xdg_data_dirs + strlen(xdg_data_dirs), ":");
while (tokenizer.GetNext()) {
search_paths.push_back(tokenizer.token());
FilePath data_dir(tokenizer.token());
search_paths.push_back(data_dir);
search_paths.push_back(data_dir.Append("applications"));
}
}
std::string template_filename(GetDesktopName());
for (std::vector<std::string>::const_iterator i = search_paths.begin();
for (std::vector<FilePath>::const_iterator i = search_paths.begin();
i != search_paths.end(); ++i) {
FilePath path = FilePath(*i).Append(template_filename);
FilePath path = (*i).Append(template_filename);
if (file_util::PathExists(path))
return file_util::ReadFileToString(path, output);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment