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

Side by Side Diff: chrome/browser/safe_browsing/incident_reporting/omnibox_watcher.cc

Issue 872433003: Remove omnibox watcher. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/safe_browsing/incident_reporting/omnibox_watcher.h"
6
7 #include "base/time/time.h"
8 #include "chrome/browser/chrome_notification_types.h"
9 #include "chrome/browser/omnibox/omnibox_log.h"
10 #include "chrome/browser/profiles/profile.h"
11 #include "chrome/browser/safe_browsing/incident_reporting/omnibox_interaction_in cident.h"
12 #include "chrome/common/safe_browsing/csd.pb.h"
13 #include "components/omnibox/autocomplete_result.h"
14 #include "content/public/browser/notification_details.h"
15 #include "content/public/browser/notification_service.h"
16
17 namespace safe_browsing {
18
19 OmniboxWatcher::OmniboxWatcher(Profile* profile,
20 const AddIncidentCallback& callback):
21 incident_callback_(callback) {
22 registrar_.Add(this, chrome::NOTIFICATION_OMNIBOX_OPENED_URL,
23 content::Source<Profile>(profile));
24 }
25
26 OmniboxWatcher::~OmniboxWatcher() {
27 }
28
29 void OmniboxWatcher::Observe(int type,
30 const content::NotificationSource& source,
31 const content::NotificationDetails& details) {
32 DCHECK_EQ(chrome::NOTIFICATION_OMNIBOX_OPENED_URL, type);
33 const OmniboxLog* log = content::Details<OmniboxLog>(details).ptr();
34 const AutocompleteMatch& selected_suggestion =
35 log->result.match_at(log->selected_index);
36 // Users tend not to type very long strings explicitly (especially without
37 // using the paste-and-go option), and certainly not in under a second.
38 // No normal person can type URLs that fast! Navigating to a URL as a
39 // result of such typing is suspicious.
40 // TODO(mpearson): Add support for suspicious queries.
41 if (!log->is_paste_and_go && !log->last_action_was_paste &&
42 log->is_popup_open && (log->text.length() > 200) &&
43 (log->elapsed_time_since_user_first_modified_omnibox <
44 base::TimeDelta::FromSeconds(1)) &&
45 !AutocompleteMatch::IsSearchType(selected_suggestion.type)) {
46 scoped_ptr<ClientIncidentReport_IncidentData_OmniboxInteractionIncident>
47 omnibox_interaction(
48 new ClientIncidentReport_IncidentData_OmniboxInteractionIncident());
49 const GURL& origin = selected_suggestion.destination_url.GetOrigin();
50 omnibox_interaction->set_origin(origin.possibly_invalid_spec());
51 incident_callback_.Run(make_scoped_ptr(
52 new OmniboxInteractionIncident(omnibox_interaction.Pass())));
53 }
54 }
55
56 } // namespace safe_browsing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698