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 {
|
namespace {
|
||||||
|
|
||||||
constexpr int kBindingsFailureExitCode = 129;
|
constexpr int kBindingsFailureExitCode = 129;
|
||||||
constexpr int kRewriteRulesProviderDisconnectExitCode = 130;
|
|
||||||
|
|
||||||
constexpr char kStubBindingsPath[] =
|
constexpr char kStubBindingsPath[] =
|
||||||
FILE_PATH_LITERAL("fuchsia/runners/cast/not_implemented_api_bindings.js");
|
FILE_PATH_LITERAL("fuchsia/runners/cast/not_implemented_api_bindings.js");
|
||||||
@ -51,7 +50,6 @@ CastComponent::CastComponent(CastRunner* runner,
|
|||||||
std::move(params.controller_request)),
|
std::move(params.controller_request)),
|
||||||
agent_manager_(std::move(params.agent_manager)),
|
agent_manager_(std::move(params.agent_manager)),
|
||||||
application_config_(std::move(params.app_config)),
|
application_config_(std::move(params.app_config)),
|
||||||
rewrite_rules_provider_(std::move(params.rewrite_rules_provider)),
|
|
||||||
touch_input_policy_(
|
touch_input_policy_(
|
||||||
TouchInputPolicyFromApplicationConfig(application_config_)),
|
TouchInputPolicyFromApplicationConfig(application_config_)),
|
||||||
connector_(frame()),
|
connector_(frame()),
|
||||||
@ -59,15 +57,6 @@ CastComponent::CastComponent(CastRunner* runner,
|
|||||||
navigation_listener_binding_(this) {
|
navigation_listener_binding_(this) {
|
||||||
base::AutoReset<bool> constructor_active_reset(&constructor_active_, true);
|
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()->SetEnableInput(false);
|
||||||
frame()->SetNavigationEventListener(
|
frame()->SetNavigationEventListener(
|
||||||
navigation_listener_binding_.NewBinding());
|
navigation_listener_binding_.NewBinding());
|
||||||
@ -94,14 +83,6 @@ void CastComponent::DestroyComponent(int termination_exit_code,
|
|||||||
WebComponent::DestroyComponent(termination_exit_code, reason);
|
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(
|
void CastComponent::OnNavigationStateChanged(
|
||||||
fuchsia::web::NavigationState change,
|
fuchsia::web::NavigationState change,
|
||||||
OnNavigationStateChangedCallback callback) {
|
OnNavigationStateChangedCallback callback) {
|
||||||
|
@ -36,9 +36,8 @@ class CastComponent : public WebComponent,
|
|||||||
fidl::InterfaceRequest<fuchsia::sys::ComponentController>
|
fidl::InterfaceRequest<fuchsia::sys::ComponentController>
|
||||||
controller_request;
|
controller_request;
|
||||||
chromium::cast::ApplicationConfig app_config;
|
chromium::cast::ApplicationConfig app_config;
|
||||||
chromium::cast::UrlRequestRewriteRulesProviderPtr rewrite_rules_provider;
|
fuchsia::web::AdditionalHeadersProviderPtr headers_provider;
|
||||||
base::Optional<std::vector<fuchsia::web::UrlRequestRewriteRule>>
|
base::Optional<std::vector<fuchsia::net::http::Header>> headers;
|
||||||
rewrite_rules;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
CastComponent(CastRunner* runner, CastComponentParams params);
|
CastComponent(CastRunner* runner, CastComponentParams params);
|
||||||
@ -52,9 +51,6 @@ class CastComponent : public WebComponent,
|
|||||||
void DestroyComponent(int termination_exit_code,
|
void DestroyComponent(int termination_exit_code,
|
||||||
fuchsia::sys::TerminationReason reason) override;
|
fuchsia::sys::TerminationReason reason) override;
|
||||||
|
|
||||||
void OnRewriteRulesReceived(
|
|
||||||
std::vector<fuchsia::web::UrlRequestRewriteRule> rewrite_rules);
|
|
||||||
|
|
||||||
// fuchsia::web::NavigationEventListener implementation.
|
// fuchsia::web::NavigationEventListener implementation.
|
||||||
// Triggers the injection of API channels into the page content.
|
// Triggers the injection of API channels into the page content.
|
||||||
void OnNavigationStateChanged(
|
void OnNavigationStateChanged(
|
||||||
@ -63,7 +59,6 @@ class CastComponent : public WebComponent,
|
|||||||
|
|
||||||
std::unique_ptr<cr_fuchsia::AgentManager> agent_manager_;
|
std::unique_ptr<cr_fuchsia::AgentManager> agent_manager_;
|
||||||
chromium::cast::ApplicationConfig application_config_;
|
chromium::cast::ApplicationConfig application_config_;
|
||||||
chromium::cast::UrlRequestRewriteRulesProviderPtr rewrite_rules_provider_;
|
|
||||||
|
|
||||||
bool constructor_active_ = false;
|
bool constructor_active_ = false;
|
||||||
TouchInputPolicy touch_input_policy_;
|
TouchInputPolicy touch_input_policy_;
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
#include "fuchsia/runners/cast/cast_runner.h"
|
#include "fuchsia/runners/cast/cast_runner.h"
|
||||||
|
|
||||||
|
#include <fuchsia/sys/cpp/fidl.h>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
@ -66,26 +67,25 @@ void CastRunner::StartComponent(
|
|||||||
base::BindOnce(&CastRunner::MaybeStartComponent, base::Unretained(this),
|
base::BindOnce(&CastRunner::MaybeStartComponent, base::Unretained(this),
|
||||||
base::Unretained(pending_component.get())));
|
base::Unretained(pending_component.get())));
|
||||||
|
|
||||||
// Get UrlRequestRewriteRulesProvider from the Agent.
|
// Get AdditionalHeadersProvider from the Agent.
|
||||||
fidl::InterfaceHandle<chromium::cast::UrlRequestRewriteRulesProvider>
|
fidl::InterfaceHandle<fuchsia::web::AdditionalHeadersProvider>
|
||||||
url_request_rules_provider;
|
additional_headers_provider;
|
||||||
pending_component->agent_manager->ConnectToAgentService(
|
pending_component->agent_manager->ConnectToAgentService(
|
||||||
kAgentComponentUrl, url_request_rules_provider.NewRequest());
|
kAgentComponentUrl, additional_headers_provider.NewRequest());
|
||||||
pending_component->rewrite_rules_provider = url_request_rules_provider.Bind();
|
pending_component->headers_provider = additional_headers_provider.Bind();
|
||||||
pending_component->rewrite_rules_provider.set_error_handler(
|
pending_component->headers_provider.set_error_handler(
|
||||||
[this, pending_component = pending_component.get()](zx_status_t status) {
|
[this, pending_component = pending_component.get()](zx_status_t error) {
|
||||||
ZX_LOG(ERROR, status) << "UrlRequestRewriteRulesProvider disconnected.";
|
if (pending_component->headers.has_value())
|
||||||
|
return;
|
||||||
// The rules provider disconnected, cancel the component launch.
|
pending_component->headers = {};
|
||||||
size_t count = pending_components_.erase(pending_component);
|
MaybeStartComponent(pending_component);
|
||||||
DCHECK_EQ(count, 1u);
|
|
||||||
});
|
});
|
||||||
pending_component->rewrite_rules_provider->GetUrlRequestRewriteRules(
|
pending_component->headers_provider->GetHeaders(
|
||||||
[this, pending_component = pending_component.get()](
|
[this, pending_component = pending_component.get()](
|
||||||
std::vector<fuchsia::web::UrlRequestRewriteRule> rewrite_rules) {
|
std::vector<fuchsia::net::http::Header> headers, zx_time_t expiry) {
|
||||||
pending_component->rewrite_rules =
|
pending_component->headers =
|
||||||
base::Optional<std::vector<fuchsia::web::UrlRequestRewriteRule>>(
|
base::Optional<std::vector<fuchsia::net::http::Header>>(
|
||||||
std::move(rewrite_rules));
|
std::move(headers));
|
||||||
MaybeStartComponent(pending_component);
|
MaybeStartComponent(pending_component);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -126,17 +126,19 @@ void CastRunner::MaybeStartComponent(
|
|||||||
return;
|
return;
|
||||||
if (!pending_component->api_bindings_client->HasBindings())
|
if (!pending_component->api_bindings_client->HasBindings())
|
||||||
return;
|
return;
|
||||||
if (!pending_component->rewrite_rules.has_value())
|
if (!pending_component->headers.has_value())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Create a component based on the returned configuration, and pass it the
|
// Create a component based on the returned configuration, and pass it the
|
||||||
// |pending_component|.
|
// |pending_component|.
|
||||||
|
std::vector<fuchsia::net::http::Header> additional_headers =
|
||||||
|
pending_component->headers.value();
|
||||||
|
|
||||||
GURL cast_app_url(pending_component->app_config.web_url());
|
GURL cast_app_url(pending_component->app_config.web_url());
|
||||||
auto component =
|
auto component =
|
||||||
std::make_unique<CastComponent>(this, std::move(*pending_component));
|
std::make_unique<CastComponent>(this, std::move(*pending_component));
|
||||||
pending_components_.erase(pending_component);
|
pending_components_.erase(pending_component);
|
||||||
|
|
||||||
component->LoadUrl(std::move(cast_app_url),
|
component->LoadUrl(std::move(cast_app_url), std::move(additional_headers));
|
||||||
std::vector<fuchsia::net::http::Header>());
|
|
||||||
RegisterComponent(std::move(component));
|
RegisterComponent(std::move(component));
|
||||||
}
|
}
|
||||||
|
@ -12,9 +12,7 @@
|
|||||||
#include "base/callback.h"
|
#include "base/callback.h"
|
||||||
#include "base/containers/flat_set.h"
|
#include "base/containers/flat_set.h"
|
||||||
#include "base/containers/unique_ptr_adapters.h"
|
#include "base/containers/unique_ptr_adapters.h"
|
||||||
#include "base/fuchsia/startup_context.h"
|
|
||||||
#include "base/macros.h"
|
#include "base/macros.h"
|
||||||
#include "fuchsia/base/agent_manager.h"
|
|
||||||
#include "fuchsia/fidl/chromium/cast/cpp/fidl.h"
|
#include "fuchsia/fidl/chromium/cast/cpp/fidl.h"
|
||||||
#include "fuchsia/runners/cast/cast_component.h"
|
#include "fuchsia/runners/cast/cast_component.h"
|
||||||
#include "fuchsia/runners/common/web_content_runner.h"
|
#include "fuchsia/runners/common/web_content_runner.h"
|
||||||
|
@ -23,7 +23,6 @@
|
|||||||
#include "fuchsia/base/result_receiver.h"
|
#include "fuchsia/base/result_receiver.h"
|
||||||
#include "fuchsia/base/string_util.h"
|
#include "fuchsia/base/string_util.h"
|
||||||
#include "fuchsia/base/test_navigation_listener.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/cast_runner.h"
|
||||||
#include "fuchsia/runners/cast/fake_application_config_manager.h"
|
#include "fuchsia/runners/cast/fake_application_config_manager.h"
|
||||||
#include "fuchsia/runners/cast/test_api_bindings.h"
|
#include "fuchsia/runners/cast/test_api_bindings.h"
|
||||||
@ -46,36 +45,28 @@ void ComponentErrorHandler(zx_status_t status) {
|
|||||||
ADD_FAILURE();
|
ADD_FAILURE();
|
||||||
}
|
}
|
||||||
|
|
||||||
class FakeUrlRequestRewriteRulesProvider
|
class FakeAdditionalHeadersProvider
|
||||||
: public chromium::cast::UrlRequestRewriteRulesProvider {
|
: public fuchsia::web::AdditionalHeadersProvider {
|
||||||
public:
|
public:
|
||||||
explicit FakeUrlRequestRewriteRulesProvider(sys::OutgoingDirectory* directory)
|
explicit FakeAdditionalHeadersProvider(sys::OutgoingDirectory* directory)
|
||||||
: binding_(directory, this) {}
|
: binding_(directory, this) {}
|
||||||
~FakeUrlRequestRewriteRulesProvider() override = default;
|
~FakeAdditionalHeadersProvider() override = default;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void GetUrlRequestRewriteRules(
|
void GetHeaders(GetHeadersCallback callback) override {
|
||||||
GetUrlRequestRewriteRulesCallback callback) override {
|
std::vector<fuchsia::net::http::Header> headers;
|
||||||
// Only send the rules once. They do not expire
|
fuchsia::net::http::Header header;
|
||||||
if (rules_sent_)
|
header.name = cr_fuchsia::StringToBytes("Test");
|
||||||
return;
|
header.value = cr_fuchsia::StringToBytes("Value");
|
||||||
rules_sent_ = true;
|
headers.push_back(std::move(header));
|
||||||
|
callback(std::move(headers), 0);
|
||||||
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));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool rules_sent_ = false;
|
|
||||||
const base::fuchsia::ScopedServiceBinding<
|
const base::fuchsia::ScopedServiceBinding<
|
||||||
chromium::cast::UrlRequestRewriteRulesProvider>
|
fuchsia::web::AdditionalHeadersProvider>
|
||||||
binding_;
|
binding_;
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(FakeUrlRequestRewriteRulesProvider);
|
DISALLOW_COPY_AND_ASSIGN(FakeAdditionalHeadersProvider);
|
||||||
};
|
};
|
||||||
|
|
||||||
class FakeApplicationControllerReceiver
|
class FakeApplicationControllerReceiver
|
||||||
@ -113,8 +104,8 @@ class FakeComponentState : public cr_fuchsia::AgentImpl::ComponentStateBase {
|
|||||||
bool provide_controller_receiver)
|
bool provide_controller_receiver)
|
||||||
: ComponentStateBase(component_url),
|
: ComponentStateBase(component_url),
|
||||||
app_config_binding_(outgoing_directory(), app_config_manager),
|
app_config_binding_(outgoing_directory(), app_config_manager),
|
||||||
url_request_rules_provider_(
|
additional_headers_provider_(
|
||||||
std::make_unique<FakeUrlRequestRewriteRulesProvider>(
|
std::make_unique<FakeAdditionalHeadersProvider>(
|
||||||
outgoing_directory())) {
|
outgoing_directory())) {
|
||||||
if (bindings_manager) {
|
if (bindings_manager) {
|
||||||
bindings_manager_binding_ = std::make_unique<
|
bindings_manager_binding_ = std::make_unique<
|
||||||
@ -147,8 +138,7 @@ class FakeComponentState : public cr_fuchsia::AgentImpl::ComponentStateBase {
|
|||||||
std::unique_ptr<
|
std::unique_ptr<
|
||||||
base::fuchsia::ScopedServiceBinding<chromium::cast::ApiBindings>>
|
base::fuchsia::ScopedServiceBinding<chromium::cast::ApiBindings>>
|
||||||
bindings_manager_binding_;
|
bindings_manager_binding_;
|
||||||
std::unique_ptr<FakeUrlRequestRewriteRulesProvider>
|
std::unique_ptr<FakeAdditionalHeadersProvider> additional_headers_provider_;
|
||||||
url_request_rules_provider_;
|
|
||||||
FakeApplicationControllerReceiver controller_receiver_;
|
FakeApplicationControllerReceiver controller_receiver_;
|
||||||
base::Optional<base::fuchsia::ScopedServiceBinding<
|
base::Optional<base::fuchsia::ScopedServiceBinding<
|
||||||
chromium::cast::ApplicationControllerReceiver>>
|
chromium::cast::ApplicationControllerReceiver>>
|
||||||
@ -404,7 +394,7 @@ TEST_F(CastRunnerIntegrationTest, IncorrectCastAppId) {
|
|||||||
EXPECT_FALSE(web_component.has_value());
|
EXPECT_FALSE(web_component.has_value());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(CastRunnerIntegrationTest, UrlRequestRewriteRulesProvider) {
|
TEST_F(CastRunnerIntegrationTest, AdditionalHeadersProvider) {
|
||||||
const char kEchoAppId[] = "00000000";
|
const char kEchoAppId[] = "00000000";
|
||||||
const char kEchoAppPath[] = "/echoheader?Test";
|
const char kEchoAppPath[] = "/echoheader?Test";
|
||||||
const GURL echo_app_url = test_server_.GetURL(kEchoAppPath);
|
const GURL echo_app_url = test_server_.GetURL(kEchoAppPath);
|
||||||
|
Reference in New Issue
Block a user