Commit 2e64d243 authored by Junbo Ke's avatar Junbo Ke Committed by Commit Bot

[Chromecast] Record metrics when a Cast app is running insecure content.

Bug: b/143499157
Test: CQ
Merge-With: eureka-internal/332932
Change-Id: I98b2331231a85c84dda4f894bf5336fae37a16af
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1894298Reviewed-by: default avatarLuke Halliwell (slow) <halliwell@chromium.org>
Reviewed-by: default avatarSean Topping <seantopping@chromium.org>
Commit-Queue: Junbo Ke <juke@chromium.org>
Cr-Commit-Position: refs/heads/master@{#713288}
parent bc94d07a
...@@ -308,10 +308,17 @@ void CastMetricsHelper::RecordEventWithValue(const std::string& event, ...@@ -308,10 +308,17 @@ void CastMetricsHelper::RecordEventWithValue(const std::string& event,
} }
void CastMetricsHelper::RecordApplicationEvent(const std::string& event) { void CastMetricsHelper::RecordApplicationEvent(const std::string& event) {
RecordApplicationEvent(app_id_, session_id_, sdk_version_, event);
}
void CastMetricsHelper::RecordApplicationEvent(const std::string& app_id,
const std::string& session_id,
const std::string& sdk_version,
const std::string& event) {
base::Value cast_event = CreateEventBase(event); base::Value cast_event = CreateEventBase(event);
cast_event.SetKey("app_id", base::Value(app_id_)); cast_event.SetKey("app_id", base::Value(app_id));
cast_event.SetKey("session_id", base::Value(session_id_)); cast_event.SetKey("session_id", base::Value(session_id));
cast_event.SetKey("sdk_version", base::Value(sdk_version_)); cast_event.SetKey("sdk_version", base::Value(sdk_version));
std::string message; std::string message;
base::JSONWriter::Write(cast_event, &message); base::JSONWriter::Write(cast_event, &message);
RecordSimpleAction(message); RecordSimpleAction(message);
......
...@@ -92,6 +92,10 @@ class CastMetricsHelper { ...@@ -92,6 +92,10 @@ class CastMetricsHelper {
// Logs application specific events. // Logs application specific events.
virtual void RecordApplicationEvent(const std::string& event); virtual void RecordApplicationEvent(const std::string& event);
virtual void RecordApplicationEvent(const std::string& app_id,
const std::string& session_id,
const std::string& sdk_version,
const std::string& event);
virtual void RecordApplicationEventWithValue(const std::string& event, virtual void RecordApplicationEventWithValue(const std::string& event,
int value); int value);
......
...@@ -33,4 +33,6 @@ CastWebView::CreateParams::CreateParams() {} ...@@ -33,4 +33,6 @@ CastWebView::CreateParams::CreateParams() {}
CastWebView::CreateParams::CreateParams(const CreateParams& other) = default; CastWebView::CreateParams::CreateParams(const CreateParams& other) = default;
CastWebView::CreateParams::~CreateParams() = default;
} // namespace chromecast } // namespace chromecast
...@@ -66,6 +66,9 @@ class CastWebView { ...@@ -66,6 +66,9 @@ class CastWebView {
// Identifies the activity that is hosted by this CastWebView. // Identifies the activity that is hosted by this CastWebView.
std::string activity_id = ""; std::string activity_id = "";
// Sdk version of the application (if available) hosted by this CastWebView.
std::string sdk_version = "";
// Whether this CastWebView is granted media access. // Whether this CastWebView is granted media access.
bool allow_media_access = false; bool allow_media_access = false;
...@@ -81,6 +84,7 @@ class CastWebView { ...@@ -81,6 +84,7 @@ class CastWebView {
CreateParams(); CreateParams();
CreateParams(const CreateParams& other); CreateParams(const CreateParams& other);
~CreateParams();
}; };
CastWebView(); CastWebView();
......
...@@ -60,6 +60,9 @@ CastWebViewDefault::CastWebViewDefault( ...@@ -60,6 +60,9 @@ CastWebViewDefault::CastWebViewDefault(
browser_context_(browser_context), browser_context_(browser_context),
site_instance_(std::move(site_instance)), site_instance_(std::move(site_instance)),
delegate_(params.delegate), delegate_(params.delegate),
activity_id_(params.activity_id),
session_id_(params.window_params.session_id),
sdk_version_(params.sdk_version),
allow_media_access_(params.allow_media_access), allow_media_access_(params.allow_media_access),
log_prefix_(params.log_prefix), log_prefix_(params.log_prefix),
web_contents_(CreateWebContents(browser_context_, site_instance_)), web_contents_(CreateWebContents(browser_context_, site_instance_)),
...@@ -272,6 +275,17 @@ CastWebViewDefault::RunBluetoothChooser( ...@@ -272,6 +275,17 @@ CastWebViewDefault::RunBluetoothChooser(
: WebContentsDelegate::RunBluetoothChooser(frame, event_handler); : WebContentsDelegate::RunBluetoothChooser(frame, event_handler);
} }
bool CastWebViewDefault::ShouldAllowRunningInsecureContent(
content::WebContents* /* web_contents */,
bool allowed_per_prefs,
const url::Origin& /* origin */,
const GURL& /* resource_url */) {
metrics::CastMetricsHelper::GetInstance()->RecordApplicationEvent(
activity_id_, session_id_, sdk_version_,
"Cast.Platform.AppRunningInsecureContent");
return allowed_per_prefs;
}
void CastWebViewDefault::DidStartNavigation( void CastWebViewDefault::DidStartNavigation(
content::NavigationHandle* navigation_handle) { content::NavigationHandle* navigation_handle) {
if (!resize_window_when_navigation_starts_) { if (!resize_window_when_navigation_starts_) {
......
...@@ -80,12 +80,19 @@ class CastWebViewDefault : public CastWebView, ...@@ -80,12 +80,19 @@ class CastWebViewDefault : public CastWebView,
std::unique_ptr<content::BluetoothChooser> RunBluetoothChooser( std::unique_ptr<content::BluetoothChooser> RunBluetoothChooser(
content::RenderFrameHost* frame, content::RenderFrameHost* frame,
const content::BluetoothChooser::EventHandler& event_handler) override; const content::BluetoothChooser::EventHandler& event_handler) override;
bool ShouldAllowRunningInsecureContent(content::WebContents* web_contents,
bool allowed_per_prefs,
const url::Origin& origin,
const GURL& resource_url) override;
CastWebContentsManager* const web_contents_manager_; CastWebContentsManager* const web_contents_manager_;
content::BrowserContext* const browser_context_; content::BrowserContext* const browser_context_;
const scoped_refptr<content::SiteInstance> site_instance_; const scoped_refptr<content::SiteInstance> site_instance_;
Delegate* const delegate_; Delegate* const delegate_;
const std::string activity_id_;
const std::string session_id_;
const std::string sdk_version_;
const bool allow_media_access_; const bool allow_media_access_;
const std::string log_prefix_; const std::string log_prefix_;
......
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