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

Unified Diff: chrome/browser/web_applications/web_app_mac.mm

Issue 9416012: Mac: Generate App Mode Loader bundle + cleanup (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix review comments 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/web_applications/web_app_mac.mm
diff --git a/chrome/browser/web_applications/web_app_mac.mm b/chrome/browser/web_applications/web_app_mac.mm
index 52ef072abeee2c60678ad702b3faf2f0f7df1758..dac3d96edcb45700dc4f0c359ca18c3aea79583f 100644
--- a/chrome/browser/web_applications/web_app_mac.mm
+++ b/chrome/browser/web_applications/web_app_mac.mm
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/browser/web_applications/web_app_mac.h"
+#import "chrome/browser/web_applications/web_app_mac.h"
#import <Cocoa/Cocoa.h>
@@ -11,7 +11,9 @@
#include "base/mac/foundation_util.h"
#include "base/scoped_temp_dir.h"
#include "base/sys_string_conversions.h"
+#include "base/utf_string_conversions.h"
#include "chrome/browser/web_applications/web_app.h"
+#include "chrome/common/chrome_paths_internal.h"
#include "chrome/common/mac/app_mode_common.h"
#include "content/public/browser/browser_thread.h"
#include "grit/chromium_strings.h"
@@ -20,8 +22,10 @@
namespace web_app {
WebAppShortcutCreator::WebAppShortcutCreator(
- const ShellIntegration::ShortcutInfo& shortcut_info)
- : info_(shortcut_info) {
+ const ShellIntegration::ShortcutInfo& shortcut_info,
+ const string16& chrome_bundle_id)
+ : info_(shortcut_info),
+ chrome_bundle_id_(chrome_bundle_id) {
}
WebAppShortcutCreator::~WebAppShortcutCreator() {
@@ -62,10 +66,8 @@ bool WebAppShortcutCreator::CreateShortcut() {
}
FilePath WebAppShortcutCreator::GetAppLoaderPath() const {
- NSString* app_loader = [l10n_util::GetNSString(IDS_PRODUCT_NAME)
- stringByAppendingString:@" App Mode Loader.app"];
return base::mac::PathForFrameworkBundleResource(
- base::mac::NSToCFCast(app_loader));
+ base::mac::NSToCFCast(@"app_mode_loader.app"));
}
FilePath WebAppShortcutCreator::GetDestinationPath(
@@ -88,12 +90,16 @@ bool WebAppShortcutCreator::UpdatePlist(const FilePath& app_path) const {
NSMutableDictionary* dict =
[NSMutableDictionary dictionaryWithContentsOfFile:plist_path];
+ [dict setObject:GetBundleIdentifier(dict)
+ forKey:base::mac::CFToNSCast(kCFBundleIdentifierKey)];
[dict setObject:base::SysUTF8ToNSString(info_.extension_id)
forKey:app_mode::kCrAppModeShortcutIDKey];
[dict setObject:base::SysUTF16ToNSString(info_.title)
forKey:app_mode::kCrAppModeShortcutNameKey];
[dict setObject:base::SysUTF8ToNSString(info_.url.spec())
forKey:app_mode::kCrAppModeShortcutURLKey];
+ [dict setObject:base::SysUTF16ToNSString(chrome_bundle_id_)
+ forKey:app_mode::kBrowserBundleIDKey];
return [dict writeToFile:plist_path atomically:YES];
}
@@ -102,6 +108,19 @@ bool WebAppShortcutCreator::UpdateIcon(const FilePath& app_path) const {
return true;
}
+NSString* WebAppShortcutCreator::GetBundleIdentifier(NSDictionary* plist) const
+{
+ NSString* bundle_id_template =
+ base::mac::ObjCCast<NSString>(
+ [plist objectForKey:base::mac::CFToNSCast(kCFBundleIdentifierKey)]);
+ NSString* extension_id = base::SysUTF8ToNSString(info_.extension_id);
Mark Mentovai 2012/02/22 16:43:22 What do these look like? How do we know they’re va
jeremy 2012/02/23 14:21:13 I've added a TODO, I'd like to land this CL since
+ NSString* bundle_id =
+ [bundle_id_template
+ stringByReplacingOccurrencesOfString:app_mode::kShortcutIdPlaceholder
+ withString:extension_id];
+ return bundle_id;
+}
+
} // namespace
namespace web_app {
@@ -111,7 +130,8 @@ void CreateShortcutTask(const FilePath& web_app_path,
const FilePath& profile_path,
const ShellIntegration::ShortcutInfo& shortcut_info) {
DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE));
- WebAppShortcutCreator shortcut_creator(shortcut_info);
+ string16 bundle_id = UTF8ToUTF16(base::mac::BaseBundleID());
+ WebAppShortcutCreator shortcut_creator(shortcut_info, bundle_id);
shortcut_creator.CreateShortcut();
}

Powered by Google App Engine
This is Rietveld 408576698