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

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

Issue 2418813002: [Reland] Refactoring of SBER preference usage (Closed)
Patch Set: Sync Created 4 years, 2 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
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 #include "chrome/browser/safe_browsing/client_side_detection_host.h" 5 #include "chrome/browser/safe_browsing/client_side_detection_host.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/memory/ref_counted.h" 13 #include "base/memory/ref_counted.h"
14 #include "base/metrics/histogram_macros.h" 14 #include "base/metrics/histogram_macros.h"
15 #include "base/sequenced_task_runner_helpers.h" 15 #include "base/sequenced_task_runner_helpers.h"
16 #include "base/strings/utf_string_conversions.h" 16 #include "base/strings/utf_string_conversions.h"
17 #include "chrome/browser/browser_process.h" 17 #include "chrome/browser/browser_process.h"
18 #include "chrome/browser/profiles/profile.h" 18 #include "chrome/browser/profiles/profile.h"
19 #include "chrome/browser/safe_browsing/browser_feature_extractor.h" 19 #include "chrome/browser/safe_browsing/browser_feature_extractor.h"
20 #include "chrome/browser/safe_browsing/client_side_detection_service.h" 20 #include "chrome/browser/safe_browsing/client_side_detection_service.h"
21 #include "chrome/browser/safe_browsing/safe_browsing_service.h" 21 #include "chrome/browser/safe_browsing/safe_browsing_service.h"
22 #include "chrome/common/pref_names.h" 22 #include "chrome/common/pref_names.h"
23 #include "chrome/common/safe_browsing/csd.pb.h" 23 #include "chrome/common/safe_browsing/csd.pb.h"
24 #include "chrome/common/safe_browsing/safebrowsing_messages.h" 24 #include "chrome/common/safe_browsing/safebrowsing_messages.h"
25 #include "components/prefs/pref_service.h" 25 #include "components/prefs/pref_service.h"
26 #include "components/safe_browsing_db/database_manager.h" 26 #include "components/safe_browsing_db/database_manager.h"
27 #include "components/safe_browsing_db/safe_browsing_prefs.h"
27 #include "content/public/browser/browser_thread.h" 28 #include "content/public/browser/browser_thread.h"
28 #include "content/public/browser/navigation_controller.h" 29 #include "content/public/browser/navigation_controller.h"
29 #include "content/public/browser/navigation_details.h" 30 #include "content/public/browser/navigation_details.h"
30 #include "content/public/browser/navigation_entry.h" 31 #include "content/public/browser/navigation_entry.h"
31 #include "content/public/browser/render_frame_host.h" 32 #include "content/public/browser/render_frame_host.h"
32 #include "content/public/browser/render_process_host.h" 33 #include "content/public/browser/render_process_host.h"
33 #include "content/public/browser/resource_request_details.h" 34 #include "content/public/browser/resource_request_details.h"
34 #include "content/public/browser/web_contents.h" 35 #include "content/public/browser/web_contents.h"
35 #include "content/public/common/frame_navigate_params.h" 36 #include "content/public/common/frame_navigate_params.h"
36 #include "content/public/common/url_constants.h" 37 #include "content/public/common/url_constants.h"
(...skipping 589 matching lines...) Expand 10 before | Expand all | Expand 10 after
626 // response because we aren't going to display a warning. 627 // response because we aren't going to display a warning.
627 if (request->is_phishing()) { 628 if (request->is_phishing()) {
628 callback = base::Bind(&ClientSideDetectionHost::MaybeShowPhishingWarning, 629 callback = base::Bind(&ClientSideDetectionHost::MaybeShowPhishingWarning,
629 weak_factory_.GetWeakPtr()); 630 weak_factory_.GetWeakPtr());
630 } 631 }
631 Profile* profile = 632 Profile* profile =
632 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); 633 Profile::FromBrowserContext(web_contents()->GetBrowserContext());
633 // Send ping even if the browser feature extraction failed. 634 // Send ping even if the browser feature extraction failed.
634 csd_service_->SendClientReportPhishingRequest( 635 csd_service_->SendClientReportPhishingRequest(
635 request.release(), // The service takes ownership of the request object. 636 request.release(), // The service takes ownership of the request object.
636 profile->GetPrefs()->GetBoolean( 637 IsExtendedReportingEnabled(*profile->GetPrefs()), callback);
637 prefs::kSafeBrowsingExtendedReportingEnabled),
638 callback);
639 } 638 }
640 639
641 void ClientSideDetectionHost::MalwareFeatureExtractionDone( 640 void ClientSideDetectionHost::MalwareFeatureExtractionDone(
642 bool feature_extraction_success, 641 bool feature_extraction_success,
643 std::unique_ptr<ClientMalwareRequest> request) { 642 std::unique_ptr<ClientMalwareRequest> request) {
644 DCHECK(request.get()); 643 DCHECK(request.get());
645 DVLOG(2) << "Malware Feature extraction done for URL: " << request->url() 644 DVLOG(2) << "Malware Feature extraction done for URL: " << request->url()
646 << ", with badip url count:" << request->bad_ip_url_info_size(); 645 << ", with badip url count:" << request->bad_ip_url_info_size();
647 UMA_HISTOGRAM_BOOLEAN( 646 UMA_HISTOGRAM_BOOLEAN(
648 "SBClientMalware.ResourceUrlMatchedBadIp", 647 "SBClientMalware.ResourceUrlMatchedBadIp",
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
716 ui_manager_->RemoveObserver(this); 715 ui_manager_->RemoveObserver(this);
717 716
718 ui_manager_ = ui_manager; 717 ui_manager_ = ui_manager;
719 if (ui_manager) 718 if (ui_manager)
720 ui_manager_->AddObserver(this); 719 ui_manager_->AddObserver(this);
721 720
722 database_manager_ = database_manager; 721 database_manager_ = database_manager;
723 } 722 }
724 723
725 } // namespace safe_browsing 724 } // namespace safe_browsing
OLDNEW
« no previous file with comments | « chrome/browser/profiles/profile.cc ('k') | chrome/browser/safe_browsing/client_side_detection_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698