OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
286 } | 286 } |
287 | 287 |
288 LOG(ERROR) << "Could not find desktop file template."; | 288 LOG(ERROR) << "Could not find desktop file template."; |
289 return false; | 289 return false; |
290 } | 290 } |
291 | 291 |
292 // static | 292 // static |
293 FilePath ShellIntegration::GetDesktopShortcutFilename(const GURL& url) { | 293 FilePath ShellIntegration::GetDesktopShortcutFilename(const GURL& url) { |
294 // Use a prefix, because xdg-desktop-menu requires it. | 294 // Use a prefix, because xdg-desktop-menu requires it. |
295 std::string filename = | 295 std::string filename = |
296 WideToUTF8(chrome::kBrowserProcessExecutableName) + "-" + url.spec(); | 296 std::string(chrome::kBrowserProcessExecutableName) + "-" + url.spec(); |
297 file_util::ReplaceIllegalCharactersInPath(&filename, '_'); | 297 file_util::ReplaceIllegalCharactersInPath(&filename, '_'); |
298 | 298 |
299 FilePath desktop_path; | 299 FilePath desktop_path; |
300 if (!PathService::Get(chrome::DIR_USER_DESKTOP, &desktop_path)) | 300 if (!PathService::Get(chrome::DIR_USER_DESKTOP, &desktop_path)) |
301 return FilePath(); | 301 return FilePath(); |
302 | 302 |
303 FilePath filepath = desktop_path.Append(filename); | 303 FilePath filepath = desktop_path.Append(filename); |
304 FilePath alternative_filepath(filepath.value() + ".desktop"); | 304 FilePath alternative_filepath(filepath.value() + ".desktop"); |
305 for (size_t i = 1; i < 100; ++i) { | 305 for (size_t i = 1; i < 100; ++i) { |
306 if (file_util::PathExists(FilePath(alternative_filepath))) { | 306 if (file_util::PathExists(FilePath(alternative_filepath))) { |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
380 std::string contents = GetDesktopFileContents( | 380 std::string contents = GetDesktopFileContents( |
381 shortcut_template, shortcut_info.url, shortcut_info.extension_id, | 381 shortcut_template, shortcut_info.url, shortcut_info.extension_id, |
382 shortcut_info.title, icon_name); | 382 shortcut_info.title, icon_name); |
383 | 383 |
384 if (shortcut_info.create_on_desktop) | 384 if (shortcut_info.create_on_desktop) |
385 CreateShortcutOnDesktop(shortcut_filename, contents); | 385 CreateShortcutOnDesktop(shortcut_filename, contents); |
386 | 386 |
387 if (shortcut_info.create_in_applications_menu) | 387 if (shortcut_info.create_in_applications_menu) |
388 CreateShortcutInApplicationsMenu(shortcut_filename, contents); | 388 CreateShortcutInApplicationsMenu(shortcut_filename, contents); |
389 } | 389 } |
OLD | NEW |