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

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

Issue 2866073002: AppShell: pass command-line files to app as launch data (Closed)
Patch Set: Exclude app shell from //apps Created 3 years, 7 months 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
« no previous file with comments | « extensions/shell/browser/DEPS ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "apps/launcher.h"
7 #include "base/command_line.h" 8 #include "base/command_line.h"
8 #include "base/files/file_path.h" 9 #include "base/files/file_path.h"
9 #include "base/files/file_util.h" 10 #include "base/files/file_util.h"
11 #include "base/path_service.h"
10 #include "base/strings/string_tokenizer.h" 12 #include "base/strings/string_tokenizer.h"
11 #include "build/build_config.h" 13 #include "build/build_config.h"
12 #include "extensions/common/switches.h" 14 #include "extensions/common/switches.h"
13 #include "extensions/shell/browser/shell_extension_system.h" 15 #include "extensions/shell/browser/shell_extension_system.h"
14 16
15 #if defined(USE_AURA) 17 #if defined(USE_AURA)
16 #include "extensions/shell/browser/shell_desktop_controller_aura.h" 18 #include "extensions/shell/browser/shell_desktop_controller_aura.h"
17 #endif 19 #endif
18 20
19 #if defined(OS_MACOSX) 21 #if defined(OS_MACOSX)
(...skipping 16 matching lines...) Expand all
36 ExtensionSystem::Get(browser_context)); 38 ExtensionSystem::Get(browser_context));
37 extension_system->Init(); 39 extension_system->Init();
38 40
39 base::CommandLine::StringType path_list = 41 base::CommandLine::StringType path_list =
40 command_line->GetSwitchValueNative(switches::kLoadApps); 42 command_line->GetSwitchValueNative(switches::kLoadApps);
41 43
42 base::StringTokenizerT<base::CommandLine::StringType, 44 base::StringTokenizerT<base::CommandLine::StringType,
43 base::CommandLine::StringType::const_iterator> 45 base::CommandLine::StringType::const_iterator>
44 tokenizer(path_list, FILE_PATH_LITERAL(",")); 46 tokenizer(path_list, FILE_PATH_LITERAL(","));
45 47
46 std::string launch_id; 48 const Extension* launch_app = nullptr;
47 while (tokenizer.GetNext()) { 49 while (tokenizer.GetNext()) {
48 base::FilePath app_absolute_dir = 50 base::FilePath app_absolute_dir =
49 base::MakeAbsoluteFilePath(base::FilePath(tokenizer.token())); 51 base::MakeAbsoluteFilePath(base::FilePath(tokenizer.token()));
50 52
51 const Extension* extension = extension_system->LoadApp(app_absolute_dir); 53 const Extension* extension = extension_system->LoadApp(app_absolute_dir);
52 if (!extension) 54 if (extension && !launch_app)
53 continue; 55 launch_app = extension;
54 if (launch_id.empty())
55 launch_id = extension->id();
56 } 56 }
57 57
58 if (!launch_id.empty()) 58 if (launch_app) {
59 extension_system->LaunchApp(launch_id); 59 base::FilePath current_directory;
60 else 60 base::PathService::Get(base::DIR_CURRENT, &current_directory);
61 apps::LaunchPlatformAppWithCommandLineAndLaunchId(
62 browser_context, launch_app, launch_app->id(), *command_line,
63 current_directory, SOURCE_COMMAND_LINE);
64 } else {
61 LOG(ERROR) << "Could not load any apps."; 65 LOG(ERROR) << "Could not load any apps.";
66 }
62 } else { 67 } else {
63 LOG(ERROR) << "--" << switches::kLoadApps 68 LOG(ERROR) << "--" << switches::kLoadApps
64 << " unset; boredom is in your future"; 69 << " unset; boredom is in your future";
65 } 70 }
66 } 71 }
67 72
68 void DefaultShellBrowserMainDelegate::Shutdown() { 73 void DefaultShellBrowserMainDelegate::Shutdown() {
69 } 74 }
70 75
71 DesktopController* DefaultShellBrowserMainDelegate::CreateDesktopController() { 76 DesktopController* DefaultShellBrowserMainDelegate::CreateDesktopController() {
72 #if defined(USE_AURA) 77 #if defined(USE_AURA)
73 return new ShellDesktopControllerAura(); 78 return new ShellDesktopControllerAura();
74 #elif defined(OS_MACOSX) 79 #elif defined(OS_MACOSX)
75 return new ShellDesktopControllerMac(); 80 return new ShellDesktopControllerMac();
76 #else 81 #else
77 return NULL; 82 return NULL;
78 #endif 83 #endif
79 } 84 }
80 85
81 } // namespace extensions 86 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/shell/browser/DEPS ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698