Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(531)

Unified Diff: chrome/browser/safe_browsing/safe_browsing_blocking_page.cc

Issue 399773002: Experience sampling insturmentation for SSL and Safe Browsing interstitials (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@sampling-api
Patch Set: rebase-update Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/safe_browsing/safe_browsing_blocking_page.cc
diff --git a/chrome/browser/safe_browsing/safe_browsing_blocking_page.cc b/chrome/browser/safe_browsing/safe_browsing_blocking_page.cc
index 81c3f2a116fdd9cee692ebffd320a0c4f6fadf70..2d73872c8d0f6e2c3c4ea1cdbde515374dcff7fc 100644
--- a/chrome/browser/safe_browsing/safe_browsing_blocking_page.cc
+++ b/chrome/browser/safe_browsing/safe_browsing_blocking_page.cc
@@ -22,6 +22,7 @@
#include "base/time/time.h"
#include "base/values.h"
#include "chrome/browser/browser_process.h"
+#include "chrome/browser/extensions/api/experience_sampling_private/experience_sampling.h"
#include "chrome/browser/history/history_service_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/renderer_preferences_util.h"
@@ -53,6 +54,7 @@ using content::InterstitialPage;
using content::OpenURLParams;
using content::Referrer;
using content::WebContents;
+using extensions::SamplingEvent;
namespace {
@@ -114,6 +116,13 @@ const char kNavigatedAwayMetaCommand[] = "closed";
const char kBoxChecked[] = "boxchecked";
const char kDisplayCheckBox[] = "displaycheckbox";
+// Constants for the Experience Sampling instrumentation.
+const char kEventNameMalware[] = "safebrowsing_interstitial_";
+const char kEventNamePhishing[] = "phishing_interstitial_";
+const char kEventNameMalwareAndPhishing[] =
+ "malware_and_phishing_interstitial_";
+const char kEventNameOther[] = "safebrowsing_other_instertitial_";
+
base::LazyInstance<SafeBrowsingBlockingPage::UnsafeResourceMap>
g_unsafe_resource_map = LAZY_INSTANCE_INITIALIZER;
@@ -310,6 +319,29 @@ SafeBrowsingBlockingPage::SafeBrowsingBlockingPage(
ui_manager_, web_contents, unsafe_resources[0]);
}
+ // ExperienceSampling: Set up new sampling event for this interstitial.
+ // This needs to handle all types of warnings this insterstitial can show.
+ std::string event_name;
+ switch (interstitial_type_) {
+ case TYPE_MALWARE_AND_PHISHING:
+ event_name = kEventNameMalwareAndPhishing;
+ break;
+ case TYPE_MALWARE:
+ event_name = kEventNameMalware;
+ break;
+ case TYPE_PHISHING:
+ event_name = kEventNamePhishing;
+ break;
+ default:
+ event_name = kEventNameOther;
+ break;
+ }
+ sampling_event_.reset(new SamplingEvent(
+ event_name,
+ url_,
+ web_contents_->GetLastCommittedURL(),
+ web_contents_->GetBrowserContext()));
+
interstitial_page_ = InterstitialPage::Create(
web_contents, IsMainPageLoadBlocked(unsafe_resources), url_, this);
}
@@ -353,6 +385,8 @@ void SafeBrowsingBlockingPage::CommandReceived(const std::string& cmd) {
NOTREACHED();
}
+ sampling_event_->has_viewed_learn_more = true;
+
OpenURLParams params(
url, Referrer(), CURRENT_TAB, content::PAGE_TRANSITION_LINK, false);
web_contents_->OpenURL(params);
@@ -373,6 +407,8 @@ void SafeBrowsingBlockingPage::CommandReceived(const std::string& cmd) {
NOTREACHED();
}
+ sampling_event_->has_viewed_learn_more = true;
+
OpenURLParams params(
url, Referrer(), CURRENT_TAB, content::PAGE_TRANSITION_LINK, false);
web_contents_->OpenURL(params);
@@ -486,6 +522,9 @@ void SafeBrowsingBlockingPage::CommandReceived(const std::string& cmd) {
// User expanded the "see more info" section of the page. We don't actually
// do any action based on this, it's just so that RecordUserReactionTime can
// track it.
+
+ // ExperienceSampling: We track that the user expanded the details.
+ sampling_event_->has_viewed_details = true;
return;
}
@@ -549,6 +588,9 @@ void SafeBrowsingBlockingPage::OnProceed() {
unsafe_resource_map->erase(iter);
}
+ // ExperienceSampling: Notify that user decided to proceed.
+ sampling_event_->CreateUserDecisionEvent(SamplingEvent::kProceed);
+
// Now that this interstitial is gone, we can show the new one.
if (blocking_page)
blocking_page->interstitial_page_->Show();
@@ -592,6 +634,10 @@ void SafeBrowsingBlockingPage::OnDontProceed() {
navigation_entry_index_to_remove_));
navigation_entry_index_to_remove_ = -1;
}
+
+ // ExperienceSampling: Notify that user decided to go back.
+ // This also occurs if the user navigates away or closes the tab.
+ sampling_event_->CreateUserDecisionEvent(SamplingEvent::kDeny);
}
void SafeBrowsingBlockingPage::OnGotHistoryCount(bool success,

Powered by Google App Engine
This is Rietveld 408576698