Revert "Reland "[fuchsia] Handle UrlRequestRewriteRulesProvider in CastRunner.""
This reverts commitbb05b31107
. Reason for revert: Still some compatibility issues between the client and server implementations, so revert until those can be diagnosed. Original change's description: > Reland "[fuchsia] Handle UrlRequestRewriteRulesProvider in CastRunner." > > This is a reland ofbbd8d1507c
, now that the > peer-component's implementation of the UrlRequestRewriteRulesProvider works > correctly. > > Original change's description: > > [fuchsia] Handle UrlRequestRewriteRulesProvider in CastRunner. > > > > * Implement handling of the > > chromium.cast.UrlRequestRewriteRulesProvider API in CastRunner. > > * Remove handling of the fuchsia.web.AdditionalHeadersProvider API in > > CastRunner as it is deprecated. > > * Adapt the integration test to use the new API. > > > > Bug: 976975 > > Change-Id: If1e97c474f79a4b6f3f0c03428b85557e3e73460 > > Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1770434 > > Commit-Queue: Wez <wez@chromium.org> > > Reviewed-by: Wez <wez@chromium.org> > > Cr-Commit-Position: refs/heads/master@{#695766} > > TBR=fdegans > > Bug: 976975 > Change-Id: Iac657c5431056f94744767506432956eb09cfdc6 > Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1809808 > Reviewed-by: Wez <wez@chromium.org> > Commit-Queue: Wez <wez@chromium.org> > Cr-Commit-Position: refs/heads/master@{#697385} TBR=wez@chromium.org,fdegans@chromium.org,xinan@google.com # Not skipping CQ checks because original CL landed > 1 day ago. Bug: 976975, b/141305604 Change-Id: I5483ba8ae93f850a8ece12af6d3db8263cb3a82f Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1815662 Reviewed-by: Wez <wez@chromium.org> Commit-Queue: Wez <wez@chromium.org> Cr-Commit-Position: refs/heads/master@{#698366}
This commit is contained in:
@ -21,7 +21,6 @@
|
||||
namespace {
|
||||
|
||||
constexpr int kBindingsFailureExitCode = 129;
|
||||
constexpr int kRewriteRulesProviderDisconnectExitCode = 130;
|
||||
|
||||
constexpr char kStubBindingsPath[] =
|
||||
FILE_PATH_LITERAL("fuchsia/runners/cast/not_implemented_api_bindings.js");
|
||||
@ -51,7 +50,6 @@ CastComponent::CastComponent(CastRunner* runner,
|
||||
std::move(params.controller_request)),
|
||||
agent_manager_(std::move(params.agent_manager)),
|
||||
application_config_(std::move(params.app_config)),
|
||||
rewrite_rules_provider_(std::move(params.rewrite_rules_provider)),
|
||||
touch_input_policy_(
|
||||
TouchInputPolicyFromApplicationConfig(application_config_)),
|
||||
connector_(frame()),
|
||||
@ -59,15 +57,6 @@ CastComponent::CastComponent(CastRunner* runner,
|
||||
navigation_listener_binding_(this) {
|
||||
base::AutoReset<bool> constructor_active_reset(&constructor_active_, true);
|
||||
|
||||
rewrite_rules_provider_.set_error_handler([this](zx_status_t status) {
|
||||
ZX_LOG(ERROR, status) << "UrlRequestRewriteRulesProvider disconnected.";
|
||||
DestroyComponent(kRewriteRulesProviderDisconnectExitCode,
|
||||
fuchsia::sys::TerminationReason::INTERNAL_ERROR);
|
||||
});
|
||||
|
||||
DCHECK(params.rewrite_rules);
|
||||
OnRewriteRulesReceived(std::move(params.rewrite_rules.value()));
|
||||
|
||||
frame()->SetEnableInput(false);
|
||||
frame()->SetNavigationEventListener(
|
||||
navigation_listener_binding_.NewBinding());
|
||||
@ -94,14 +83,6 @@ void CastComponent::DestroyComponent(int termination_exit_code,
|
||||
WebComponent::DestroyComponent(termination_exit_code, reason);
|
||||
}
|
||||
|
||||
void CastComponent::OnRewriteRulesReceived(
|
||||
std::vector<fuchsia::web::UrlRequestRewriteRule> rewrite_rules) {
|
||||
frame()->SetUrlRequestRewriteRules(std::move(rewrite_rules), [this]() {
|
||||
rewrite_rules_provider_->GetUrlRequestRewriteRules(
|
||||
fit::bind_member(this, &CastComponent::OnRewriteRulesReceived));
|
||||
});
|
||||
}
|
||||
|
||||
void CastComponent::OnNavigationStateChanged(
|
||||
fuchsia::web::NavigationState change,
|
||||
OnNavigationStateChangedCallback callback) {
|
||||
|
@ -36,9 +36,8 @@ class CastComponent : public WebComponent,
|
||||
fidl::InterfaceRequest<fuchsia::sys::ComponentController>
|
||||
controller_request;
|
||||
chromium::cast::ApplicationConfig app_config;
|
||||
chromium::cast::UrlRequestRewriteRulesProviderPtr rewrite_rules_provider;
|
||||
base::Optional<std::vector<fuchsia::web::UrlRequestRewriteRule>>
|
||||
rewrite_rules;
|
||||
fuchsia::web::AdditionalHeadersProviderPtr headers_provider;
|
||||
base::Optional<std::vector<fuchsia::net::http::Header>> headers;
|
||||
};
|
||||
|
||||
CastComponent(CastRunner* runner, CastComponentParams params);
|
||||
@ -52,9 +51,6 @@ class CastComponent : public WebComponent,
|
||||
void DestroyComponent(int termination_exit_code,
|
||||
fuchsia::sys::TerminationReason reason) override;
|
||||
|
||||
void OnRewriteRulesReceived(
|
||||
std::vector<fuchsia::web::UrlRequestRewriteRule> rewrite_rules);
|
||||
|
||||
// fuchsia::web::NavigationEventListener implementation.
|
||||
// Triggers the injection of API channels into the page content.
|
||||
void OnNavigationStateChanged(
|
||||
@ -63,7 +59,6 @@ class CastComponent : public WebComponent,
|
||||
|
||||
std::unique_ptr<cr_fuchsia::AgentManager> agent_manager_;
|
||||
chromium::cast::ApplicationConfig application_config_;
|
||||
chromium::cast::UrlRequestRewriteRulesProviderPtr rewrite_rules_provider_;
|
||||
|
||||
bool constructor_active_ = false;
|
||||
TouchInputPolicy touch_input_policy_;
|
||||
|
@ -4,6 +4,7 @@
|
||||
|
||||
#include "fuchsia/runners/cast/cast_runner.h"
|
||||
|
||||
#include <fuchsia/sys/cpp/fidl.h>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
@ -66,26 +67,25 @@ void CastRunner::StartComponent(
|
||||
base::BindOnce(&CastRunner::MaybeStartComponent, base::Unretained(this),
|
||||
base::Unretained(pending_component.get())));
|
||||
|
||||
// Get UrlRequestRewriteRulesProvider from the Agent.
|
||||
fidl::InterfaceHandle<chromium::cast::UrlRequestRewriteRulesProvider>
|
||||
url_request_rules_provider;
|
||||
// Get AdditionalHeadersProvider from the Agent.
|
||||
fidl::InterfaceHandle<fuchsia::web::AdditionalHeadersProvider>
|
||||
additional_headers_provider;
|
||||
pending_component->agent_manager->ConnectToAgentService(
|
||||
kAgentComponentUrl, url_request_rules_provider.NewRequest());
|
||||
pending_component->rewrite_rules_provider = url_request_rules_provider.Bind();
|
||||
pending_component->rewrite_rules_provider.set_error_handler(
|
||||
[this, pending_component = pending_component.get()](zx_status_t status) {
|
||||
ZX_LOG(ERROR, status) << "UrlRequestRewriteRulesProvider disconnected.";
|
||||
|
||||
// The rules provider disconnected, cancel the component launch.
|
||||
size_t count = pending_components_.erase(pending_component);
|
||||
DCHECK_EQ(count, 1u);
|
||||
kAgentComponentUrl, additional_headers_provider.NewRequest());
|
||||
pending_component->headers_provider = additional_headers_provider.Bind();
|
||||
pending_component->headers_provider.set_error_handler(
|
||||
[this, pending_component = pending_component.get()](zx_status_t error) {
|
||||
if (pending_component->headers.has_value())
|
||||
return;
|
||||
pending_component->headers = {};
|
||||
MaybeStartComponent(pending_component);
|
||||
});
|
||||
pending_component->rewrite_rules_provider->GetUrlRequestRewriteRules(
|
||||
pending_component->headers_provider->GetHeaders(
|
||||
[this, pending_component = pending_component.get()](
|
||||
std::vector<fuchsia::web::UrlRequestRewriteRule> rewrite_rules) {
|
||||
pending_component->rewrite_rules =
|
||||
base::Optional<std::vector<fuchsia::web::UrlRequestRewriteRule>>(
|
||||
std::move(rewrite_rules));
|
||||
std::vector<fuchsia::net::http::Header> headers, zx_time_t expiry) {
|
||||
pending_component->headers =
|
||||
base::Optional<std::vector<fuchsia::net::http::Header>>(
|
||||
std::move(headers));
|
||||
MaybeStartComponent(pending_component);
|
||||
});
|
||||
|
||||
@ -126,17 +126,19 @@ void CastRunner::MaybeStartComponent(
|
||||
return;
|
||||
if (!pending_component->api_bindings_client->HasBindings())
|
||||
return;
|
||||
if (!pending_component->rewrite_rules.has_value())
|
||||
if (!pending_component->headers.has_value())
|
||||
return;
|
||||
|
||||
// Create a component based on the returned configuration, and pass it the
|
||||
// |pending_component|.
|
||||
std::vector<fuchsia::net::http::Header> additional_headers =
|
||||
pending_component->headers.value();
|
||||
|
||||
GURL cast_app_url(pending_component->app_config.web_url());
|
||||
auto component =
|
||||
std::make_unique<CastComponent>(this, std::move(*pending_component));
|
||||
pending_components_.erase(pending_component);
|
||||
|
||||
component->LoadUrl(std::move(cast_app_url),
|
||||
std::vector<fuchsia::net::http::Header>());
|
||||
component->LoadUrl(std::move(cast_app_url), std::move(additional_headers));
|
||||
RegisterComponent(std::move(component));
|
||||
}
|
||||
|
@ -12,9 +12,7 @@
|
||||
#include "base/callback.h"
|
||||
#include "base/containers/flat_set.h"
|
||||
#include "base/containers/unique_ptr_adapters.h"
|
||||
#include "base/fuchsia/startup_context.h"
|
||||
#include "base/macros.h"
|
||||
#include "fuchsia/base/agent_manager.h"
|
||||
#include "fuchsia/fidl/chromium/cast/cpp/fidl.h"
|
||||
#include "fuchsia/runners/cast/cast_component.h"
|
||||
#include "fuchsia/runners/common/web_content_runner.h"
|
||||
|
@ -23,7 +23,6 @@
|
||||
#include "fuchsia/base/result_receiver.h"
|
||||
#include "fuchsia/base/string_util.h"
|
||||
#include "fuchsia/base/test_navigation_listener.h"
|
||||
#include "fuchsia/base/url_request_rewrite_test_util.h"
|
||||
#include "fuchsia/runners/cast/cast_runner.h"
|
||||
#include "fuchsia/runners/cast/fake_application_config_manager.h"
|
||||
#include "fuchsia/runners/cast/test_api_bindings.h"
|
||||
@ -46,36 +45,28 @@ void ComponentErrorHandler(zx_status_t status) {
|
||||
ADD_FAILURE();
|
||||
}
|
||||
|
||||
class FakeUrlRequestRewriteRulesProvider
|
||||
: public chromium::cast::UrlRequestRewriteRulesProvider {
|
||||
class FakeAdditionalHeadersProvider
|
||||
: public fuchsia::web::AdditionalHeadersProvider {
|
||||
public:
|
||||
explicit FakeUrlRequestRewriteRulesProvider(sys::OutgoingDirectory* directory)
|
||||
explicit FakeAdditionalHeadersProvider(sys::OutgoingDirectory* directory)
|
||||
: binding_(directory, this) {}
|
||||
~FakeUrlRequestRewriteRulesProvider() override = default;
|
||||
~FakeAdditionalHeadersProvider() override = default;
|
||||
|
||||
private:
|
||||
void GetUrlRequestRewriteRules(
|
||||
GetUrlRequestRewriteRulesCallback callback) override {
|
||||
// Only send the rules once. They do not expire
|
||||
if (rules_sent_)
|
||||
return;
|
||||
rules_sent_ = true;
|
||||
|
||||
std::vector<fuchsia::web::UrlRequestRewrite> rewrites;
|
||||
rewrites.push_back(cr_fuchsia::CreateRewriteAddHeaders("Test", "Value"));
|
||||
fuchsia::web::UrlRequestRewriteRule rule;
|
||||
rule.set_rewrites(std::move(rewrites));
|
||||
std::vector<fuchsia::web::UrlRequestRewriteRule> rules;
|
||||
rules.push_back(std::move(rule));
|
||||
callback(std::move(rules));
|
||||
void GetHeaders(GetHeadersCallback callback) override {
|
||||
std::vector<fuchsia::net::http::Header> headers;
|
||||
fuchsia::net::http::Header header;
|
||||
header.name = cr_fuchsia::StringToBytes("Test");
|
||||
header.value = cr_fuchsia::StringToBytes("Value");
|
||||
headers.push_back(std::move(header));
|
||||
callback(std::move(headers), 0);
|
||||
}
|
||||
|
||||
bool rules_sent_ = false;
|
||||
const base::fuchsia::ScopedServiceBinding<
|
||||
chromium::cast::UrlRequestRewriteRulesProvider>
|
||||
fuchsia::web::AdditionalHeadersProvider>
|
||||
binding_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(FakeUrlRequestRewriteRulesProvider);
|
||||
DISALLOW_COPY_AND_ASSIGN(FakeAdditionalHeadersProvider);
|
||||
};
|
||||
|
||||
class FakeApplicationControllerReceiver
|
||||
@ -113,8 +104,8 @@ class FakeComponentState : public cr_fuchsia::AgentImpl::ComponentStateBase {
|
||||
bool provide_controller_receiver)
|
||||
: ComponentStateBase(component_url),
|
||||
app_config_binding_(outgoing_directory(), app_config_manager),
|
||||
url_request_rules_provider_(
|
||||
std::make_unique<FakeUrlRequestRewriteRulesProvider>(
|
||||
additional_headers_provider_(
|
||||
std::make_unique<FakeAdditionalHeadersProvider>(
|
||||
outgoing_directory())) {
|
||||
if (bindings_manager) {
|
||||
bindings_manager_binding_ = std::make_unique<
|
||||
@ -147,8 +138,7 @@ class FakeComponentState : public cr_fuchsia::AgentImpl::ComponentStateBase {
|
||||
std::unique_ptr<
|
||||
base::fuchsia::ScopedServiceBinding<chromium::cast::ApiBindings>>
|
||||
bindings_manager_binding_;
|
||||
std::unique_ptr<FakeUrlRequestRewriteRulesProvider>
|
||||
url_request_rules_provider_;
|
||||
std::unique_ptr<FakeAdditionalHeadersProvider> additional_headers_provider_;
|
||||
FakeApplicationControllerReceiver controller_receiver_;
|
||||
base::Optional<base::fuchsia::ScopedServiceBinding<
|
||||
chromium::cast::ApplicationControllerReceiver>>
|
||||
@ -404,7 +394,7 @@ TEST_F(CastRunnerIntegrationTest, IncorrectCastAppId) {
|
||||
EXPECT_FALSE(web_component.has_value());
|
||||
}
|
||||
|
||||
TEST_F(CastRunnerIntegrationTest, UrlRequestRewriteRulesProvider) {
|
||||
TEST_F(CastRunnerIntegrationTest, AdditionalHeadersProvider) {
|
||||
const char kEchoAppId[] = "00000000";
|
||||
const char kEchoAppPath[] = "/echoheader?Test";
|
||||
const GURL echo_app_url = test_server_.GetURL(kEchoAppPath);
|
||||
|
Reference in New Issue
Block a user