Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(610)

Side by Side Diff: chrome/browser/web_applications/web_app_mac.mm

Issue 9423048: Add user data dir field to Mac platform apps (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix build Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/web_applications/web_app_mac.h" 5 #include "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 21 matching lines...) Expand all
32 return base::mac::ObjCCast<NSBitmapImageRep>( 32 return base::mac::ObjCCast<NSBitmapImageRep>(
33 [[image representations] lastObject]); 33 [[image representations] lastObject]);
34 } 34 }
35 35
36 } // namespace 36 } // namespace
37 37
38 38
39 namespace web_app { 39 namespace web_app {
40 40
41 WebAppShortcutCreator::WebAppShortcutCreator( 41 WebAppShortcutCreator::WebAppShortcutCreator(
42 const FilePath& user_data_dir,
42 const ShellIntegration::ShortcutInfo& shortcut_info) 43 const ShellIntegration::ShortcutInfo& shortcut_info)
43 : info_(shortcut_info) { 44 : user_data_dir_(user_data_dir),
45 info_(shortcut_info) {
44 } 46 }
45 47
46 WebAppShortcutCreator::~WebAppShortcutCreator() { 48 WebAppShortcutCreator::~WebAppShortcutCreator() {
47 } 49 }
48 50
49 bool WebAppShortcutCreator::CreateShortcut() { 51 bool WebAppShortcutCreator::CreateShortcut() {
50 FilePath app_name = internals::GetSanitizedFileName(info_.title); 52 FilePath app_name = internals::GetSanitizedFileName(info_.title);
51 FilePath app_file_name = app_name.ReplaceExtension("app"); 53 FilePath app_file_name = app_name.ReplaceExtension("app");
52 ScopedTempDir scoped_temp_dir; 54 ScopedTempDir scoped_temp_dir;
53 if (!scoped_temp_dir.CreateUniqueTempDir()) 55 if (!scoped_temp_dir.CreateUniqueTempDir())
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 app_path.Append("Contents").Append("Info.plist")); 108 app_path.Append("Contents").Append("Info.plist"));
107 NSMutableDictionary* dict = 109 NSMutableDictionary* dict =
108 [NSMutableDictionary dictionaryWithContentsOfFile:plist_path]; 110 [NSMutableDictionary dictionaryWithContentsOfFile:plist_path];
109 111
110 [dict setObject:base::SysUTF8ToNSString(info_.extension_id) 112 [dict setObject:base::SysUTF8ToNSString(info_.extension_id)
111 forKey:app_mode::kCrAppModeShortcutIDKey]; 113 forKey:app_mode::kCrAppModeShortcutIDKey];
112 [dict setObject:base::SysUTF16ToNSString(info_.title) 114 [dict setObject:base::SysUTF16ToNSString(info_.title)
113 forKey:app_mode::kCrAppModeShortcutNameKey]; 115 forKey:app_mode::kCrAppModeShortcutNameKey];
114 [dict setObject:base::SysUTF8ToNSString(info_.url.spec()) 116 [dict setObject:base::SysUTF8ToNSString(info_.url.spec())
115 forKey:app_mode::kCrAppModeShortcutURLKey]; 117 forKey:app_mode::kCrAppModeShortcutURLKey];
118 [dict setObject:base::mac::FilePathToNSString(user_data_dir_)
119 forKey:app_mode::kCrAppModeUserDataDirKey];
116 return [dict writeToFile:plist_path atomically:YES]; 120 return [dict writeToFile:plist_path atomically:YES];
117 } 121 }
118 122
119 bool WebAppShortcutCreator::UpdateIcon(const FilePath& app_path) const { 123 bool WebAppShortcutCreator::UpdateIcon(const FilePath& app_path) const {
120 // TODO(sail): Add support for multiple icon sizes. 124 // TODO(sail): Add support for multiple icon sizes.
121 if (info_.favicon.empty() || info_.favicon.width() != 32 || 125 if (info_.favicon.empty() || info_.favicon.width() != 32 ||
122 info_.favicon.height() != 32) { 126 info_.favicon.height() != 32) {
123 return true; 127 return true;
124 } 128 }
125 129
(...skipping 22 matching lines...) Expand all
148 152
149 } // namespace 153 } // namespace
150 154
151 namespace web_app { 155 namespace web_app {
152 namespace internals { 156 namespace internals {
153 157
154 void CreateShortcutTask(const FilePath& web_app_path, 158 void CreateShortcutTask(const FilePath& web_app_path,
155 const FilePath& profile_path, 159 const FilePath& profile_path,
156 const ShellIntegration::ShortcutInfo& shortcut_info) { 160 const ShellIntegration::ShortcutInfo& shortcut_info) {
157 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE)); 161 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE));
158 WebAppShortcutCreator shortcut_creator(shortcut_info); 162 WebAppShortcutCreator shortcut_creator(web_app_path, shortcut_info);
159 shortcut_creator.CreateShortcut(); 163 shortcut_creator.CreateShortcut();
160 } 164 }
161 165
162 } // namespace internals 166 } // namespace internals
163 } // namespace web_app 167 } // namespace web_app
OLDNEW
« no previous file with comments | « chrome/browser/web_applications/web_app_mac.h ('k') | chrome/browser/web_applications/web_app_mac_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698