Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(10)

Side by Side Diff: extensions/shell/browser/default_shell_browser_main_delegate.cc

Issue 727963004: app_shell: Change flag for loading apps to --load-app and only launch (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Code review fixes Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "base/strings/string_tokenizer.h"
11 #include "extensions/common/switches.h"
11 #include "extensions/shell/browser/shell_desktop_controller.h" 12 #include "extensions/shell/browser/shell_desktop_controller.h"
12 #include "extensions/shell/browser/shell_extension_system.h" 13 #include "extensions/shell/browser/shell_extension_system.h"
13 #include "extensions/shell/common/switches.h"
14 14
15 namespace extensions { 15 namespace extensions {
16 16
17 DefaultShellBrowserMainDelegate::DefaultShellBrowserMainDelegate() { 17 DefaultShellBrowserMainDelegate::DefaultShellBrowserMainDelegate() {
18 } 18 }
19 19
20 DefaultShellBrowserMainDelegate::~DefaultShellBrowserMainDelegate() { 20 DefaultShellBrowserMainDelegate::~DefaultShellBrowserMainDelegate() {
21 } 21 }
22 22
23 void DefaultShellBrowserMainDelegate::Start( 23 void DefaultShellBrowserMainDelegate::Start(
24 content::BrowserContext* browser_context) { 24 content::BrowserContext* browser_context) {
25 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); 25 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
26 if (command_line->HasSwitch(switches::kAppShellAppPath)) { 26 if (command_line->HasSwitch(switches::kLoadApps)) {
27 ShellExtensionSystem* extension_system = static_cast<ShellExtensionSystem*>( 27 ShellExtensionSystem* extension_system = static_cast<ShellExtensionSystem*>(
28 ExtensionSystem::Get(browser_context)); 28 ExtensionSystem::Get(browser_context));
29 extension_system->Init(); 29 extension_system->Init();
30 30
31 CommandLine::StringType path_list = 31 CommandLine::StringType path_list =
32 command_line->GetSwitchValueNative(switches::kAppShellAppPath); 32 command_line->GetSwitchValueNative(switches::kLoadApps);
33 33
34 base::StringTokenizerT<CommandLine::StringType, 34 base::StringTokenizerT<CommandLine::StringType,
35 CommandLine::StringType::const_iterator> 35 CommandLine::StringType::const_iterator>
36 tokenizer(path_list, FILE_PATH_LITERAL(",")); 36 tokenizer(path_list, FILE_PATH_LITERAL(","));
37
38
39 std::string launch_id;
37 while (tokenizer.GetNext()) { 40 while (tokenizer.GetNext()) {
38 base::FilePath app_absolute_dir = 41 base::FilePath app_absolute_dir =
39 base::MakeAbsoluteFilePath(base::FilePath(tokenizer.token())); 42 base::MakeAbsoluteFilePath(base::FilePath(tokenizer.token()));
40 43
41 const Extension* extension = extension_system->LoadApp(app_absolute_dir); 44 const Extension* extension = extension_system->LoadApp(app_absolute_dir);
42 if (!extension) 45 if (!extension)
43 continue; 46 continue;
44 extension_system->LaunchApp(extension->id()); 47 if (launch_id.empty())
48 launch_id = extension->id();
45 } 49 }
50
51 if (!launch_id.empty())
52 extension_system->LaunchApp(launch_id);
53 else
54 LOG(ERROR) << "Could not load any apps.";
46 } else { 55 } else {
47 LOG(ERROR) << "--" << switches::kAppShellAppPath 56 LOG(ERROR) << "--" << switches::kLoadApps
48 << " unset; boredom is in your future"; 57 << " unset; boredom is in your future";
49 } 58 }
50 } 59 }
51 60
52 void DefaultShellBrowserMainDelegate::Shutdown() { 61 void DefaultShellBrowserMainDelegate::Shutdown() {
53 } 62 }
54 63
55 DesktopController* DefaultShellBrowserMainDelegate::CreateDesktopController() { 64 DesktopController* DefaultShellBrowserMainDelegate::CreateDesktopController() {
56 return new ShellDesktopController(); 65 return new ShellDesktopController();
57 } 66 }
58 67
59 } // namespace extensions 68 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698