Commit 9d291627 authored by grt's avatar grt Committed by Commit bot

Remove omnibox watcher.

This is effectively a revert of commit positions 308378 and 307774.

BUG=451173
TBR=bauerb@chromium.org,rogerta@chromium.org

Review URL: https://codereview.chromium.org/872433003

Cr-Commit-Position: refs/heads/master@{#312943}
parent 887eb463
......@@ -224,7 +224,6 @@ void AutocompleteControllerAndroid::OnSuggestionSelected(
true,
selected_index,
false,
false, /* don't know */
SessionTabHelper::IdForTab(web_contents),
current_page_classification,
base::TimeDelta::FromMilliseconds(elapsed_time_since_first_modified),
......
......@@ -11,7 +11,6 @@ OmniboxLog::OmniboxLog(
bool is_popup_open,
size_t selected_index,
bool is_paste_and_go,
bool last_action_was_paste,
SessionID::id_type tab_id,
metrics::OmniboxEventProto::PageClassification current_page_classification,
base::TimeDelta elapsed_time_since_user_first_modified_omnibox,
......@@ -24,7 +23,6 @@ OmniboxLog::OmniboxLog(
is_popup_open(is_popup_open),
selected_index(selected_index),
is_paste_and_go(is_paste_and_go),
last_action_was_paste(last_action_was_paste),
tab_id(tab_id),
current_page_classification(current_page_classification),
elapsed_time_since_user_first_modified_omnibox(
......
......@@ -26,7 +26,6 @@ struct OmniboxLog {
bool is_popup_open,
size_t selected_index,
bool is_paste_and_go,
bool last_action_was_paste,
SessionID::id_type tab_id,
metrics::OmniboxEventProto::PageClassification
current_page_classification,
......@@ -57,10 +56,6 @@ struct OmniboxLog {
// (The codebase refers to both these types as paste-and-go.)
bool is_paste_and_go;
// True if the user's last action was a paste or if (somehow) the user is
// still in the act of pasting.
bool last_action_was_paste;
// ID of the tab the selected autocomplete suggestion was opened in.
// Set to -1 if we haven't yet determined the destination tab.
SessionID::id_type tab_id;
......
......@@ -251,7 +251,7 @@ void RlzLibTest::SimulateOmniboxUsage() {
// with empty or invalid values.
AutocompleteResult empty_result;
OmniboxLog dummy(base::string16(), false, metrics::OmniboxInputType::INVALID,
true, 0, false, false, -1,
true, 0, false, -1,
metrics::OmniboxEventProto::INVALID_SPEC,
base::TimeDelta::FromSeconds(0), 0,
base::TimeDelta::FromSeconds(0),
......
......@@ -27,7 +27,6 @@
#include "chrome/browser/safe_browsing/incident_reporting/environment_data_collection.h"
#include "chrome/browser/safe_browsing/incident_reporting/incident.h"
#include "chrome/browser/safe_browsing/incident_reporting/incident_report_uploader_impl.h"
#include "chrome/browser/safe_browsing/incident_reporting/omnibox_watcher.h"
#include "chrome/browser/safe_browsing/incident_reporting/preference_validation_delegate.h"
#include "chrome/browser/safe_browsing/safe_browsing_service.h"
#include "chrome/common/pref_names.h"
......@@ -156,9 +155,6 @@ struct IncidentReportingService::ProfileContext {
// Will contain null values for pruned incidents.
ScopedVector<Incident> incidents;
// Watches for suspicious omnibox interactions on this profile.
scoped_ptr<OmniboxWatcher> omnibox_watcher;
// False until PROFILE_ADDED notification is received.
bool added;
......@@ -364,11 +360,6 @@ void IncidentReportingService::OnProfileAdded(Profile* profile) {
// so that the service can determine whether or not it can evaluate a
// profile's preferences at the time of incident addition.
ProfileContext* context = GetOrCreateProfileContext(profile);
// Start watching the profile now if necessary.
if (!context->omnibox_watcher) {
context->omnibox_watcher.reset(
new OmniboxWatcher(profile, GetAddIncidentCallback(profile)));
}
context->added = true;
const bool safe_browsing_enabled =
......
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/safe_browsing/incident_reporting/omnibox_interaction_incident.h"
#include "base/logging.h"
#include "chrome/common/safe_browsing/csd.pb.h"
namespace safe_browsing {
OmniboxInteractionIncident::OmniboxInteractionIncident(
scoped_ptr<ClientIncidentReport_IncidentData_OmniboxInteractionIncident>
omnibox_interaction_incident) {
DCHECK(omnibox_interaction_incident);
DCHECK(omnibox_interaction_incident->has_origin());
payload()->set_allocated_omnibox_interaction(
omnibox_interaction_incident.release());
}
OmniboxInteractionIncident::~OmniboxInteractionIncident() {
}
IncidentType OmniboxInteractionIncident::GetType() const {
return IncidentType::OMNIBOX_INTERACTION;
}
std::string OmniboxInteractionIncident::GetKey() const {
// Return a constant, as only one kind of suspicious interaction is detected.
return "1";
}
uint32_t OmniboxInteractionIncident::ComputeDigest() const {
// Return a constant (independent of the incident's payload) so that only the
// first suspicious interaction is reported.
return 1u;
}
} // namespace safe_browsing
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_SAFE_BROWSING_INCIDENT_REPORTING_OMNIBOX_INTERACTION_INCIDENT_H_
#define CHROME_BROWSER_SAFE_BROWSING_INCIDENT_REPORTING_OMNIBOX_INTERACTION_INCIDENT_H_
#include "base/memory/scoped_ptr.h"
#include "chrome/browser/safe_browsing/incident_reporting/incident.h"
namespace safe_browsing {
class ClientIncidentReport_IncidentData_OmniboxInteractionIncident;
// An incident representing a suspicious omnibox interaction.
class OmniboxInteractionIncident : public Incident {
public:
explicit OmniboxInteractionIncident(
scoped_ptr<ClientIncidentReport_IncidentData_OmniboxInteractionIncident>
omnibox_interaction);
~OmniboxInteractionIncident() override;
// Incident methods:
IncidentType GetType() const override;
std::string GetKey() const override;
uint32_t ComputeDigest() const override;
private:
DISALLOW_COPY_AND_ASSIGN(OmniboxInteractionIncident);
};
} // namespace safe_browsing
#endif // CHROME_BROWSER_SAFE_BROWSING_INCIDENT_REPORTING_OMNIBOX_INTERACTION_INCIDENT_H_
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/safe_browsing/incident_reporting/omnibox_watcher.h"
#include "base/time/time.h"
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/omnibox/omnibox_log.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/safe_browsing/incident_reporting/omnibox_interaction_incident.h"
#include "chrome/common/safe_browsing/csd.pb.h"
#include "components/omnibox/autocomplete_result.h"
#include "content/public/browser/notification_details.h"
#include "content/public/browser/notification_service.h"
namespace safe_browsing {
OmniboxWatcher::OmniboxWatcher(Profile* profile,
const AddIncidentCallback& callback):
incident_callback_(callback) {
registrar_.Add(this, chrome::NOTIFICATION_OMNIBOX_OPENED_URL,
content::Source<Profile>(profile));
}
OmniboxWatcher::~OmniboxWatcher() {
}
void OmniboxWatcher::Observe(int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) {
DCHECK_EQ(chrome::NOTIFICATION_OMNIBOX_OPENED_URL, type);
const OmniboxLog* log = content::Details<OmniboxLog>(details).ptr();
const AutocompleteMatch& selected_suggestion =
log->result.match_at(log->selected_index);
// Users tend not to type very long strings explicitly (especially without
// using the paste-and-go option), and certainly not in under a second.
// No normal person can type URLs that fast! Navigating to a URL as a
// result of such typing is suspicious.
// TODO(mpearson): Add support for suspicious queries.
if (!log->is_paste_and_go && !log->last_action_was_paste &&
log->is_popup_open && (log->text.length() > 200) &&
(log->elapsed_time_since_user_first_modified_omnibox <
base::TimeDelta::FromSeconds(1)) &&
!AutocompleteMatch::IsSearchType(selected_suggestion.type)) {
scoped_ptr<ClientIncidentReport_IncidentData_OmniboxInteractionIncident>
omnibox_interaction(
new ClientIncidentReport_IncidentData_OmniboxInteractionIncident());
const GURL& origin = selected_suggestion.destination_url.GetOrigin();
omnibox_interaction->set_origin(origin.possibly_invalid_spec());
incident_callback_.Run(make_scoped_ptr(
new OmniboxInteractionIncident(omnibox_interaction.Pass())));
}
}
} // namespace safe_browsing
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_SAFE_BROWSING_INCIDENT_REPORTING_OMNIBOX_WATCHER_H_
#define CHROME_BROWSER_SAFE_BROWSING_INCIDENT_REPORTING_OMNIBOX_WATCHER_H_
#include "base/callback.h"
#include "base/macros.h"
#include "chrome/browser/safe_browsing/incident_reporting/add_incident_callback.h"
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h"
class Profile;
namespace safe_browsing {
// Observes all URLs opened via the omnibox, adding an incident to the
// incident reporting service for those that are typed impossibly quickly.
class OmniboxWatcher : public content::NotificationObserver {
public:
OmniboxWatcher(Profile* profile, const AddIncidentCallback& callback);
~OmniboxWatcher() override;
private:
// content::NotificationObserver:
void Observe(int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) override;
// The place to send a callback when we witness a suspicious omnibox
// navigation.
AddIncidentCallback incident_callback_;
// Registrar for receiving Omnibox event notifications.
content::NotificationRegistrar registrar_;
DISALLOW_COPY_AND_ASSIGN(OmniboxWatcher);
};
} // namespace safe_browsing
#endif // CHROME_BROWSER_SAFE_BROWSING_INCIDENT_REPORTING_OMNIBOX_WATCHER_H_
......@@ -743,8 +743,7 @@ void OmniboxEditModel::OpenMatch(AutocompleteMatch match,
input_.type(),
popup_model()->IsOpen(),
(!popup_model()->IsOpen() || !pasted_text.empty()) ? 0 : index,
!pasted_text.empty(), // is_paste_and_go
paste_state_ != NONE, // last_action_was_paste
!pasted_text.empty(),
-1, // don't yet know tab ID; set later if appropriate
ClassifyPage(),
elapsed_time_since_user_first_modified_omnibox,
......
......@@ -2315,10 +2315,6 @@
'browser/safe_browsing/incident_reporting/module_integrity_verifier_win.h',
'browser/safe_browsing/incident_reporting/off_domain_inclusion_detector.cc',
'browser/safe_browsing/incident_reporting/off_domain_inclusion_detector.h',
'browser/safe_browsing/incident_reporting/omnibox_interaction_incident.cc',
'browser/safe_browsing/incident_reporting/omnibox_interaction_incident.h',
'browser/safe_browsing/incident_reporting/omnibox_watcher.cc',
'browser/safe_browsing/incident_reporting/omnibox_watcher.h',
'browser/safe_browsing/incident_reporting/preference_validation_delegate.cc',
'browser/safe_browsing/incident_reporting/preference_validation_delegate.h',
'browser/safe_browsing/incident_reporting/tracked_preference_incident.cc',
......
......@@ -364,9 +364,6 @@ message ClientIncidentReport {
optional ClientDownloadRequest.SignatureInfo signature = 5;
optional ClientDownloadRequest.ImageHeaders image_headers = 6;
}
message OmniboxInteractionIncident {
optional string origin = 1;
}
message VariationsSeedSignatureIncident {
optional string variations_seed_signature = 1;
}
......@@ -374,7 +371,7 @@ message ClientIncidentReport {
optional TrackedPreferenceIncident tracked_preference = 2;
optional BinaryIntegrityIncident binary_integrity = 3;
optional BlacklistLoadIncident blacklist_load = 4;
optional OmniboxInteractionIncident omnibox_interaction = 5;
// Note: skip tag 5 because it was previously used.
optional VariationsSeedSignatureIncident variations_seed_signature = 6;
}
......
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