| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/safe_browsing/incident_reporting/omnibox_watcher.h" | 5 #include "chrome/browser/safe_browsing/incident_reporting/omnibox_watcher.h" |
| 6 | 6 |
| 7 #include "base/time/time.h" | 7 #include "base/time/time.h" |
| 8 #include "chrome/browser/chrome_notification_types.h" | 8 #include "chrome/browser/chrome_notification_types.h" |
| 9 #include "chrome/browser/omnibox/omnibox_log.h" | 9 #include "chrome/browser/omnibox/omnibox_log.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 const content::NotificationDetails& details) { | 30 const content::NotificationDetails& details) { |
| 31 DCHECK_EQ(chrome::NOTIFICATION_OMNIBOX_OPENED_URL, type); | 31 DCHECK_EQ(chrome::NOTIFICATION_OMNIBOX_OPENED_URL, type); |
| 32 const OmniboxLog* log = content::Details<OmniboxLog>(details).ptr(); | 32 const OmniboxLog* log = content::Details<OmniboxLog>(details).ptr(); |
| 33 const AutocompleteMatch& selected_suggestion = | 33 const AutocompleteMatch& selected_suggestion = |
| 34 log->result.match_at(log->selected_index); | 34 log->result.match_at(log->selected_index); |
| 35 // Users tend not to type very long strings explicitly (especially without | 35 // Users tend not to type very long strings explicitly (especially without |
| 36 // using the paste-and-go option), and certainly not in under a second. | 36 // using the paste-and-go option), and certainly not in under a second. |
| 37 // No normal person can type URLs that fast! Navigating to a URL as a | 37 // No normal person can type URLs that fast! Navigating to a URL as a |
| 38 // result of such typing is suspicious. | 38 // result of such typing is suspicious. |
| 39 // TODO(mpearson): Add support for suspicious queries. | 39 // TODO(mpearson): Add support for suspicious queries. |
| 40 if (!log->is_paste_and_go && !log->last_action_was_paste && | 40 if (!log->is_paste_and_go && log->is_popup_open && |
| 41 log->is_popup_open && (log->text.length() > 200) && | 41 (log->text.length() > 200) && |
| 42 (log->elapsed_time_since_user_first_modified_omnibox < | 42 (log->elapsed_time_since_user_first_modified_omnibox < |
| 43 base::TimeDelta::FromSeconds(1)) && | 43 base::TimeDelta::FromSeconds(1)) && |
| 44 !AutocompleteMatch::IsSearchType(selected_suggestion.type)) { | 44 !AutocompleteMatch::IsSearchType(selected_suggestion.type)) { |
| 45 scoped_ptr<ClientIncidentReport_IncidentData> incident_data( | 45 scoped_ptr<ClientIncidentReport_IncidentData> incident_data( |
| 46 new ClientIncidentReport_IncidentData()); | 46 new ClientIncidentReport_IncidentData()); |
| 47 const GURL& origin = selected_suggestion.destination_url.GetOrigin(); | 47 const GURL& origin = selected_suggestion.destination_url.GetOrigin(); |
| 48 incident_data->mutable_omnibox_interaction()->set_origin( | 48 incident_data->mutable_omnibox_interaction()->set_origin( |
| 49 origin.possibly_invalid_spec()); | 49 origin.possibly_invalid_spec()); |
| 50 incident_callback_.Run(incident_data.Pass()); | 50 incident_callback_.Run(incident_data.Pass()); |
| 51 } | 51 } |
| 52 } | 52 } |
| 53 | 53 |
| 54 } // namespace safe_browsing | 54 } // namespace safe_browsing |
| OLD | NEW |