Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "extensions/shell/browser/default_shell_browser_main_delegate.h" | 5 #include "extensions/shell/browser/default_shell_browser_main_delegate.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
| 9 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
| 10 #include "base/strings/string_tokenizer.h" | |
| 10 #include "extensions/shell/browser/shell_desktop_controller.h" | 11 #include "extensions/shell/browser/shell_desktop_controller.h" |
| 11 #include "extensions/shell/browser/shell_extension_system.h" | 12 #include "extensions/shell/browser/shell_extension_system.h" |
| 12 #include "extensions/shell/common/switches.h" | 13 #include "extensions/shell/common/switches.h" |
| 13 | 14 |
| 14 namespace extensions { | 15 namespace extensions { |
| 15 | 16 |
| 16 DefaultShellBrowserMainDelegate::DefaultShellBrowserMainDelegate() { | 17 DefaultShellBrowserMainDelegate::DefaultShellBrowserMainDelegate() { |
| 17 } | 18 } |
| 18 | 19 |
| 19 DefaultShellBrowserMainDelegate::~DefaultShellBrowserMainDelegate() { | 20 DefaultShellBrowserMainDelegate::~DefaultShellBrowserMainDelegate() { |
| 20 } | 21 } |
| 21 | 22 |
| 22 void DefaultShellBrowserMainDelegate::Start( | 23 void DefaultShellBrowserMainDelegate::Start( |
| 23 content::BrowserContext* browser_context) { | 24 content::BrowserContext* browser_context) { |
| 24 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | 25 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
| 25 if (command_line->HasSwitch(switches::kAppShellAppPath)) { | 26 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*>( | 27 ShellExtensionSystem* extension_system = static_cast<ShellExtensionSystem*>( |
| 31 ExtensionSystem::Get(browser_context)); | 28 ExtensionSystem::Get(browser_context)); |
| 32 if (!extension_system->LoadApp(app_absolute_dir)) | 29 CommandLine::StringType path_list = |
| 33 return; | 30 command_line->GetSwitchValueNative(switches::kAppShellAppPath); |
| 34 extension_system->LaunchApp(); | 31 |
| 32 base::StringTokenizerT<CommandLine::StringType, | |
| 33 CommandLine::StringType::const_iterator> | |
| 34 t(path_list, FILE_PATH_LITERAL(",")); | |
|
James Cook
2014/10/23 21:29:52
Give this a more descriptive name than "t"
lfg
2014/10/23 22:04:05
Done.
| |
| 35 extension_system->Init(); | |
|
James Cook
2014/10/23 21:29:52
I would move this above the tokenizer declaration
lfg
2014/10/23 22:04:05
Done.
| |
| 36 while (t.GetNext()) { | |
| 37 base::FilePath app_absolute_dir = | |
| 38 base::MakeAbsoluteFilePath(base::FilePath(t.token())); | |
| 39 | |
| 40 const Extension* extension = extension_system->LoadApp(app_absolute_dir); | |
| 41 if (!extension) | |
| 42 continue; | |
| 43 extension_system->LaunchApp(extension->id()); | |
| 44 } | |
| 35 } else { | 45 } else { |
| 36 LOG(ERROR) << "--" << switches::kAppShellAppPath | 46 LOG(ERROR) << "--" << switches::kAppShellAppPath |
| 37 << " unset; boredom is in your future"; | 47 << " unset; boredom is in your future"; |
| 38 } | 48 } |
| 39 } | 49 } |
| 40 | 50 |
| 41 void DefaultShellBrowserMainDelegate::Shutdown() { | 51 void DefaultShellBrowserMainDelegate::Shutdown() { |
| 42 } | 52 } |
| 43 | 53 |
| 44 DesktopController* DefaultShellBrowserMainDelegate::CreateDesktopController() { | 54 DesktopController* DefaultShellBrowserMainDelegate::CreateDesktopController() { |
| 45 return new ShellDesktopController(); | 55 return new ShellDesktopController(); |
| 46 } | 56 } |
| 47 | 57 |
| 48 } // namespace extensions | 58 } // namespace extensions |
| OLD | NEW |