blob: 561d33f25995222416ab4dfbf3c69756d38df57a [file] [log] [blame]
// Copyright (c) 2011 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/chrome_paths_internal.h"
#include "chrome/common/mac/app_mode_common.h"
extern "C" {
// |ChromeAppModeStart()| is the point of entry into the framework from the app
// mode loader.
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;
FilePath* chrome_versioned_path = new FilePath(info->chrome_versioned_path);
// TODO(viettrungluu): do something intelligent with data
// return ChromeMain(info->argc, info->argv);
// For now, a cheesy hack instead.
std::string argv1(std::string("--app=") + info->app_mode_url);
std::string argv2(std::string("--user-data-dir=/tmp/") + info->app_mode_id);
char* argv[] = { info->argv[0],
const_cast<char*>(argv2.c_str()) };
return ChromeMain(static_cast<int>(arraysize(argv)), argv);