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

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

Issue 1260263002: Move ShouldFilterAutofillResult from ChromePasswordManagerClient to PasswordManager (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Just rebased Created 5 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 41c188b9813ea22d37f6684ca11df266d17dd4bc..c41061fb21aec1e6c2be7319ff661e004a5aa18c 100644
--- a/chrome/browser/password_manager/chrome_password_manager_client.cc
+++ b/chrome/browser/password_manager/chrome_password_manager_client.cc
@@ -40,6 +40,7 @@
#include "components/password_manager/core/common/credential_manager_types.h"
#include "components/password_manager/core/common/password_manager_pref_names.h"
#include "components/password_manager/core/common/password_manager_switches.h"
+#include "components/password_manager/sync/browser/sync_store_result_filter.h"
#include "components/version_info/version_info.h"
#include "content/public/browser/navigation_entry.h"
#include "content/public/browser/render_view_host.h"
@@ -112,9 +113,7 @@ ChromePasswordManagerClient::ChromePasswordManagerClient(
driver_factory_(nullptr),
credential_manager_dispatcher_(web_contents, this),
observer_(nullptr),
- can_use_log_router_(false),
- autofill_sync_state_(ALLOW_SYNC_CREDENTIALS),
- sync_credential_was_filtered_(false) {
+ can_use_log_router_(false) {
ContentPasswordManagerDriverFactory::CreateForWebContents(web_contents, this,
autofill_client);
driver_factory_ =
@@ -124,7 +123,6 @@ ChromePasswordManagerClient::ChromePasswordManagerClient(
PasswordManagerInternalsServiceFactory::GetForBrowserContext(profile_);
if (service)
can_use_log_router_ = service->RegisterClient(this);
- SetUpAutofillSyncState();
saving_passwords_enabled_.Init(
password_manager::prefs::kPasswordManagerSavingEnabled, GetPrefs());
ReportMetrics(*saving_passwords_enabled_, this);
@@ -178,26 +176,6 @@ bool ChromePasswordManagerClient::IsSavingEnabledForCurrentPage() const {
IsPasswordManagementEnabledForCurrentPage();
}
-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;
-}
-
std::string ChromePasswordManagerClient::GetSyncUsername() const {
return password_manager_sync_metrics::GetSyncUsername(profile_);
}
@@ -209,12 +187,6 @@ bool ChromePasswordManagerClient::IsSyncAccountCredential(
profile_, username, realm);
}
-void ChromePasswordManagerClient::AutofillResultsComputed() {
- UMA_HISTOGRAM_BOOLEAN("PasswordManager.SyncCredentialFiltered",
- sync_credential_was_filtered_);
- sync_credential_was_filtered_ = false;
-}
-
bool ChromePasswordManagerClient::PromptUserToSaveOrUpdatePassword(
scoped_ptr<password_manager::PasswordFormManager> form_to_save,
password_manager::CredentialSourceType type,
@@ -487,24 +459,6 @@ void ChromePasswordManagerClient::NotifyRendererOfLoggingAvailability() {
can_use_log_router_));
}
-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::IsURLPasswordWebsiteReauth(
const GURL& url) const {
if (url.GetOrigin() != GaiaUrls::GetInstance()->gaia_url().GetOrigin())
@@ -572,38 +526,21 @@ bool ChromePasswordManagerClient::EnabledForSyncSignin() {
return group_name != "Disabled";
}
-void ChromePasswordManagerClient::SetUpAutofillSyncState() {
- std::string group_name =
- base::FieldTrialList::FindFullName("AutofillSyncCredential");
+const GURL& ChromePasswordManagerClient::GetMainFrameURL() const {
+ return web_contents()->GetVisibleURL();
+}
- base::CommandLine* command_line = base::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;
- }
+const GURL& ChromePasswordManagerClient::GetLastCommittedEntryURL() const {
+ DCHECK(web_contents());
+ content::NavigationEntry* entry =
+ web_contents()->GetController().GetLastCommittedEntry();
+ if (!entry)
+ return GURL::EmptyGURL();
- 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;
- }
+ return entry->GetURL();
}
-const GURL& ChromePasswordManagerClient::GetMainFrameURL() const {
- return web_contents()->GetVisibleURL();
+scoped_ptr<password_manager::StoreResultFilter>
+ChromePasswordManagerClient::CreateStoreResultFilter() const {
+ return make_scoped_ptr(new password_manager::SyncStoreResultFilter(this));
}

Powered by Google App Engine
This is Rietveld 408576698