Skip to content

Commit

Permalink
AppShell: pass command-line files to app as launch data
Browse files Browse the repository at this point in the history
An app that registers file handlers can be passed filenames on the
command line to use those files.

BUG=679870

Original Review-Url: https://codereview.chromium.org/2824553002

Review-Url: https://codereview.chromium.org/2866073002
Cr-Commit-Position: refs/heads/master@{#470810}
  • Loading branch information
michaelpg authored and Commit bot committed May 11, 2017
1 parent 34f6d31 commit 11b6e40
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 11 deletions.
2 changes: 2 additions & 0 deletions apps/DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ include_rules = [
"+components/keyed_service",
"+components/user_manager",
"+extensions",
# app_shell may depend on apps, but not vice versa.
"-extensions/shell",
"+net/base",
]

Expand Down
1 change: 1 addition & 0 deletions extensions/shell/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ source_set("app_shell_lib") {
deps = [
":resources",
":version_header",
"//apps",
"//base",
"//components/guest_view/browser",
"//components/guest_view/common",
Expand Down
3 changes: 0 additions & 3 deletions extensions/shell/DEPS
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
include_rules = [
# The apps module has dependencies on chrome.
"-apps",

# Individual subdirectories should have their own DEPS that include
# their allowed directories.
"-extensions/shell",
Expand Down
1 change: 1 addition & 0 deletions extensions/shell/browser/DEPS
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
include_rules = [
"+apps",
"+chromeos",
"+components/keyed_service",
"+components/nacl/browser",
Expand Down
21 changes: 13 additions & 8 deletions extensions/shell/browser/default_shell_browser_main_delegate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@

#include "extensions/shell/browser/default_shell_browser_main_delegate.h"

#include "apps/launcher.h"
#include "base/command_line.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/path_service.h"
#include "base/strings/string_tokenizer.h"
#include "build/build_config.h"
#include "extensions/common/switches.h"
Expand Down Expand Up @@ -43,22 +45,25 @@ void DefaultShellBrowserMainDelegate::Start(
base::CommandLine::StringType::const_iterator>
tokenizer(path_list, FILE_PATH_LITERAL(","));

std::string launch_id;
const Extension* launch_app = nullptr;
while (tokenizer.GetNext()) {
base::FilePath app_absolute_dir =
base::MakeAbsoluteFilePath(base::FilePath(tokenizer.token()));

const Extension* extension = extension_system->LoadApp(app_absolute_dir);
if (!extension)
continue;
if (launch_id.empty())
launch_id = extension->id();
if (extension && !launch_app)
launch_app = extension;
}

if (!launch_id.empty())
extension_system->LaunchApp(launch_id);
else
if (launch_app) {
base::FilePath current_directory;
base::PathService::Get(base::DIR_CURRENT, &current_directory);
apps::LaunchPlatformAppWithCommandLineAndLaunchId(
browser_context, launch_app, launch_app->id(), *command_line,
current_directory, SOURCE_COMMAND_LINE);
} else {
LOG(ERROR) << "Could not load any apps.";
}
} else {
LOG(ERROR) << "--" << switches::kLoadApps
<< " unset; boredom is in your future";
Expand Down

0 comments on commit 11b6e40

Please sign in to comment.