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

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: 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..38930ecc0380523ba2fa9c3b45915dc337e6a7ae 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>
@@ -12,6 +12,7 @@
#include "base/scoped_temp_dir.h"
#include "base/sys_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"
@@ -27,7 +28,7 @@ WebAppShortcutCreator::WebAppShortcutCreator(
WebAppShortcutCreator::~WebAppShortcutCreator() {
}
-bool WebAppShortcutCreator::CreateShortcut() {
+bool WebAppShortcutCreator::CreateShortcut(NSString* chrome_bundle_id) {
FilePath app_name = internals::GetSanitizedFileName(info_.title);
FilePath app_file_name = app_name.ReplaceExtension("app");
ScopedTempDir scoped_temp_dir;
@@ -43,7 +44,7 @@ bool WebAppShortcutCreator::CreateShortcut() {
return false;
}
- if (!UpdatePlist(staging_path))
+ if (!UpdatePlist(staging_path, chrome_bundle_id))
return false;
if (!UpdateIcon(staging_path))
@@ -62,10 +63,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(
@@ -82,18 +81,36 @@ FilePath WebAppShortcutCreator::GetDestinationPath(
return FilePath();
}
-bool WebAppShortcutCreator::UpdatePlist(const FilePath& app_path) const {
+bool WebAppShortcutCreator::UpdatePlist(
+ const FilePath& app_path, NSString* chrome_bundle_id) const {
+ NSString* const kCFBundleIdentifer = @"CFBundleIdentifier";
sail 2012/02/17 16:42:09 you could also use kCFBundleIdentifierKey here
jeremy 2012/02/19 14:36:41 Done.
+
NSString* plist_path = base::mac::FilePathToNSString(
app_path.Append("Contents").Append("Info.plist"));
NSMutableDictionary* dict =
[NSMutableDictionary dictionaryWithContentsOfFile:plist_path];
- [dict setObject:base::SysUTF8ToNSString(info_.extension_id)
+ NSString* extension_id = base::SysUTF8ToNSString(info_.extension_id);
+
+ // Set the bundle signature.
+ NSString* bundle_id_template =
+ base::mac::ObjCCast<NSString>([dict objectForKey:kCFBundleIdentifer]);
+ NSString* bundle_id =
+ [bundle_id_template
+ stringByReplacingOccurrencesOfString:app_mode::kShortcutIdPlaceholder
sail 2012/02/17 16:42:09 this function is becoming a bit long, could you ch
jeremy 2012/02/19 14:36:41 Done.
+ withString:extension_id];
+ [dict setObject:bundle_id
+ forKey:kCFBundleIdentifer];
+
+
+ [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:chrome_bundle_id
+ forKey:app_mode::kBrowserBundleIDKey];
return [dict writeToFile:plist_path atomically:YES];
}
@@ -112,7 +129,7 @@ void CreateShortcutTask(const FilePath& web_app_path,
const ShellIntegration::ShortcutInfo& shortcut_info) {
DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE));
WebAppShortcutCreator shortcut_creator(shortcut_info);
- shortcut_creator.CreateShortcut();
+ shortcut_creator.CreateShortcut([chrome::OuterAppBundle() bundleIdentifier]);
sail 2012/02/17 16:42:09 bug 24842 seems to imply that NSBundle isn't threa
jeremy 2012/02/19 14:36:41 Good catch! Thanks!
}
} // namespace internals

Powered by Google App Engine
This is Rietveld 408576698