summaryrefslogtreecommitdiffstats
path: root/components
diff options
context:
space:
mode:
authorvabr@chromium.org <vabr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-07-03 11:41:59 +0000
committervabr@chromium.org <vabr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-07-03 11:41:59 +0000
commit8f3e10675c7b5378d651bcdc124e4544fa214576 (patch)
tree2fedb582fc04c7c67c918a80e9f697691b382329 /components
parent58bef62ae317a605c08d3a7184e63c5ff753645f (diff)
downloadchromium_src-8f3e10675c7b5378d651bcdc124e4544fa214576.zip
chromium_src-8f3e10675c7b5378d651bcdc124e4544fa214576.tar.gz
chromium_src-8f3e10675c7b5378d651bcdc124e4544fa214576.tar.bz2
Make PasswordFormManager::observed_form_ const
A simple refactoring to make it obvious that observed_form_ is not changed during the life of a PasswordFormManager. BUG=390468 Review URL: https://codereview.chromium.org/361183003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@281234 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'components')
-rw-r--r--components/password_manager/content/browser/content_password_manager_driver.cc4
-rw-r--r--components/password_manager/content/browser/content_password_manager_driver.h4
-rw-r--r--components/password_manager/core/browser/password_form_manager.cc14
-rw-r--r--components/password_manager/core/browser/password_form_manager.h4
-rw-r--r--components/password_manager/core/browser/password_form_manager_unittest.cc3
-rw-r--r--components/password_manager/core/browser/password_manager_driver.h3
-rw-r--r--components/password_manager/core/browser/stub_password_manager_driver.cc2
-rw-r--r--components/password_manager/core/browser/stub_password_manager_driver.h2
8 files changed, 22 insertions, 14 deletions
diff --git a/components/password_manager/content/browser/content_password_manager_driver.cc b/components/password_manager/content/browser/content_password_manager_driver.cc
index 5d68d0b..35b3820 100644
--- a/components/password_manager/content/browser/content_password_manager_driver.cc
+++ b/components/password_manager/content/browser/content_password_manager_driver.cc
@@ -42,9 +42,9 @@ void ContentPasswordManagerDriver::FillPasswordForm(
}
void ContentPasswordManagerDriver::AllowPasswordGenerationForForm(
- autofill::PasswordForm* form) {
+ const autofill::PasswordForm& form) {
content::RenderViewHost* host = web_contents()->GetRenderViewHost();
- host->Send(new AutofillMsg_FormNotBlacklisted(host->GetRoutingID(), *form));
+ host->Send(new AutofillMsg_FormNotBlacklisted(host->GetRoutingID(), form));
}
void ContentPasswordManagerDriver::AccountCreationFormsFound(
diff --git a/components/password_manager/content/browser/content_password_manager_driver.h b/components/password_manager/content/browser/content_password_manager_driver.h
index d7fcc0f..52d7a76 100644
--- a/components/password_manager/content/browser/content_password_manager_driver.h
+++ b/components/password_manager/content/browser/content_password_manager_driver.h
@@ -37,8 +37,8 @@ class ContentPasswordManagerDriver : public PasswordManagerDriver,
OVERRIDE;
virtual bool DidLastPageLoadEncounterSSLErrors() OVERRIDE;
virtual bool IsOffTheRecord() OVERRIDE;
- virtual void AllowPasswordGenerationForForm(autofill::PasswordForm* form)
- OVERRIDE;
+ virtual void AllowPasswordGenerationForForm(
+ const autofill::PasswordForm& form) OVERRIDE;
virtual void AccountCreationFormsFound(
const std::vector<autofill::FormData>& forms) OVERRIDE;
virtual void FillSuggestion(const base::string16& username,
diff --git a/components/password_manager/core/browser/password_form_manager.cc b/components/password_manager/core/browser/password_form_manager.cc
index 5f7d21f..e544792 100644
--- a/components/password_manager/core/browser/password_form_manager.cc
+++ b/components/password_manager/core/browser/password_form_manager.cc
@@ -53,6 +53,13 @@ void LogPasswordGenerationSubmissionEvent(
event, SUBMISSION_EVENT_ENUM_COUNT);
}
+PasswordForm CopyAndModifySSLValidity(const PasswordForm& orig,
+ bool ssl_valid) {
+ PasswordForm result(orig);
+ result.ssl_valid = ssl_valid;
+ return result;
+}
+
} // namespace
PasswordFormManager::PasswordFormManager(PasswordManager* password_manager,
@@ -61,7 +68,7 @@ PasswordFormManager::PasswordFormManager(PasswordManager* password_manager,
const PasswordForm& observed_form,
bool ssl_valid)
: best_matches_deleter_(&best_matches_),
- observed_form_(observed_form),
+ observed_form_(CopyAndModifySSLValidity(observed_form, ssl_valid)),
is_new_login_(true),
has_generated_password_(false),
password_manager_(password_manager),
@@ -74,7 +81,6 @@ PasswordFormManager::PasswordFormManager(PasswordManager* password_manager,
submit_result_(kSubmitResultNotSubmitted) {
if (observed_form_.origin.is_valid())
base::SplitString(observed_form_.origin.path(), '/', &form_path_tokens_);
- observed_form_.ssl_valid = ssl_valid;
}
PasswordFormManager::~PasswordFormManager() {
@@ -409,7 +415,7 @@ void PasswordFormManager::OnRequestDone(
// If not blacklisted, inform the driver that password generation is allowed
// for |observed_form_|.
- driver_->AllowPasswordGenerationForForm(&observed_form_);
+ driver_->AllowPasswordGenerationForForm(observed_form_);
// Proceed to autofill.
// Note that we provide the choices but don't actually prefill a value if:
@@ -437,7 +443,7 @@ void PasswordFormManager::OnGetPasswordStoreResults(
// No result means that we visit this site the first time so we don't need
// to check whether this site is blacklisted or not. Just send a message
// to allow password generation.
- driver_->AllowPasswordGenerationForForm(&observed_form_);
+ driver_->AllowPasswordGenerationForForm(observed_form_);
return;
}
OnRequestDone(results);
diff --git a/components/password_manager/core/browser/password_form_manager.h b/components/password_manager/core/browser/password_form_manager.h
index 80712d6..d258471 100644
--- a/components/password_manager/core/browser/password_form_manager.h
+++ b/components/password_manager/core/browser/password_form_manager.h
@@ -257,8 +257,8 @@ class PasswordFormManager : public PasswordStoreConsumer {
// Cleans up when best_matches_ goes out of scope.
STLValueDeleter<autofill::PasswordFormMap> best_matches_deleter_;
- // The PasswordForm from the page or dialog managed by this.
- autofill::PasswordForm observed_form_;
+ // The PasswordForm from the page or dialog managed by |this|.
+ const autofill::PasswordForm observed_form_;
// The origin url path of observed_form_ tokenized, for convenience when
// scoring.
diff --git a/components/password_manager/core/browser/password_form_manager_unittest.cc b/components/password_manager/core/browser/password_form_manager_unittest.cc
index 62152b6..c5694d1 100644
--- a/components/password_manager/core/browser/password_form_manager_unittest.cc
+++ b/components/password_manager/core/browser/password_form_manager_unittest.cc
@@ -48,7 +48,8 @@ void RunAllPendingTasks() {
class MockPasswordManagerDriver : public StubPasswordManagerDriver {
public:
MOCK_METHOD0(IsOffTheRecord, bool());
- MOCK_METHOD1(AllowPasswordGenerationForForm, void(autofill::PasswordForm*));
+ MOCK_METHOD1(AllowPasswordGenerationForForm,
+ void(const autofill::PasswordForm&));
};
class TestPasswordManagerClient : public StubPasswordManagerClient {
diff --git a/components/password_manager/core/browser/password_manager_driver.h b/components/password_manager/core/browser/password_manager_driver.h
index 54001c2..6e01c55 100644
--- a/components/password_manager/core/browser/password_manager_driver.h
+++ b/components/password_manager/core/browser/password_manager_driver.h
@@ -42,7 +42,8 @@ class PasswordManagerDriver {
virtual bool IsOffTheRecord() = 0;
// Informs the driver that |form| can be used for password generation.
- virtual void AllowPasswordGenerationForForm(autofill::PasswordForm* form) = 0;
+ virtual void AllowPasswordGenerationForForm(
+ const autofill::PasswordForm& form) = 0;
// Notifies the driver that account creation |forms| were found.
virtual void AccountCreationFormsFound(
diff --git a/components/password_manager/core/browser/stub_password_manager_driver.cc b/components/password_manager/core/browser/stub_password_manager_driver.cc
index 1c7f377..a883a84 100644
--- a/components/password_manager/core/browser/stub_password_manager_driver.cc
+++ b/components/password_manager/core/browser/stub_password_manager_driver.cc
@@ -25,7 +25,7 @@ bool StubPasswordManagerDriver::IsOffTheRecord() {
}
void StubPasswordManagerDriver::AllowPasswordGenerationForForm(
- autofill::PasswordForm* form) {
+ const autofill::PasswordForm& form) {
}
void StubPasswordManagerDriver::AccountCreationFormsFound(
diff --git a/components/password_manager/core/browser/stub_password_manager_driver.h b/components/password_manager/core/browser/stub_password_manager_driver.h
index 552b844..a6b4577 100644
--- a/components/password_manager/core/browser/stub_password_manager_driver.h
+++ b/components/password_manager/core/browser/stub_password_manager_driver.h
@@ -23,7 +23,7 @@ class StubPasswordManagerDriver : public PasswordManagerDriver {
virtual bool DidLastPageLoadEncounterSSLErrors() OVERRIDE;
virtual bool IsOffTheRecord() OVERRIDE;
virtual void AllowPasswordGenerationForForm(
- autofill::PasswordForm* form) OVERRIDE;
+ const autofill::PasswordForm& form) OVERRIDE;
virtual void AccountCreationFormsFound(
const std::vector<autofill::FormData>& forms) OVERRIDE;
virtual void FillSuggestion(const base::string16& username,