summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsail@chromium.org <sail@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-24 06:52:47 +0000
committersail@chromium.org <sail@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-24 06:52:47 +0000
commit37801707bc6cfae9a473e1319a04569a0f37e7ca (patch)
tree95f832946c9b3b78df755be188332f03e25d5356
parent8936b55b8e4b271892924bdbcd4c196c75ddd5bc (diff)
downloadchromium_src-37801707bc6cfae9a473e1319a04569a0f37e7ca.zip
chromium_src-37801707bc6cfae9a473e1319a04569a0f37e7ca.tar.gz
chromium_src-37801707bc6cfae9a473e1319a04569a0f37e7ca.tar.bz2
Add extension path field to Mac platform apps
This CL adds a new extension path field to Mac platform apps. This path is used to load the extension for Mac platform apps. BUG=112651 TEST=Installed a platform app. Verified that it could run side by side with Chromium. Review URL: http://codereview.chromium.org/9374009 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@123443 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/app/app_mode_loader_mac.mm3
-rw-r--r--chrome/app/chrome_main_app_mode_mac.mm26
-rw-r--r--chrome/browser/extensions/app_shortcut_manager.cc1
-rw-r--r--chrome/browser/shell_integration.h3
-rw-r--r--chrome/browser/web_applications/web_app_mac.mm2
-rw-r--r--chrome/common/mac/app_mode_common.h6
-rw-r--r--chrome/common/mac/app_mode_common.mm1
7 files changed, 31 insertions, 11 deletions
diff --git a/chrome/app/app_mode_loader_mac.mm b/chrome/app/app_mode_loader_mac.mm
index 80dc808..3d10145 100644
--- a/chrome/app/app_mode_loader_mac.mm
+++ b/chrome/app/app_mode_loader_mac.mm
@@ -98,6 +98,9 @@ void LoadFramework(void** cr_dylib, app_mode::ChromeAppModeInfo* info) {
info->user_data_dir = base::mac::NSStringToFilePath(
[info_plist objectForKey:app_mode::kCrAppModeUserDataDirKey]);
+ info->extension_path = base::mac::NSStringToFilePath(
+ [info_plist objectForKey:app_mode::kCrAppModeExtensionPathKey]);
+
// Open the framework.
*cr_dylib = dlopen(framework_shlib_path.value().c_str(), RTLD_LAZY);
CHECK(cr_dylib) << "couldn't load framework: " << dlerror();
diff --git a/chrome/app/chrome_main_app_mode_mac.mm b/chrome/app/chrome_main_app_mode_mac.mm
index b2c7824..b32ae31 100644
--- a/chrome/app/chrome_main_app_mode_mac.mm
+++ b/chrome/app/chrome_main_app_mode_mac.mm
@@ -10,9 +10,11 @@
#include <string> // TODO(viettrungluu): only needed for temporary hack
#include "base/basictypes.h"
+#include "base/command_line.h"
#include "base/file_path.h"
#include "base/logging.h"
#include "chrome/common/chrome_paths_internal.h"
+#include "chrome/common/chrome_switches.h"
#include "chrome/common/mac/app_mode_common.h"
extern "C" {
@@ -42,15 +44,19 @@ int ChromeAppModeStart(const app_mode::ChromeAppModeInfo* info) {
RAW_CHECK(!chrome_versioned_path->empty());
chrome::SetOverrideVersionedDirectory(chrome_versioned_path);
- // TODO(viettrungluu): do something intelligent with data
- // return ChromeMain(info->argc, info->argv);
- // For now, a cheesy hack instead.
+ CommandLine command_line(CommandLine::NO_PROGRAM);
+ command_line.AppendSwitch(info->argv[0]);
RAW_CHECK(info->app_mode_id.size());
- std::string argv1(std::string("--app-id=") + info->app_mode_id);
- std::string argv2(
- std::string("--user-data-dir=") + info->user_data_dir.value());
- char* argv[] = { info->argv[0],
- const_cast<char*>(argv1.c_str()),
- const_cast<char*>(argv2.c_str()) };
- return ChromeMain(static_cast<int>(arraysize(argv)), argv);
+ command_line.AppendSwitchASCII(switches::kAppId, info->app_mode_id);
+ command_line.AppendSwitchPath(switches::kUserDataDir, info->user_data_dir);
+ // TODO(sail): Use a different flag that doesn't imply Location::LOAD for the
+ // extension.
+ command_line.AppendSwitchPath(switches::kLoadExtension, info->extension_path);
+
+ int argc = command_line.argv().size();
+ char* argv[argc];
+ for (int i = 0; i < argc; ++i)
+ argv[i] = const_cast<char*>(command_line.argv()[i].c_str());
+
+ return ChromeMain(argc, argv);
}
diff --git a/chrome/browser/extensions/app_shortcut_manager.cc b/chrome/browser/extensions/app_shortcut_manager.cc
index 33ccb06..e24fc91 100644
--- a/chrome/browser/extensions/app_shortcut_manager.cc
+++ b/chrome/browser/extensions/app_shortcut_manager.cc
@@ -71,6 +71,7 @@ void AppShortcutManager::InstallApplicationShortcuts(
shortcut_info_.url = GURL(extension->launch_web_url());
shortcut_info_.title = UTF8ToUTF16(extension->name());
shortcut_info_.description = UTF8ToUTF16(extension->description());
+ shortcut_info_.extension_path = extension->path();
shortcut_info_.create_in_applications_menu = true;
shortcut_info_.create_in_quick_launch_bar = true;
shortcut_info_.create_on_desktop = true;
diff --git a/chrome/browser/shell_integration.h b/chrome/browser/shell_integration.h
index 205fdf9..be5121f 100644
--- a/chrome/browser/shell_integration.h
+++ b/chrome/browser/shell_integration.h
@@ -9,13 +9,13 @@
#include <string>
#include "base/basictypes.h"
+#include "base/file_path.h"
#include "base/memory/ref_counted.h"
#include "base/string16.h"
#include "googleurl/src/gurl.h"
#include "third_party/skia/include/core/SkBitmap.h"
class CommandLine;
-class FilePath;
#if defined(USE_X11)
namespace base {
@@ -76,6 +76,7 @@ class ShellIntegration {
std::string extension_id;
string16 title;
string16 description;
+ FilePath extension_path;
SkBitmap favicon;
bool create_on_desktop;
diff --git a/chrome/browser/web_applications/web_app_mac.mm b/chrome/browser/web_applications/web_app_mac.mm
index 210482ef..2bdfe1a 100644
--- a/chrome/browser/web_applications/web_app_mac.mm
+++ b/chrome/browser/web_applications/web_app_mac.mm
@@ -117,6 +117,8 @@ bool WebAppShortcutCreator::UpdatePlist(const FilePath& app_path) const {
forKey:app_mode::kCrAppModeShortcutURLKey];
[dict setObject:base::mac::FilePathToNSString(user_data_dir_)
forKey:app_mode::kCrAppModeUserDataDirKey];
+ [dict setObject:base::mac::FilePathToNSString(info_.extension_path)
+ forKey:app_mode::kCrAppModeExtensionPathKey];
return [dict writeToFile:plist_path atomically:YES];
}
diff --git a/chrome/common/mac/app_mode_common.h b/chrome/common/mac/app_mode_common.h
index 04851de..930d22d 100644
--- a/chrome/common/mac/app_mode_common.h
+++ b/chrome/common/mac/app_mode_common.h
@@ -39,6 +39,9 @@ extern NSString* const kCrAppModeShortcutURLKey;
// Key for the app user data directory.
extern NSString* const kCrAppModeUserDataDirKey;
+// Key for the app's extension path.
+extern NSString* const kCrAppModeExtensionPathKey;
+
// Current major/minor version numbers of |ChromeAppModeInfo| (defined below).
const unsigned kCurrentChromeAppModeInfoMajorVersion = 1;
const unsigned kCurrentChromeAppModeInfoMinorVersion = 0;
@@ -85,6 +88,9 @@ struct ChromeAppModeInfo {
// Path to the app's user data directory.
FilePath user_data_dir;
+
+ // Path to the app's extension.
+ FilePath extension_path;
};
} // namespace app_mode
diff --git a/chrome/common/mac/app_mode_common.mm b/chrome/common/mac/app_mode_common.mm
index 40de720..48bf38e 100644
--- a/chrome/common/mac/app_mode_common.mm
+++ b/chrome/common/mac/app_mode_common.mm
@@ -13,6 +13,7 @@ NSString* const kCrAppModeShortcutShortNameKey = @"CrAppModeShortcutShortName";
NSString* const kCrAppModeShortcutNameKey = @"CrAppModeShortcutName";
NSString* const kCrAppModeShortcutURLKey = @"CrAppModeShortcutURL";
NSString* const kCrAppModeUserDataDirKey = @"CrAppModeUserDataDir";
+NSString* const kCrAppModeExtensionPathKey = @"CrAppModeExtensionPath";
ChromeAppModeInfo::ChromeAppModeInfo()
: major_version(0),