Upstreaming browser/ui/uikit_ui_util from iOS.
[chromium-blink-merge.git] / extensions / shell / browser / default_shell_browser_main_delegate.cc
blobbbd237f86e6649a011cbe827dbfb1fddff38abbb
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 "base/strings/string_tokenizer.h"
11 #include "extensions/common/switches.h"
12 #include "extensions/shell/browser/shell_extension_system.h"
14 #if defined(USE_AURA)
15 #include "extensions/shell/browser/shell_desktop_controller_aura.h"
16 #endif
18 #if defined(OS_MACOSX)
19 #include "extensions/shell/browser/shell_desktop_controller_mac.h"
20 #endif
22 namespace extensions {
24 DefaultShellBrowserMainDelegate::DefaultShellBrowserMainDelegate() {
27 DefaultShellBrowserMainDelegate::~DefaultShellBrowserMainDelegate() {
30 void DefaultShellBrowserMainDelegate::Start(
31 content::BrowserContext* browser_context) {
32 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
33 if (command_line->HasSwitch(switches::kLoadApps)) {
34 ShellExtensionSystem* extension_system = static_cast<ShellExtensionSystem*>(
35 ExtensionSystem::Get(browser_context));
36 extension_system->Init();
38 base::CommandLine::StringType path_list =
39 command_line->GetSwitchValueNative(switches::kLoadApps);
41 base::StringTokenizerT<base::CommandLine::StringType,
42 base::CommandLine::StringType::const_iterator>
43 tokenizer(path_list, FILE_PATH_LITERAL(","));
45 std::string launch_id;
46 while (tokenizer.GetNext()) {
47 base::FilePath app_absolute_dir =
48 base::MakeAbsoluteFilePath(base::FilePath(tokenizer.token()));
50 const Extension* extension = extension_system->LoadApp(app_absolute_dir);
51 if (!extension)
52 continue;
53 if (launch_id.empty())
54 launch_id = extension->id();
57 if (!launch_id.empty())
58 extension_system->LaunchApp(launch_id);
59 else
60 LOG(ERROR) << "Could not load any apps.";
61 } else {
62 LOG(ERROR) << "--" << switches::kLoadApps
63 << " unset; boredom is in your future";
67 void DefaultShellBrowserMainDelegate::Shutdown() {
70 DesktopController* DefaultShellBrowserMainDelegate::CreateDesktopController() {
71 #if defined(USE_AURA)
72 return new ShellDesktopControllerAura();
73 #elif defined(OS_MACOSX)
74 return new ShellDesktopControllerMac();
75 #else
76 return NULL;
77 #endif
80 } // namespace extensions