| 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" |
| 11 #include "chrome/browser/safe_browsing/incident_reporting/omnibox_interaction_in
cident.h" |
| 11 #include "chrome/common/safe_browsing/csd.pb.h" | 12 #include "chrome/common/safe_browsing/csd.pb.h" |
| 12 #include "components/omnibox/autocomplete_result.h" | 13 #include "components/omnibox/autocomplete_result.h" |
| 13 #include "content/public/browser/notification_details.h" | 14 #include "content/public/browser/notification_details.h" |
| 14 #include "content/public/browser/notification_service.h" | 15 #include "content/public/browser/notification_service.h" |
| 15 | 16 |
| 16 namespace safe_browsing { | 17 namespace safe_browsing { |
| 17 | 18 |
| 18 OmniboxWatcher::OmniboxWatcher(Profile* profile, | 19 OmniboxWatcher::OmniboxWatcher(Profile* profile, |
| 19 const AddIncidentCallback& callback): | 20 const AddIncidentCallback& callback): |
| 20 incident_callback_(callback) { | 21 incident_callback_(callback) { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 35 // Users tend not to type very long strings explicitly (especially without | 36 // 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. | 37 // 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 | 38 // No normal person can type URLs that fast! Navigating to a URL as a |
| 38 // result of such typing is suspicious. | 39 // result of such typing is suspicious. |
| 39 // TODO(mpearson): Add support for suspicious queries. | 40 // TODO(mpearson): Add support for suspicious queries. |
| 40 if (!log->is_paste_and_go && !log->last_action_was_paste && | 41 if (!log->is_paste_and_go && !log->last_action_was_paste && |
| 41 log->is_popup_open && (log->text.length() > 200) && | 42 log->is_popup_open && (log->text.length() > 200) && |
| 42 (log->elapsed_time_since_user_first_modified_omnibox < | 43 (log->elapsed_time_since_user_first_modified_omnibox < |
| 43 base::TimeDelta::FromSeconds(1)) && | 44 base::TimeDelta::FromSeconds(1)) && |
| 44 !AutocompleteMatch::IsSearchType(selected_suggestion.type)) { | 45 !AutocompleteMatch::IsSearchType(selected_suggestion.type)) { |
| 45 scoped_ptr<ClientIncidentReport_IncidentData> incident_data( | 46 scoped_ptr<ClientIncidentReport_IncidentData_OmniboxInteractionIncident> |
| 46 new ClientIncidentReport_IncidentData()); | 47 omnibox_interaction( |
| 48 new ClientIncidentReport_IncidentData_OmniboxInteractionIncident()); |
| 47 const GURL& origin = selected_suggestion.destination_url.GetOrigin(); | 49 const GURL& origin = selected_suggestion.destination_url.GetOrigin(); |
| 48 incident_data->mutable_omnibox_interaction()->set_origin( | 50 omnibox_interaction->set_origin(origin.possibly_invalid_spec()); |
| 49 origin.possibly_invalid_spec()); | 51 incident_callback_.Run(make_scoped_ptr( |
| 50 incident_callback_.Run(incident_data.Pass()); | 52 new OmniboxInteractionIncident(omnibox_interaction.Pass()))); |
| 51 } | 53 } |
| 52 } | 54 } |
| 53 | 55 |
| 54 } // namespace safe_browsing | 56 } // namespace safe_browsing |
| OLD | NEW |