1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "extensions/shell/browser/default_shell_browser_main_delegate.h"
7 #include "base/command_line.h"
8 #include "base/files/file_path.h"
9 #include "base/files/file_util.h"
10 #include "extensions/shell/browser/shell_desktop_controller.h"
11 #include "extensions/shell/browser/shell_extension_system.h"
12 #include "extensions/shell/common/switches.h"
14 namespace extensions
{
16 DefaultShellBrowserMainDelegate::DefaultShellBrowserMainDelegate() {
19 DefaultShellBrowserMainDelegate::~DefaultShellBrowserMainDelegate() {
22 void DefaultShellBrowserMainDelegate::Start(
23 content::BrowserContext
* browser_context
) {
24 base::CommandLine
* command_line
= base::CommandLine::ForCurrentProcess();
25 if (command_line
->HasSwitch(switches::kAppShellAppPath
)) {
26 base::FilePath
app_dir(
27 command_line
->GetSwitchValueNative(switches::kAppShellAppPath
));
28 base::FilePath app_absolute_dir
= base::MakeAbsoluteFilePath(app_dir
);
30 ShellExtensionSystem
* extension_system
= static_cast<ShellExtensionSystem
*>(
31 ExtensionSystem::Get(browser_context
));
32 if (!extension_system
->LoadApp(app_absolute_dir
))
34 extension_system
->LaunchApp();
36 LOG(ERROR
) << "--" << switches::kAppShellAppPath
37 << " unset; boredom is in your future";
41 void DefaultShellBrowserMainDelegate::Shutdown() {
44 DesktopController
* DefaultShellBrowserMainDelegate::CreateDesktopController() {
45 return new ShellDesktopController();
48 } // namespace extensions