Commit 40fb9038 authored by Randy Rossi's avatar Randy Rossi Committed by Commit Bot

Stub commandLinePrivate API on chromecast

The ChromeVox extension was changed recently to call
commandLinePrivate to detect some experimental switches.
This API is not available on ChromeCast and was causing
the extension to fail on init.  Stubbing this API out
so the extension doesn't fail.

Bug: None
Test: Manual, display assistant
Change-Id: I86322b85778ca7d96d66ca90a119eae9347b84f1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1786581Reviewed-by: default avatarDavid Tseng <dtseng@chromium.org>
Reviewed-by: default avatarDaniel Nicoara <dnicoara@chromium.org>
Commit-Queue: Randy Rossi <rmrossi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#694903}
parent 5a15b7fb
......@@ -298,6 +298,8 @@ cast_source_set("browser") {
"extensions/api/bookmarks/bookmarks_api.h",
"extensions/api/braille_display_private/braille_display_private_api.cc",
"extensions/api/braille_display_private/braille_display_private_api.h",
"extensions/api/command_line_private/command_line_private_api.cc",
"extensions/api/command_line_private/command_line_private_api.h",
"extensions/api/history/history_api.cc",
"extensions/api/history/history_api.h",
"extensions/api/i18n/i18n_api.cc",
......
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chromecast/browser/extensions/api/command_line_private/command_line_private_api.h"
#include <memory>
#include <string>
#include "base/command_line.h"
#include "base/values.h"
#include "chromecast/common/extensions_api/command_line_private.h"
namespace extensions {
namespace command_line_private = cast::api::command_line_private;
ExtensionFunction::ResponseAction CommandLinePrivateHasSwitchFunction::Run() {
// This API is stubbed on chromecast to always return false.
return RespondNow(
ArgumentList(command_line_private::HasSwitch::Results::Create(false)));
}
} // namespace extensions
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROMECAST_BROWSER_EXTENSIONS_API_COMMAND_LINE_PRIVATE_COMMAND_LINE_PRIVATE_API_H_
#define CHROMECAST_BROWSER_EXTENSIONS_API_COMMAND_LINE_PRIVATE_COMMAND_LINE_PRIVATE_API_H_
#include "extensions/browser/extension_function.h"
namespace extensions {
class CommandLinePrivateHasSwitchFunction : public ExtensionFunction {
DECLARE_EXTENSION_FUNCTION("commandLinePrivate.hasSwitch",
COMMANDLINEPRIVATE_HASSWITCH)
protected:
~CommandLinePrivateHasSwitchFunction() override {}
// ExtensionFunction:
ResponseAction Run() override;
};
} // namespace extensions
#endif // CHROMECAST_BROWSER_EXTENSIONS_API_COMMAND_LINE_PRIVATE_COMMAND_LINE_PRIVATE_API_H_
......@@ -115,7 +115,7 @@ const Extension* CastExtensionSystem::LoadExtension(
int load_flags = Extension::FOLLOW_SYMLINKS_ANYWHERE;
std::string load_error;
scoped_refptr<Extension> extension = file_util::LoadExtension(
extension_dir, Manifest::COMMAND_LINE, load_flags, &load_error);
extension_dir, Manifest::COMPONENT, load_flags, &load_error);
if (!extension.get()) {
LOG(ERROR) << "Loading extension at " << extension_dir.value()
<< " failed with: " << load_error;
......
......@@ -17,6 +17,7 @@ schema_sources = [
"accessibility_private.json",
"bookmarks.json",
"braille_display_private.idl",
"command_line_private.json",
"history.json",
"identity.idl",
"i18n.json",
......
......@@ -15,6 +15,10 @@
"dependencies": ["permission:brailleDisplayPrivate"],
"contexts": ["blessed_extension"]
},
"commandLinePrivate": {
"dependencies": ["permission:commandLinePrivate"],
"contexts": ["blessed_extension"]
},
"i18n": {
"channel": "stable",
"extension_types": ["extension", "legacy_packaged_app", "platform_app"],
......
......@@ -17,6 +17,11 @@
"extension_types": ["extension", "legacy_packaged_app", "platform_app"],
"location": "component"
},
"commandLinePrivate": {
"channel": "stable",
"extension_types": ["extension", "legacy_packaged_app", "platform_app"],
"location": "component"
},
"history": {
"channel": "stable",
"extension_types": ["extension", "legacy_packaged_app"]
......
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
[
{
"namespace": "commandLinePrivate",
"description": "none",
"functions": [
{
"name": "hasSwitch",
"type": "function",
"description": "Returns whether a switch is specified on the command line when launching Chrome.",
"parameters": [
{
"name": "name",
"type": "string",
"description": "The name of a command line switch, without leading \"--\", such as \"enable-experimental-extension-apis\"."
},
{
"name": "callback",
"type": "function",
"parameters": [
{
"name": "result",
"type": "boolean",
"description": "Whether the switch is specified on the command line."
}
]
}
]
}
]
}
]
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment