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/shell_integration_linux.h" | 5 #include "chrome/browser/shell_integration_linux.h" |
6 | 6 |
7 #include <fcntl.h> | 7 #include <fcntl.h> |
8 #include <glib.h> | 8 #include <glib.h> |
9 #include <stdlib.h> | 9 #include <stdlib.h> |
10 #include <sys/stat.h> | 10 #include <sys/stat.h> |
11 #include <sys/types.h> | 11 #include <sys/types.h> |
12 #include <unistd.h> | 12 #include <unistd.h> |
13 | 13 |
14 #include <string> | 14 #include <string> |
15 #include <vector> | 15 #include <vector> |
16 | 16 |
17 #include "base/base_paths.h" | 17 #include "base/base_paths.h" |
18 #include "base/command_line.h" | 18 #include "base/command_line.h" |
19 #include "base/environment.h" | 19 #include "base/environment.h" |
20 #include "base/file_path.h" | 20 #include "base/file_path.h" |
21 #include "base/file_util.h" | 21 #include "base/file_util.h" |
22 #include "base/files/scoped_temp_dir.h" | 22 #include "base/files/scoped_temp_dir.h" |
23 #include "base/i18n/file_util_icu.h" | 23 #include "base/i18n/file_util_icu.h" |
24 #include "base/message_loop.h" | 24 #include "base/message_loop.h" |
25 #include "base/path_service.h" | 25 #include "base/path_service.h" |
26 #include "base/posix/eintr_wrapper.h" | 26 #include "base/posix/eintr_wrapper.h" |
27 #include "base/process_util.h" | 27 #include "base/process_util.h" |
28 #include "base/string_number_conversions.h" | 28 #include "base/string_number_conversions.h" |
29 #include "base/string_tokenizer.h" | 29 #include "base/strings/string_tokenizer.h" |
30 #include "base/threading/thread.h" | 30 #include "base/threading/thread.h" |
31 #include "base/threading/thread_restrictions.h" | 31 #include "base/threading/thread_restrictions.h" |
32 #include "base/utf_string_conversions.h" | 32 #include "base/utf_string_conversions.h" |
33 #include "build/build_config.h" | 33 #include "build/build_config.h" |
34 #include "chrome/browser/web_applications/web_app.h" | 34 #include "chrome/browser/web_applications/web_app.h" |
35 #include "chrome/common/chrome_constants.h" | 35 #include "chrome/common/chrome_constants.h" |
36 #include "content/public/browser/browser_thread.h" | 36 #include "content/public/browser/browser_thread.h" |
37 #include "googleurl/src/gurl.h" | 37 #include "googleurl/src/gurl.h" |
38 #include "ui/gfx/codec/png_codec.h" | 38 #include "ui/gfx/codec/png_codec.h" |
39 | 39 |
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
447 | 447 |
448 std::string xdg_data_home; | 448 std::string xdg_data_home; |
449 if (env->GetVar("XDG_DATA_HOME", &xdg_data_home) && | 449 if (env->GetVar("XDG_DATA_HOME", &xdg_data_home) && |
450 !xdg_data_home.empty()) { | 450 !xdg_data_home.empty()) { |
451 search_paths.push_back(FilePath(xdg_data_home)); | 451 search_paths.push_back(FilePath(xdg_data_home)); |
452 } | 452 } |
453 | 453 |
454 std::string xdg_data_dirs; | 454 std::string xdg_data_dirs; |
455 if (env->GetVar("XDG_DATA_DIRS", &xdg_data_dirs) && | 455 if (env->GetVar("XDG_DATA_DIRS", &xdg_data_dirs) && |
456 !xdg_data_dirs.empty()) { | 456 !xdg_data_dirs.empty()) { |
457 StringTokenizer tokenizer(xdg_data_dirs, ":"); | 457 base::StringTokenizer tokenizer(xdg_data_dirs, ":"); |
458 while (tokenizer.GetNext()) { | 458 while (tokenizer.GetNext()) { |
459 FilePath data_dir(tokenizer.token()); | 459 FilePath data_dir(tokenizer.token()); |
460 search_paths.push_back(data_dir); | 460 search_paths.push_back(data_dir); |
461 search_paths.push_back(data_dir.Append("applications")); | 461 search_paths.push_back(data_dir.Append("applications")); |
462 } | 462 } |
463 } | 463 } |
464 | 464 |
465 // Add some fallback paths for systems which don't have XDG_DATA_DIRS or have | 465 // Add some fallback paths for systems which don't have XDG_DATA_DIRS or have |
466 // it incomplete. | 466 // it incomplete. |
467 search_paths.push_back(FilePath("/usr/share/applications")); | 467 search_paths.push_back(FilePath("/usr/share/applications")); |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
576 final_title = url.spec(); | 576 final_title = url.spec(); |
577 } | 577 } |
578 g_key_file_set_string(key_file, kDesktopEntry, "Name", final_title.c_str()); | 578 g_key_file_set_string(key_file, kDesktopEntry, "Name", final_title.c_str()); |
579 | 579 |
580 // Set the "Exec" key. | 580 // Set the "Exec" key. |
581 char* exec_c_string = g_key_file_get_string(key_file, kDesktopEntry, "Exec", | 581 char* exec_c_string = g_key_file_get_string(key_file, kDesktopEntry, "Exec", |
582 NULL); | 582 NULL); |
583 if (exec_c_string) { | 583 if (exec_c_string) { |
584 std::string exec_string(exec_c_string); | 584 std::string exec_string(exec_c_string); |
585 g_free(exec_c_string); | 585 g_free(exec_c_string); |
586 StringTokenizer exec_tokenizer(exec_string, " "); | 586 base::StringTokenizer exec_tokenizer(exec_string, " "); |
587 | 587 |
588 std::string final_path; | 588 std::string final_path; |
589 while (exec_tokenizer.GetNext() && exec_tokenizer.token() != "%U") { | 589 while (exec_tokenizer.GetNext() && exec_tokenizer.token() != "%U") { |
590 if (!final_path.empty()) | 590 if (!final_path.empty()) |
591 final_path += " "; | 591 final_path += " "; |
592 final_path += exec_tokenizer.token(); | 592 final_path += exec_tokenizer.token(); |
593 } | 593 } |
594 CommandLine cmd_line(CommandLine::NO_PROGRAM); | 594 CommandLine cmd_line(CommandLine::NO_PROGRAM); |
595 cmd_line = ShellIntegration::CommandLineArgsForLauncher( | 595 cmd_line = ShellIntegration::CommandLineArgsForLauncher( |
596 url, extension_id, profile_path); | 596 url, extension_id, profile_path); |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
685 | 685 |
686 FilePath shortcut_filename = GetExtensionShortcutFilename( | 686 FilePath shortcut_filename = GetExtensionShortcutFilename( |
687 profile_path, extension_id); | 687 profile_path, extension_id); |
688 DCHECK(!shortcut_filename.empty()); | 688 DCHECK(!shortcut_filename.empty()); |
689 | 689 |
690 DeleteShortcutOnDesktop(shortcut_filename); | 690 DeleteShortcutOnDesktop(shortcut_filename); |
691 DeleteShortcutInApplicationsMenu(shortcut_filename); | 691 DeleteShortcutInApplicationsMenu(shortcut_filename); |
692 } | 692 } |
693 | 693 |
694 } // namespace ShellIntegrationLinux | 694 } // namespace ShellIntegrationLinux |
OLD | NEW |