OLD | NEW |
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/web_applications/web_app_win.h" | 5 #include "chrome/browser/web_applications/web_app_win.h" |
6 | 6 |
7 #include <shlobj.h> | 7 #include <shlobj.h> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 // Returns true on success, false on failure. | 160 // Returns true on success, false on failure. |
161 // Must be called on the FILE thread. | 161 // Must be called on the FILE thread. |
162 bool CreateShortcutsInPaths( | 162 bool CreateShortcutsInPaths( |
163 const base::FilePath& web_app_path, | 163 const base::FilePath& web_app_path, |
164 const ShellIntegration::ShortcutInfo& shortcut_info, | 164 const ShellIntegration::ShortcutInfo& shortcut_info, |
165 const std::vector<base::FilePath>& shortcut_paths, | 165 const std::vector<base::FilePath>& shortcut_paths, |
166 web_app::ShortcutCreationReason creation_reason, | 166 web_app::ShortcutCreationReason creation_reason, |
167 std::vector<base::FilePath>* out_filenames) { | 167 std::vector<base::FilePath>* out_filenames) { |
168 // Ensure web_app_path exists. | 168 // Ensure web_app_path exists. |
169 if (!base::PathExists(web_app_path) && | 169 if (!base::PathExists(web_app_path) && |
170 !file_util::CreateDirectory(web_app_path)) { | 170 !base::CreateDirectory(web_app_path)) { |
171 return false; | 171 return false; |
172 } | 172 } |
173 | 173 |
174 // Generates file name to use with persisted ico and shortcut file. | 174 // Generates file name to use with persisted ico and shortcut file. |
175 base::FilePath file_name = | 175 base::FilePath file_name = |
176 web_app::internals::GetSanitizedFileName(shortcut_info.title); | 176 web_app::internals::GetSanitizedFileName(shortcut_info.title); |
177 | 177 |
178 // Creates an ico file to use with shortcut. | 178 // Creates an ico file to use with shortcut. |
179 base::FilePath icon_file = web_app_path.Append(file_name).AddExtension( | 179 base::FilePath icon_file = web_app_path.Append(file_name).AddExtension( |
180 FILE_PATH_LITERAL(".ico")); | 180 FILE_PATH_LITERAL(".ico")); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 } | 237 } |
238 base::win::ShortcutProperties shortcut_properties; | 238 base::win::ShortcutProperties shortcut_properties; |
239 shortcut_properties.set_target(chrome_exe); | 239 shortcut_properties.set_target(chrome_exe); |
240 shortcut_properties.set_working_dir(working_dir); | 240 shortcut_properties.set_working_dir(working_dir); |
241 shortcut_properties.set_arguments(wide_switches); | 241 shortcut_properties.set_arguments(wide_switches); |
242 shortcut_properties.set_description(description); | 242 shortcut_properties.set_description(description); |
243 shortcut_properties.set_icon(icon_file, 0); | 243 shortcut_properties.set_icon(icon_file, 0); |
244 shortcut_properties.set_app_id(app_id); | 244 shortcut_properties.set_app_id(app_id); |
245 shortcut_properties.set_dual_mode(false); | 245 shortcut_properties.set_dual_mode(false); |
246 if (!base::PathExists(shortcut_file.DirName()) && | 246 if (!base::PathExists(shortcut_file.DirName()) && |
247 !file_util::CreateDirectory(shortcut_file.DirName())) { | 247 !base::CreateDirectory(shortcut_file.DirName())) { |
248 NOTREACHED(); | 248 NOTREACHED(); |
249 return false; | 249 return false; |
250 } | 250 } |
251 success = base::win::CreateOrUpdateShortcutLink( | 251 success = base::win::CreateOrUpdateShortcutLink( |
252 shortcut_file, shortcut_properties, | 252 shortcut_file, shortcut_properties, |
253 base::win::SHORTCUT_CREATE_ALWAYS) && success; | 253 base::win::SHORTCUT_CREATE_ALWAYS) && success; |
254 if (out_filenames) | 254 if (out_filenames) |
255 out_filenames->push_back(shortcut_file); | 255 out_filenames->push_back(shortcut_file); |
256 } | 256 } |
257 | 257 |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
524 path = path.Append(locations[i].subdir); | 524 path = path.Append(locations[i].subdir); |
525 shortcut_paths.push_back(path); | 525 shortcut_paths.push_back(path); |
526 } | 526 } |
527 } | 527 } |
528 return shortcut_paths; | 528 return shortcut_paths; |
529 } | 529 } |
530 | 530 |
531 } // namespace internals | 531 } // namespace internals |
532 | 532 |
533 } // namespace web_app | 533 } // namespace web_app |
OLD | NEW |