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

Unified Diff: chrome/browser/password_manager/chrome_password_manager_client.cc

Issue 451853003: [Password Manager] Setup experiment to restrict autofilling of sync credential (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Unittest fix Created 6 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/password_manager/chrome_password_manager_client.cc
diff --git a/chrome/browser/password_manager/chrome_password_manager_client.cc b/chrome/browser/password_manager/chrome_password_manager_client.cc
index df029aee357b8dec1ca6818c1e06058f092054f7..c5c50bf4136126177d73dbf711fad41cdcd6e35e 100644
--- a/chrome/browser/password_manager/chrome_password_manager_client.cc
+++ b/chrome/browser/password_manager/chrome_password_manager_client.cc
@@ -8,6 +8,7 @@
#include "base/command_line.h"
#include "base/memory/singleton.h"
#include "base/metrics/histogram.h"
+#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/password_manager/password_manager_util.h"
#include "chrome/browser/password_manager/password_store_factory.h"
#include "chrome/browser/password_manager/save_password_infobar_delegate.h"
@@ -33,6 +34,8 @@
#include "content/public/browser/navigation_entry.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/web_contents.h"
+#include "google_apis/gaia/gaia_urls.h"
+#include "net/base/url_util.h"
#if defined(OS_ANDROID)
#include "chrome/browser/android/password_authentication_manager.h"
@@ -63,11 +66,14 @@ ChromePasswordManagerClient::ChromePasswordManagerClient(
driver_(web_contents, this, autofill_client),
observer_(NULL),
weak_factory_(this),
- can_use_log_router_(false) {
+ can_use_log_router_(false),
+ autofill_sync_state_(ALLOW_SYNC_CREDENTIALS),
+ sync_credential_was_filtered_(false) {
PasswordManagerInternalsService* service =
PasswordManagerInternalsServiceFactory::GetForBrowserContext(profile_);
if (service)
can_use_log_router_ = service->RegisterClient(this);
+ SetUpAutofillSyncState();
}
ChromePasswordManagerClient::~ChromePasswordManagerClient() {
@@ -79,7 +85,7 @@ ChromePasswordManagerClient::~ChromePasswordManagerClient() {
bool ChromePasswordManagerClient::IsAutomaticPasswordSavingEnabled() const {
return CommandLine::ForCurrentProcess()->HasSwitch(
- password_manager::switches::kEnableAutomaticPasswordSaving) &&
+ password_manager::switches::kEnableAutomaticPasswordSaving) &&
chrome::VersionInfo::GetChannel() ==
chrome::VersionInfo::CHANNEL_UNKNOWN;
}
@@ -102,12 +108,38 @@ bool ChromePasswordManagerClient::IsPasswordManagerEnabledForCurrentPage()
return entry->GetURL().host() != chrome::kChromeUIChromeSigninHost;
}
+bool ChromePasswordManagerClient::ShouldFilterAutofillResult(
+ const autofill::PasswordForm& form) {
+ if (!IsSyncAccountCredential(base::UTF16ToUTF8(form.username_value),
+ form.signon_realm))
+ return false;
+
+ if (autofill_sync_state_ == DISALLOW_SYNC_CREDENTIALS) {
+ sync_credential_was_filtered_ = true;
+ return true;
+ }
+
+ if (autofill_sync_state_ == DISALLOW_SYNC_CREDENTIALS_FOR_REAUTH &&
+ LastLoadWasTransactionalReauthPage()) {
+ sync_credential_was_filtered_ = true;
+ return true;
+ }
+
+ return false;
+}
+
bool ChromePasswordManagerClient::IsSyncAccountCredential(
const std::string& username, const std::string& origin) const {
return password_manager_sync_metrics::IsSyncAccountCredential(
profile_, username, origin);
}
+void ChromePasswordManagerClient::AutofillResultsComputed() {
+ UMA_HISTOGRAM_BOOLEAN("PasswordManager.SyncCredentialFiltered",
+ sync_credential_was_filtered_);
+ sync_credential_was_filtered_ = false;
+}
+
void ChromePasswordManagerClient::PromptUserToSavePassword(
scoped_ptr<password_manager::PasswordFormManager> form_to_save) {
if (IsTheHotNewBubbleUIEnabled()) {
@@ -353,6 +385,24 @@ void ChromePasswordManagerClient::CommitFillPasswordForm(
driver_.FillPasswordForm(*data);
}
+bool ChromePasswordManagerClient::LastLoadWasTransactionalReauthPage() const {
+ DCHECK(web_contents());
+ content::NavigationEntry* entry =
+ web_contents()->GetController().GetLastCommittedEntry();
+ if (!entry)
+ return false;
+
+ if (entry->GetURL().GetOrigin() !=
+ GaiaUrls::GetInstance()->gaia_url().GetOrigin())
+ return false;
+
+ // "rart" is the transactional reauth paramter.
+ std::string ignored_value;
+ return net::GetValueForKeyInQuery(entry->GetURL(),
+ "rart",
+ &ignored_value);
+}
+
bool ChromePasswordManagerClient::IsTheHotNewBubbleUIEnabled() {
#if !defined(USE_AURA)
return false;
@@ -386,3 +436,35 @@ bool ChromePasswordManagerClient::EnabledForSyncSignin() {
base::FieldTrialList::FindFullName("PasswordManagerStateForSyncSignin");
return group_name != "Disabled";
}
+
+void ChromePasswordManagerClient::SetUpAutofillSyncState() {
+ std::string group_name =
+ base::FieldTrialList::FindFullName("AutofillSyncCredential");
+
+ CommandLine* command_line = CommandLine::ForCurrentProcess();
+ if (command_line->HasSwitch(
+ password_manager::switches::kAllowAutofillSyncCredential)) {
+ autofill_sync_state_ = ALLOW_SYNC_CREDENTIALS;
+ return;
+ }
+ if (command_line->HasSwitch(
+ password_manager::switches::
+ kDisallowAutofillSyncCredentialForReauth)) {
+ autofill_sync_state_ = DISALLOW_SYNC_CREDENTIALS_FOR_REAUTH;
+ return;
+ }
+ if (command_line->HasSwitch(
+ password_manager::switches::kDisallowAutofillSyncCredential)) {
+ autofill_sync_state_ = DISALLOW_SYNC_CREDENTIALS;
+ return;
+ }
+
+ if (group_name == "DisallowSyncCredentialsForReauth") {
+ autofill_sync_state_ = DISALLOW_SYNC_CREDENTIALS_FOR_REAUTH;
+ } else if (group_name == "DisallowSyncCredentials") {
+ autofill_sync_state_ = DISALLOW_SYNC_CREDENTIALS;
+ } else {
+ // Allow by default.
+ autofill_sync_state_ = ALLOW_SYNC_CREDENTIALS;
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698