OLD | NEW |
---|---|
(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/common/safe_browsing/csd.pb.h" | |
11 #include "components/omnibox/autocomplete_result.h" | |
12 #include "content/public/browser/notification_details.h" | |
13 #include "content/public/browser/notification_service.h" | |
14 | |
15 namespace safe_browsing { | |
16 | |
17 OmniboxWatcher::OmniboxWatcher(const AddIncidentCallback& callback): | |
18 incident_callback_(callback) { | |
19 registrar_.Add(this, chrome::NOTIFICATION_OMNIBOX_OPENED_URL, | |
20 content::NotificationService::AllSources()); | |
grt (UTC plus 2)
2014/12/05 18:40:56
pass in the Profile* and use content::Source<Profi
Mark P
2014/12/09 19:23:30
Good idea. Done.
| |
21 } | |
22 | |
23 OmniboxWatcher::~OmniboxWatcher() { | |
24 } | |
25 | |
26 void OmniboxWatcher::Observe(int type, | |
27 const content::NotificationSource& source, | |
28 const content::NotificationDetails& details) { | |
29 DCHECK_EQ(chrome::NOTIFICATION_OMNIBOX_OPENED_URL, type); | |
30 const OmniboxLog* log = content::Details<OmniboxLog>(details).ptr(); | |
31 const AutocompleteMatch& selected_suggestion = | |
32 log->result.match_at(log->selected_index); | |
33 // Users tend not to type very long strings explicitly (especially without | |
34 // using the paste-and-go option), and certainly not in under a second. | |
35 // No normal person can type URLs that fast! Navigating to a URL as a | |
36 // result of such typing is suspicious. (Queries are suspicious too--all | |
37 // such typing is--but we don't monitor queries for now.) | |
grt (UTC plus 2)
2014/12/05 18:40:56
consider replacing the parenthetical remark with:
Mark P
2014/12/09 19:23:30
Done.
| |
38 if (!log->is_paste_and_go && (log->text.length() > 200) && | |
39 (log->elapsed_time_since_user_first_modified_omnibox < | |
40 base::TimeDelta::FromSeconds(1)) && | |
41 !AutocompleteMatch::IsSearchType(selected_suggestion.type)) { | |
42 scoped_ptr<ClientIncidentReport_IncidentData> incident_data( | |
43 new ClientIncidentReport_IncidentData()); | |
44 const GURL& origin = selected_suggestion.destination_url.GetOrigin(); | |
grt (UTC plus 2)
2014/12/05 18:40:56
gurl.h says that GetOrigin() may return an empty U
Mark P
2014/12/09 19:23:30
I don't believe so. The omnibox suggestions (whic
| |
45 incident_data->mutable_omnibox_interaction()->set_origin( | |
46 origin.possibly_invalid_spec()); | |
47 incident_callback_.Run(incident_data.Pass()); | |
48 } | |
49 } | |
50 | |
51 } // namespace safe_browsing | |
OLD | NEW |