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> |
11 #include <unistd.h> | 11 #include <unistd.h> |
12 | 12 |
13 #include <string> | 13 #include <string> |
14 #include <vector> | 14 #include <vector> |
15 | 15 |
16 #include "base/command_line.h" | 16 #include "base/command_line.h" |
17 #include "base/eintr_wrapper.h" | 17 #include "base/eintr_wrapper.h" |
18 #include "base/env_var.h" | 18 #include "base/env_var.h" |
19 #include "base/file_path.h" | 19 #include "base/file_path.h" |
20 #include "base/file_util.h" | 20 #include "base/file_util.h" |
21 #include "base/i18n/file_util_icu.h" | 21 #include "base/i18n/file_util_icu.h" |
22 #include "base/message_loop.h" | 22 #include "base/message_loop.h" |
23 #include "base/path_service.h" | 23 #include "base/path_service.h" |
24 #include "base/process_util.h" | 24 #include "base/process_util.h" |
25 #include "base/scoped_temp_dir.h" | 25 #include "base/scoped_temp_dir.h" |
26 #include "base/string_tokenizer.h" | 26 #include "base/string_tokenizer.h" |
27 #include "base/string_util.h" | 27 #include "base/string_util.h" |
28 #include "base/task.h" | 28 #include "base/task.h" |
29 #include "base/thread.h" | 29 #include "base/thread.h" |
| 30 #include "base/string_number_conversions.h" |
30 #include "base/utf_string_conversions.h" | 31 #include "base/utf_string_conversions.h" |
31 #include "chrome/browser/browser_process.h" | 32 #include "chrome/browser/browser_process.h" |
32 #include "chrome/common/chrome_constants.h" | 33 #include "chrome/common/chrome_constants.h" |
33 #include "chrome/common/chrome_paths.h" | 34 #include "chrome/common/chrome_paths.h" |
34 #include "chrome/common/chrome_plugin_util.h" | 35 #include "chrome/common/chrome_plugin_util.h" |
35 #include "chrome/common/chrome_switches.h" | 36 #include "chrome/common/chrome_switches.h" |
36 #include "chrome/browser/chrome_thread.h" | 37 #include "chrome/browser/chrome_thread.h" |
37 #include "gfx/codec/png_codec.h" | 38 #include "gfx/codec/png_codec.h" |
38 #include "googleurl/src/gurl.h" | 39 #include "googleurl/src/gurl.h" |
39 | 40 |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
296 file_util::ReplaceIllegalCharactersInPath(&filename, '_'); | 297 file_util::ReplaceIllegalCharactersInPath(&filename, '_'); |
297 | 298 |
298 FilePath desktop_path; | 299 FilePath desktop_path; |
299 if (!PathService::Get(chrome::DIR_USER_DESKTOP, &desktop_path)) | 300 if (!PathService::Get(chrome::DIR_USER_DESKTOP, &desktop_path)) |
300 return FilePath(); | 301 return FilePath(); |
301 | 302 |
302 FilePath filepath = desktop_path.Append(filename); | 303 FilePath filepath = desktop_path.Append(filename); |
303 FilePath alternative_filepath(filepath.value() + ".desktop"); | 304 FilePath alternative_filepath(filepath.value() + ".desktop"); |
304 for (size_t i = 1; i < 100; ++i) { | 305 for (size_t i = 1; i < 100; ++i) { |
305 if (file_util::PathExists(FilePath(alternative_filepath))) { | 306 if (file_util::PathExists(FilePath(alternative_filepath))) { |
306 alternative_filepath = FilePath(filepath.value() + "_" + IntToString(i) + | 307 alternative_filepath = FilePath( |
307 ".desktop"); | 308 filepath.value() + "_" + base::IntToString(i) + ".desktop"); |
308 } else { | 309 } else { |
309 return FilePath(alternative_filepath).BaseName(); | 310 return FilePath(alternative_filepath).BaseName(); |
310 } | 311 } |
311 } | 312 } |
312 | 313 |
313 return FilePath(); | 314 return FilePath(); |
314 } | 315 } |
315 | 316 |
316 // static | 317 // static |
317 std::string ShellIntegration::GetDesktopFileContents( | 318 std::string ShellIntegration::GetDesktopFileContents( |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
379 std::string contents = GetDesktopFileContents( | 380 std::string contents = GetDesktopFileContents( |
380 shortcut_template, shortcut_info.url, shortcut_info.extension_id, | 381 shortcut_template, shortcut_info.url, shortcut_info.extension_id, |
381 shortcut_info.title, icon_name); | 382 shortcut_info.title, icon_name); |
382 | 383 |
383 if (shortcut_info.create_on_desktop) | 384 if (shortcut_info.create_on_desktop) |
384 CreateShortcutOnDesktop(shortcut_filename, contents); | 385 CreateShortcutOnDesktop(shortcut_filename, contents); |
385 | 386 |
386 if (shortcut_info.create_in_applications_menu) | 387 if (shortcut_info.create_in_applications_menu) |
387 CreateShortcutInApplicationsMenu(shortcut_filename, contents); | 388 CreateShortcutInApplicationsMenu(shortcut_filename, contents); |
388 } | 389 } |
OLD | NEW |