| 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 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 296 argv.push_back("default-web-browser"); | 296 argv.push_back("default-web-browser"); |
| 297 | 297 |
| 298 std::string browser; | 298 std::string browser; |
| 299 // We don't care about the return value here. | 299 // We don't care about the return value here. |
| 300 base::GetAppOutput(CommandLine(argv), &browser); | 300 base::GetAppOutput(CommandLine(argv), &browser); |
| 301 return browser.find("irefox") != std::string::npos; | 301 return browser.find("irefox") != std::string::npos; |
| 302 } | 302 } |
| 303 | 303 |
| 304 FilePath ShellIntegration::GetDesktopShortcutFilename(const GURL& url) { | 304 FilePath ShellIntegration::GetDesktopShortcutFilename(const GURL& url) { |
| 305 // Use a prefix, because xdg-desktop-menu requires it. | 305 // Use a prefix, because xdg-desktop-menu requires it. |
| 306 std::wstring filename_wide = | 306 std::string filename = |
| 307 std::wstring(chrome::kBrowserProcessExecutableName) + L"-" + | 307 WideToUTF8(chrome::kBrowserProcessExecutableName) + "-" + url.spec(); |
| 308 UTF8ToWide(url.spec()); | 308 file_util::ReplaceIllegalCharactersInPath(&filename, '_'); |
| 309 file_util::ReplaceIllegalCharacters(&filename_wide, '_'); | |
| 310 | 309 |
| 311 FilePath desktop_path; | 310 FilePath desktop_path; |
| 312 if (!PathService::Get(chrome::DIR_USER_DESKTOP, &desktop_path)) | 311 if (!PathService::Get(chrome::DIR_USER_DESKTOP, &desktop_path)) |
| 313 return FilePath(); | 312 return FilePath(); |
| 314 | 313 |
| 315 FilePath filepath = desktop_path.Append( | 314 FilePath filepath = desktop_path.Append(filename); |
| 316 FilePath::FromWStringHack(filename_wide)); | |
| 317 FilePath alternative_filepath(filepath.value() + ".desktop"); | 315 FilePath alternative_filepath(filepath.value() + ".desktop"); |
| 318 for (size_t i = 1; i < 100; ++i) { | 316 for (size_t i = 1; i < 100; ++i) { |
| 319 if (file_util::PathExists(FilePath(alternative_filepath))) { | 317 if (file_util::PathExists(FilePath(alternative_filepath))) { |
| 320 alternative_filepath = FilePath(filepath.value() + "_" + IntToString(i) + | 318 alternative_filepath = FilePath(filepath.value() + "_" + IntToString(i) + |
| 321 ".desktop"); | 319 ".desktop"); |
| 322 } else { | 320 } else { |
| 323 return FilePath(alternative_filepath).BaseName(); | 321 return FilePath(alternative_filepath).BaseName(); |
| 324 } | 322 } |
| 325 } | 323 } |
| 326 | 324 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 370 } | 368 } |
| 371 } | 369 } |
| 372 return output_buffer; | 370 return output_buffer; |
| 373 } | 371 } |
| 374 | 372 |
| 375 void ShellIntegration::CreateDesktopShortcut( | 373 void ShellIntegration::CreateDesktopShortcut( |
| 376 const ShortcutInfo& shortcut_info) { | 374 const ShortcutInfo& shortcut_info) { |
| 377 g_browser_process->file_thread()->message_loop()->PostTask(FROM_HERE, | 375 g_browser_process->file_thread()->message_loop()->PostTask(FROM_HERE, |
| 378 new CreateDesktopShortcutTask(shortcut_info)); | 376 new CreateDesktopShortcutTask(shortcut_info)); |
| 379 } | 377 } |
| OLD | NEW |