diff options
author | viettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-05-18 22:09:40 +0000 |
---|---|---|
committer | viettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-05-18 22:09:40 +0000 |
commit | adf0225bfea22dd085a1e0816871af9e8f1fe372 (patch) | |
tree | 96fd5362f73388c6a72359db01b33dfbc6d15f81 /chrome/app/chrome_dll_app_mode_mac.mm | |
parent | 98e94a40052f163889a5d6026a24d750edf28818 (diff) | |
download | chromium_src-adf0225bfea22dd085a1e0816871af9e8f1fe372.zip chromium_src-adf0225bfea22dd085a1e0816871af9e8f1fe372.tar.gz chromium_src-adf0225bfea22dd085a1e0816871af9e8f1fe372.tar.bz2 |
Mac: app mode loader (shim).
Define an interface using which Chrome can be loaded from a minimal loader.
Produce a binary for this loader (which can be put into a bundle).
BUG=13148
TEST=not yet
Review URL: http://codereview.chromium.org/2066004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@47576 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/app/chrome_dll_app_mode_mac.mm')
-rw-r--r-- | chrome/app/chrome_dll_app_mode_mac.mm | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/chrome/app/chrome_dll_app_mode_mac.mm b/chrome/app/chrome_dll_app_mode_mac.mm new file mode 100644 index 0000000..678547d --- /dev/null +++ b/chrome/app/chrome_dll_app_mode_mac.mm @@ -0,0 +1,56 @@ +// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// On Mac, one can't make shortcuts with command-line arguments. Instead, we +// produce small app bundles which locate the Chromium framework and load it, +// passing the appropriate data. This is the entry point into the framework for +// those app bundles. + +#include <string> // TODO(viettrungluu): only needed for temporary hack + +#include "base/basictypes.h" +#include "base/file_path.h" +#include "base/logging.h" +#include "chrome/common/app_mode_common_mac.h" +#include "chrome/common/chrome_paths_internal.h" + +extern "C" { + +// |ChromeAppModeStart()| is the point of entry into the framework from the app +// mode loader. +__attribute__((visibility("default"))) +int ChromeAppModeStart(const app_mode::ChromeAppModeInfo* info); + +// TODO(viettrungluu): put this in a header file somewhere. +int ChromeMain(int argc, char** argv); + +} // extern "C" + +int ChromeAppModeStart(const app_mode::ChromeAppModeInfo* info) { + if (info->major_version < app_mode::kCurrentChromeAppModeInfoMajorVersion) { + RAW_LOG(ERROR, "App Mode Loader too old."); + return 1; + } + if (info->major_version > app_mode::kCurrentChromeAppModeInfoMajorVersion) { + RAW_LOG(ERROR, "Browser Framework too old to load App Shortcut."); + return 1; + } + + RAW_CHECK(info->chrome_versioned_path); + FilePath* chrome_versioned_path = new FilePath(info->chrome_versioned_path); + 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. + RAW_CHECK(info->app_mode_url); + std::string argv1(std::string("--app=") + info->app_mode_url); + RAW_CHECK(info->app_mode_id); + std::string argv2(std::string("--user-data-dir=/tmp/") + info->app_mode_id); + 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); +} |