Chromium Code Reviews| 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 <Cocoa/Cocoa.h> | 7 #import <Cocoa/Cocoa.h> |
| 8 | 8 |
| 9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/mac/bundle_locations.h" | 10 #include "base/mac/bundle_locations.h" |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 65 | 65 |
| 66 return [image_rep.release() autorelease]; | 66 return [image_rep.release() autorelease]; |
| 67 } | 67 } |
| 68 | 68 |
| 69 } // namespace | 69 } // namespace |
| 70 | 70 |
| 71 | 71 |
| 72 namespace web_app { | 72 namespace web_app { |
| 73 | 73 |
| 74 WebAppShortcutCreator::WebAppShortcutCreator( | 74 WebAppShortcutCreator::WebAppShortcutCreator( |
| 75 const FilePath& data_dir, | |
| 75 const ShellIntegration::ShortcutInfo& shortcut_info, | 76 const ShellIntegration::ShortcutInfo& shortcut_info, |
| 76 const string16& chrome_bundle_id) | 77 const string16& chrome_bundle_id) |
| 77 : info_(shortcut_info), | 78 : data_dir_(data_dir), |
| 79 info_(shortcut_info), | |
| 78 chrome_bundle_id_(chrome_bundle_id) { | 80 chrome_bundle_id_(chrome_bundle_id) { |
| 79 } | 81 } |
| 80 | 82 |
| 81 WebAppShortcutCreator::~WebAppShortcutCreator() { | 83 WebAppShortcutCreator::~WebAppShortcutCreator() { |
| 82 } | 84 } |
| 83 | 85 |
| 84 bool WebAppShortcutCreator::CreateShortcut() { | 86 bool WebAppShortcutCreator::CreateShortcut() { |
| 85 FilePath app_name = internals::GetSanitizedFileName(info_.title); | 87 FilePath app_name = internals::GetSanitizedFileName(info_.title); |
| 86 FilePath app_file_name = app_name.ReplaceExtension("app"); | 88 FilePath app_file_name = app_name.ReplaceExtension("app"); |
| 87 ScopedTempDir scoped_temp_dir; | 89 ScopedTempDir scoped_temp_dir; |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 164 [value substringWithRange:NSMakeRange(1, [value length] - 2)]; | 166 [value substringWithRange:NSMakeRange(1, [value length] - 2)]; |
| 165 | 167 |
| 166 NSString* substitution = [replacement_dict valueForKey:variable]; | 168 NSString* substitution = [replacement_dict valueForKey:variable]; |
| 167 if (substitution) | 169 if (substitution) |
| 168 [plist setObject:substitution forKey:key]; | 170 [plist setObject:substitution forKey:key]; |
| 169 } | 171 } |
| 170 | 172 |
| 171 // 2. Fill in other values. | 173 // 2. Fill in other values. |
| 172 [plist setObject:GetBundleIdentifier(plist) | 174 [plist setObject:GetBundleIdentifier(plist) |
| 173 forKey:base::mac::CFToNSCast(kCFBundleIdentifierKey)]; | 175 forKey:base::mac::CFToNSCast(kCFBundleIdentifierKey)]; |
| 176 [plist setObject:base::mac::FilePathToNSString(data_dir_) | |
| 177 forKey:app_mode::kCrAppModeUserDataDirKey]; | |
|
Robert Sesek
2012/02/23 01:30:43
nit: align colons. Line above, too.
sail
2012/02/23 03:00:41
Done.
| |
| 174 | 178 |
| 175 return [plist writeToFile:plist_path atomically:YES]; | 179 return [plist writeToFile:plist_path atomically:YES]; |
| 176 } | 180 } |
| 177 | 181 |
| 178 bool WebAppShortcutCreator::UpdateIcon(const FilePath& app_path) const { | 182 bool WebAppShortcutCreator::UpdateIcon(const FilePath& app_path) const { |
| 179 // TODO(sail): Add support for multiple icon sizes. | 183 // TODO(sail): Add support for multiple icon sizes. |
| 180 if (info_.favicon.empty() || info_.favicon.width() != 32 || | 184 if (info_.favicon.empty() || info_.favicon.width() != 32 || |
| 181 info_.favicon.height() != 32) { | 185 info_.favicon.height() != 32) { |
| 182 return true; | 186 return true; |
| 183 } | 187 } |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 228 } // namespace | 232 } // namespace |
| 229 | 233 |
| 230 namespace web_app { | 234 namespace web_app { |
| 231 namespace internals { | 235 namespace internals { |
| 232 | 236 |
| 233 void CreateShortcutTask(const FilePath& web_app_path, | 237 void CreateShortcutTask(const FilePath& web_app_path, |
| 234 const FilePath& profile_path, | 238 const FilePath& profile_path, |
| 235 const ShellIntegration::ShortcutInfo& shortcut_info) { | 239 const ShellIntegration::ShortcutInfo& shortcut_info) { |
| 236 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE)); | 240 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE)); |
| 237 string16 bundle_id = UTF8ToUTF16(base::mac::BaseBundleID()); | 241 string16 bundle_id = UTF8ToUTF16(base::mac::BaseBundleID()); |
| 238 WebAppShortcutCreator shortcut_creator(shortcut_info, bundle_id); | 242 WebAppShortcutCreator shortcut_creator( |
| 243 web_app_path, shortcut_info, bundle_id); | |
| 239 shortcut_creator.CreateShortcut(); | 244 shortcut_creator.CreateShortcut(); |
| 240 } | 245 } |
| 241 | 246 |
| 242 } // namespace internals | 247 } // namespace internals |
| 243 } // namespace web_app | 248 } // namespace web_app |
| OLD | NEW |