Commit e5b33742 authored by Albert Chaulk's avatar Albert Chaulk Committed by Commit Bot

[Chromecast] Change from depending on extensions/shell API

Previously the API build targets from //extensions/shell were used
to simplify the porting process. As we will be needing to extend this
with custom features this moves the shell API build files and changes
them to be correct for chromecast

This also adds content_scripts from chrome and custom cast_url
manifest features to match the removed code

Bug: b/73383411
Test: Load local extension verify things still work
Change-Id: I4e3a08e463ed7560c93ac45d7a4295dfdca8e4d4
Reviewed-on: https://chromium-review.googlesource.com/963074
Commit-Queue: Albert Chaulk <achaulk@chromium.org>
Reviewed-by: default avatarLuke Halliwell <halliwell@chromium.org>
Cr-Commit-Position: refs/heads/master@{#543820}
parent 2b116b4d
...@@ -238,6 +238,7 @@ cast_source_set("browser") { ...@@ -238,6 +238,7 @@ cast_source_set("browser") {
] ]
deps += [ deps += [
"//chromecast/common/extensions_api:api_registration_bundle_generator_registration",
"//components/guest_view/browser", "//components/guest_view/browser",
"//components/keyed_service/content", "//components/keyed_service/content",
"//components/pref_registry", "//components/pref_registry",
...@@ -247,7 +248,6 @@ cast_source_set("browser") { ...@@ -247,7 +248,6 @@ cast_source_set("browser") {
"//extensions/browser", "//extensions/browser",
"//extensions/common", "//extensions/common",
"//extensions/common/api", "//extensions/common/api",
"//extensions/shell/common/api:api_registration_bundle_generator_registration",
"//google_apis:google_apis", "//google_apis:google_apis",
] ]
} }
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
#include "chromecast/browser/extensions/api/identity/identity_api.h" #include "chromecast/browser/extensions/api/identity/identity_api.h"
namespace extensions { namespace extensions {
namespace shell { namespace cast {
namespace { namespace {
const char kErrorNoUserAccount[] = "No user account."; const char kErrorNoUserAccount[] = "No user account.";
...@@ -35,5 +35,5 @@ ExtensionFunction::ResponseAction IdentityRemoveCachedAuthTokenFunction::Run() { ...@@ -35,5 +35,5 @@ ExtensionFunction::ResponseAction IdentityRemoveCachedAuthTokenFunction::Run() {
return RespondNow(NoArguments()); return RespondNow(NoArguments());
} }
} // namespace shell } // namespace cast
} // namespace extensions } // namespace extensions
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
#include "extensions/browser/extension_function.h" #include "extensions/browser/extension_function.h"
namespace extensions { namespace extensions {
namespace shell { namespace cast {
// Returns an OAuth2 access token for a user. See the IDL file for // Returns an OAuth2 access token for a user. See the IDL file for
// documentation. // documentation.
...@@ -49,7 +49,7 @@ class IdentityRemoveCachedAuthTokenFunction : public UIThreadExtensionFunction { ...@@ -49,7 +49,7 @@ class IdentityRemoveCachedAuthTokenFunction : public UIThreadExtensionFunction {
DISALLOW_COPY_AND_ASSIGN(IdentityRemoveCachedAuthTokenFunction); DISALLOW_COPY_AND_ASSIGN(IdentityRemoveCachedAuthTokenFunction);
}; };
} // namespace shell } // namespace cast
} // namespace extensions } // namespace extensions
#endif // CHROMECAST_BROWSER_EXTENSIONS_API_IDENTITY_IDENTITY_API_H_ #endif // CHROMECAST_BROWSER_EXTENSIONS_API_IDENTITY_IDENTITY_API_H_
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include "base/memory/ptr_util.h" #include "base/memory/ptr_util.h"
#include "build/build_config.h" #include "build/build_config.h"
#include "chromecast/browser/extensions/api/generated_api_registration.h"
#include "chromecast/browser/extensions/cast_extension_host_delegate.h" #include "chromecast/browser/extensions/cast_extension_host_delegate.h"
#include "chromecast/browser/extensions/cast_extension_system_factory.h" #include "chromecast/browser/extensions/cast_extension_system_factory.h"
#include "chromecast/browser/extensions/cast_extension_web_contents_observer.h" #include "chromecast/browser/extensions/cast_extension_web_contents_observer.h"
...@@ -27,7 +28,6 @@ ...@@ -27,7 +28,6 @@
#include "extensions/browser/updater/null_extension_cache.h" #include "extensions/browser/updater/null_extension_cache.h"
#include "extensions/browser/url_request_util.h" #include "extensions/browser/url_request_util.h"
#include "extensions/common/features/feature_channel.h" #include "extensions/common/features/feature_channel.h"
#include "extensions/shell/browser/api/generated_api_registration.h"
using content::BrowserContext; using content::BrowserContext;
using content::BrowserThread; using content::BrowserThread;
...@@ -191,7 +191,7 @@ void CastExtensionsBrowserClient::RegisterExtensionFunctions( ...@@ -191,7 +191,7 @@ void CastExtensionsBrowserClient::RegisterExtensionFunctions(
api::GeneratedFunctionRegistry::RegisterAll(registry); api::GeneratedFunctionRegistry::RegisterAll(registry);
// cast_shell-only APIs. // cast_shell-only APIs.
shell::api::ShellGeneratedFunctionRegistry::RegisterAll(registry); cast::api::CastGeneratedFunctionRegistry::RegisterAll(registry);
} }
void CastExtensionsBrowserClient::RegisterExtensionInterfaces( void CastExtensionsBrowserClient::RegisterExtensionInterfaces(
......
...@@ -33,15 +33,15 @@ cast_source_set("common") { ...@@ -33,15 +33,15 @@ cast_source_set("common") {
] ]
deps += [ deps += [
"//chromecast/common/extensions_api:api",
"//chromecast/common/extensions_api:api_registration",
"//chromecast/common/extensions_api:extensions_features",
"//components/version_info", "//components/version_info",
"//extensions:extensions_resources_grd_grit", "//extensions:extensions_resources_grd_grit",
"//extensions/common", "//extensions/common",
"//extensions/common/api:generated_api_bundle_generator_schema", "//extensions/common/api:generated_api_bundle_generator_schema",
"//extensions/shell:resources", "//extensions/shell:resources",
"//extensions/shell:resources_grit", "//extensions/shell:resources_grit",
"//extensions/shell/common/api",
"//extensions/shell/common/api:api_registration",
"//extensions/shell/common/api:extensions_features",
] ]
} }
} }
......
...@@ -10,6 +10,11 @@ ...@@ -10,6 +10,11 @@
#include "base/lazy_instance.h" #include "base/lazy_instance.h"
#include "base/logging.h" #include "base/logging.h"
#include "base/macros.h" #include "base/macros.h"
#include "chromecast/common/extensions_api/cast_api_features.h"
#include "chromecast/common/extensions_api/cast_behavior_features.h"
#include "chromecast/common/extensions_api/cast_manifest_features.h"
#include "chromecast/common/extensions_api/cast_permission_features.h"
#include "chromecast/common/extensions_api/generated_schemas.h"
#include "components/version_info/version_info.h" #include "components/version_info/version_info.h"
#include "content/public/common/user_agent.h" #include "content/public/common/user_agent.h"
#include "extensions/common/api/generated_schemas.h" #include "extensions/common/api/generated_schemas.h"
...@@ -26,11 +31,6 @@ ...@@ -26,11 +31,6 @@
#include "extensions/common/permissions/permissions_provider.h" #include "extensions/common/permissions/permissions_provider.h"
#include "extensions/common/url_pattern_set.h" #include "extensions/common/url_pattern_set.h"
#include "extensions/grit/extensions_resources.h" #include "extensions/grit/extensions_resources.h"
#include "extensions/shell/common/api/generated_schemas.h"
#include "extensions/shell/common/api/shell_api_features.h"
#include "extensions/shell/common/api/shell_behavior_features.h"
#include "extensions/shell/common/api/shell_manifest_features.h"
#include "extensions/shell/common/api/shell_permission_features.h"
#include "extensions/shell/grit/app_shell_resources.h" #include "extensions/shell/grit/app_shell_resources.h"
namespace extensions { namespace extensions {
...@@ -112,27 +112,13 @@ std::unique_ptr<FeatureProvider> CastExtensionsClient::CreateFeatureProvider( ...@@ -112,27 +112,13 @@ std::unique_ptr<FeatureProvider> CastExtensionsClient::CreateFeatureProvider(
const std::string& name) const { const std::string& name) const {
std::unique_ptr<FeatureProvider> provider; std::unique_ptr<FeatureProvider> provider;
if (name == "api") { if (name == "api") {
provider = std::make_unique<ShellAPIFeatureProvider>(); provider = std::make_unique<CastAPIFeatureProvider>();
} else if (name == "manifest") { } else if (name == "manifest") {
provider = std::make_unique<ShellManifestFeatureProvider>(); provider = std::make_unique<CastManifestFeatureProvider>();
auto* feature = new extensions::ManifestFeature();
feature->set_name("cast_url");
feature->set_channel(version_info::Channel::STABLE);
feature->set_extension_types({extensions::Manifest::TYPE_PLATFORM_APP});
provider->AddFeature("cast_url", feature);
feature = new extensions::ManifestFeature();
feature->set_name("content_scripts");
feature->set_channel(version_info::Channel::STABLE);
feature->set_extension_types(
{extensions::Manifest::TYPE_EXTENSION,
extensions::Manifest::TYPE_LEGACY_PACKAGED_APP});
provider->AddFeature("content_scripts", feature);
} else if (name == "permission") { } else if (name == "permission") {
provider = std::make_unique<ShellPermissionFeatureProvider>(); provider = std::make_unique<CastPermissionFeatureProvider>();
} else if (name == "behavior") { } else if (name == "behavior") {
provider = std::make_unique<ShellBehaviorFeatureProvider>(); provider = std::make_unique<CastBehaviorFeatureProvider>();
} else { } else {
NOTREACHED(); NOTREACHED();
} }
...@@ -181,14 +167,14 @@ bool CastExtensionsClient::IsScriptableURL(const GURL& url, ...@@ -181,14 +167,14 @@ bool CastExtensionsClient::IsScriptableURL(const GURL& url,
bool CastExtensionsClient::IsAPISchemaGenerated(const std::string& name) const { bool CastExtensionsClient::IsAPISchemaGenerated(const std::string& name) const {
return api::GeneratedSchemas::IsGenerated(name) || return api::GeneratedSchemas::IsGenerated(name) ||
shell::api::ShellGeneratedSchemas::IsGenerated(name); cast::api::CastGeneratedSchemas::IsGenerated(name);
} }
base::StringPiece CastExtensionsClient::GetAPISchema( base::StringPiece CastExtensionsClient::GetAPISchema(
const std::string& name) const { const std::string& name) const {
// Schema for cast_shell-only APIs. // Schema for cast_shell-only APIs.
if (shell::api::ShellGeneratedSchemas::IsGenerated(name)) if (cast::api::CastGeneratedSchemas::IsGenerated(name))
return shell::api::ShellGeneratedSchemas::Get(name); return cast::api::CastGeneratedSchemas::Get(name);
// Core extensions APIs. // Core extensions APIs.
return api::GeneratedSchemas::Get(name); return api::GeneratedSchemas::Get(name);
......
# Copyright 2018 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.
import("//extensions/buildflags/buildflags.gni")
import("//tools/json_schema_compiler/json_features.gni")
import("//tools/json_schema_compiler/json_schema_api.gni")
assert(enable_extensions,
"Cannot depend on extensions because enable_extensions=false.")
schema_sources = [ "identity.idl" ]
root_namespace = "extensions::cast::api::%(namespace)s"
json_schema_api("api") {
sources = schema_sources
schemas = true
bundle = true
bundle_name = "Cast"
}
json_schema_api("api_registration") {
sources = schema_sources
impl_dir = "//chromecast/browser/extensions/api"
bundle_registration = true
bundle_name = "Cast"
deps = [
":api",
"//extensions/common",
]
}
json_features("cast_api_features") {
feature_type = "APIFeature"
provider_class = "CastAPIFeatureProvider"
sources = [
"../../../extensions/common/api/_api_features.json",
"_api_features.json",
]
}
json_features("cast_permission_features") {
feature_type = "PermissionFeature"
provider_class = "CastPermissionFeatureProvider"
sources = [
"../../../extensions/common/api/_permission_features.json",
]
}
json_features("cast_manifest_features") {
feature_type = "ManifestFeature"
provider_class = "CastManifestFeatureProvider"
sources = [
"../../../extensions/common/api/_manifest_features.json",
"_manifest_features.json",
]
}
json_features("cast_behavior_features") {
feature_type = "BehaviorFeature"
provider_class = "CastBehaviorFeatureProvider"
sources = [
"../../../extensions/common/api/_behavior_features.json",
]
}
group("extensions_features") {
public_deps = [
":cast_api_features",
":cast_behavior_features",
":cast_manifest_features",
":cast_permission_features",
]
}
// Copyright 2018 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.
// This file defines extension APIs implemented under src/chromecast.
// See extensions/common/features/* to understand this file, in particular
// feature.h, simple_feature.h, and feature_provider.h.
{
// Stub implementation of chrome.identity for app_shell.
"identity": {
"channel": "dev",
"contexts": ["blessed_extension"],
"extension_types": ["platform_app"]
},
// Setup related functions for a Google Cloud Devices (GCD) target device.
"shell.gcd": {
"channel": "dev",
"contexts": ["blessed_extension"],
"extension_types": ["platform_app"]
}
}
// Copyright 2018 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.
{
"cast_url": {
"channel": "stable",
"extension_types": ["platform_app"]
},
"content_scripts": {
"channel": "stable",
"extension_types": ["extension", "legacy_packaged_app"]
}
}
// Copyright 2018 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.
// Simplified implementation of the <code>chrome.identity</code> for
// cast_shell.
namespace identity {
dictionary GetAuthTokenDetails {
// Ignored parameter. Exists only for compatibility.
boolean? interactive;
};
dictionary InvalidTokenDetails {
// Ignored parameter. Exists only for compatibility.
DOMString? token;
};
// Called with the OAuth2 access token on success or undefined on error.
callback GetAuthTokenCallback = void (optional DOMString token);
// Called by removeCachedAuthToken().
callback InvalidateAuthTokenCallback = void ();
interface Functions {
// Returns an OAuth2 access token for the current cast_shell user for scopes
// from the manifest. Does not prompt the user.
static void getAuthToken(GetAuthTokenDetails options,
GetAuthTokenCallback callback);
// Stub. Calls callback immediately because cast_shell does not cache access
// tokens the way Chrome does.
static void removeCachedAuthToken(InvalidTokenDetails details,
InvalidateAuthTokenCallback callback);
};
interface Events {
// Stub. Never fired because cast_shell only supports a single user account.
static void onSignInChanged(object account, boolean signedIn);
};
};
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