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

Side by Side Diff: chrome/browser/safe_browsing/threat_details.cc

Issue 2796123003: Componentize safe_browsing: factor out chrome/ deps in ThreatDetailsRedirectsCollector. (Closed)
Patch Set: fix crashes Created 3 years, 8 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
« no previous file with comments | « no previous file | chrome/browser/safe_browsing/threat_details_history.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 // Implementation of the ThreatDetails class. 5 // Implementation of the ThreatDetails class.
6 6
7 #include "chrome/browser/safe_browsing/threat_details.h" 7 #include "chrome/browser/safe_browsing/threat_details.h"
8 8
9 #include <stddef.h> 9 #include <stddef.h>
10 #include <stdint.h> 10 #include <stdint.h>
11 #include <unordered_set> 11 #include <unordered_set>
12 12
13 #include "base/bind.h" 13 #include "base/bind.h"
14 #include "base/lazy_instance.h" 14 #include "base/lazy_instance.h"
15 #include "base/macros.h" 15 #include "base/macros.h"
16 #include "base/metrics/histogram_macros.h" 16 #include "base/metrics/histogram_macros.h"
17 #include "base/strings/string_util.h" 17 #include "base/strings/string_util.h"
18 #include "chrome/browser/history/history_service_factory.h"
18 #include "chrome/browser/profiles/profile.h" 19 #include "chrome/browser/profiles/profile.h"
19 #include "chrome/browser/safe_browsing/threat_details_cache.h" 20 #include "chrome/browser/safe_browsing/threat_details_cache.h"
20 #include "chrome/browser/safe_browsing/threat_details_history.h" 21 #include "chrome/browser/safe_browsing/threat_details_history.h"
22 #include "components/history/core/browser/history_service.h"
21 #include "components/safe_browsing/common/safebrowsing_messages.h" 23 #include "components/safe_browsing/common/safebrowsing_messages.h"
22 #include "content/public/browser/browser_thread.h" 24 #include "content/public/browser/browser_thread.h"
23 #include "content/public/browser/navigation_controller.h" 25 #include "content/public/browser/navigation_controller.h"
24 #include "content/public/browser/navigation_entry.h" 26 #include "content/public/browser/navigation_entry.h"
25 #include "content/public/browser/render_frame_host.h" 27 #include "content/public/browser/render_frame_host.h"
26 #include "content/public/browser/web_contents.h" 28 #include "content/public/browser/web_contents.h"
27 #include "net/url_request/url_request_context_getter.h" 29 #include "net/url_request/url_request_context_getter.h"
28 30
29 using content::BrowserThread; 31 using content::BrowserThread;
30 using content::NavigationEntry; 32 using content::NavigationEntry;
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 const UnsafeResource& resource) 174 const UnsafeResource& resource)
173 : content::WebContentsObserver(web_contents), 175 : content::WebContentsObserver(web_contents),
174 profile_(Profile::FromBrowserContext(web_contents->GetBrowserContext())), 176 profile_(Profile::FromBrowserContext(web_contents->GetBrowserContext())),
175 request_context_getter_(profile_->GetRequestContext()), 177 request_context_getter_(profile_->GetRequestContext()),
176 ui_manager_(ui_manager), 178 ui_manager_(ui_manager),
177 resource_(resource), 179 resource_(resource),
178 cache_result_(false), 180 cache_result_(false),
179 did_proceed_(false), 181 did_proceed_(false),
180 num_visits_(0), 182 num_visits_(0),
181 ambiguous_dom_(false), 183 ambiguous_dom_(false),
182 cache_collector_(new ThreatDetailsCacheCollector), 184 cache_collector_(new ThreatDetailsCacheCollector) {
183 redirects_collector_(new ThreatDetailsRedirectsCollector(profile_)) { 185 history::HistoryService* history_service =
186 HistoryServiceFactory::GetForProfile(profile_,
187 ServiceAccessType::EXPLICIT_ACCESS);
188 redirects_collector_ = new ThreatDetailsRedirectsCollector(
Jialiu Lin 2017/04/05 18:19:47 If history_service is not available, maybe we don'
timvolodine 2017/04/06 14:15:23 Yes that would seem reasonable, because the redire
189 history_service ? history_service->AsWeakPtr()
190 : base::WeakPtr<history::HistoryService>());
184 StartCollection(); 191 StartCollection();
185 } 192 }
186 193
187 ThreatDetails::~ThreatDetails() {} 194 ThreatDetails::~ThreatDetails() {}
188 195
189 bool ThreatDetails::OnMessageReceived(const IPC::Message& message, 196 bool ThreatDetails::OnMessageReceived(const IPC::Message& message,
190 RenderFrameHost* render_frame_host) { 197 RenderFrameHost* render_frame_host) {
191 bool handled = true; 198 bool handled = true;
192 IPC_BEGIN_MESSAGE_MAP_WITH_PARAM(ThreatDetails, message, render_frame_host) 199 IPC_BEGIN_MESSAGE_MAP_WITH_PARAM(ThreatDetails, message, render_frame_host)
193 IPC_MESSAGE_HANDLER(SafeBrowsingHostMsg_ThreatDOMDetails, 200 IPC_MESSAGE_HANDLER(SafeBrowsingHostMsg_ThreatDOMDetails,
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after
583 // Send the report, using the SafeBrowsingService. 590 // Send the report, using the SafeBrowsingService.
584 std::string serialized; 591 std::string serialized;
585 if (!report_->SerializeToString(&serialized)) { 592 if (!report_->SerializeToString(&serialized)) {
586 DLOG(ERROR) << "Unable to serialize the threat report."; 593 DLOG(ERROR) << "Unable to serialize the threat report.";
587 return; 594 return;
588 } 595 }
589 ui_manager_->SendSerializedThreatDetails(serialized); 596 ui_manager_->SendSerializedThreatDetails(serialized);
590 } 597 }
591 598
592 } // namespace safe_browsing 599 } // namespace safe_browsing
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/safe_browsing/threat_details_history.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698