Commit 46c80dce authored by oshima@chromium.org's avatar oshima@chromium.org

Minimal athena shell main

BUG=362288

Review URL: https://codereview.chromium.org/270763002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@269643 0039d316-1c4b-4281-b951-d872f2087c98
parent 8a33b058
......@@ -4,6 +4,7 @@
#include "apps/shell/app/shell_main_delegate.h"
#include "apps/shell/browser/default_shell_browser_main_delegate.h"
#include "apps/shell/browser/shell_content_browser_client.h"
#include "apps/shell/common/shell_content_client.h"
#include "apps/shell/renderer/shell_content_renderer_client.h"
......@@ -65,7 +66,8 @@ void ShellMainDelegate::PreSandboxStartup() {
}
content::ContentBrowserClient* ShellMainDelegate::CreateContentBrowserClient() {
browser_client_.reset(new apps::ShellContentBrowserClient);
browser_client_.reset(
new apps::ShellContentBrowserClient(CreateShellBrowserMainDelegate()));
return browser_client_.get();
}
......@@ -75,6 +77,10 @@ ShellMainDelegate::CreateContentRendererClient() {
return renderer_client_.get();
}
ShellBrowserMainDelegate* ShellMainDelegate::CreateShellBrowserMainDelegate() {
return new DefaultShellBrowserMainDelegate();
}
// static
bool ShellMainDelegate::ProcessNeedsResourceBundle(
const std::string& process_type) {
......
......@@ -9,11 +9,15 @@
#include "base/memory/scoped_ptr.h"
#include "content/public/app/content_main_delegate.h"
namespace apps {
namespace content {
class BrowserContext;
class ContentBrowserClient;
class ContentClient;
class ContentRendererClient;
}
class ShellContentBrowserClient;
class ShellContentClient;
class ShellContentRendererClient;
namespace apps {
class ShellBrowserMainDelegate;
class ShellMainDelegate : public content::ContentMainDelegate {
public:
......@@ -27,6 +31,10 @@ class ShellMainDelegate : public content::ContentMainDelegate {
virtual content::ContentRendererClient* CreateContentRendererClient()
OVERRIDE;
protected:
// The created object is owned by ShellBrowserMainParts.
virtual ShellBrowserMainDelegate* CreateShellBrowserMainDelegate();
private:
// |process_type| is zygote, renderer, utility, etc. Returns true if the
// process needs data from resources.pak.
......@@ -35,9 +43,9 @@ class ShellMainDelegate : public content::ContentMainDelegate {
// Initializes the resource bundle and resources.pak.
static void InitializeResourceBundle();
scoped_ptr<ShellContentClient> content_client_;
scoped_ptr<ShellContentBrowserClient> browser_client_;
scoped_ptr<ShellContentRendererClient> renderer_client_;
scoped_ptr<content::ContentClient> content_client_;
scoped_ptr<content::ContentBrowserClient> browser_client_;
scoped_ptr<content::ContentRendererClient> renderer_client_;
DISALLOW_COPY_AND_ASSIGN(ShellMainDelegate);
};
......
......@@ -97,12 +97,15 @@
'app/shell_main_delegate.h',
'browser/api/shell/shell_api.cc',
'browser/api/shell/shell_api.h',
'browser/default_shell_browser_main_delegate.cc',
'browser/default_shell_browser_main_delegate.h',
'browser/shell_app_sorting.cc',
'browser/shell_app_sorting.h',
'browser/shell_app_window.cc',
'browser/shell_app_window.h',
'browser/shell_browser_context.cc',
'browser/shell_browser_context.h',
'browser/shell_browser_main_delegate.h',
'browser/shell_browser_main_parts.cc',
'browser/shell_browser_main_parts.h',
'browser/shell_content_browser_client.cc',
......
// Copyright 2014 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.
#include "apps/shell/browser/default_shell_browser_main_delegate.h"
#include "apps/shell/browser/shell_extension_system.h"
#include "base/command_line.h"
#include "base/file_util.h"
#include "base/files/file_path.h"
namespace apps {
DefaultShellBrowserMainDelegate::DefaultShellBrowserMainDelegate() {
}
DefaultShellBrowserMainDelegate::~DefaultShellBrowserMainDelegate() {
}
void DefaultShellBrowserMainDelegate::Start(
content::BrowserContext* browser_context) {
const std::string kAppSwitch = "app";
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
if (command_line->HasSwitch(kAppSwitch)) {
base::FilePath app_dir(command_line->GetSwitchValueNative(kAppSwitch));
base::FilePath app_absolute_dir = base::MakeAbsoluteFilePath(app_dir);
extensions::ShellExtensionSystem* extension_system =
static_cast<extensions::ShellExtensionSystem*>(
extensions::ExtensionSystem::Get(browser_context));
extension_system->LoadAndLaunchApp(app_absolute_dir);
} else {
LOG(ERROR) << "--" << kAppSwitch << " unset; boredom is in your future";
}
}
} // namespace apps
// Copyright 2014 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.
#ifndef APPS_SHELL_BROWSER_DEFAULT_SHELL_BROWSER_MAIN_DELEGATE_H_
#define APPS_SHELL_BROWSER_DEFAULT_SHELL_BROWSER_MAIN_DELEGATE_H_
#include "apps/shell/browser/shell_browser_main_delegate.h"
#include "base/compiler_specific.h"
#include "base/macros.h"
namespace apps {
// A ShellBrowserMainDelegate that starts an application specified
// by the "--app" command line. This is used only in the browser process.
class DefaultShellBrowserMainDelegate : public ShellBrowserMainDelegate {
public:
DefaultShellBrowserMainDelegate();
virtual ~DefaultShellBrowserMainDelegate();
// ShellBrowserMainDelegate:
virtual void Start(content::BrowserContext* context) OVERRIDE;
private:
DISALLOW_COPY_AND_ASSIGN(DefaultShellBrowserMainDelegate);
};
} // namespace apps
#endif // DEFAULT_SHELL_BROWSER_MAIN_DELEGATE_H_
// Copyright 2014 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.
#ifndef APPS_SHELL_BROWSER_SHELL_BROWSER_MAIN_DELEGATE_H_
#define APPS_SHELL_BROWSER_SHELL_BROWSER_MAIN_DELEGATE_H_
namespace content {
class BrowserContext;
}
namespace apps {
class ShellBrowserMainDelegate {
public:
virtual ~ShellBrowserMainDelegate() {}
// Called to start an application after all initialization processes that are
// necesary to run apps are completed.
virtual void Start(content::BrowserContext* context) = 0;
};
} // namespace apps
#endif // APPS_SHELL_BROWSER_SHELL_BROWSER_MAIN_DELEGATE_H_
......@@ -5,14 +5,12 @@
#include "apps/shell/browser/shell_browser_main_parts.h"
#include "apps/shell/browser/shell_browser_context.h"
#include "apps/shell/browser/shell_browser_main_delegate.h"
#include "apps/shell/browser/shell_desktop_controller.h"
#include "apps/shell/browser/shell_extension_system.h"
#include "apps/shell/browser/shell_extension_system_factory.h"
#include "apps/shell/browser/shell_extensions_browser_client.h"
#include "apps/shell/common/shell_extensions_client.h"
#include "base/command_line.h"
#include "base/file_util.h"
#include "base/files/file_path.h"
#include "base/run_loop.h"
#include "components/keyed_service/content/browser_context_dependency_manager.h"
#include "content/public/common/result_codes.h"
......@@ -47,10 +45,13 @@ void EnsureBrowserContextKeyedServiceFactoriesBuilt() {
namespace apps {
ShellBrowserMainParts::ShellBrowserMainParts(
const content::MainFunctionParams& parameters)
const content::MainFunctionParams& parameters,
ShellBrowserMainDelegate* browser_main_delegate)
: extension_system_(NULL),
parameters_(parameters),
run_message_loop_(true) {}
run_message_loop_(true),
browser_main_delegate_(browser_main_delegate) {
}
ShellBrowserMainParts::~ShellBrowserMainParts() {
}
......@@ -105,20 +106,13 @@ void ShellBrowserMainParts::PreMainMessageLoopRun() {
devtools_delegate_.reset(
new content::ShellDevToolsDelegate(browser_context_.get()));
const std::string kAppSwitch = "app";
CommandLine* command_line = CommandLine::ForCurrentProcess();
if (command_line->HasSwitch(kAppSwitch)) {
base::FilePath app_dir(command_line->GetSwitchValueNative(kAppSwitch));
base::FilePath app_absolute_dir = base::MakeAbsoluteFilePath(app_dir);
extension_system_->LoadAndLaunchApp(app_absolute_dir);
} else if (parameters_.ui_task) {
if (parameters_.ui_task) {
// For running browser tests.
parameters_.ui_task->Run();
delete parameters_.ui_task;
run_message_loop_ = false;
} else {
LOG(ERROR) << "--" << kAppSwitch << " unset; boredom is in your future";
browser_main_delegate_->Start(browser_context_.get());
}
}
......
......@@ -34,6 +34,7 @@ class NetLog;
namespace apps {
class ShellBrowserContext;
class ShellBrowserMainDelegate;
class ShellDesktopController;
class ShellExtensionsClient;
......@@ -45,8 +46,8 @@ class ShellNetworkController;
class ShellBrowserMainParts : public content::BrowserMainParts,
public aura::WindowTreeHostObserver {
public:
explicit ShellBrowserMainParts(
const content::MainFunctionParams& parameters);
ShellBrowserMainParts(const content::MainFunctionParams& parameters,
ShellBrowserMainDelegate* browser_main_delegate);
virtual ~ShellBrowserMainParts();
ShellBrowserContext* browser_context() {
......@@ -96,6 +97,8 @@ class ShellBrowserMainParts : public content::BrowserMainParts,
// in MainMessageLoopRun. If false, it has already been run.
bool run_message_loop_;
scoped_ptr<ShellBrowserMainDelegate> browser_main_delegate_;
DISALLOW_COPY_AND_ASSIGN(ShellBrowserMainParts);
};
......
......@@ -34,8 +34,9 @@ ShellContentBrowserClient* g_instance = NULL;
} // namespace
ShellContentBrowserClient::ShellContentBrowserClient()
: browser_main_parts_(NULL) {
ShellContentBrowserClient::ShellContentBrowserClient(
ShellBrowserMainDelegate* browser_main_delegate)
: browser_main_parts_(NULL), browser_main_delegate_(browser_main_delegate) {
DCHECK(!g_instance);
g_instance = this;
}
......@@ -53,7 +54,8 @@ content::BrowserContext* ShellContentBrowserClient::GetBrowserContext() {
content::BrowserMainParts* ShellContentBrowserClient::CreateBrowserMainParts(
const content::MainFunctionParams& parameters) {
browser_main_parts_ = new ShellBrowserMainParts(parameters);
browser_main_parts_ =
new ShellBrowserMainParts(parameters, browser_main_delegate_);
return browser_main_parts_;
}
......
......@@ -19,12 +19,14 @@ class Extension;
}
namespace apps {
class ShellBrowserMainDelegate;
class ShellBrowserMainParts;
// Content module browser process support for app_shell.
class ShellContentBrowserClient : public content::ContentBrowserClient {
public:
ShellContentBrowserClient();
explicit ShellContentBrowserClient(
ShellBrowserMainDelegate* browser_main_delegate);
virtual ~ShellContentBrowserClient();
// Returns the single instance.
......@@ -64,6 +66,9 @@ class ShellContentBrowserClient : public content::ContentBrowserClient {
// Owned by content::BrowserMainLoop.
ShellBrowserMainParts* browser_main_parts_;
// Owned by ShellBrowserMainParts.
ShellBrowserMainDelegate* browser_main_delegate_;
DISALLOW_COPY_AND_ASSIGN(ShellContentBrowserClient);
};
......
# Please do not add dependency to chrome/ and its subdirectories
include_rules = [
# Components within athena must state their dependencies explicitly.
"-athena",
]
include_rules = [
"+apps/shell/app",
"+apps/shell/browser",
"+content/public/app",
]
// Copyright 2014 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.
#include "apps/shell/app/shell_main_delegate.h"
#include "apps/shell/browser/shell_browser_main_delegate.h"
#include "content/public/app/content_main.h"
class AthenaBrowserMainDelegate : public apps::ShellBrowserMainDelegate {
public:
AthenaBrowserMainDelegate() {}
virtual ~AthenaBrowserMainDelegate() {}
// apps::ShellBrowserMainDelegate:
virtual void Start(content::BrowserContext* context) OVERRIDE {}
private:
DISALLOW_COPY_AND_ASSIGN(AthenaBrowserMainDelegate);
};
class AthenaMainDelegate : public apps::ShellMainDelegate {
public:
AthenaMainDelegate() {}
virtual ~AthenaMainDelegate() {}
private:
// apps::ShellMainDelegate:
virtual apps::ShellBrowserMainDelegate* CreateShellBrowserMainDelegate()
OVERRIDE {
return new AthenaBrowserMainDelegate();
}
DISALLOW_COPY_AND_ASSIGN(AthenaMainDelegate);
};
int main(int argc, const char** argv) {
AthenaMainDelegate delegate;
content::ContentMainParams params(&delegate);
params.argc = argc;
params.argv = argv;
return content::ContentMain(params);
}
# Copyright 2014 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.
{
'variables': {
'chromium_code': 1,
},
'targets': [
{
'target_name': 'athena_main',
'type': 'executable',
'dependencies': [
'../../apps/shell/app_shell.gyp:app_shell_lib',
],
'include_dirs': [
'../..',
],
'sources': [
'athena_main.cc',
],
},
], # targets
}
......@@ -225,6 +225,11 @@
'../apps/shell/app_shell.gyp:*',
],
}],
['chromeos==1', {
'dependencies': [
'../athena/main/athena_main.gyp:*',
],
}],
],
}, # target_name: All
{
......@@ -1202,6 +1207,7 @@
['chromeos==1', {
'dependencies': [
'../chromeos/chromeos.gyp:chromeos_unittests',
'../athena/main/athena_main.gyp:*',
],
}],
['use_ozone==1', {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment