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

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: Tweak 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..f26d64b1ac97e8e60ff13f91c29b40858c3ef495 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,17 @@ bool WebAppShortcutCreator::UpdatePlist(const FilePath& app_path) const {
NSMutableDictionary* dict =
[NSMutableDictionary dictionaryWithContentsOfFile:plist_path];
- [dict setObject:base::SysUTF8ToNSString(info_.extension_id)
+ [dict setObject:GetBundleIdentifier(base::mac::ObjCCast<NSDictionary>(dict))
sail 2012/02/19 21:08:55 you don't need a base::mac::ObjCCast() here since
jeremy 2012/02/20 05:41:00 Done.
+ forKey:base::mac::CFToNSCast(kCFBundleIdentifierKey)];
+ NSString* extension_id = base::SysUTF8ToNSString(info_.extension_id);
sail 2012/02/19 21:08:55 you don't need this temp variable
jeremy 2012/02/20 05:41:00 Done.
+ [dict setObject: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 +109,19 @@ bool WebAppShortcutCreator::UpdateIcon(const FilePath& app_path) const {
return true;
}
+NSString* WebAppShortcutCreator::GetBundleIdentifier(NSDictionary* plist) const
+{
+ NSString* bundle_id_template =
sail 2012/02/19 21:08:55 I didn't know about BaseBundleID(). That's very co
jeremy 2012/02/20 05:41:00 I prefer to keep it this way since: 1. It's easier
+ base::mac::ObjCCast<NSString>(
+ [plist objectForKey:base::mac::CFToNSCast(kCFBundleIdentifierKey)]);
+ NSString* extension_id = base::SysUTF8ToNSString(info_.extension_id);
+ NSString* bundle_id =
+ [bundle_id_template
+ stringByReplacingOccurrencesOfString:app_mode::kShortcutIdPlaceholder
+ withString:extension_id];
+ return bundle_id;
+}
+
} // namespace
namespace web_app {
@@ -111,7 +131,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