| 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 #import "chrome/browser/web_applications/web_app_mac.h" | 5 #import "chrome/browser/web_applications/web_app_mac.h" |
| 6 | 6 |
| 7 #import <Carbon/Carbon.h> | 7 #import <Carbon/Carbon.h> |
| 8 #import <Cocoa/Cocoa.h> | 8 #import <Cocoa/Cocoa.h> |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| 11 #include "base/file_util.h" | 11 #include "base/file_util.h" |
| 12 #include "base/files/file_enumerator.h" | 12 #include "base/files/file_enumerator.h" |
| 13 #include "base/files/scoped_temp_dir.h" | 13 #include "base/files/scoped_temp_dir.h" |
| 14 #include "base/mac/foundation_util.h" | 14 #include "base/mac/foundation_util.h" |
| 15 #include "base/mac/launch_services_util.h" | 15 #include "base/mac/launch_services_util.h" |
| 16 #include "base/mac/mac_util.h" | 16 #include "base/mac/mac_util.h" |
| 17 #include "base/mac/scoped_cftyperef.h" | 17 #include "base/mac/scoped_cftyperef.h" |
| 18 #include "base/mac/scoped_nsobject.h" | 18 #include "base/mac/scoped_nsobject.h" |
| 19 #include "base/path_service.h" | 19 #include "base/path_service.h" |
| 20 #include "base/process/process_handle.h" | 20 #include "base/process/process_handle.h" |
| 21 #include "base/strings/string16.h" | 21 #include "base/strings/string16.h" |
| 22 #include "base/strings/string_number_conversions.h" | 22 #include "base/strings/string_number_conversions.h" |
| 23 #include "base/strings/string_util.h" | 23 #include "base/strings/string_util.h" |
| 24 #include "base/strings/sys_string_conversions.h" | 24 #include "base/strings/sys_string_conversions.h" |
| 25 #include "base/strings/utf_string_conversions.h" | 25 #include "base/strings/utf_string_conversions.h" |
| 26 #import "chrome/browser/mac/dock.h" | 26 #import "chrome/browser/mac/dock.h" |
| 27 #include "chrome/browser/browser_process.h" |
| 27 #include "chrome/browser/profiles/profile.h" | 28 #include "chrome/browser/profiles/profile.h" |
| 29 #include "chrome/browser/profiles/profile_manager.h" |
| 28 #include "chrome/browser/shell_integration.h" | 30 #include "chrome/browser/shell_integration.h" |
| 29 #include "chrome/common/chrome_constants.h" | 31 #include "chrome/common/chrome_constants.h" |
| 30 #include "chrome/common/chrome_paths.h" | 32 #include "chrome/common/chrome_paths.h" |
| 31 #include "chrome/common/chrome_switches.h" | 33 #include "chrome/common/chrome_switches.h" |
| 32 #include "chrome/common/chrome_version_info.h" | 34 #include "chrome/common/chrome_version_info.h" |
| 33 #import "chrome/common/mac/app_mode_common.h" | 35 #import "chrome/common/mac/app_mode_common.h" |
| 34 #include "content/public/browser/browser_thread.h" | 36 #include "content/public/browser/browser_thread.h" |
| 37 #include "extensions/browser/extension_registry.h" |
| 35 #include "extensions/common/extension.h" | 38 #include "extensions/common/extension.h" |
| 36 #include "grit/chrome_unscaled_resources.h" | 39 #include "grit/chrome_unscaled_resources.h" |
| 37 #include "grit/chromium_strings.h" | 40 #include "grit/chromium_strings.h" |
| 38 #include "grit/generated_resources.h" | 41 #include "grit/generated_resources.h" |
| 39 #import "skia/ext/skia_utils_mac.h" | 42 #import "skia/ext/skia_utils_mac.h" |
| 40 #include "third_party/skia/include/core/SkBitmap.h" | 43 #include "third_party/skia/include/core/SkBitmap.h" |
| 41 #include "third_party/skia/include/core/SkColor.h" | 44 #include "third_party/skia/include/core/SkColor.h" |
| 42 #include "ui/base/l10n/l10n_util.h" | 45 #include "ui/base/l10n/l10n_util.h" |
| 43 #import "ui/base/l10n/l10n_util_mac.h" | 46 #import "ui/base/l10n/l10n_util_mac.h" |
| 44 #include "ui/base/resource/resource_bundle.h" | 47 #include "ui/base/resource/resource_bundle.h" |
| (...skipping 863 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 908 [application_folder_checkbox state] == NSOnState) { | 911 [application_folder_checkbox state] == NSOnState) { |
| 909 dialog_accepted = true; | 912 dialog_accepted = true; |
| 910 CreateShortcuts( | 913 CreateShortcuts( |
| 911 SHORTCUT_CREATION_BY_USER, ShortcutLocations(), profile, app); | 914 SHORTCUT_CREATION_BY_USER, ShortcutLocations(), profile, app); |
| 912 } | 915 } |
| 913 | 916 |
| 914 if (!close_callback.is_null()) | 917 if (!close_callback.is_null()) |
| 915 close_callback.Run(dialog_accepted); | 918 close_callback.Run(dialog_accepted); |
| 916 } | 919 } |
| 917 | 920 |
| 921 void UpdateShortcutsForAllApps(Profile* profile, |
| 922 const base::Closure& callback) { |
| 923 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 924 |
| 925 extensions::ExtensionRegistry* registry = |
| 926 extensions::ExtensionRegistry::Get(profile); |
| 927 if (!registry) |
| 928 return; |
| 929 |
| 930 // Update all apps. |
| 931 scoped_ptr<extensions::ExtensionSet> everything = |
| 932 registry->GenerateInstalledExtensionsSet(); |
| 933 for (extensions::ExtensionSet::const_iterator it = everything->begin(); |
| 934 it != everything->end(); ++it) { |
| 935 if (web_app::ShouldCreateShortcutFor(profile, it->get())) |
| 936 web_app::UpdateAllShortcuts(base::string16(), profile, it->get()); |
| 937 } |
| 938 |
| 939 callback.Run(); |
| 940 } |
| 941 |
| 918 namespace internals { | 942 namespace internals { |
| 919 | 943 |
| 920 bool CreatePlatformShortcuts( | 944 bool CreatePlatformShortcuts( |
| 921 const base::FilePath& app_data_path, | 945 const base::FilePath& app_data_path, |
| 922 const ShortcutInfo& shortcut_info, | 946 const ShortcutInfo& shortcut_info, |
| 923 const extensions::FileHandlersInfo& file_handlers_info, | 947 const extensions::FileHandlersInfo& file_handlers_info, |
| 924 const ShortcutLocations& creation_locations, | 948 const ShortcutLocations& creation_locations, |
| 925 ShortcutCreationReason creation_reason) { | 949 ShortcutCreationReason creation_reason) { |
| 926 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE)); | 950 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE)); |
| 927 if (AppShimsDisabledForTest()) | 951 if (AppShimsDisabledForTest()) |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 983 web_app::UpdateShortcutInfoAndIconForApp( | 1007 web_app::UpdateShortcutInfoAndIconForApp( |
| 984 app, | 1008 app, |
| 985 profile, | 1009 profile, |
| 986 base::Bind(&web_app::CreateAppShortcutInfoLoaded, | 1010 base::Bind(&web_app::CreateAppShortcutInfoLoaded, |
| 987 profile, | 1011 profile, |
| 988 app, | 1012 app, |
| 989 close_callback)); | 1013 close_callback)); |
| 990 } | 1014 } |
| 991 | 1015 |
| 992 } // namespace chrome | 1016 } // namespace chrome |
| OLD | NEW |