OLD | NEW |
---|---|
1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 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.h" | 5 #include "chrome/browser/shell_integration.h" |
6 | 6 |
7 #include <fcntl.h> | 7 #include <fcntl.h> |
8 #include <stdlib.h> | 8 #include <stdlib.h> |
9 #include <sys/stat.h> | 9 #include <sys/stat.h> |
10 #include <sys/types.h> | 10 #include <sys/types.h> |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
70 return false; | 70 return false; |
71 } | 71 } |
72 close(devnull); | 72 close(devnull); |
73 | 73 |
74 int success_code; | 74 int success_code; |
75 base::WaitForExitCode(handle, &success_code); | 75 base::WaitForExitCode(handle, &success_code); |
76 return success_code == EXIT_SUCCESS; | 76 return success_code == EXIT_SUCCESS; |
77 } | 77 } |
78 | 78 |
79 bool GetDesktopShortcutTemplate(std::string* output) { | 79 bool GetDesktopShortcutTemplate(std::string* output) { |
80 std::vector<std::string> search_paths; | 80 std::vector<FilePath> search_paths; |
81 | 81 |
82 const char* xdg_data_home = getenv("XDG_DATA_HOME"); | 82 const char* xdg_data_home = getenv("XDG_DATA_HOME"); |
83 if (xdg_data_home) | 83 if (xdg_data_home) |
84 search_paths.push_back(xdg_data_home); | 84 search_paths.push_back(FilePath(xdg_data_home)); |
85 | 85 |
86 const char* xdg_data_dirs = getenv("XDG_DATA_DIRS"); | 86 const char* xdg_data_dirs = getenv("XDG_DATA_DIRS"); |
87 if (xdg_data_dirs) { | 87 if (xdg_data_dirs) { |
88 CStringTokenizer tokenizer(xdg_data_dirs, | 88 CStringTokenizer tokenizer(xdg_data_dirs, |
89 xdg_data_dirs + strlen(xdg_data_dirs), ":"); | 89 xdg_data_dirs + strlen(xdg_data_dirs), ":"); |
90 while (tokenizer.GetNext()) { | 90 while (tokenizer.GetNext()) { |
91 search_paths.push_back(tokenizer.token()); | 91 FilePath data_dir(tokenizer.token()); |
92 search_paths.push_back(data_dir); | |
93 search_paths.push_back(data_dir.Append("applications")); | |
Mike Mammarella
2009/09/17 17:23:53
Technically the string constant should be wrapped
| |
92 } | 94 } |
93 } | 95 } |
94 | 96 |
95 std::string template_filename(GetDesktopName()); | 97 std::string template_filename(GetDesktopName()); |
96 for (std::vector<std::string>::const_iterator i = search_paths.begin(); | 98 for (std::vector<FilePath>::const_iterator i = search_paths.begin(); |
97 i != search_paths.end(); ++i) { | 99 i != search_paths.end(); ++i) { |
98 FilePath path = FilePath(*i).Append(template_filename); | 100 FilePath path = (*i).Append(template_filename); |
99 if (file_util::PathExists(path)) | 101 if (file_util::PathExists(path)) |
100 return file_util::ReadFileToString(path, output); | 102 return file_util::ReadFileToString(path, output); |
101 } | 103 } |
102 | 104 |
103 return false; | 105 return false; |
104 } | 106 } |
105 | 107 |
106 class CreateDesktopShortcutTask : public Task { | 108 class CreateDesktopShortcutTask : public Task { |
107 public: | 109 public: |
108 CreateDesktopShortcutTask(const ShellIntegration::ShortcutInfo& shortcut_info) | 110 CreateDesktopShortcutTask(const ShellIntegration::ShortcutInfo& shortcut_info) |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
260 } | 262 } |
261 } | 263 } |
262 return output_buffer; | 264 return output_buffer; |
263 } | 265 } |
264 | 266 |
265 void ShellIntegration::CreateDesktopShortcut( | 267 void ShellIntegration::CreateDesktopShortcut( |
266 const ShortcutInfo& shortcut_info) { | 268 const ShortcutInfo& shortcut_info) { |
267 g_browser_process->file_thread()->message_loop()->PostTask(FROM_HERE, | 269 g_browser_process->file_thread()->message_loop()->PostTask(FROM_HERE, |
268 new CreateDesktopShortcutTask(shortcut_info)); | 270 new CreateDesktopShortcutTask(shortcut_info)); |
269 } | 271 } |
OLD | NEW |