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

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

Issue 14514003: Make OSX App Launcher Launchable from the Dock. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: rebase off cl14603002 Created 7 years, 7 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
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 #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/files/scoped_temp_dir.h" 10 #include "base/files/scoped_temp_dir.h"
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 file_util::PathIsWritable(path)) { 91 file_util::PathIsWritable(path)) {
92 return path; 92 return path;
93 } 93 }
94 if (base::mac::GetUserDirectory(NSApplicationDirectory, &path)) 94 if (base::mac::GetUserDirectory(NSApplicationDirectory, &path))
95 return path; 95 return path;
96 return base::FilePath(); 96 return base::FilePath();
97 } 97 }
98 98
99 } // namespace 99 } // namespace
100 100
101
102 namespace web_app { 101 namespace web_app {
103 102
104 const char kChromeAppDirName[] = "Chrome Apps.localized"; 103 const char kChromeAppDirName[] = "Chrome Apps.localized";
105 104
106 WebAppShortcutCreator::WebAppShortcutCreator( 105 WebAppShortcutCreator::WebAppShortcutCreator(
107 const base::FilePath& user_data_dir, 106 const base::FilePath& user_data_dir,
108 const ShellIntegration::ShortcutInfo& shortcut_info, 107 const ShellIntegration::ShortcutInfo& shortcut_info,
109 const string16& chrome_bundle_id) 108 const string16& chrome_bundle_id)
110 : user_data_dir_(user_data_dir), 109 : user_data_dir_(user_data_dir),
111 info_(shortcut_info), 110 info_(shortcut_info),
112 chrome_bundle_id_(chrome_bundle_id) { 111 chrome_bundle_id_(chrome_bundle_id) {
113 } 112 }
114 113
115 WebAppShortcutCreator::~WebAppShortcutCreator() { 114 WebAppShortcutCreator::~WebAppShortcutCreator() {
116 } 115 }
117 116
117 base::FilePath WebAppShortcutCreator::GetShortcutPath() const {
118 base::FilePath dst_path = GetDestinationPath();
119 if (dst_path.empty())
120 return dst_path;
121
122 base::FilePath app_name = internals::GetSanitizedFileName(info_.title);
123 return dst_path.Append(app_name.ReplaceExtension("app"));
124 }
125
118 bool WebAppShortcutCreator::CreateShortcut() { 126 bool WebAppShortcutCreator::CreateShortcut() {
119 base::FilePath app_name = internals::GetSanitizedFileName(info_.title); 127 base::FilePath app_name = internals::GetSanitizedFileName(info_.title);
120 base::FilePath app_file_name = app_name.ReplaceExtension("app"); 128 base::FilePath app_file_name = app_name.ReplaceExtension("app");
121 base::FilePath dst_path = GetDestinationPath(); 129 base::FilePath dst_path = GetDestinationPath();
122 if (dst_path.empty() || !file_util::DirectoryExists(dst_path.DirName())) { 130 if (dst_path.empty() || !file_util::DirectoryExists(dst_path.DirName())) {
123 LOG(ERROR) << "Couldn't find an Applications directory to copy app to."; 131 LOG(ERROR) << "Couldn't find an Applications directory to copy app to.";
124 return false; 132 return false;
125 } 133 }
126 if (!file_util::CreateDirectory(dst_path)) { 134 if (!file_util::CreateDirectory(dst_path)) {
127 LOG(ERROR) << "Creating directory " << dst_path.value() << " failed."; 135 LOG(ERROR) << "Creating directory " << dst_path.value() << " failed.";
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 file_util::Delete(bundle_path, true); 332 file_util::Delete(bundle_path, true);
325 } 333 }
326 334
327 void UpdatePlatformShortcuts( 335 void UpdatePlatformShortcuts(
328 const base::FilePath& web_app_path, 336 const base::FilePath& web_app_path,
329 const ShellIntegration::ShortcutInfo& shortcut_info) { 337 const ShellIntegration::ShortcutInfo& shortcut_info) {
330 // TODO(benwells): Implement this when shortcuts / weblings are enabled on 338 // TODO(benwells): Implement this when shortcuts / weblings are enabled on
331 // mac. 339 // mac.
332 } 340 }
333 341
342 base::FilePath GetAppInstallPath(
343 const ShellIntegration::ShortcutInfo& shortcut_info) {
344 WebAppShortcutCreator shortcut_creator(base::FilePath(),
345 shortcut_info,
346 string16());
347 return shortcut_creator.GetShortcutPath();
348 }
349
334 } // namespace internals 350 } // namespace internals
335 351
336 } // namespace web_app 352 } // 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