Commit 9ea54f9f authored by Jiaqi Han's avatar Jiaqi Han Committed by Commit Bot

[chromecast] Add whitelist entry to enable the URL filter

Provides a whitelist entry for the Activity URL filter as a parameter
to CastWebContents. No whitelist implies no restrictions.

Bug: internal b/148820675
Test: CQ, verified url request blocking in devtools

Merge-With: eureka-internal/360987

Cq-Depend: chromium:2050038
Change-Id: I9e0c329b31e62e9c6c8e039c0f9de395fd119412
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2050039
Commit-Queue: Jiaqi Han <jiaqih@google.com>
Reviewed-by: default avatarSean Topping <seantopping@chromium.org>
Cr-Commit-Position: refs/heads/master@{#743326}
parent 669cb067
...@@ -225,6 +225,10 @@ class CastWebContents { ...@@ -225,6 +225,10 @@ class CastWebContents {
// Clients can use it to send queryable values to the render frames. // Clients can use it to send queryable values to the render frames.
// queryable_data_host() will return a nullptr if this is false. // queryable_data_host() will return a nullptr if this is false.
bool enable_queryable_data_host = false; bool enable_queryable_data_host = false;
// Whether to provide a URL filter applied to network requests for the
// activity hosted by this CastWebContents.
// No filters implies no restrictions.
base::Optional<std::vector<std::string>> url_filters = base::nullopt;
InitParams(); InitParams();
InitParams(const InitParams& other); InitParams(const InitParams& other);
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#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/browser/queryable_data_host_cast.h"
#include "chromecast/common/mojom/activity_url_filter.mojom.h"
#include "chromecast/common/mojom/media_playback_options.mojom.h" #include "chromecast/common/mojom/media_playback_options.mojom.h"
#include "chromecast/common/mojom/on_load_script_injector.mojom.h" #include "chromecast/common/mojom/on_load_script_injector.mojom.h"
#include "chromecast/common/mojom/queryable_data_store.mojom.h" #include "chromecast/common/mojom/queryable_data_store.mojom.h"
...@@ -144,6 +145,7 @@ CastWebContentsImpl::CastWebContentsImpl(content::WebContents* web_contents, ...@@ -144,6 +145,7 @@ CastWebContentsImpl::CastWebContentsImpl(content::WebContents* web_contents,
media_blocker_(init_params.use_media_blocker media_blocker_(init_params.use_media_blocker
? std::make_unique<CastMediaBlocker>(web_contents_) ? std::make_unique<CastMediaBlocker>(web_contents_)
: nullptr), : nullptr),
activity_url_filter_(std::move(init_params.url_filters)),
main_process_host_(nullptr), main_process_host_(nullptr),
tab_id_(init_params.is_root_window ? 0 : next_tab_id++), tab_id_(init_params.is_root_window ? 0 : next_tab_id++),
is_websql_enabled_(init_params.enable_websql), is_websql_enabled_(init_params.enable_websql),
...@@ -491,6 +493,17 @@ void CastWebContentsImpl::RenderFrameCreated( ...@@ -491,6 +493,17 @@ void CastWebContentsImpl::RenderFrameCreated(
// base::Value is not copyable. // base::Value is not copyable.
queryable_data_store_remote->Set(value.first, value.second.Clone()); queryable_data_store_remote->Set(value.first, value.second.Clone());
} }
// Set up URL filter
if (activity_url_filter_) {
mojo::AssociatedRemote<chromecast::mojom::ActivityUrlFilterConfiguration>
activity_filter_setter;
render_frame_host->GetRemoteAssociatedInterfaces()->GetInterface(
&activity_filter_setter);
activity_filter_setter->SetFilter(
chromecast::mojom::ActivityUrlFilterCriteria::New(
activity_url_filter_.value()));
}
} }
void CastWebContentsImpl::RenderFrameHostChanged( void CastWebContentsImpl::RenderFrameHostChanged(
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#ifndef CHROMECAST_BROWSER_CAST_WEB_CONTENTS_IMPL_H_ #ifndef CHROMECAST_BROWSER_CAST_WEB_CONTENTS_IMPL_H_
#define CHROMECAST_BROWSER_CAST_WEB_CONTENTS_IMPL_H_ #define CHROMECAST_BROWSER_CAST_WEB_CONTENTS_IMPL_H_
#include <map>
#include <memory> #include <memory>
#include <set> #include <set>
#include <string> #include <string>
...@@ -169,6 +170,7 @@ class CastWebContentsImpl : public CastWebContents, ...@@ -169,6 +170,7 @@ class CastWebContentsImpl : public CastWebContents,
BackgroundColor view_background_color_; BackgroundColor view_background_color_;
shell::RemoteDebuggingServer* const remote_debugging_server_; shell::RemoteDebuggingServer* const remote_debugging_server_;
std::unique_ptr<CastMediaBlocker> media_blocker_; std::unique_ptr<CastMediaBlocker> media_blocker_;
base::Optional<std::vector<std::string>> activity_url_filter_;
// Retained so that this observer can be removed before being destroyed: // Retained so that this observer can be removed before being destroyed:
content::RenderProcessHost* main_process_host_; content::RenderProcessHost* main_process_host_;
......
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