| 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 "apps/launcher.h" | |
| 8 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 9 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
| 10 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
| 11 #include "base/path_service.h" | |
| 12 #include "base/strings/string_tokenizer.h" | 10 #include "base/strings/string_tokenizer.h" |
| 13 #include "build/build_config.h" | 11 #include "build/build_config.h" |
| 14 #include "extensions/common/switches.h" | 12 #include "extensions/common/switches.h" |
| 15 #include "extensions/shell/browser/shell_extension_system.h" | 13 #include "extensions/shell/browser/shell_extension_system.h" |
| 16 | 14 |
| 17 #if defined(USE_AURA) | 15 #if defined(USE_AURA) |
| 18 #include "extensions/shell/browser/shell_desktop_controller_aura.h" | 16 #include "extensions/shell/browser/shell_desktop_controller_aura.h" |
| 19 #endif | 17 #endif |
| 20 | 18 |
| 21 #if defined(OS_MACOSX) | 19 #if defined(OS_MACOSX) |
| (...skipping 16 matching lines...) Expand all Loading... |
| 38 ExtensionSystem::Get(browser_context)); | 36 ExtensionSystem::Get(browser_context)); |
| 39 extension_system->Init(); | 37 extension_system->Init(); |
| 40 | 38 |
| 41 base::CommandLine::StringType path_list = | 39 base::CommandLine::StringType path_list = |
| 42 command_line->GetSwitchValueNative(switches::kLoadApps); | 40 command_line->GetSwitchValueNative(switches::kLoadApps); |
| 43 | 41 |
| 44 base::StringTokenizerT<base::CommandLine::StringType, | 42 base::StringTokenizerT<base::CommandLine::StringType, |
| 45 base::CommandLine::StringType::const_iterator> | 43 base::CommandLine::StringType::const_iterator> |
| 46 tokenizer(path_list, FILE_PATH_LITERAL(",")); | 44 tokenizer(path_list, FILE_PATH_LITERAL(",")); |
| 47 | 45 |
| 48 const Extension* launch_app = nullptr; | 46 std::string launch_id; |
| 49 while (tokenizer.GetNext()) { | 47 while (tokenizer.GetNext()) { |
| 50 base::FilePath app_absolute_dir = | 48 base::FilePath app_absolute_dir = |
| 51 base::MakeAbsoluteFilePath(base::FilePath(tokenizer.token())); | 49 base::MakeAbsoluteFilePath(base::FilePath(tokenizer.token())); |
| 52 | 50 |
| 53 const Extension* extension = extension_system->LoadApp(app_absolute_dir); | 51 const Extension* extension = extension_system->LoadApp(app_absolute_dir); |
| 54 if (extension && !launch_app) | 52 if (!extension) |
| 55 launch_app = extension; | 53 continue; |
| 54 if (launch_id.empty()) |
| 55 launch_id = extension->id(); |
| 56 } | 56 } |
| 57 | 57 |
| 58 if (launch_app) { | 58 if (!launch_id.empty()) |
| 59 base::FilePath current_directory; | 59 extension_system->LaunchApp(launch_id); |
| 60 base::PathService::Get(base::DIR_CURRENT, ¤t_directory); | 60 else |
| 61 apps::LaunchPlatformAppWithCommandLineAndLaunchId( | |
| 62 browser_context, launch_app, launch_app->id(), *command_line, | |
| 63 current_directory, SOURCE_COMMAND_LINE); | |
| 64 } else { | |
| 65 LOG(ERROR) << "Could not load any apps."; | 61 LOG(ERROR) << "Could not load any apps."; |
| 66 } | |
| 67 } else { | 62 } else { |
| 68 LOG(ERROR) << "--" << switches::kLoadApps | 63 LOG(ERROR) << "--" << switches::kLoadApps |
| 69 << " unset; boredom is in your future"; | 64 << " unset; boredom is in your future"; |
| 70 } | 65 } |
| 71 } | 66 } |
| 72 | 67 |
| 73 void DefaultShellBrowserMainDelegate::Shutdown() { | 68 void DefaultShellBrowserMainDelegate::Shutdown() { |
| 74 } | 69 } |
| 75 | 70 |
| 76 DesktopController* DefaultShellBrowserMainDelegate::CreateDesktopController() { | 71 DesktopController* DefaultShellBrowserMainDelegate::CreateDesktopController() { |
| 77 #if defined(USE_AURA) | 72 #if defined(USE_AURA) |
| 78 return new ShellDesktopControllerAura(); | 73 return new ShellDesktopControllerAura(); |
| 79 #elif defined(OS_MACOSX) | 74 #elif defined(OS_MACOSX) |
| 80 return new ShellDesktopControllerMac(); | 75 return new ShellDesktopControllerMac(); |
| 81 #else | 76 #else |
| 82 return NULL; | 77 return NULL; |
| 83 #endif | 78 #endif |
| 84 } | 79 } |
| 85 | 80 |
| 86 } // namespace extensions | 81 } // namespace extensions |
| OLD | NEW |