Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(116)

Side by Side Diff: chrome/browser/shell_integration_linux.cc

Issue 271056: Do some cleanup of file path name handling. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/download/save_package.cc ('k') | chrome/browser/views/new_profile_dialog.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 }
OLDNEW
« no previous file with comments | « chrome/browser/download/save_package.cc ('k') | chrome/browser/views/new_profile_dialog.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698