default_shell_browser_main_delegate.cc revision 1320f92c476a1ad9d19dba2a48c72b75566198e9
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.
4
5#include "extensions/shell/browser/default_shell_browser_main_delegate.h"
6
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"
13
14namespace extensions {
15
16DefaultShellBrowserMainDelegate::DefaultShellBrowserMainDelegate() {
17}
18
19DefaultShellBrowserMainDelegate::~DefaultShellBrowserMainDelegate() {
20}
21
22void 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);
29
30    ShellExtensionSystem* extension_system = static_cast<ShellExtensionSystem*>(
31        ExtensionSystem::Get(browser_context));
32    if (!extension_system->LoadApp(app_absolute_dir))
33      return;
34    extension_system->LaunchApp();
35  } else {
36    LOG(ERROR) << "--" << switches::kAppShellAppPath
37               << " unset; boredom is in your future";
38  }
39}
40
41void DefaultShellBrowserMainDelegate::Shutdown() {
42}
43
44DesktopController* DefaultShellBrowserMainDelegate::CreateDesktopController() {
45  return new ShellDesktopController();
46}
47
48}  // namespace extensions
49