OLD | NEW |
---|---|
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 "base/bind_helpers.h" | 7 #include "base/bind_helpers.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/memory/singleton.h" | 9 #include "base/memory/singleton.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
85 | 85 |
86 bool ChromePasswordManagerClient::IsAutomaticPasswordSavingEnabled() const { | 86 bool ChromePasswordManagerClient::IsAutomaticPasswordSavingEnabled() const { |
87 return CommandLine::ForCurrentProcess()->HasSwitch( | 87 return CommandLine::ForCurrentProcess()->HasSwitch( |
88 password_manager::switches::kEnableAutomaticPasswordSaving) && | 88 password_manager::switches::kEnableAutomaticPasswordSaving) && |
89 chrome::VersionInfo::GetChannel() == | 89 chrome::VersionInfo::GetChannel() == |
90 chrome::VersionInfo::CHANNEL_UNKNOWN; | 90 chrome::VersionInfo::CHANNEL_UNKNOWN; |
91 } | 91 } |
92 | 92 |
93 bool ChromePasswordManagerClient::IsPasswordManagerEnabledForCurrentPage() | 93 bool ChromePasswordManagerClient::IsPasswordManagerEnabledForCurrentPage() |
94 const { | 94 const { |
95 if (EnabledForSyncSignin()) | |
96 return true; | |
97 | |
98 DCHECK(web_contents()); | 95 DCHECK(web_contents()); |
99 content::NavigationEntry* entry = | 96 content::NavigationEntry* entry = |
100 web_contents()->GetController().GetLastCommittedEntry(); | 97 web_contents()->GetController().GetLastCommittedEntry(); |
101 if (!entry) { | 98 if (!entry) { |
102 // TODO(gcasto): Determine if fix for crbug.com/388246 is relevant here. | 99 // TODO(gcasto): Determine if fix for crbug.com/388246 is relevant here. |
103 return true; | 100 return true; |
104 } | 101 } |
102 | |
103 // Disable the password manager for online password management. | |
104 if (IsURLPasswordWebsiteReauth(entry->GetURL())) | |
105 return false; | |
106 | |
107 if (EnabledForSyncSignin()) | |
108 return true; | |
109 | |
105 // Do not fill nor save password when a user is signing in for sync. This | 110 // Do not fill nor save password when a user is signing in for sync. This |
106 // is because users need to remember their password if they are syncing as | 111 // is because users need to remember their password if they are syncing as |
107 // this is effectively their master password. | 112 // this is effectively their master password. |
108 return entry->GetURL().host() != chrome::kChromeUIChromeSigninHost; | 113 return entry->GetURL().host() != chrome::kChromeUIChromeSigninHost; |
109 } | 114 } |
110 | 115 |
111 bool ChromePasswordManagerClient::ShouldFilterAutofillResult( | 116 bool ChromePasswordManagerClient::ShouldFilterAutofillResult( |
112 const autofill::PasswordForm& form) { | 117 const autofill::PasswordForm& form) { |
113 if (!IsSyncAccountCredential(base::UTF16ToUTF8(form.username_value), | 118 if (!IsSyncAccountCredential(base::UTF16ToUTF8(form.username_value), |
114 form.signon_realm)) | 119 form.signon_realm)) |
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
396 GaiaUrls::GetInstance()->gaia_url().GetOrigin()) | 401 GaiaUrls::GetInstance()->gaia_url().GetOrigin()) |
397 return false; | 402 return false; |
398 | 403 |
399 // "rart" is the transactional reauth paramter. | 404 // "rart" is the transactional reauth paramter. |
400 std::string ignored_value; | 405 std::string ignored_value; |
401 return net::GetValueForKeyInQuery(entry->GetURL(), | 406 return net::GetValueForKeyInQuery(entry->GetURL(), |
402 "rart", | 407 "rart", |
403 &ignored_value); | 408 &ignored_value); |
404 } | 409 } |
405 | 410 |
411 bool ChromePasswordManagerClient::IsURLPasswordWebsiteReauth(GURL url) const { | |
412 if (url.GetOrigin() != GaiaUrls::GetInstance()->gaia_url().GetOrigin()) | |
413 return false; | |
414 | |
415 // "rart" param signals this page is for transactional reauth. | |
jww
2014/08/22 22:42:10
Seems like this might be worth factoring out as a
Garrett Casto
2014/08/25 08:16:49
I'm not sure. I could imagine it possibly going in
| |
416 std::string param_value; | |
417 if (!net::GetValueForKeyInQuery(url, "rart", ¶m_value)) | |
418 return false; | |
419 | |
420 // Check the "continue" param to see if this reauth page is for the passwords | |
421 // website. | |
422 param_value.clear(); | |
423 if (!net::GetValueForKeyInQuery(url, "continue", ¶m_value)) | |
424 return false; | |
425 | |
426 return GURL(param_value).GetOrigin() == | |
Mike West
2014/08/24 05:37:57
If a user changes the value of the continue param
Garrett Casto
2014/08/25 08:16:49
Ah, interesting. I assumed that the server side ch
| |
427 GURL(chrome::kPasswordManagerAccountDashboardURL).GetOrigin(); | |
428 } | |
429 | |
406 bool ChromePasswordManagerClient::IsTheHotNewBubbleUIEnabled() { | 430 bool ChromePasswordManagerClient::IsTheHotNewBubbleUIEnabled() { |
407 #if !defined(USE_AURA) | 431 #if !defined(USE_AURA) |
408 return false; | 432 return false; |
409 #endif | 433 #endif |
410 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 434 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
411 if (command_line->HasSwitch(switches::kDisableSavePasswordBubble)) | 435 if (command_line->HasSwitch(switches::kDisableSavePasswordBubble)) |
412 return false; | 436 return false; |
413 | 437 |
414 if (command_line->HasSwitch(switches::kEnableSavePasswordBubble)) | 438 if (command_line->HasSwitch(switches::kEnableSavePasswordBubble)) |
415 return true; | 439 return true; |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
461 | 485 |
462 if (group_name == "DisallowSyncCredentialsForReauth") { | 486 if (group_name == "DisallowSyncCredentialsForReauth") { |
463 autofill_sync_state_ = DISALLOW_SYNC_CREDENTIALS_FOR_REAUTH; | 487 autofill_sync_state_ = DISALLOW_SYNC_CREDENTIALS_FOR_REAUTH; |
464 } else if (group_name == "DisallowSyncCredentials") { | 488 } else if (group_name == "DisallowSyncCredentials") { |
465 autofill_sync_state_ = DISALLOW_SYNC_CREDENTIALS; | 489 autofill_sync_state_ = DISALLOW_SYNC_CREDENTIALS; |
466 } else { | 490 } else { |
467 // Allow by default. | 491 // Allow by default. |
468 autofill_sync_state_ = ALLOW_SYNC_CREDENTIALS; | 492 autofill_sync_state_ = ALLOW_SYNC_CREDENTIALS; |
469 } | 493 } |
470 } | 494 } |
OLD | NEW |