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

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

Issue 733953002: Do not save passwords if the landing page has HTTP status 5xx or 4xx (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 6 years, 1 month 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 b7be0f4b10f006fb92e9525e810fc4ca9c385cc9..535f7f8fe007ee82f11c0b9c2d377b6b4645b6c6 100644
--- a/chrome/browser/password_manager/chrome_password_manager_client.cc
+++ b/chrome/browser/password_manager/chrome_password_manager_client.cc
@@ -29,6 +29,7 @@
#include "components/password_manager/content/browser/password_manager_internals_service_factory.h"
#include "components/password_manager/content/common/credential_manager_messages.h"
#include "components/password_manager/content/common/credential_manager_types.h"
+#include "components/password_manager/core/browser/browser_save_password_progress_logger.h"
#include "components/password_manager/core/browser/log_receiver.h"
#include "components/password_manager/core/browser/password_form_manager.h"
#include "components/password_manager/core/browser/password_manager.h"
@@ -51,6 +52,10 @@ using password_manager::PasswordManagerInternalsServiceFactory;
DEFINE_WEB_CONTENTS_USER_DATA_KEY(ChromePasswordManagerClient);
+// Shorten the name to spare line breaks. The code provides enough context
+// already.
+typedef autofill::SavePasswordProgressLogger Logger;
+
// static
void ChromePasswordManagerClient::CreateForWebContentsWithAutofillClient(
content::WebContents* contents,
@@ -290,6 +295,30 @@ bool ChromePasswordManagerClient::IsLoggingActive() const {
return can_use_log_router_ && !web_contents()->GetWebUI();
}
+bool ChromePasswordManagerClient::WasLastNavigationHTTPError() const {
+ DCHECK(web_contents());
+
+ scoped_ptr<password_manager::BrowserSavePasswordProgressLogger> logger;
+ if (IsLoggingActive()) {
+ logger.reset(new password_manager::BrowserSavePasswordProgressLogger(this));
+ logger->LogMessage(
+ Logger::STRING_WAS_LAST_NAVIGATION_HTTP_ERROR_METHOD);
+ }
+
+ content::NavigationEntry* entry =
+ web_contents()->GetController().GetVisibleEntry();
+ if (!entry)
+ return false;
+ int http_status_code = entry->GetHttpStatusCode();
+
+ if (logger)
+ logger->LogNumber(Logger::STRING_HTTP_STATUS_CODE, http_status_code);
+
+ if (http_status_code >= 400 && http_status_code < 600)
+ return true;
+ return false;
+}
+
// static
password_manager::PasswordGenerationManager*
ChromePasswordManagerClient::GetGenerationManagerFromWebContents(

Powered by Google App Engine
This is Rietveld 408576698