Commit bb1d3b95 authored by Jiawei Li's avatar Jiawei Li Committed by Commit Bot

[Chromecast] Delegate JS console logs from CastWebView

Bug: internal b/71879643

Test: Build cast_shell
Change-Id: I47b8ab347a9f307e8c504dc609ab1eebd4a6cc52
Reviewed-on: https://chromium-review.googlesource.com/924279Reviewed-by: default avatarLuke Halliwell <halliwell@chromium.org>
Commit-Queue: Jiawei Li <lijiawei@chromium.org>
Cr-Commit-Position: refs/heads/master@{#537873}
parent 27ff1601
...@@ -5,6 +5,9 @@ ...@@ -5,6 +5,9 @@
#ifndef CHROMECAST_BROWSER_CAST_WEB_VIEW_H_ #ifndef CHROMECAST_BROWSER_CAST_WEB_VIEW_H_
#define CHROMECAST_BROWSER_CAST_WEB_VIEW_H_ #define CHROMECAST_BROWSER_CAST_WEB_VIEW_H_
#include <cstdint>
#include "base/strings/string16.h"
#include "base/time/time.h" #include "base/time/time.h"
#include "chromecast/browser/cast_content_window.h" #include "chromecast/browser/cast_content_window.h"
#include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents.h"
...@@ -26,6 +29,16 @@ class CastWebView { ...@@ -26,6 +29,16 @@ class CastWebView {
// Called during WebContentsDelegate::LoadingStateChanged. // Called during WebContentsDelegate::LoadingStateChanged.
// |loading| indicates if web_contents_ IsLoading or not. // |loading| indicates if web_contents_ IsLoading or not.
virtual void OnLoadingStateChanged(bool loading) = 0; virtual void OnLoadingStateChanged(bool loading) = 0;
// Called when there is console log output from web_contents.
// Returning true indicates that the delegate handled the message.
// If false is returned the default logging mechanism will be used.
virtual bool OnAddMessageToConsoleReceived(
content::WebContents* source,
int32_t level,
const base::string16& message,
int32_t line_no,
const base::string16& source_id) = 0;
}; };
// The parameters used to create a CastWebView instance. Passed to // The parameters used to create a CastWebView instance. Passed to
......
...@@ -173,6 +173,16 @@ bool CastWebViewDefault::CheckMediaAccessPermission( ...@@ -173,6 +173,16 @@ bool CastWebViewDefault::CheckMediaAccessPermission(
return true; return true;
} }
bool CastWebViewDefault::DidAddMessageToConsole(
content::WebContents* source,
int32_t level,
const base::string16& message,
int32_t line_no,
const base::string16& source_id) {
return delegate_->OnAddMessageToConsoleReceived(source, level, message,
line_no, source_id);
}
const content::MediaStreamDevice* GetRequestedDeviceOrDefault( const content::MediaStreamDevice* GetRequestedDeviceOrDefault(
const content::MediaStreamDevices& devices, const content::MediaStreamDevices& devices,
const std::string& requested_device_id) { const std::string& requested_device_id) {
......
...@@ -82,6 +82,11 @@ class CastWebViewDefault : public CastWebView, ...@@ -82,6 +82,11 @@ class CastWebViewDefault : public CastWebView,
bool CheckMediaAccessPermission(content::WebContents* web_contents, bool CheckMediaAccessPermission(content::WebContents* web_contents,
const GURL& security_origin, const GURL& security_origin,
content::MediaStreamType type) override; content::MediaStreamType type) override;
bool DidAddMessageToConsole(content::WebContents* source,
int32_t level,
const base::string16& message,
int32_t line_no,
const base::string16& source_id) override;
void RequestMediaAccessPermission( void RequestMediaAccessPermission(
content::WebContents* web_contents, content::WebContents* web_contents,
const content::MediaStreamRequest& request, const content::MediaStreamRequest& request,
......
...@@ -87,5 +87,14 @@ void CastServiceSimple::OnWindowDestroyed() {} ...@@ -87,5 +87,14 @@ void CastServiceSimple::OnWindowDestroyed() {}
void CastServiceSimple::OnKeyEvent(const ui::KeyEvent& key_event) {} void CastServiceSimple::OnKeyEvent(const ui::KeyEvent& key_event) {}
bool CastServiceSimple::OnAddMessageToConsoleReceived(
content::WebContents* source,
int32_t level,
const base::string16& message,
int32_t line_no,
const base::string16& source_id) {
return false;
}
} // namespace shell } // namespace shell
} // namespace chromecast } // namespace chromecast
...@@ -35,6 +35,11 @@ class CastServiceSimple : public CastService, public CastWebView::Delegate { ...@@ -35,6 +35,11 @@ class CastServiceSimple : public CastService, public CastWebView::Delegate {
// CastWebView::Delegate implementation: // CastWebView::Delegate implementation:
void OnPageStopped(int error_code) override; void OnPageStopped(int error_code) override;
void OnLoadingStateChanged(bool loading) override; void OnLoadingStateChanged(bool loading) override;
bool OnAddMessageToConsoleReceived(content::WebContents* source,
int32_t level,
const base::string16& message,
int32_t line_no,
const base::string16& source_id) override;
// CastContentWindow::Delegate implementation: // CastContentWindow::Delegate implementation:
void OnWindowDestroyed() override; void OnWindowDestroyed() override;
......
...@@ -86,5 +86,13 @@ void CastBrowserTest::OnWindowDestroyed() {} ...@@ -86,5 +86,13 @@ void CastBrowserTest::OnWindowDestroyed() {}
void CastBrowserTest::OnKeyEvent(const ui::KeyEvent& key_event) {} void CastBrowserTest::OnKeyEvent(const ui::KeyEvent& key_event) {}
bool CastBrowserTest::OnAddMessageToConsoleReceived(
content::WebContents* source,
int32_t level,
const base::string16& message,
int32_t line_no,
const base::string16& source_id) {
return false;
}
} // namespace shell } // namespace shell
} // namespace chromecast } // namespace chromecast
...@@ -47,6 +47,11 @@ class CastBrowserTest : public content::BrowserTestBase, CastWebView::Delegate { ...@@ -47,6 +47,11 @@ class CastBrowserTest : public content::BrowserTestBase, CastWebView::Delegate {
void OnLoadingStateChanged(bool loading) override; void OnLoadingStateChanged(bool loading) override;
void OnWindowDestroyed() override; void OnWindowDestroyed() override;
void OnKeyEvent(const ui::KeyEvent& key_event) override; void OnKeyEvent(const ui::KeyEvent& key_event) override;
bool OnAddMessageToConsoleReceived(content::WebContents* source,
int32_t level,
const base::string16& message,
int32_t line_no,
const base::string16& source_id) override;
std::unique_ptr<CastWebContentsManager> web_contents_manager_; std::unique_ptr<CastWebContentsManager> web_contents_manager_;
std::unique_ptr<CastWebView> cast_web_view_; std::unique_ptr<CastWebView> cast_web_view_;
......
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