Home | History | Annotate | Download | only in browser
      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 "apps/shell/browser/default_shell_browser_main_delegate.h"
      6 
      7 #include "apps/shell/browser/default_shell_app_window_controller.h"
      8 #include "apps/shell/browser/shell_desktop_controller.h"
      9 #include "apps/shell/browser/shell_extension_system.h"
     10 #include "base/command_line.h"
     11 #include "base/file_util.h"
     12 #include "base/files/file_path.h"
     13 
     14 namespace apps {
     15 
     16 DefaultShellBrowserMainDelegate::DefaultShellBrowserMainDelegate() {
     17 }
     18 
     19 DefaultShellBrowserMainDelegate::~DefaultShellBrowserMainDelegate() {
     20 }
     21 
     22 void DefaultShellBrowserMainDelegate::Start(
     23     content::BrowserContext* browser_context) {
     24   const std::string kAppSwitch = "app";
     25   base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
     26   if (command_line->HasSwitch(kAppSwitch)) {
     27     base::FilePath app_dir(command_line->GetSwitchValueNative(kAppSwitch));
     28     base::FilePath app_absolute_dir = base::MakeAbsoluteFilePath(app_dir);
     29 
     30     extensions::ShellExtensionSystem* extension_system =
     31         static_cast<extensions::ShellExtensionSystem*>(
     32             extensions::ExtensionSystem::Get(browser_context));
     33     if (!extension_system->LoadApp(app_absolute_dir))
     34       return;
     35     extension_system->LaunchApp();
     36   } else {
     37     LOG(ERROR) << "--" << kAppSwitch << " unset; boredom is in your future";
     38   }
     39 }
     40 
     41 void DefaultShellBrowserMainDelegate::Shutdown() {
     42 }
     43 
     44 ShellDesktopController*
     45 DefaultShellBrowserMainDelegate::CreateDesktopController() {
     46   ShellDesktopController* desktop = new ShellDesktopController();
     47   desktop->SetAppWindowController(new DefaultShellAppWindowController(desktop));
     48   return desktop;
     49 }
     50 
     51 }  // namespace apps
     52