Commit 33bad92b authored by Jiawei Li's avatar Jiawei Li Committed by Commit Bot

[chromecast] Cleanup QueryableDataBindings

Gin-based QueryableDataBindings is deprecated in favor of using
HTML5 MessageChannel based bindings.

Major changes:
- feature::kUseQueryableDataBackend is removed
- QueryableDataHostCast is removed
- QueryableDataBindings is removed

Merge-With: eureka-internal/452219

Bug: Internal b/141323597
Test: None; New binding is stable on production.
Change-Id: I2cab76239bbecceda492265d7d036ce1ebdef654
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2412781Reviewed-by: default avatarSean Topping <seantopping@chromium.org>
Reviewed-by: default avatarYuchen Liu <yucliu@chromium.org>
Commit-Queue: Jiawei Li <lijiawei@chromium.org>
Cr-Commit-Position: refs/heads/master@{#809073}
parent 04537e85
...@@ -151,10 +151,6 @@ const base::Feature kDisableIdleSocketsCloseOnMemoryPressure{ ...@@ -151,10 +151,6 @@ const base::Feature kDisableIdleSocketsCloseOnMemoryPressure{
const base::Feature kEnableGeneralAudienceBrowsing{ const base::Feature kEnableGeneralAudienceBrowsing{
"enable_general_audience_browsing", base::FEATURE_DISABLED_BY_DEFAULT}; "enable_general_audience_browsing", base::FEATURE_DISABLED_BY_DEFAULT};
// Uses unified IPC QueryableData bindings backend instead of v8 injection.
const base::Feature kUseQueryableDataBackend{"use_queryable_data_backend",
base::FEATURE_ENABLED_BY_DEFAULT};
const base::Feature kEnableSideGesturePassThrough{ const base::Feature kEnableSideGesturePassThrough{
"enable_side_gesture_pass_through", base::FEATURE_DISABLED_BY_DEFAULT}; "enable_side_gesture_pass_through", base::FEATURE_DISABLED_BY_DEFAULT};
...@@ -172,7 +168,6 @@ const base::Feature* kFeatures[] = { ...@@ -172,7 +168,6 @@ const base::Feature* kFeatures[] = {
&kSingleBuffer, &kSingleBuffer,
&kDisableIdleSocketsCloseOnMemoryPressure, &kDisableIdleSocketsCloseOnMemoryPressure,
&kEnableGeneralAudienceBrowsing, &kEnableGeneralAudienceBrowsing,
&kUseQueryableDataBackend,
&kEnableSideGesturePassThrough, &kEnableSideGesturePassThrough,
&kEnableChromeAudioManagerAndroid, &kEnableChromeAudioManagerAndroid,
}; };
......
...@@ -29,7 +29,6 @@ extern const base::Feature kTripleBuffer720; ...@@ -29,7 +29,6 @@ extern const base::Feature kTripleBuffer720;
extern const base::Feature kSingleBuffer; extern const base::Feature kSingleBuffer;
extern const base::Feature kDisableIdleSocketsCloseOnMemoryPressure; extern const base::Feature kDisableIdleSocketsCloseOnMemoryPressure;
extern const base::Feature kEnableGeneralAudienceBrowsing; extern const base::Feature kEnableGeneralAudienceBrowsing;
extern const base::Feature kUseQueryableDataBackend;
extern const base::Feature kEnableSideGesturePassThrough; extern const base::Feature kEnableSideGesturePassThrough;
extern const base::Feature kEnableChromeAudioManagerAndroid; extern const base::Feature kEnableChromeAudioManagerAndroid;
......
...@@ -130,8 +130,6 @@ cast_source_set("browser") { ...@@ -130,8 +130,6 @@ cast_source_set("browser") {
"media/media_caps_impl.h", "media/media_caps_impl.h",
"media/supported_codec_finder.cc", "media/supported_codec_finder.cc",
"media/supported_codec_finder.h", "media/supported_codec_finder.h",
"queryable_data_host_cast.cc",
"queryable_data_host_cast.h",
"renderer_prelauncher.cc", "renderer_prelauncher.cc",
"renderer_prelauncher.h", "renderer_prelauncher.h",
"service/cast_service_simple.cc", "service/cast_service_simple.cc",
......
...@@ -37,8 +37,6 @@ class OnLoadScriptInjectorHost; ...@@ -37,8 +37,6 @@ class OnLoadScriptInjectorHost;
namespace chromecast { namespace chromecast {
class QueryableDataHost;
struct RendererFeature { struct RendererFeature {
const std::string name; const std::string name;
base::Value value; base::Value value;
...@@ -230,10 +228,6 @@ class CastWebContents { ...@@ -230,10 +228,6 @@ class CastWebContents {
bool enable_websql = false; bool enable_websql = false;
// Enable mixer audio support for this CastWebContents. // Enable mixer audio support for this CastWebContents.
bool enable_mixer_audio = false; bool enable_mixer_audio = false;
// Whether to provide a QueryableDataHost for this CastWebContents.
// Clients can use it to send queryable values to the render frames.
// queryable_data_host() will return a nullptr if this is false.
bool enable_queryable_data_host = false;
// Whether to provide a URL filter applied to network requests for the // Whether to provide a URL filter applied to network requests for the
// activity hosted by this CastWebContents. // activity hosted by this CastWebContents.
// No filters implies no restrictions. // No filters implies no restrictions.
...@@ -276,10 +270,6 @@ class CastWebContents { ...@@ -276,10 +270,6 @@ class CastWebContents {
virtual content::WebContents* web_contents() const = 0; virtual content::WebContents* web_contents() const = 0;
virtual PageState page_state() const = 0; virtual PageState page_state() const = 0;
// Returns QueryableDataHost that is used to push values to the renderer.
// Returns nullptr if the new queryable data bindings is enabled.
virtual QueryableDataHost* queryable_data_host() const = 0;
// Returns the PID of the main frame process if valid. // Returns the PID of the main frame process if valid.
virtual base::Optional<pid_t> GetMainFrameRenderProcessPid() const = 0; virtual base::Optional<pid_t> GetMainFrameRenderProcessPid() const = 0;
......
...@@ -13,13 +13,11 @@ ...@@ -13,13 +13,11 @@
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "base/threading/sequenced_task_runner_handle.h" #include "base/threading/sequenced_task_runner_handle.h"
#include "base/values.h" #include "base/values.h"
#include "chromecast/activity/queryable_data_host.h"
#include "chromecast/base/cast_features.h" #include "chromecast/base/cast_features.h"
#include "chromecast/base/chromecast_switches.h" #include "chromecast/base/chromecast_switches.h"
#include "chromecast/base/metrics/cast_metrics_helper.h" #include "chromecast/base/metrics/cast_metrics_helper.h"
#include "chromecast/browser/cast_browser_process.h" #include "chromecast/browser/cast_browser_process.h"
#include "chromecast/browser/devtools/remote_debugging_server.h" #include "chromecast/browser/devtools/remote_debugging_server.h"
#include "chromecast/browser/queryable_data_host_cast.h"
#include "chromecast/common/mojom/activity_url_filter.mojom.h" #include "chromecast/common/mojom/activity_url_filter.mojom.h"
#include "chromecast/common/mojom/queryable_data_store.mojom.h" #include "chromecast/common/mojom/queryable_data_store.mojom.h"
#include "chromecast/common/queryable_data.h" #include "chromecast/common/queryable_data.h"
...@@ -163,13 +161,6 @@ CastWebContentsImpl::CastWebContentsImpl(content::WebContents* web_contents, ...@@ -163,13 +161,6 @@ CastWebContentsImpl::CastWebContentsImpl(content::WebContents* web_contents,
renderer_type_ == content::mojom::RendererType::MOJO_RENDERER) { renderer_type_ == content::mojom::RendererType::MOJO_RENDERER) {
renderer_type_ = content::mojom::RendererType::DEFAULT_RENDERER; renderer_type_ = content::mojom::RendererType::DEFAULT_RENDERER;
} }
// Provides QueryableDataHostCast if the new QueryableData bindings is not
// enabled.
if (init_params.enable_queryable_data_host) {
queryable_data_host_ =
std::make_unique<QueryableDataHostCast>(web_contents_);
}
} }
CastWebContentsImpl::~CastWebContentsImpl() { CastWebContentsImpl::~CastWebContentsImpl() {
...@@ -202,10 +193,6 @@ CastWebContents::PageState CastWebContentsImpl::page_state() const { ...@@ -202,10 +193,6 @@ CastWebContents::PageState CastWebContentsImpl::page_state() const {
return page_state_; return page_state_;
} }
QueryableDataHost* CastWebContentsImpl::queryable_data_host() const {
return queryable_data_host_.get();
}
base::Optional<pid_t> CastWebContentsImpl::GetMainFrameRenderProcessPid() base::Optional<pid_t> CastWebContentsImpl::GetMainFrameRenderProcessPid()
const { const {
// Returns empty value if |web_contents_| is (being) destroyed or the main // Returns empty value if |web_contents_| is (being) destroyed or the main
......
...@@ -33,8 +33,6 @@ ...@@ -33,8 +33,6 @@
namespace chromecast { namespace chromecast {
class QueryableDataHost;
namespace shell { namespace shell {
class RemoteDebuggingServer; class RemoteDebuggingServer;
} // namespace shell } // namespace shell
...@@ -51,8 +49,6 @@ class CastWebContentsImpl : public CastWebContents, ...@@ -51,8 +49,6 @@ class CastWebContentsImpl : public CastWebContents,
PageState page_state() const override; PageState page_state() const override;
base::Optional<pid_t> GetMainFrameRenderProcessPid() const override; base::Optional<pid_t> GetMainFrameRenderProcessPid() const override;
QueryableDataHost* queryable_data_host() const override;
// CastWebContents implementation: // CastWebContents implementation:
int tab_id() const override; int tab_id() const override;
int id() const override; int id() const override;
...@@ -190,8 +186,6 @@ class CastWebContentsImpl : public CastWebContents, ...@@ -190,8 +186,6 @@ class CastWebContentsImpl : public CastWebContents,
base::flat_map<InterfaceSet, service_manager::InterfaceProvider*> base::flat_map<InterfaceSet, service_manager::InterfaceProvider*>
interface_providers_map_; interface_providers_map_;
std::unique_ptr<QueryableDataHost> queryable_data_host_;
SEQUENCE_CHECKER(sequence_checker_); SEQUENCE_CHECKER(sequence_checker_);
base::WeakPtrFactory<CastWebContentsImpl> weak_factory_; base::WeakPtrFactory<CastWebContentsImpl> weak_factory_;
......
// 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/queryable_data_host_cast.h"
#include "chromecast/common/mojom/queryable_data_store.mojom.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/web_contents.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "services/service_manager/public/cpp/interface_provider.h"
namespace chromecast {
QueryableDataHostCast::QueryableDataHostCast(content::WebContents* web_contents)
: web_contents_(web_contents) {
DCHECK(web_contents_);
}
QueryableDataHostCast::~QueryableDataHostCast() {}
void QueryableDataHostCast::SendQueryableValue(const std::string& key,
const base::Value& value) {
for (content::RenderFrameHost* render_frame_host :
web_contents_->GetAllFrames()) {
mojo::Remote<shell::mojom::QueryableDataStore> queryable_data_store_remote;
render_frame_host->GetRemoteInterfaces()->GetInterface(
queryable_data_store_remote.BindNewPipeAndPassReceiver());
queryable_data_store_remote->Set(key, value.Clone());
}
}
} // namespace chromecast
// 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_QUERYABLE_DATA_HOST_CAST_H_
#define CHROMECAST_BROWSER_QUERYABLE_DATA_HOST_CAST_H_
#include <string>
#include "base/macros.h"
#include "base/values.h"
#include "chromecast/activity/queryable_data_host.h"
namespace content {
class WebContents;
} // namespace content
namespace chromecast {
// Sends queryable data to a non fuchsia Host.
class QueryableDataHostCast : public QueryableDataHost {
public:
explicit QueryableDataHostCast(content::WebContents* web_contents);
~QueryableDataHostCast() override;
// chromecast::QueryableDataHost implementation:
void SendQueryableValue(const std::string& key,
const base::Value& value) override;
private:
content::WebContents* const web_contents_;
DISALLOW_COPY_AND_ASSIGN(QueryableDataHostCast);
};
} // namespace chromecast
#endif // CHROMECAST_BROWSER_QUERYABLE_DATA_HOST_CAST_H_
...@@ -20,7 +20,6 @@ class MockCastWebContents : public CastWebContents { ...@@ -20,7 +20,6 @@ class MockCastWebContents : public CastWebContents {
MOCK_METHOD(int, id, (), (const, override)); MOCK_METHOD(int, id, (), (const, override));
MOCK_METHOD(content::WebContents*, web_contents, (), (const, override)); MOCK_METHOD(content::WebContents*, web_contents, (), (const, override));
MOCK_METHOD(PageState, page_state, (), (const, override)); MOCK_METHOD(PageState, page_state, (), (const, override));
MOCK_METHOD(QueryableDataHost*, queryable_data_host, (), (const, override));
MOCK_METHOD(base::Optional<pid_t>, MOCK_METHOD(base::Optional<pid_t>,
GetMainFrameRenderProcessPid, GetMainFrameRenderProcessPid,
(), (),
......
...@@ -43,8 +43,6 @@ cast_source_set("renderer") { ...@@ -43,8 +43,6 @@ cast_source_set("renderer") {
"js_channel_bindings.h", "js_channel_bindings.h",
"native_bindings_helper.cc", "native_bindings_helper.cc",
"native_bindings_helper.h", "native_bindings_helper.h",
"queryable_data_bindings.cc",
"queryable_data_bindings.h",
"queryable_data_store.cc", "queryable_data_store.cc",
"queryable_data_store.h", "queryable_data_store.h",
] ]
......
...@@ -22,7 +22,6 @@ ...@@ -22,7 +22,6 @@
#include "chromecast/renderer/js_channel_bindings.h" #include "chromecast/renderer/js_channel_bindings.h"
#include "chromecast/renderer/media/key_systems_cast.h" #include "chromecast/renderer/media/key_systems_cast.h"
#include "chromecast/renderer/media/media_caps_observer_impl.h" #include "chromecast/renderer/media/media_caps_observer_impl.h"
#include "chromecast/renderer/queryable_data_bindings.h"
#include "components/media_control/renderer/media_playback_options.h" #include "components/media_control/renderer/media_playback_options.h"
#include "components/network_hints/renderer/web_prescient_networking_impl.h" #include "components/network_hints/renderer/web_prescient_networking_impl.h"
#include "components/on_load_script_injector/renderer/on_load_script_injector.h" #include "components/on_load_script_injector/renderer/on_load_script_injector.h"
...@@ -182,9 +181,6 @@ void CastContentRendererClient::RenderFrameCreated( ...@@ -182,9 +181,6 @@ void CastContentRendererClient::RenderFrameCreated(
// Lifetime is tied to |render_frame| via content::RenderFrameObserver. // Lifetime is tied to |render_frame| via content::RenderFrameObserver.
new media_control::MediaPlaybackOptions(render_frame); new media_control::MediaPlaybackOptions(render_frame);
if (!::chromecast::IsFeatureEnabled(kUseQueryableDataBackend)) {
new QueryableDataBindings(render_frame);
}
// Add script injection support to the RenderFrame, used by Cast platform // Add script injection support to the RenderFrame, used by Cast platform
// APIs. The injector's lifetime is bound to the RenderFrame's lifetime. // APIs. The injector's lifetime is bound to the RenderFrame's lifetime.
......
// 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/renderer/queryable_data_bindings.h"
#include "base/bind_helpers.h"
#include "base/logging.h"
#include "chromecast/common/queryable_data.h"
#include "content/public/renderer/render_frame.h"
#include "content/public/renderer/v8_value_converter.h"
#include "services/service_manager/public/cpp/interface_provider.h"
#include "third_party/blink/public/web/blink.h"
#include "third_party/blink/public/web/web_local_frame.h"
#include "v8/include/v8.h"
namespace chromecast {
namespace {
const char kQueryPlatformValueMethodName[] = "queryPlatformValue";
} // namespace
QueryableDataBindings::QueryableDataBindings(content::RenderFrame* frame)
: CastBinding(frame),
queryable_data_store_(std::make_unique<QueryableDataStore>(
base::ThreadTaskRunnerHandle::Get())) {
registry_.AddInterface<shell::mojom::QueryableDataStore>(
base::BindRepeating(&QueryableDataStore::BindQueryableDataStoreReceiver,
base::Unretained(queryable_data_store_.get())));
}
QueryableDataBindings::~QueryableDataBindings() {}
void QueryableDataBindings::Install(v8::Local<v8::Object> cast_platform,
v8::Isolate* isolate) {
VLOG(1) << "Installing QueryableDataBindings";
InstallBinding(isolate, cast_platform, kQueryPlatformValueMethodName,
&QueryableDataBindings::QueryPlatformValue,
base::Unretained(this));
}
void QueryableDataBindings::OnInterfaceRequestForFrame(
const std::string& interface_name,
mojo::ScopedMessagePipeHandle* interface_pipe) {
registry_.TryBindInterface(interface_name, interface_pipe);
}
v8::Local<v8::Value> QueryableDataBindings::QueryPlatformValue(
const std::string& query_key) {
VLOG(1) << __FUNCTION__ << ": " << query_key;
v8::Isolate* isolate = blink::MainThreadIsolate();
const base::Value* query_value = QueryableData::Query(query_key);
if (!query_value)
return v8::Local<v8::Value>(v8::Undefined(isolate));
return content::V8ValueConverter::Create()->ToV8Value(
query_value, render_frame()->GetWebFrame()->MainWorldScriptContext());
}
} // namespace chromecast
// 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_RENDERER_QUERYABLE_DATA_BINDINGS_H_
#define CHROMECAST_RENDERER_QUERYABLE_DATA_BINDINGS_H_
#include <string>
#include "base/macros.h"
#include "chromecast/renderer/native_bindings_helper.h"
#include "chromecast/renderer/queryable_data_store.h"
#include "content/public/renderer/render_frame_observer.h"
#include "services/service_manager/public/cpp/binder_registry.h"
namespace chromecast {
class QueryableDataBindings : public CastBinding {
public:
explicit QueryableDataBindings(content::RenderFrame* frame);
// content::RenderFrameObserver implementation:
void OnInterfaceRequestForFrame(
const std::string& interface_name,
mojo::ScopedMessagePipeHandle* interface_pipe) override;
private:
friend class CastBinding;
~QueryableDataBindings() override;
// CastBinding implementation:
void Install(v8::Local<v8::Object> cast_platform,
v8::Isolate* isolate) override;
// Binding methods
v8::Local<v8::Value> QueryPlatformValue(const std::string& query_key);
service_manager::BinderRegistry registry_;
const std::unique_ptr<QueryableDataStore> queryable_data_store_;
DISALLOW_COPY_AND_ASSIGN(QueryableDataBindings);
};
} // namespace chromecast
#endif // CHROMECAST_RENDERER_QUERYABLE_DATA_BINDINGS_H_
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