Chromium Code Reviews| 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/callback.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()); | |
| 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()); | |
|
grt (UTC plus 2)
2014/11/15 17:56:15
do you need to copy the log here? how about:
con
Mark P
2014/11/18 00:54:44
Done.
| |
| 31 // Users tend not to type very long strings explicitly (especially without | |
| 32 // using the paste-and-go option); it's suspicious when they do so. | |
| 33 if (!log.is_paste_and_go && (log.text.length() > 200)) { | |
| 34 scoped_ptr<ClientIncidentReport_IncidentData> incident_data( | |
| 35 new ClientIncidentReport_IncidentData()); | |
| 36 ClientIncidentReport_IncidentData_OmniboxIncident* | |
| 37 omnibox_interaction = incident_data->mutable_omnibox_interaction(); | |
| 38 omnibox_interaction->set_destination_url( | |
| 39 log.result.match_at(log.selected_index).destination_url.spec()); | |
| 40 incident_callback_.Run(incident_data.Pass()); | |
| 41 } | |
| 42 } | |
| 43 | |
| 44 } // namespace safe_browsing | |
| OLD | NEW |