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 <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
(...skipping 29 matching lines...) Expand all Loading... |
40 #include "base/strings/string_tokenizer.h" | 40 #include "base/strings/string_tokenizer.h" |
41 #include "base/strings/string_util.h" | 41 #include "base/strings/string_util.h" |
42 #include "base/strings/utf_string_conversions.h" | 42 #include "base/strings/utf_string_conversions.h" |
43 #include "base/threading/thread.h" | 43 #include "base/threading/thread.h" |
44 #include "base/threading/thread_restrictions.h" | 44 #include "base/threading/thread_restrictions.h" |
45 #include "build/build_config.h" | 45 #include "build/build_config.h" |
46 #include "chrome/browser/shell_integration.h" | 46 #include "chrome/browser/shell_integration.h" |
47 #include "chrome/common/channel_info.h" | 47 #include "chrome/common/channel_info.h" |
48 #include "chrome/common/chrome_constants.h" | 48 #include "chrome/common/chrome_constants.h" |
49 #include "chrome/common/chrome_switches.h" | 49 #include "chrome/common/chrome_switches.h" |
| 50 #include "chrome/common/features.h" |
50 #include "chrome/grit/chrome_unscaled_resources.h" | 51 #include "chrome/grit/chrome_unscaled_resources.h" |
51 #include "components/version_info/version_info.h" | 52 #include "components/version_info/version_info.h" |
52 #include "content/public/browser/browser_thread.h" | 53 #include "content/public/browser/browser_thread.h" |
53 #include "ui/base/resource/resource_bundle.h" | 54 #include "ui/base/resource/resource_bundle.h" |
54 #include "ui/gfx/image/image_family.h" | 55 #include "ui/gfx/image/image_family.h" |
55 #include "url/gurl.h" | 56 #include "url/gurl.h" |
56 | 57 |
57 using content::BrowserThread; | 58 using content::BrowserThread; |
58 | 59 |
59 namespace shell_integration { | 60 namespace shell_integration { |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 DefaultWebClientState IsDefaultProtocolClient(const std::string& protocol) { | 261 DefaultWebClientState IsDefaultProtocolClient(const std::string& protocol) { |
261 return GetIsDefaultWebClient(protocol); | 262 return GetIsDefaultWebClient(protocol); |
262 } | 263 } |
263 | 264 |
264 } // namespace shell_integration | 265 } // namespace shell_integration |
265 | 266 |
266 namespace shell_integration_linux { | 267 namespace shell_integration_linux { |
267 | 268 |
268 namespace { | 269 namespace { |
269 | 270 |
270 #if defined(ENABLE_APP_LIST) | 271 #if BUILDFLAG(ENABLE_APP_LIST) |
271 // The Categories for the App Launcher desktop shortcut. Should be the same as | 272 // The Categories for the App Launcher desktop shortcut. Should be the same as |
272 // the Chrome desktop shortcut, so they are in the same sub-menu. | 273 // the Chrome desktop shortcut, so they are in the same sub-menu. |
273 const char kAppListCategories[] = "Network;WebBrowser;"; | 274 const char kAppListCategories[] = "Network;WebBrowser;"; |
274 #endif | 275 #endif |
275 | 276 |
276 std::string CreateShortcutIcon(const gfx::ImageFamily& icon_images, | 277 std::string CreateShortcutIcon(const gfx::ImageFamily& icon_images, |
277 const base::FilePath& shortcut_filename) { | 278 const base::FilePath& shortcut_filename) { |
278 if (icon_images.empty()) | 279 if (icon_images.empty()) |
279 return std::string(); | 280 return std::string(); |
280 | 281 |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
492 return quoted_path; | 493 return quoted_path; |
493 } | 494 } |
494 | 495 |
495 const char kDesktopEntry[] = "Desktop Entry"; | 496 const char kDesktopEntry[] = "Desktop Entry"; |
496 | 497 |
497 const char kXdgOpenShebang[] = "#!/usr/bin/env xdg-open"; | 498 const char kXdgOpenShebang[] = "#!/usr/bin/env xdg-open"; |
498 #endif | 499 #endif |
499 | 500 |
500 const char kDirectoryFilename[] = "chrome-apps.directory"; | 501 const char kDirectoryFilename[] = "chrome-apps.directory"; |
501 | 502 |
502 #if defined(ENABLE_APP_LIST) | 503 #if BUILDFLAG(ENABLE_APP_LIST) |
503 #if defined(GOOGLE_CHROME_BUILD) | 504 #if defined(GOOGLE_CHROME_BUILD) |
504 const char kAppListDesktopName[] = "chrome-app-list"; | 505 const char kAppListDesktopName[] = "chrome-app-list"; |
505 #else // CHROMIUM_BUILD | 506 #else // CHROMIUM_BUILD |
506 const char kAppListDesktopName[] = "chromium-app-list"; | 507 const char kAppListDesktopName[] = "chromium-app-list"; |
507 #endif | 508 #endif |
508 #endif | 509 #endif |
509 | 510 |
510 // Get the value of NoDisplay from the [Desktop Entry] section of a .desktop | 511 // Get the value of NoDisplay from the [Desktop Entry] section of a .desktop |
511 // file, given in |shortcut_contents|. If the key is not found, returns false. | 512 // file, given in |shortcut_contents|. If the key is not found, returns false. |
512 bool GetNoDisplayFromDesktopFile(const std::string& shortcut_contents) { | 513 bool GetNoDisplayFromDesktopFile(const std::string& shortcut_contents) { |
(...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1021 "", | 1022 "", |
1022 creation_locations.applications_menu_location == | 1023 creation_locations.applications_menu_location == |
1023 web_app::APP_MENU_LOCATION_HIDDEN); | 1024 web_app::APP_MENU_LOCATION_HIDDEN); |
1024 success = CreateShortcutInApplicationsMenu( | 1025 success = CreateShortcutInApplicationsMenu( |
1025 shortcut_filename, contents, directory_filename, directory_contents) && | 1026 shortcut_filename, contents, directory_filename, directory_contents) && |
1026 success; | 1027 success; |
1027 | 1028 |
1028 return success; | 1029 return success; |
1029 } | 1030 } |
1030 | 1031 |
1031 #if defined(ENABLE_APP_LIST) | 1032 #if BUILDFLAG(ENABLE_APP_LIST) |
1032 bool CreateAppListDesktopShortcut( | 1033 bool CreateAppListDesktopShortcut( |
1033 const std::string& wm_class, | 1034 const std::string& wm_class, |
1034 const std::string& title) { | 1035 const std::string& title) { |
1035 DCHECK_CURRENTLY_ON(BrowserThread::FILE); | 1036 DCHECK_CURRENTLY_ON(BrowserThread::FILE); |
1036 | 1037 |
1037 base::FilePath desktop_name(kAppListDesktopName); | 1038 base::FilePath desktop_name(kAppListDesktopName); |
1038 base::FilePath shortcut_filename = desktop_name.AddExtension("desktop"); | 1039 base::FilePath shortcut_filename = desktop_name.AddExtension("desktop"); |
1039 | 1040 |
1040 // We do not want duplicate shortcuts. Delete any that already exist and | 1041 // We do not want duplicate shortcuts. Delete any that already exist and |
1041 // replace them. | 1042 // replace them. |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1106 base::FilePath applications_menu = GetDataWriteLocation(env.get()); | 1107 base::FilePath applications_menu = GetDataWriteLocation(env.get()); |
1107 applications_menu = applications_menu.AppendASCII("applications"); | 1108 applications_menu = applications_menu.AppendASCII("applications"); |
1108 std::vector<base::FilePath> shortcut_filenames_app_menu = | 1109 std::vector<base::FilePath> shortcut_filenames_app_menu = |
1109 GetExistingProfileShortcutFilenames(profile_path, applications_menu); | 1110 GetExistingProfileShortcutFilenames(profile_path, applications_menu); |
1110 for (const auto& menu : shortcut_filenames_app_menu) { | 1111 for (const auto& menu : shortcut_filenames_app_menu) { |
1111 DeleteShortcutInApplicationsMenu(menu, base::FilePath(kDirectoryFilename)); | 1112 DeleteShortcutInApplicationsMenu(menu, base::FilePath(kDirectoryFilename)); |
1112 } | 1113 } |
1113 } | 1114 } |
1114 | 1115 |
1115 } // namespace shell_integration_linux | 1116 } // namespace shell_integration_linux |
OLD | NEW |