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" |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 ScopedCarbonHandle raw_data(bitmap.getSize()); | 141 ScopedCarbonHandle raw_data(bitmap.getSize()); |
142 ConvertSkiaToARGB(bitmap, &raw_data); | 142 ConvertSkiaToARGB(bitmap, &raw_data); |
143 OSErr result = SetIconFamilyData(icon_family, icon_type, raw_data.Get()); | 143 OSErr result = SetIconFamilyData(icon_family, icon_type, raw_data.Get()); |
144 DCHECK_EQ(noErr, result); | 144 DCHECK_EQ(noErr, result); |
145 return result == noErr; | 145 return result == noErr; |
146 } | 146 } |
147 | 147 |
148 bool AppShimsDisabledForTest() { | 148 bool AppShimsDisabledForTest() { |
149 // Disable app shims in tests because shims created in ~/Applications will not | 149 // Disable app shims in tests because shims created in ~/Applications will not |
150 // be cleaned up. | 150 // be cleaned up. |
151 return CommandLine::ForCurrentProcess()->HasSwitch(switches::kTestType); | 151 return base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kTestType); |
152 } | 152 } |
153 | 153 |
154 base::FilePath GetWritableApplicationsDirectory() { | 154 base::FilePath GetWritableApplicationsDirectory() { |
155 base::FilePath path; | 155 base::FilePath path; |
156 if (base::mac::GetUserDirectory(NSApplicationDirectory, &path)) { | 156 if (base::mac::GetUserDirectory(NSApplicationDirectory, &path)) { |
157 if (!base::DirectoryExists(path)) { | 157 if (!base::DirectoryExists(path)) { |
158 if (!base::CreateDirectory(path)) | 158 if (!base::CreateDirectory(path)) |
159 return base::FilePath(); | 159 return base::FilePath(); |
160 | 160 |
161 // Create a zero-byte ".localized" file to inherit localizations from OSX | 161 // Create a zero-byte ".localized" file to inherit localizations from OSX |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 // The user may have deleted the copy in the Applications folder, use the | 229 // The user may have deleted the copy in the Applications folder, use the |
230 // one in the web app's |app_data_dir_|. | 230 // one in the web app's |app_data_dir_|. |
231 base::FilePath app_data_dir = web_app::GetWebAppDataDirectory( | 231 base::FilePath app_data_dir = web_app::GetWebAppDataDirectory( |
232 shortcut_info.profile_path, shortcut_info.extension_id, GURL()); | 232 shortcut_info.profile_path, shortcut_info.extension_id, GURL()); |
233 shim_path = app_data_dir.Append(shim_path.BaseName()); | 233 shim_path = app_data_dir.Append(shim_path.BaseName()); |
234 } | 234 } |
235 | 235 |
236 if (!base::PathExists(shim_path)) | 236 if (!base::PathExists(shim_path)) |
237 return; | 237 return; |
238 | 238 |
239 CommandLine command_line(CommandLine::NO_PROGRAM); | 239 base::CommandLine command_line(base::CommandLine::NO_PROGRAM); |
240 command_line.AppendSwitchASCII( | 240 command_line.AppendSwitchASCII( |
241 app_mode::kLaunchedByChromeProcessId, | 241 app_mode::kLaunchedByChromeProcessId, |
242 base::IntToString(base::GetCurrentProcId())); | 242 base::IntToString(base::GetCurrentProcId())); |
243 if (launched_after_rebuild) | 243 if (launched_after_rebuild) |
244 command_line.AppendSwitch(app_mode::kLaunchedAfterRebuild); | 244 command_line.AppendSwitch(app_mode::kLaunchedAfterRebuild); |
245 // Launch without activating (kLSLaunchDontSwitch). | 245 // Launch without activating (kLSLaunchDontSwitch). |
246 base::mac::OpenApplicationWithPath( | 246 base::mac::OpenApplicationWithPath( |
247 shim_path, command_line, kLSLaunchDefaults | kLSLaunchDontSwitch, NULL); | 247 shim_path, command_line, kLSLaunchDefaults | kLSLaunchDontSwitch, NULL); |
248 } | 248 } |
249 | 249 |
(...skipping 602 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
852 if (info_.extension_id == app_mode::kAppListModeId) { | 852 if (info_.extension_id == app_mode::kAppListModeId) { |
853 // Prevent the app list from bouncing in the dock, and getting a run light. | 853 // Prevent the app list from bouncing in the dock, and getting a run light. |
854 [plist setObject:[NSNumber numberWithBool:YES] | 854 [plist setObject:[NSNumber numberWithBool:YES] |
855 forKey:kLSUIElement]; | 855 forKey:kLSUIElement]; |
856 } | 856 } |
857 | 857 |
858 base::FilePath app_name = app_path.BaseName().RemoveExtension(); | 858 base::FilePath app_name = app_path.BaseName().RemoveExtension(); |
859 [plist setObject:base::mac::FilePathToNSString(app_name) | 859 [plist setObject:base::mac::FilePathToNSString(app_name) |
860 forKey:base::mac::CFToNSCast(kCFBundleNameKey)]; | 860 forKey:base::mac::CFToNSCast(kCFBundleNameKey)]; |
861 | 861 |
862 if (CommandLine::ForCurrentProcess()->HasSwitch( | 862 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
863 switches::kEnableAppsFileAssociations)) { | 863 switches::kEnableAppsFileAssociations)) { |
864 UpdateFileTypes(plist, file_handlers_info_); | 864 UpdateFileTypes(plist, file_handlers_info_); |
865 } | 865 } |
866 | 866 |
867 return [plist writeToFile:plist_path | 867 return [plist writeToFile:plist_path |
868 atomically:YES]; | 868 atomically:YES]; |
869 } | 869 } |
870 | 870 |
871 bool WebAppShortcutCreator::UpdateDisplayName( | 871 bool WebAppShortcutCreator::UpdateDisplayName( |
872 const base::FilePath& app_path) const { | 872 const base::FilePath& app_path) const { |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
993 !g_app_shims_allow_update_and_launch_in_tests) { | 993 !g_app_shims_allow_update_and_launch_in_tests) { |
994 return; | 994 return; |
995 } | 995 } |
996 | 996 |
997 content::BrowserThread::PostTask( | 997 content::BrowserThread::PostTask( |
998 content::BrowserThread::FILE, | 998 content::BrowserThread::FILE, |
999 FROM_HERE, | 999 FROM_HERE, |
1000 base::Bind(&LaunchShimOnFileThread, shortcut_info, false)); | 1000 base::Bind(&LaunchShimOnFileThread, shortcut_info, false)); |
1001 } | 1001 } |
1002 | 1002 |
1003 bool MaybeRebuildShortcut(const CommandLine& command_line) { | 1003 bool MaybeRebuildShortcut(const base::CommandLine& command_line) { |
1004 if (!command_line.HasSwitch(app_mode::kAppShimError)) | 1004 if (!command_line.HasSwitch(app_mode::kAppShimError)) |
1005 return false; | 1005 return false; |
1006 | 1006 |
1007 base::PostTaskAndReplyWithResult( | 1007 base::PostTaskAndReplyWithResult( |
1008 content::BrowserThread::GetBlockingPool(), | 1008 content::BrowserThread::GetBlockingPool(), |
1009 FROM_HERE, | 1009 FROM_HERE, |
1010 base::Bind(&RecordAppShimErrorAndBuildShortcutInfo, | 1010 base::Bind(&RecordAppShimErrorAndBuildShortcutInfo, |
1011 command_line.GetSwitchValuePath(app_mode::kAppShimError)), | 1011 command_line.GetSwitchValuePath(app_mode::kAppShimError)), |
1012 base::Bind(&RebuildAppAndLaunch)); | 1012 base::Bind(&RebuildAppAndLaunch)); |
1013 return true; | 1013 return true; |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1176 web_app::GetShortcutInfoForApp( | 1176 web_app::GetShortcutInfoForApp( |
1177 app, | 1177 app, |
1178 profile, | 1178 profile, |
1179 base::Bind(&web_app::CreateAppShortcutInfoLoaded, | 1179 base::Bind(&web_app::CreateAppShortcutInfoLoaded, |
1180 profile, | 1180 profile, |
1181 app, | 1181 app, |
1182 close_callback)); | 1182 close_callback)); |
1183 } | 1183 } |
1184 | 1184 |
1185 } // namespace chrome | 1185 } // namespace chrome |
OLD | NEW |