Allow packaging accessibility extension from chromecast build
Make changes to build files to allow packaging chromevox from chromecast builds. Need to split out chromevox and common deps from deps that will only build for chromeos. Also add the ability to specify a manifest file using the FileUtil::LoadExtension method instead of assuming 'manifest.json' hard coded constant. Bug: None Test: Test case, Local chromecast build Change-Id: Id4e5ac0cbb80241536a2e7e3cf48a71dd5f1124a Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2112573 Reviewed-by: Mike Pinkerton <pinkerton@chromium.org> Reviewed-by: David Tseng <dtseng@chromium.org> Commit-Queue: Randy Rossi <rmrossi@chromium.org> Cr-Commit-Position: refs/heads/master@{#754093}
This commit is contained in:
BUILD.gn
chrome/browser/resources/chromeos/accessibility
chromecast/browser/extensions
extensions/common
4
BUILD.gn
4
BUILD.gn
@ -666,9 +666,7 @@ group("gn_all") {
|
|||||||
deps += [ "//chromecast:cast_shell" ]
|
deps += [ "//chromecast:cast_shell" ]
|
||||||
}
|
}
|
||||||
if (enable_extensions && use_aura) {
|
if (enable_extensions && use_aura) {
|
||||||
deps += [
|
deps += [ "//chrome/browser/resources/chromeos/accessibility:build" ]
|
||||||
"//chrome/browser/resources/chromeos/accessibility/chromevox:build",
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ import("//chrome/common/features.gni")
|
|||||||
import("//chromecast/chromecast.gni")
|
import("//chromecast/chromecast.gni")
|
||||||
import("strings/accessibility_strings.gni")
|
import("strings/accessibility_strings.gni")
|
||||||
|
|
||||||
assert(is_chromeos)
|
assert(is_chromeos || is_chromecast)
|
||||||
|
|
||||||
accessibility_out_dir = "$root_out_dir/resources/chromeos/accessibility/"
|
accessibility_out_dir = "$root_out_dir/resources/chromeos/accessibility/"
|
||||||
|
|
||||||
@ -16,16 +16,20 @@ group("build") {
|
|||||||
":accessibility_strings",
|
":accessibility_strings",
|
||||||
":chromevox_guest_manifest",
|
":chromevox_guest_manifest",
|
||||||
":chromevox_manifest",
|
":chromevox_manifest",
|
||||||
":select_to_speak_guest_manifest",
|
|
||||||
":select_to_speak_manifest",
|
|
||||||
":switch_access_guest_manifest",
|
|
||||||
":switch_access_manifest",
|
|
||||||
"autoclick:build",
|
|
||||||
"chromevox:build",
|
"chromevox:build",
|
||||||
"common:build",
|
"common:build",
|
||||||
"select_to_speak:build",
|
|
||||||
"switch_access:build",
|
|
||||||
]
|
]
|
||||||
|
if (is_chromeos) {
|
||||||
|
deps += [
|
||||||
|
":select_to_speak_guest_manifest",
|
||||||
|
":select_to_speak_manifest",
|
||||||
|
":switch_access_guest_manifest",
|
||||||
|
":switch_access_manifest",
|
||||||
|
"autoclick:build",
|
||||||
|
"select_to_speak:build",
|
||||||
|
"switch_access:build",
|
||||||
|
]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template("manifest") {
|
template("manifest") {
|
||||||
@ -99,11 +103,13 @@ accessibility_strings("accessibility_strings") {
|
|||||||
|
|
||||||
group("browser_tests") {
|
group("browser_tests") {
|
||||||
testonly = true
|
testonly = true
|
||||||
deps = [
|
if (is_chromeos) {
|
||||||
"autoclick:browser_tests",
|
deps = [
|
||||||
"chromevox:browser_tests",
|
"autoclick:browser_tests",
|
||||||
"common:browser_tests",
|
"chromevox:browser_tests",
|
||||||
"select_to_speak:browser_tests",
|
"common:browser_tests",
|
||||||
"switch_access:browser_tests",
|
"select_to_speak:browser_tests",
|
||||||
]
|
"switch_access:browser_tests",
|
||||||
|
]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@ import("//chrome/test/base/js2gtest.gni")
|
|||||||
import("//testing/test.gni")
|
import("//testing/test.gni")
|
||||||
import("//third_party/closure_compiler/compile_js.gni")
|
import("//third_party/closure_compiler/compile_js.gni")
|
||||||
|
|
||||||
assert(is_chromeos)
|
assert(is_chromeos || is_chromecast)
|
||||||
|
|
||||||
accessibility_common_out_dir =
|
accessibility_common_out_dir =
|
||||||
"$root_out_dir/resources/chromeos/accessibility/common"
|
"$root_out_dir/resources/chromeos/accessibility/common"
|
||||||
@ -111,12 +111,14 @@ js2gtest("accessibility_tests") {
|
|||||||
"../chromevox/testing/mock_feedback.js",
|
"../chromevox/testing/mock_feedback.js",
|
||||||
]
|
]
|
||||||
|
|
||||||
# The test base classes generate C++ code with these deps.
|
if (is_chromeos) {
|
||||||
deps = [
|
# The test base classes generate C++ code with these deps.
|
||||||
"//ash",
|
deps = [
|
||||||
"//base",
|
"//ash",
|
||||||
"//chrome/browser/chromeos",
|
"//base",
|
||||||
"//chrome/common",
|
"//chrome/browser/chromeos",
|
||||||
]
|
"//chrome/common",
|
||||||
|
]
|
||||||
|
}
|
||||||
defines = [ "HAS_OUT_OF_PROC_TEST_RUNNER" ]
|
defines = [ "HAS_OUT_OF_PROC_TEST_RUNNER" ]
|
||||||
}
|
}
|
||||||
|
@ -109,14 +109,21 @@ const Extension* CastExtensionSystem::LoadExtensionByManifest(
|
|||||||
|
|
||||||
const Extension* CastExtensionSystem::LoadExtension(
|
const Extension* CastExtensionSystem::LoadExtension(
|
||||||
const base::FilePath& extension_dir) {
|
const base::FilePath& extension_dir) {
|
||||||
|
return LoadExtension(kManifestFilename, extension_dir);
|
||||||
|
}
|
||||||
|
|
||||||
|
const Extension* CastExtensionSystem::LoadExtension(
|
||||||
|
const base::FilePath::CharType* manifest_file,
|
||||||
|
const base::FilePath& extension_dir) {
|
||||||
// cast_shell only supports unpacked extensions.
|
// cast_shell only supports unpacked extensions.
|
||||||
// NOTE: If you add packed extension support consider removing the flag
|
// NOTE: If you add packed extension support consider removing the flag
|
||||||
// FOLLOW_SYMLINKS_ANYWHERE below. Packed extensions should not have symlinks.
|
// FOLLOW_SYMLINKS_ANYWHERE below. Packed extensions should not have symlinks.
|
||||||
CHECK(base::DirectoryExists(extension_dir)) << extension_dir.AsUTF8Unsafe();
|
CHECK(base::DirectoryExists(extension_dir)) << extension_dir.AsUTF8Unsafe();
|
||||||
int load_flags = Extension::FOLLOW_SYMLINKS_ANYWHERE;
|
int load_flags = Extension::FOLLOW_SYMLINKS_ANYWHERE;
|
||||||
std::string load_error;
|
std::string load_error;
|
||||||
scoped_refptr<Extension> extension = file_util::LoadExtension(
|
scoped_refptr<Extension> extension =
|
||||||
extension_dir, Manifest::COMPONENT, load_flags, &load_error);
|
file_util::LoadExtension(extension_dir, manifest_file, std::string(),
|
||||||
|
Manifest::COMPONENT, load_flags, &load_error);
|
||||||
if (!extension.get()) {
|
if (!extension.get()) {
|
||||||
LOG(ERROR) << "Loading extension at " << extension_dir.value()
|
LOG(ERROR) << "Loading extension at " << extension_dir.value()
|
||||||
<< " failed with: " << load_error;
|
<< " failed with: " << load_error;
|
||||||
|
@ -8,16 +8,13 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "base/compiler_specific.h"
|
#include "base/compiler_specific.h"
|
||||||
|
#include "base/files/file_path.h"
|
||||||
#include "base/macros.h"
|
#include "base/macros.h"
|
||||||
#include "base/memory/weak_ptr.h"
|
#include "base/memory/weak_ptr.h"
|
||||||
#include "base/one_shot_event.h"
|
#include "base/one_shot_event.h"
|
||||||
#include "extensions/browser/extension_registrar.h"
|
#include "extensions/browser/extension_registrar.h"
|
||||||
#include "extensions/browser/extension_system.h"
|
#include "extensions/browser/extension_system.h"
|
||||||
|
|
||||||
namespace base {
|
|
||||||
class FilePath;
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace content {
|
namespace content {
|
||||||
class BrowserContext;
|
class BrowserContext;
|
||||||
}
|
}
|
||||||
@ -38,6 +35,11 @@ class CastExtensionSystem : public ExtensionSystem,
|
|||||||
// success, or nullptr otherwise.
|
// success, or nullptr otherwise.
|
||||||
const Extension* LoadExtension(const base::FilePath& extension_dir);
|
const Extension* LoadExtension(const base::FilePath& extension_dir);
|
||||||
|
|
||||||
|
// Loads an unpacked extension from a manifest file with the provided
|
||||||
|
// dir. Returns the extension on success, or nullptr otherwise.
|
||||||
|
const Extension* LoadExtension(const base::FilePath::CharType* manifest_file,
|
||||||
|
const base::FilePath& extension_dir);
|
||||||
|
|
||||||
// Load an extension from the contents of a manifest file.
|
// Load an extension from the contents of a manifest file.
|
||||||
const Extension* LoadExtensionByManifest(const std::string& manifest);
|
const Extension* LoadExtensionByManifest(const std::string& manifest);
|
||||||
|
|
||||||
|
@ -196,7 +196,8 @@ scoped_refptr<Extension> LoadExtension(const base::FilePath& extension_path,
|
|||||||
Manifest::Location location,
|
Manifest::Location location,
|
||||||
int flags,
|
int flags,
|
||||||
std::string* error) {
|
std::string* error) {
|
||||||
return LoadExtension(extension_path, std::string(), location, flags, error);
|
return LoadExtension(extension_path, nullptr, std::string(), location, flags,
|
||||||
|
error);
|
||||||
}
|
}
|
||||||
|
|
||||||
scoped_refptr<Extension> LoadExtension(const base::FilePath& extension_path,
|
scoped_refptr<Extension> LoadExtension(const base::FilePath& extension_path,
|
||||||
@ -204,8 +205,23 @@ scoped_refptr<Extension> LoadExtension(const base::FilePath& extension_path,
|
|||||||
Manifest::Location location,
|
Manifest::Location location,
|
||||||
int flags,
|
int flags,
|
||||||
std::string* error) {
|
std::string* error) {
|
||||||
std::unique_ptr<base::DictionaryValue> manifest =
|
return LoadExtension(extension_path, nullptr, extension_id, location, flags,
|
||||||
LoadManifest(extension_path, error);
|
error);
|
||||||
|
}
|
||||||
|
|
||||||
|
scoped_refptr<Extension> LoadExtension(
|
||||||
|
const base::FilePath& extension_path,
|
||||||
|
const base::FilePath::CharType* manifest_file,
|
||||||
|
const std::string& extension_id,
|
||||||
|
Manifest::Location location,
|
||||||
|
int flags,
|
||||||
|
std::string* error) {
|
||||||
|
std::unique_ptr<base::DictionaryValue> manifest;
|
||||||
|
if (!manifest_file) {
|
||||||
|
manifest = LoadManifest(extension_path, error);
|
||||||
|
} else {
|
||||||
|
manifest = LoadManifest(extension_path, manifest_file, error);
|
||||||
|
}
|
||||||
if (!manifest.get())
|
if (!manifest.get())
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
|
@ -46,8 +46,9 @@ base::FilePath InstallExtension(const base::FilePath& unpacked_source_dir,
|
|||||||
void UninstallExtension(const base::FilePath& extensions_dir,
|
void UninstallExtension(const base::FilePath& extensions_dir,
|
||||||
const std::string& id);
|
const std::string& id);
|
||||||
|
|
||||||
// Loads and validates an extension from the specified directory. Returns NULL
|
// Loads and validates an extension from the specified directory. Uses
|
||||||
// on failure, with a description of the error in |error|.
|
// the default manifest filename. Returns nullptr on failure, with a
|
||||||
|
// description of the error in |error|.
|
||||||
scoped_refptr<Extension> LoadExtension(const base::FilePath& extension_root,
|
scoped_refptr<Extension> LoadExtension(const base::FilePath& extension_root,
|
||||||
Manifest::Location location,
|
Manifest::Location location,
|
||||||
int flags,
|
int flags,
|
||||||
@ -60,6 +61,17 @@ scoped_refptr<Extension> LoadExtension(const base::FilePath& extension_root,
|
|||||||
int flags,
|
int flags,
|
||||||
std::string* error);
|
std::string* error);
|
||||||
|
|
||||||
|
// The same as LoadExtension except use the provided |manifest_file| and
|
||||||
|
// |extension_id|. If manifest_file is not specified, uses the default
|
||||||
|
// manifest filename.
|
||||||
|
scoped_refptr<Extension> LoadExtension(
|
||||||
|
const base::FilePath& extension_root,
|
||||||
|
const base::FilePath::CharType* manifest_file,
|
||||||
|
const std::string& extension_id,
|
||||||
|
Manifest::Location location,
|
||||||
|
int flags,
|
||||||
|
std::string* error);
|
||||||
|
|
||||||
// Loads an extension manifest from the specified directory. Returns NULL
|
// Loads an extension manifest from the specified directory. Returns NULL
|
||||||
// on failure, with a description of the error in |error|.
|
// on failure, with a description of the error in |error|.
|
||||||
std::unique_ptr<base::DictionaryValue> LoadManifest(
|
std::unique_ptr<base::DictionaryValue> LoadManifest(
|
||||||
|
@ -41,6 +41,10 @@ const char manifest_content[] =
|
|||||||
" \"manifest_version\": 2\n"
|
" \"manifest_version\": 2\n"
|
||||||
"}\n";
|
"}\n";
|
||||||
|
|
||||||
|
const char kCustomManifest[] = "custom_manifest.json";
|
||||||
|
const base::FilePath::CharType kCustomManifestFilename[] =
|
||||||
|
FILE_PATH_LITERAL("custom_manifest.json");
|
||||||
|
|
||||||
scoped_refptr<Extension> LoadExtensionManifest(
|
scoped_refptr<Extension> LoadExtensionManifest(
|
||||||
const base::DictionaryValue& manifest,
|
const base::DictionaryValue& manifest,
|
||||||
const base::FilePath& manifest_dir,
|
const base::FilePath& manifest_dir,
|
||||||
@ -510,6 +514,33 @@ TEST_F(FileUtilTest, WarnOnPrivateKey) {
|
|||||||
"extension includes the key file.*ext_root.a_key.pem"));
|
"extension includes the key file.*ext_root.a_key.pem"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Specify a file other than manifest.json
|
||||||
|
TEST_F(FileUtilTest, SpecifyManifestFile) {
|
||||||
|
base::ScopedTempDir temp;
|
||||||
|
ASSERT_TRUE(temp.CreateUniqueTempDir());
|
||||||
|
|
||||||
|
base::FilePath ext_path = temp.GetPath().AppendASCII("ext_root");
|
||||||
|
ASSERT_TRUE(base::CreateDirectory(ext_path));
|
||||||
|
|
||||||
|
const char manifest[] =
|
||||||
|
"{\n"
|
||||||
|
" \"name\": \"Test Extension\",\n"
|
||||||
|
" \"version\": \"1.0\",\n"
|
||||||
|
" \"manifest_version\": 2,\n"
|
||||||
|
" \"description\": \"The first extension that I made.\"\n"
|
||||||
|
"}\n";
|
||||||
|
ASSERT_EQ(static_cast<int>(strlen(manifest)),
|
||||||
|
base::WriteFile(ext_path.AppendASCII(kCustomManifest), manifest,
|
||||||
|
strlen(manifest)));
|
||||||
|
|
||||||
|
std::string error;
|
||||||
|
scoped_refptr<Extension> extension(file_util::LoadExtension(
|
||||||
|
ext_path, kCustomManifestFilename, "the_id", Manifest::EXTERNAL_PREF,
|
||||||
|
Extension::NO_FLAGS, &error));
|
||||||
|
ASSERT_TRUE(extension.get()) << error;
|
||||||
|
ASSERT_EQ(0u, extension->install_warnings().size());
|
||||||
|
}
|
||||||
|
|
||||||
// Try to install an extension with a zero-length icon file.
|
// Try to install an extension with a zero-length icon file.
|
||||||
TEST_F(FileUtilTest, CheckZeroLengthAndMissingIconFile) {
|
TEST_F(FileUtilTest, CheckZeroLengthAndMissingIconFile) {
|
||||||
base::FilePath install_dir;
|
base::FilePath install_dir;
|
||||||
|
Reference in New Issue
Block a user