Commit f7bddeee authored by Shawn Gallea's avatar Shawn Gallea Committed by Commit Bot

Enable webview debugging via bool at service creation

This allows webview debugging to be specified at
PlatformViewsAsyncService creation.

Merge-With: eureka-internal/369473
Bug: Internal b/149833693
Test: NONE
Change-Id: Ia9b02cd6f59e1343b4fce70ed639196f80a03010
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2079033Reviewed-by: default avatarDaniel Nicoara <dnicoara@chromium.org>
Commit-Queue: Shawn Gallea <sagallea@google.com>
Cr-Commit-Position: refs/heads/master@{#745132}
parent f674ebc6
...@@ -19,12 +19,14 @@ PlatformViewsAsyncService::PlatformViewsAsyncService( ...@@ -19,12 +19,14 @@ PlatformViewsAsyncService::PlatformViewsAsyncService(
std::unique_ptr<grpc::ServerCompletionQueue> cq, std::unique_ptr<grpc::ServerCompletionQueue> cq,
scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner, scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner,
WebContentsProvider* web_contents_provider, WebContentsProvider* web_contents_provider,
CastWindowManager* cast_window_manager) CastWindowManager* cast_window_manager,
bool enabled_for_dev)
: ui_task_runner_(std::move(ui_task_runner)), : ui_task_runner_(std::move(ui_task_runner)),
cq_(std::move(cq)), cq_(std::move(cq)),
service_(std::move(service)), service_(std::move(service)),
window_manager_(cast_window_manager), window_manager_(cast_window_manager),
web_contents_provider_(web_contents_provider) { web_contents_provider_(web_contents_provider),
enabled_for_dev_(enabled_for_dev) {
base::PlatformThread::Create(0, this, &rpc_thread_); base::PlatformThread::Create(0, this, &rpc_thread_);
} }
...@@ -41,7 +43,7 @@ void PlatformViewsAsyncService::ThreadMain() { ...@@ -41,7 +43,7 @@ void PlatformViewsAsyncService::ThreadMain() {
new CastAppRpcInstance(service_.get(), cq_.get(), ui_task_runner_, new CastAppRpcInstance(service_.get(), cq_.get(), ui_task_runner_,
&window_manager_, web_contents_provider_); &window_manager_, web_contents_provider_);
new WebviewRpcInstance(service_.get(), cq_.get(), ui_task_runner_, new WebviewRpcInstance(service_.get(), cq_.get(), ui_task_runner_,
&window_manager_); &window_manager_, enabled_for_dev_);
// This thread is joined when this service is destroyed. // This thread is joined when this service is destroyed.
while (cq_->Next(&tag, &ok)) { while (cq_->Next(&tag, &ok)) {
reinterpret_cast<GrpcCallback*>(tag)->Run(ok); reinterpret_cast<GrpcCallback*>(tag)->Run(ok);
......
...@@ -28,7 +28,8 @@ class PlatformViewsAsyncService : public base::PlatformThread::Delegate { ...@@ -28,7 +28,8 @@ class PlatformViewsAsyncService : public base::PlatformThread::Delegate {
std::unique_ptr<grpc::ServerCompletionQueue> cq, std::unique_ptr<grpc::ServerCompletionQueue> cq,
scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner, scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner,
WebContentsProvider* web_contents_provider, WebContentsProvider* web_contents_provider,
CastWindowManager* cast_window_manager); CastWindowManager* cast_window_manager,
bool enabled_for_dev);
~PlatformViewsAsyncService() override; ~PlatformViewsAsyncService() override;
private: private:
...@@ -46,6 +47,7 @@ class PlatformViewsAsyncService : public base::PlatformThread::Delegate { ...@@ -46,6 +47,7 @@ class PlatformViewsAsyncService : public base::PlatformThread::Delegate {
WebviewWindowManager window_manager_; WebviewWindowManager window_manager_;
WebContentsProvider* web_contents_provider_; WebContentsProvider* web_contents_provider_;
bool enabled_for_dev_;
DISALLOW_COPY_AND_ASSIGN(PlatformViewsAsyncService); DISALLOW_COPY_AND_ASSIGN(PlatformViewsAsyncService);
}; };
......
...@@ -45,7 +45,8 @@ class WebviewUserData : public base::SupportsUserData::Data { ...@@ -45,7 +45,8 @@ class WebviewUserData : public base::SupportsUserData::Data {
} // namespace } // namespace
WebviewController::WebviewController(content::BrowserContext* browser_context, WebviewController::WebviewController(content::BrowserContext* browser_context,
Client* client) Client* client,
bool enabled_for_dev)
: WebContentController(client) { : WebContentController(client) {
content::WebContents::CreateParams create_params(browser_context, nullptr); content::WebContents::CreateParams create_params(browser_context, nullptr);
contents_ = content::WebContents::Create(create_params); contents_ = content::WebContents::Create(create_params);
...@@ -53,7 +54,7 @@ WebviewController::WebviewController(content::BrowserContext* browser_context, ...@@ -53,7 +54,7 @@ WebviewController::WebviewController(content::BrowserContext* browser_context,
std::make_unique<WebviewUserData>(this)); std::make_unique<WebviewUserData>(this));
CastWebContents::InitParams cast_contents_init; CastWebContents::InitParams cast_contents_init;
cast_contents_init.is_root_window = true; cast_contents_init.is_root_window = true;
cast_contents_init.enabled_for_dev = CAST_IS_DEBUG_BUILD(); cast_contents_init.enabled_for_dev = enabled_for_dev;
cast_contents_init.delegate = weak_ptr_factory_.GetWeakPtr(); cast_contents_init.delegate = weak_ptr_factory_.GetWeakPtr();
cast_web_contents_ = std::make_unique<CastWebContentsImpl>( cast_web_contents_ = std::make_unique<CastWebContentsImpl>(
contents_.get(), cast_contents_init); contents_.get(), cast_contents_init);
......
...@@ -35,7 +35,9 @@ class WebviewController : public CastWebContents::Delegate, ...@@ -35,7 +35,9 @@ class WebviewController : public CastWebContents::Delegate,
public CastWebContents::Observer, public CastWebContents::Observer,
public WebContentController { public WebContentController {
public: public:
WebviewController(content::BrowserContext* browser_context, Client* client); WebviewController(content::BrowserContext* browser_context,
Client* client,
bool enabled_for_dev);
~WebviewController() override; ~WebviewController() override;
// Returns a navigation throttle for the current navigation request, if one is // Returns a navigation throttle for the current navigation request, if one is
......
...@@ -21,9 +21,11 @@ WebviewRpcInstance::WebviewRpcInstance( ...@@ -21,9 +21,11 @@ WebviewRpcInstance::WebviewRpcInstance(
webview::PlatformViewsService::AsyncService* service, webview::PlatformViewsService::AsyncService* service,
grpc::ServerCompletionQueue* cq, grpc::ServerCompletionQueue* cq,
scoped_refptr<base::SingleThreadTaskRunner> task_runner, scoped_refptr<base::SingleThreadTaskRunner> task_runner,
WebviewWindowManager* window_manager) WebviewWindowManager* window_manager,
bool enabled_for_dev)
: PlatformViewsRpcInstance(cq, task_runner, window_manager), : PlatformViewsRpcInstance(cq, task_runner, window_manager),
platform_views_service_(service) { platform_views_service_(service),
enabled_for_dev_(enabled_for_dev) {
platform_views_service_->RequestCreateWebview(&ctx_, &io_, cq_, cq_, platform_views_service_->RequestCreateWebview(&ctx_, &io_, cq_, cq_,
&init_callback_); &init_callback_);
} }
...@@ -32,7 +34,7 @@ WebviewRpcInstance::~WebviewRpcInstance() {} ...@@ -32,7 +34,7 @@ WebviewRpcInstance::~WebviewRpcInstance() {}
void WebviewRpcInstance::CreateNewInstance() { void WebviewRpcInstance::CreateNewInstance() {
new WebviewRpcInstance(platform_views_service_, cq_, task_runner_, new WebviewRpcInstance(platform_views_service_, cq_, task_runner_,
window_manager_); window_manager_, enabled_for_dev_);
} }
bool WebviewRpcInstance::Initialize() { bool WebviewRpcInstance::Initialize() {
...@@ -58,7 +60,8 @@ void WebviewRpcInstance::CreateWebview(int app_id, int window_id) { ...@@ -58,7 +60,8 @@ void WebviewRpcInstance::CreateWebview(int app_id, int window_id) {
content::BrowserContext* browser_context = content::BrowserContext* browser_context =
shell::CastBrowserProcess::GetInstance()->browser_context(); shell::CastBrowserProcess::GetInstance()->browser_context();
controller_ = std::make_unique<WebviewController>(browser_context, this); controller_ = std::make_unique<WebviewController>(browser_context, this,
enabled_for_dev_);
// Begin reading again. // Begin reading again.
io_.Read(request_.get(), &read_callback_); io_.Read(request_.get(), &read_callback_);
......
...@@ -14,7 +14,8 @@ class WebviewRpcInstance : public PlatformViewsRpcInstance { ...@@ -14,7 +14,8 @@ class WebviewRpcInstance : public PlatformViewsRpcInstance {
WebviewRpcInstance(webview::PlatformViewsService::AsyncService* service, WebviewRpcInstance(webview::PlatformViewsService::AsyncService* service,
grpc::ServerCompletionQueue* cq, grpc::ServerCompletionQueue* cq,
scoped_refptr<base::SingleThreadTaskRunner> task_runner, scoped_refptr<base::SingleThreadTaskRunner> task_runner,
WebviewWindowManager* window_manager); WebviewWindowManager* window_manager,
bool enabled_for_dev);
~WebviewRpcInstance() override; ~WebviewRpcInstance() override;
protected: protected:
...@@ -24,6 +25,7 @@ class WebviewRpcInstance : public PlatformViewsRpcInstance { ...@@ -24,6 +25,7 @@ class WebviewRpcInstance : public PlatformViewsRpcInstance {
private: private:
void CreateWebview(int app_id, int window_id); void CreateWebview(int app_id, int window_id);
webview::PlatformViewsService::AsyncService* platform_views_service_; webview::PlatformViewsService::AsyncService* platform_views_service_;
bool enabled_for_dev_ = false;
DISALLOW_COPY_AND_ASSIGN(WebviewRpcInstance); DISALLOW_COPY_AND_ASSIGN(WebviewRpcInstance);
}; };
......
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