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

Side by Side Diff: chrome/browser/password_manager/chrome_password_manager_client.cc

Issue 2673053002: Obsolete HTTP Cleaner (Closed)
Patch Set: Created 3 years, 10 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 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/password_manager/chrome_password_manager_client.h" 5 #include "chrome/browser/password_manager/chrome_password_manager_client.h"
6 6
7 #include <string> 7 #include <string>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 #include "content/public/browser/child_process_security_policy.h" 53 #include "content/public/browser/child_process_security_policy.h"
54 #include "content/public/browser/navigation_entry.h" 54 #include "content/public/browser/navigation_entry.h"
55 #include "content/public/browser/navigation_handle.h" 55 #include "content/public/browser/navigation_handle.h"
56 #include "content/public/browser/render_view_host.h" 56 #include "content/public/browser/render_view_host.h"
57 #include "content/public/browser/ssl_status.h" 57 #include "content/public/browser/ssl_status.h"
58 #include "content/public/browser/web_contents.h" 58 #include "content/public/browser/web_contents.h"
59 #include "content/public/common/origin_util.h" 59 #include "content/public/common/origin_util.h"
60 #include "extensions/features/features.h" 60 #include "extensions/features/features.h"
61 #include "google_apis/gaia/gaia_urls.h" 61 #include "google_apis/gaia/gaia_urls.h"
62 #include "net/base/url_util.h" 62 #include "net/base/url_util.h"
63 #include "net/http/transport_security_state.h"
64 #include "net/url_request/url_request_context.h"
63 #include "third_party/re2/src/re2/re2.h" 65 #include "third_party/re2/src/re2/re2.h"
64 66
65 #if defined(OS_ANDROID) 67 #if defined(OS_ANDROID)
66 #include "chrome/browser/android/tab_android.h" 68 #include "chrome/browser/android/tab_android.h"
67 #include "chrome/browser/password_manager/account_chooser_dialog_android.h" 69 #include "chrome/browser/password_manager/account_chooser_dialog_android.h"
68 #include "chrome/browser/password_manager/auto_signin_first_run_dialog_android.h " 70 #include "chrome/browser/password_manager/auto_signin_first_run_dialog_android.h "
69 #include "chrome/browser/password_manager/generated_password_saved_infobar_deleg ate_android.h" 71 #include "chrome/browser/password_manager/generated_password_saved_infobar_deleg ate_android.h"
70 #include "chrome/browser/password_manager/save_password_infobar_delegate_android .h" 72 #include "chrome/browser/password_manager/save_password_infobar_delegate_android .h"
71 #include "chrome/browser/password_manager/update_password_infobar_delegate_andro id.h" 73 #include "chrome/browser/password_manager/update_password_infobar_delegate_andro id.h"
72 #include "chrome/browser/ui/android/snackbars/auto_signin_prompt_controller.h" 74 #include "chrome/browser/ui/android/snackbars/auto_signin_prompt_controller.h"
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 135
134 } // namespace 136 } // namespace
135 137
136 // static 138 // static
137 void ChromePasswordManagerClient::CreateForWebContentsWithAutofillClient( 139 void ChromePasswordManagerClient::CreateForWebContentsWithAutofillClient(
138 content::WebContents* contents, 140 content::WebContents* contents,
139 autofill::AutofillClient* autofill_client) { 141 autofill::AutofillClient* autofill_client) {
140 if (FromWebContents(contents)) 142 if (FromWebContents(contents))
141 return; 143 return;
142 144
143 contents->SetUserData( 145 contents->SetUserData(UserDataKey(), new ChromePasswordManagerClient(
144 UserDataKey(), 146 contents, autofill_client));
jdoerrie 2017/02/03 16:49:15 I'm just seeing these now, most likely they are ca
vasilii 2017/02/06 16:43:24 Better remove. The previous formatting is nicer.
145 new ChromePasswordManagerClient(contents, autofill_client));
146 } 147 }
147 148
148 ChromePasswordManagerClient::ChromePasswordManagerClient( 149 ChromePasswordManagerClient::ChromePasswordManagerClient(
149 content::WebContents* web_contents, 150 content::WebContents* web_contents,
150 autofill::AutofillClient* autofill_client) 151 autofill::AutofillClient* autofill_client)
151 : content::WebContentsObserver(web_contents), 152 : content::WebContentsObserver(web_contents),
152 profile_(Profile::FromBrowserContext(web_contents->GetBrowserContext())), 153 profile_(Profile::FromBrowserContext(web_contents->GetBrowserContext())),
153 password_manager_(this), 154 password_manager_(this),
154 password_reuse_detection_manager_(this), 155 password_reuse_detection_manager_(this),
155 driver_factory_(nullptr), 156 driver_factory_(nullptr),
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 // here once we decide to switch to new settings behavior for everyone. 217 // here once we decide to switch to new settings behavior for everyone.
217 return *saving_and_filling_passwords_enabled_ && !IsOffTheRecord() && 218 return *saving_and_filling_passwords_enabled_ && !IsOffTheRecord() &&
218 IsFillingEnabledForCurrentPage(); 219 IsFillingEnabledForCurrentPage();
219 } 220 }
220 221
221 bool ChromePasswordManagerClient::IsFillingEnabledForCurrentPage() const { 222 bool ChromePasswordManagerClient::IsFillingEnabledForCurrentPage() const {
222 return !DidLastPageLoadEncounterSSLErrors() && 223 return !DidLastPageLoadEncounterSSLErrors() &&
223 IsPasswordManagementEnabledForCurrentPage(); 224 IsPasswordManagementEnabledForCurrentPage();
224 } 225 }
225 226
227 bool ChromePasswordManagerClient::IsHSTSActiveForOrigin(
jdoerrie 2017/02/03 16:49:15 I'm not quite sure if naming is correct here. Mayb
vasilii 2017/02/06 16:43:24 Agree with host.
jdoerrie 2017/02/07 13:15:00 Done.
228 const GURL& origin) const {
229 if (!origin.is_valid())
230 return false;
231
232 net::TransportSecurityState* security_state =
233 profile_->GetRequestContext()
234 ->GetURLRequestContext()
235 ->transport_security_state();
236
237 if (!security_state)
238 return false;
239
240 const std::string host = origin.host();
241 net::TransportSecurityState::STSState sts_state;
242 net::TransportSecurityState::PKPState pkp_state;
243 return security_state->GetStaticDomainState(host, &sts_state, &pkp_state) ||
244 security_state->GetDynamicSTSState(host, &sts_state) ||
245 security_state->GetDynamicPKPState(host, &pkp_state);
jdoerrie 2017/02/03 16:49:15 This check is very similar to what is done in |Tra
vasilii 2017/02/06 16:43:24 The code should be here. How is HPKP relevant here
jdoerrie 2017/02/07 13:15:00 Not sure, I reached out to security folks regardin
246 }
247
226 bool ChromePasswordManagerClient::OnCredentialManagerUsed() { 248 bool ChromePasswordManagerClient::OnCredentialManagerUsed() {
227 prerender::PrerenderContents* prerender_contents = 249 prerender::PrerenderContents* prerender_contents =
228 prerender::PrerenderContents::FromWebContents(web_contents()); 250 prerender::PrerenderContents::FromWebContents(web_contents());
229 if (prerender_contents) { 251 if (prerender_contents) {
230 prerender_contents->Destroy(prerender::FINAL_STATUS_CREDENTIAL_MANAGER_API); 252 prerender_contents->Destroy(prerender::FINAL_STATUS_CREDENTIAL_MANAGER_API);
231 return false; 253 return false;
232 } 254 }
233 return true; 255 return true;
234 } 256 }
235 257
(...skipping 18 matching lines...) Expand all
254 } 276 }
255 #else 277 #else
256 if (form_to_save->IsBlacklisted()) 278 if (form_to_save->IsBlacklisted())
257 return false; 279 return false;
258 280
259 if (update_password) { 281 if (update_password) {
260 UpdatePasswordInfoBarDelegate::Create(web_contents(), 282 UpdatePasswordInfoBarDelegate::Create(web_contents(),
261 std::move(form_to_save)); 283 std::move(form_to_save));
262 return true; 284 return true;
263 } 285 }
264 SavePasswordInfoBarDelegate::Create(web_contents(), 286 SavePasswordInfoBarDelegate::Create(web_contents(), std::move(form_to_save));
265 std::move(form_to_save));
266 #endif // !defined(OS_ANDROID) 287 #endif // !defined(OS_ANDROID)
267 return true; 288 return true;
268 } 289 }
269 290
270 bool ChromePasswordManagerClient::PromptUserToChooseCredentials( 291 bool ChromePasswordManagerClient::PromptUserToChooseCredentials(
271 std::vector<std::unique_ptr<autofill::PasswordForm>> local_forms, 292 std::vector<std::unique_ptr<autofill::PasswordForm>> local_forms,
272 const GURL& origin, 293 const GURL& origin,
273 const CredentialsCallback& callback) { 294 const CredentialsCallback& callback) {
274 // Set up an intercept callback if the prompt is zero-clickable (e.g. just one 295 // Set up an intercept callback if the prompt is zero-clickable (e.g. just one
275 // form provided). 296 // form provided).
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
404 return; 425 return;
405 const blink::WebKeyboardEvent& key_event = 426 const blink::WebKeyboardEvent& key_event =
406 static_cast<const blink::WebKeyboardEvent&>(event); 427 static_cast<const blink::WebKeyboardEvent&>(event);
407 password_reuse_detection_manager_.OnKeyPressed(key_event.text); 428 password_reuse_detection_manager_.OnKeyPressed(key_event.text);
408 } 429 }
409 430
410 PrefService* ChromePasswordManagerClient::GetPrefs() { 431 PrefService* ChromePasswordManagerClient::GetPrefs() {
411 return profile_->GetPrefs(); 432 return profile_->GetPrefs();
412 } 433 }
413 434
414 password_manager::PasswordStore* 435 password_manager::PasswordStore* ChromePasswordManagerClient::GetPasswordStore()
415 ChromePasswordManagerClient::GetPasswordStore() const { 436 const {
416 // Always use EXPLICIT_ACCESS as the password manager checks IsOffTheRecord 437 // Always use EXPLICIT_ACCESS as the password manager checks IsOffTheRecord
417 // itself when it shouldn't access the PasswordStore. 438 // itself when it shouldn't access the PasswordStore.
418 // TODO(gcasto): Is is safe to change this to 439 // TODO(gcasto): Is is safe to change this to
419 // ServiceAccessType::IMPLICIT_ACCESS? 440 // ServiceAccessType::IMPLICIT_ACCESS?
420 return PasswordStoreFactory::GetForProfile( 441 return PasswordStoreFactory::GetForProfile(profile_,
421 profile_, ServiceAccessType::EXPLICIT_ACCESS).get(); 442 ServiceAccessType::EXPLICIT_ACCESS)
443 .get();
422 } 444 }
423 445
424 password_manager::PasswordSyncState 446 password_manager::PasswordSyncState
425 ChromePasswordManagerClient::GetPasswordSyncState() const { 447 ChromePasswordManagerClient::GetPasswordSyncState() const {
426 const browser_sync::ProfileSyncService* sync_service = 448 const browser_sync::ProfileSyncService* sync_service =
427 ProfileSyncServiceFactory::GetForProfile(profile_); 449 ProfileSyncServiceFactory::GetForProfile(profile_);
428 return password_manager_util::GetPasswordSyncState(sync_service); 450 return password_manager_util::GetPasswordSyncState(sync_service);
429 } 451 }
430 452
431 bool ChromePasswordManagerClient::WasLastNavigationHTTPError() const { 453 bool ChromePasswordManagerClient::WasLastNavigationHTTPError() const {
432 DCHECK(web_contents()); 454 DCHECK(web_contents());
433 455
434 std::unique_ptr<password_manager::BrowserSavePasswordProgressLogger> logger; 456 std::unique_ptr<password_manager::BrowserSavePasswordProgressLogger> logger;
435 if (log_manager_->IsLoggingActive()) { 457 if (log_manager_->IsLoggingActive()) {
436 logger.reset(new password_manager::BrowserSavePasswordProgressLogger( 458 logger.reset(new password_manager::BrowserSavePasswordProgressLogger(
437 log_manager_.get())); 459 log_manager_.get()));
438 logger->LogMessage( 460 logger->LogMessage(Logger::STRING_WAS_LAST_NAVIGATION_HTTP_ERROR_METHOD);
439 Logger::STRING_WAS_LAST_NAVIGATION_HTTP_ERROR_METHOD);
440 } 461 }
441 462
442 content::NavigationEntry* entry = 463 content::NavigationEntry* entry =
443 web_contents()->GetController().GetVisibleEntry(); 464 web_contents()->GetController().GetVisibleEntry();
444 if (!entry) 465 if (!entry)
445 return false; 466 return false;
446 int http_status_code = entry->GetHttpStatusCode(); 467 int http_status_code = entry->GetHttpStatusCode();
447 468
448 if (logger) 469 if (logger)
449 logger->LogNumber(Logger::STRING_HTTP_STATUS_CODE, http_status_code); 470 logger->LogNumber(Logger::STRING_HTTP_STATUS_CODE, http_status_code);
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
658 // static 679 // static
659 bool ChromePasswordManagerClient::CanShowBubbleOnURL(const GURL& url) { 680 bool ChromePasswordManagerClient::CanShowBubbleOnURL(const GURL& url) {
660 std::string scheme = url.scheme(); 681 std::string scheme = url.scheme();
661 return (content::ChildProcessSecurityPolicy::GetInstance()->IsWebSafeScheme( 682 return (content::ChildProcessSecurityPolicy::GetInstance()->IsWebSafeScheme(
662 scheme) && 683 scheme) &&
663 #if BUILDFLAG(ENABLE_EXTENSIONS) 684 #if BUILDFLAG(ENABLE_EXTENSIONS)
664 scheme != extensions::kExtensionScheme && 685 scheme != extensions::kExtensionScheme &&
665 #endif 686 #endif
666 scheme != content::kChromeDevToolsScheme); 687 scheme != content::kChromeDevToolsScheme);
667 } 688 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698