diff options
author | scr@chromium.org <scr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-07 23:37:01 +0000 |
---|---|---|
committer | scr@chromium.org <scr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-07 23:37:01 +0000 |
commit | 6b1be9d8ea3244c6d04e7bb4da063842fcc16a61 (patch) | |
tree | 2ba046eee0cc6a659a6356ef6c85d7d8a8f9127b /chrome | |
parent | 52f41b82157a5580dcc5ed538c4059d563841f1b (diff) | |
download | chromium_src-6b1be9d8ea3244c6d04e7bb4da063842fcc16a61.zip chromium_src-6b1be9d8ea3244c6d04e7bb4da063842fcc16a61.tar.gz chromium_src-6b1be9d8ea3244c6d04e7bb4da063842fcc16a61.tar.bz2 |
Chrome: Crash Report - Stack Signature: GURL::spec()...
Check whether the form has been set because non-GetLogins requests won't set this.
Note: this is the same effect as the previous check of whether the stl map had the
request.
Carry over from http://codereview.chromium.org/6677125/
BUG=78726,75296,78723
TEST=
Review URL: http://codereview.chromium.org/6810026
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@80867 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/password_manager/password_store_win.cc | 56 | ||||
-rw-r--r-- | chrome/browser/password_manager/password_store_win.h | 12 |
2 files changed, 36 insertions, 32 deletions
diff --git a/chrome/browser/password_manager/password_store_win.cc b/chrome/browser/password_manager/password_store_win.cc index b27d231..415fbc4 100644 --- a/chrome/browser/password_manager/password_store_win.cc +++ b/chrome/browser/password_manager/password_store_win.cc @@ -14,25 +14,24 @@ using webkit_glue::PasswordForm; namespace { -// Subclass GetLoginsRequest in order to hold the form information for -// ForwardLoginsResult call. Note that the form will be empty at first and we -// populate it in GetLoginsImpl. DCHECK to ensure the form is set before -// accessing it. +// Subclass GetLoginsRequest in order to hold a copy of the form information +// from the GetLogins request for the ForwardLoginsResult call. Note that the +// other calls such as GetBlacklistLogins and GetAutofillableLogins, the form is +// not set. class FormGetLoginsRequest : public PasswordStore::GetLoginsRequest { public: explicit FormGetLoginsRequest(PasswordStore::GetLoginsCallback* callback) : GetLoginsRequest(callback) {} - // Accessors for the |form_|. The request owns a pointer to a copy of the - // form so that it can verify with DCHECK that the form has been set before - // being accessed. - void set_form(const PasswordForm& form) { + // We hold a copy of the |form| used in GetLoginsImpl as a pointer. If the + // form is not set (is NULL), then we are not a GetLogins request. + void SetLoginsRequestForm(const PasswordForm& form) { form_.reset(new PasswordForm(form)); } - const PasswordForm& form() const { - DCHECK(form_.get()) << "form has not been set."; - return *form_; + PasswordForm* form() const { + return form_.get(); } + bool IsLoginsRequest() const { return !!form_.get(); } private: scoped_ptr<PasswordForm> form_; @@ -55,27 +54,26 @@ PasswordStoreWin::~PasswordStoreWin() { } } +PasswordStore::GetLoginsRequest* PasswordStoreWin::NewGetLoginsRequest( + GetLoginsCallback* callback) { + return new FormGetLoginsRequest(callback); +} + void PasswordStoreWin::ForwardLoginsResult(GetLoginsRequest* request) { - if (!request->value.empty()) { - PasswordStore::ForwardLoginsResult(request); - } else { + if (static_cast<FormGetLoginsRequest*>(request)->IsLoginsRequest() && + request->value.empty()) { IE7PasswordInfo info; std::wstring url = ASCIIToWide( - static_cast<FormGetLoginsRequest*>(request)->form().origin.spec()); + static_cast<FormGetLoginsRequest*>(request)->form()->origin.spec()); info.url_hash = ie7_password::GetUrlHash(url); WebDataService::Handle handle = web_data_service_->GetIE7Login(info, this); TrackRequest(handle, request); + } else { + PasswordStore::ForwardLoginsResult(request); } } -void PasswordStoreWin::GetLoginsImpl(GetLoginsRequest* request, - const PasswordForm& form) { - static_cast<FormGetLoginsRequest*>(request)->set_form(form); - - PasswordStoreDefault::GetLoginsImpl(request, form); -} - void PasswordStoreWin::OnWebDataServiceRequestDone( WebDataService::Handle handle, const WDTypedResult* result) { if (!result) @@ -89,8 +87,10 @@ void PasswordStoreWin::OnWebDataServiceRequestDone( return; // This is a response from WebDataService::GetIE7Login. - PasswordForm* ie7_form = GetIE7Result( - result, static_cast<FormGetLoginsRequest*>(request.get())->form()); + PasswordForm* form = static_cast<FormGetLoginsRequest*>( + request.get())->form(); + DCHECK(form); + PasswordForm* ie7_form = GetIE7Result(result, *form); if (ie7_form) request->value.push_back(ie7_form); @@ -101,9 +101,11 @@ void PasswordStoreWin::OnWebDataServiceRequestDone( } } -PasswordStore::GetLoginsRequest* PasswordStoreWin::NewGetLoginsRequest( - GetLoginsCallback* callback) { - return new FormGetLoginsRequest(callback); +void PasswordStoreWin::GetLoginsImpl(GetLoginsRequest* request, + const PasswordForm& form) { + static_cast<FormGetLoginsRequest*>(request)->SetLoginsRequestForm(form); + + PasswordStoreDefault::GetLoginsImpl(request, form); } void PasswordStoreWin::TrackRequest(WebDataService::Handle handle, diff --git a/chrome/browser/password_manager/password_store_win.h b/chrome/browser/password_manager/password_store_win.h index 277c7d0..2cf238d 100644 --- a/chrome/browser/password_manager/password_store_win.h +++ b/chrome/browser/password_manager/password_store_win.h @@ -30,15 +30,17 @@ class PasswordStoreWin : public PasswordStoreDefault { private: virtual ~PasswordStoreWin(); + virtual GetLoginsRequest* NewGetLoginsRequest( + GetLoginsCallback* callback) OVERRIDE; + // See PasswordStoreDefault. - virtual void OnWebDataServiceRequestDone(WebDataService::Handle h, - const WDTypedResult* result); - virtual GetLoginsRequest* NewGetLoginsRequest(GetLoginsCallback* callback); - virtual void ForwardLoginsResult(GetLoginsRequest* request); + virtual void ForwardLoginsResult(GetLoginsRequest* request) OVERRIDE; + virtual void OnWebDataServiceRequestDone( + WebDataService::Handle h, const WDTypedResult* result) OVERRIDE; // Overridden so that we can save the form for later use. virtual void GetLoginsImpl(GetLoginsRequest* request, - const webkit_glue::PasswordForm& form); + const webkit_glue::PasswordForm& form) OVERRIDE; // Takes ownership of |request| and tracks it under |handle|. void TrackRequest(WebDataService::Handle handle, GetLoginsRequest* request); |