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

Side by Side Diff: components/safe_browsing/password_protection/password_protection_request.cc

Issue 2892093003: Don't trigger Phishguard pings if we cannot compute URL reputation. (Closed)
Patch Set: update comments Created 3 years, 7 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 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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 #include "components/safe_browsing/password_protection/password_protection_reque st.h" 4 #include "components/safe_browsing/password_protection/password_protection_reque st.h"
5 5
6 #include "base/memory/ptr_util.h" 6 #include "base/memory/ptr_util.h"
7 #include "base/memory/weak_ptr.h" 7 #include "base/memory/weak_ptr.h"
8 #include "base/metrics/histogram_macros.h" 8 #include "base/metrics/histogram_macros.h"
9 #include "components/data_use_measurement/core/data_use_user_data.h" 9 #include "components/data_use_measurement/core/data_use_user_data.h"
10 #include "components/safe_browsing_db/database_manager.h" 10 #include "content/public/browser/web_contents.h"
11 #include "net/base/escape.h" 11 #include "net/base/escape.h"
12 #include "net/base/load_flags.h" 12 #include "net/base/load_flags.h"
13 #include "net/base/url_util.h" 13 #include "net/base/url_util.h"
14 #include "net/http/http_status_code.h" 14 #include "net/http/http_status_code.h"
15 15
16 using content::BrowserThread; 16 using content::BrowserThread;
17 using content::WebContents;
17 18
18 namespace safe_browsing { 19 namespace safe_browsing {
19 20
20 PasswordProtectionRequest::PasswordProtectionRequest( 21 PasswordProtectionRequest::PasswordProtectionRequest(
22 WebContents* web_contents,
21 const GURL& main_frame_url, 23 const GURL& main_frame_url,
22 const GURL& password_form_action, 24 const GURL& password_form_action,
23 const GURL& password_form_frame_url, 25 const GURL& password_form_frame_url,
24 const std::string& saved_domain, 26 const std::string& saved_domain,
25 LoginReputationClientRequest::TriggerType type, 27 LoginReputationClientRequest::TriggerType type,
26 PasswordProtectionService* pps, 28 PasswordProtectionService* pps,
27 int request_timeout_in_ms) 29 int request_timeout_in_ms)
28 : main_frame_url_(main_frame_url), 30 : web_contents_(web_contents),
31 main_frame_url_(main_frame_url),
29 password_form_action_(password_form_action), 32 password_form_action_(password_form_action),
30 password_form_frame_url_(password_form_frame_url), 33 password_form_frame_url_(password_form_frame_url),
31 saved_domain_(saved_domain), 34 saved_domain_(saved_domain),
32 request_type_(type), 35 request_type_(type),
33 password_protection_service_(pps), 36 password_protection_service_(pps),
34 database_manager_(password_protection_service_->database_manager()),
35 request_timeout_in_ms_(request_timeout_in_ms), 37 request_timeout_in_ms_(request_timeout_in_ms),
36 weakptr_factory_(this) { 38 weakptr_factory_(this) {
37 DCHECK_CURRENTLY_ON(BrowserThread::UI); 39 DCHECK_CURRENTLY_ON(BrowserThread::UI);
38 } 40 }
39 41
40 PasswordProtectionRequest::~PasswordProtectionRequest() { 42 PasswordProtectionRequest::~PasswordProtectionRequest() {
41 weakptr_factory_.InvalidateWeakPtrs(); 43 weakptr_factory_.InvalidateWeakPtrs();
42 } 44 }
43 45
44 void PasswordProtectionRequest::Start() { 46 void PasswordProtectionRequest::Start() {
45 DCHECK_CURRENTLY_ON(BrowserThread::UI); 47 DCHECK_CURRENTLY_ON(BrowserThread::UI);
46 CheckWhitelistOnUIThread(); 48 CheckWhitelistOnUIThread();
47 } 49 }
48 50
49 void PasswordProtectionRequest::CheckWhitelistOnUIThread() { 51 void PasswordProtectionRequest::CheckWhitelistOnUIThread() {
50 DCHECK_CURRENTLY_ON(BrowserThread::UI); 52 DCHECK_CURRENTLY_ON(BrowserThread::UI);
51 bool* match_whitelist = new bool(false); 53 bool* match_whitelist = new bool(false);
52 // TODO(jialiul): Move CheckCsdWhitelistOnIOThread to 54
53 // PasswordProtectionRequest class, since PasswordProtectionService no longer
54 // need it.
55 tracker_.PostTaskAndReply( 55 tracker_.PostTaskAndReply(
56 BrowserThread::GetTaskRunnerForThread(BrowserThread::IO).get(), FROM_HERE, 56 BrowserThread::GetTaskRunnerForThread(BrowserThread::IO).get(), FROM_HERE,
57 base::Bind(&PasswordProtectionService::CheckCsdWhitelistOnIOThread, 57 base::Bind(&PasswordProtectionService::CheckCsdWhitelistOnIOThread,
58 base::Unretained(password_protection_service_), 58 base::Unretained(password_protection_service_),
59 main_frame_url_, match_whitelist), 59 main_frame_url_, match_whitelist),
60 base::Bind(&PasswordProtectionRequest::OnWhitelistCheckDone, this, 60 base::Bind(&PasswordProtectionRequest::OnWhitelistCheckDone, this,
61 base::Owned(match_whitelist))); 61 base::Owned(match_whitelist)));
62 } 62 }
63 63
64 void PasswordProtectionRequest::OnWhitelistCheckDone( 64 void PasswordProtectionRequest::OnWhitelistCheckDone(
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 void PasswordProtectionRequest::Cancel(bool timed_out) { 247 void PasswordProtectionRequest::Cancel(bool timed_out) {
248 DCHECK_CURRENTLY_ON(BrowserThread::UI); 248 DCHECK_CURRENTLY_ON(BrowserThread::UI);
249 fetcher_.reset(); 249 fetcher_.reset();
250 250
251 Finish(timed_out ? PasswordProtectionService::TIMEDOUT 251 Finish(timed_out ? PasswordProtectionService::TIMEDOUT
252 : PasswordProtectionService::CANCELED, 252 : PasswordProtectionService::CANCELED,
253 nullptr); 253 nullptr);
254 } 254 }
255 255
256 } // namespace safe_browsing 256 } // namespace safe_browsing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698