diff options
22 files changed, 134 insertions, 96 deletions
diff --git a/chrome/browser/password_manager/password_manager.cc b/chrome/browser/password_manager/password_manager.cc index fbebafc..258a254 100644 --- a/chrome/browser/password_manager/password_manager.cc +++ b/chrome/browser/password_manager/password_manager.cc @@ -13,6 +13,7 @@ #include "base/utf_string_conversions.h" #include "chrome/browser/metrics/user_metrics.h" #include "chrome/browser/password_manager/password_form_manager.h" +#include "chrome/browser/password_manager/password_manager_delegate.h" #include "chrome/browser/pref_service.h" #include "chrome/browser/profile.h" #include "chrome/common/notification_registrar.h" @@ -49,7 +50,7 @@ static void ReportMetrics(bool password_manager_enabled) { UserMetrics::RecordAction(UserMetricsAction("PasswordManager_Disabled")); } -PasswordManager::PasswordManager(Delegate* delegate) +PasswordManager::PasswordManager(PasswordManagerDelegate* delegate) : login_managers_deleter_(&pending_login_managers_), delegate_(delegate), observer_(NULL) { @@ -195,7 +196,7 @@ void PasswordManager::Autofill( case PasswordForm::SCHEME_HTML: { // Note the check above is required because the observer_ for a non-HTML // schemed password form may have been freed, so we need to distinguish. - webkit_glue::PasswordFormDomManager::FillData fill_data; + webkit_glue::PasswordFormFillData fill_data; webkit_glue::PasswordFormDomManager::InitFillData(form_for_autofill, best_matches, preferred_match, diff --git a/chrome/browser/password_manager/password_manager.h b/chrome/browser/password_manager/password_manager.h index a4eaafb..22447bb 100644 --- a/chrome/browser/password_manager/password_manager.h +++ b/chrome/browser/password_manager/password_manager.h @@ -13,6 +13,7 @@ #include "webkit/glue/password_form.h" #include "webkit/glue/password_form_dom_manager.h" +class PasswordManagerDelegate; class PasswordFormManager; class PrefService; @@ -22,37 +23,10 @@ class PrefService; // for purposes of supporting HTTP authentication dialogs. class PasswordManager : public LoginModel { public: - // An abstraction of operations in the external environment (TabContents) - // that the PasswordManager depends on. This allows for more targeted - // unit testing. - class Delegate { - public: - Delegate() {} - virtual ~Delegate() {} - - // Fill forms matching |form_data| in |tab_contents|. By default, goes - // through the RenderViewHost to FillPasswordForm. Tests can override this - // to sever the dependency on the entire rendering stack. - virtual void FillPasswordForm( - const webkit_glue::PasswordFormDomManager::FillData& form_data) = 0; - - // A mechanism to show an infobar in the current tab at our request. - virtual void AddSavePasswordInfoBar(PasswordFormManager* form_to_save) = 0; - - // Get the profile for which we are managing passwords. - virtual Profile* GetProfileForPasswordManager() = 0; - - // If any SSL certificate errors were encountered as a result of the last - // page load. - virtual bool DidLastPageLoadEncounterSSLErrors() = 0; - private: - DISALLOW_COPY_AND_ASSIGN(Delegate); - }; - static void RegisterUserPrefs(PrefService* prefs); // The delegate passed in is required to outlive the PasswordManager. - explicit PasswordManager(Delegate* delegate); + explicit PasswordManager(PasswordManagerDelegate* delegate); ~PasswordManager(); // Called by a PasswordFormManager when it decides a form can be autofilled @@ -122,7 +96,7 @@ class PasswordManager : public LoginModel { // Our delegate for carrying out external operations. This is typically the // containing TabContents. - Delegate* delegate_; + PasswordManagerDelegate* delegate_; // The LoginModelObserver (i.e LoginView) requiring autofill. LoginModelObserver* observer_; diff --git a/chrome/browser/password_manager/password_manager_delegate.h b/chrome/browser/password_manager/password_manager_delegate.h new file mode 100644 index 0000000..830121b --- /dev/null +++ b/chrome/browser/password_manager/password_manager_delegate.h @@ -0,0 +1,44 @@ +// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_MANAGER_DELEGATE_H_ +#define CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_MANAGER_DELEGATE_H_ + +namespace webkit_glue { +struct PasswordFormFillData; +} // namespace webkit_glue + +class PasswordFormManager; +class Profile; + +// An abstraction of operations in the external environment (TabContents) +// that the PasswordManager depends on. This allows for more targeted +// unit testing. +class PasswordManagerDelegate { + public: + PasswordManagerDelegate() {} + virtual ~PasswordManagerDelegate() {} + + // Fill forms matching |form_data| in |tab_contents|. By default, goes + // through the RenderViewHost to FillPasswordForm. Tests can override this + // to sever the dependency on the entire rendering stack. + virtual void FillPasswordForm( + const webkit_glue::PasswordFormFillData& form_data) = 0; + + // A mechanism to show an infobar in the current tab at our request. + virtual void AddSavePasswordInfoBar(PasswordFormManager* form_to_save) = 0; + + // Get the profile for which we are managing passwords. + virtual Profile* GetProfileForPasswordManager() = 0; + + // If any SSL certificate errors were encountered as a result of the last + // page load. + virtual bool DidLastPageLoadEncounterSSLErrors() = 0; + + private: + DISALLOW_COPY_AND_ASSIGN(PasswordManagerDelegate); +}; + + +#endif // CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_MANAGER_DELEGATE_H_ diff --git a/chrome/browser/password_manager/password_manager_unittest.cc b/chrome/browser/password_manager/password_manager_unittest.cc index e8430f7..9f5acc3 100644 --- a/chrome/browser/password_manager/password_manager_unittest.cc +++ b/chrome/browser/password_manager/password_manager_unittest.cc @@ -5,6 +5,7 @@ #include "base/file_path.h" #include "base/string_util.h" #include "chrome/browser/password_manager/password_manager.h" +#include "chrome/browser/password_manager/password_manager_delegate.h" #include "chrome/browser/password_manager/password_store.h" #include "chrome/browser/pref_service.h" #include "chrome/common/url_constants.h" @@ -19,10 +20,10 @@ using ::testing::Exactly; using ::testing::WithArg; using ::testing::Return; -class MockPasswordManagerDelegate : public PasswordManager::Delegate { +class MockPasswordManagerDelegate : public PasswordManagerDelegate { public: MOCK_METHOD1(FillPasswordForm, void( - const webkit_glue::PasswordFormDomManager::FillData&)); + const webkit_glue::PasswordFormFillData&)); MOCK_METHOD1(AddSavePasswordInfoBar, void(PasswordFormManager*)); MOCK_METHOD0(GetProfileForPasswordManager, Profile*()); MOCK_METHOD0(DidLastPageLoadEncounterSSLErrors, bool()); diff --git a/chrome/browser/renderer_host/render_view_host.cc b/chrome/browser/renderer_host/render_view_host.cc index 15fd450..60182ef 100644 --- a/chrome/browser/renderer_host/render_view_host.cc +++ b/chrome/browser/renderer_host/render_view_host.cc @@ -56,6 +56,7 @@ using base::TimeDelta; using webkit_glue::FormData; using webkit_glue::PasswordForm; using webkit_glue::PasswordFormDomManager; +using webkit_glue::PasswordFormFillData; using webkit_glue::WebApplicationInfo; using WebKit::WebConsoleMessage; using WebKit::WebDragOperation; @@ -430,7 +431,7 @@ void RenderViewHost::SetAlternateErrorPageURL(const GURL& url) { } void RenderViewHost::FillPasswordForm( - const PasswordFormDomManager::FillData& form_data) { + const webkit_glue::PasswordFormFillData& form_data) { Send(new ViewMsg_FillPasswordForm(routing_id(), form_data)); } diff --git a/chrome/browser/renderer_host/render_view_host.h b/chrome/browser/renderer_host/render_view_host.h index 2021cfb..b1478b5 100644 --- a/chrome/browser/renderer_host/render_view_host.h +++ b/chrome/browser/renderer_host/render_view_host.h @@ -21,11 +21,11 @@ #include "third_party/WebKit/WebKit/chromium/public/WebDragOperation.h" #include "third_party/WebKit/WebKit/chromium/public/WebPopupType.h" #include "third_party/WebKit/WebKit/chromium/public/WebTextDirection.h" -#include "webkit/glue/password_form_dom_manager.h" #include "webkit/glue/webaccessibility.h" #include "webkit/glue/window_open_disposition.h" class FilePath; +class GURL; class ListValue; class RenderViewHostDelegate; class SiteInstance; @@ -50,6 +50,8 @@ class Point; namespace webkit_glue { struct FormData; class FormField; +struct PasswordForm; +struct PasswordFormFillData; struct WebApplicationInfo; } // namespace webkit_glue @@ -220,7 +222,7 @@ class RenderViewHost : public RenderWidgetHost { // Fill out a password form and trigger DOM autocomplete in the case // of multiple matching logins. void FillPasswordForm( - const webkit_glue::PasswordFormDomManager::FillData& form_data); + const webkit_glue::PasswordFormFillData& form_data); // D&d drop target messages that get sent to WebKit. void DragTargetDragEnter(const WebDropData& drop_data, diff --git a/chrome/browser/tab_contents/tab_contents.cc b/chrome/browser/tab_contents/tab_contents.cc index fb62732..f55a6c5 100644 --- a/chrome/browser/tab_contents/tab_contents.cc +++ b/chrome/browser/tab_contents/tab_contents.cc @@ -95,7 +95,6 @@ #include "net/base/net_errors.h" #include "net/base/net_util.h" #include "net/base/registry_controlled_domain.h" -#include "webkit/glue/password_form.h" #include "webkit/glue/webpreferences.h" // Cross-Site Navigations @@ -3178,7 +3177,7 @@ class SavePasswordInfoBarDelegate : public ConfirmInfoBarDelegate { }; void TabContents::FillPasswordForm( - const webkit_glue::PasswordFormDomManager::FillData& form_data) { + const webkit_glue::PasswordFormFillData& form_data) { render_view_host()->FillPasswordForm(form_data); } diff --git a/chrome/browser/tab_contents/tab_contents.h b/chrome/browser/tab_contents/tab_contents.h index e01772f..ed8b08d 100644 --- a/chrome/browser/tab_contents/tab_contents.h +++ b/chrome/browser/tab_contents/tab_contents.h @@ -24,7 +24,7 @@ #include "chrome/browser/find_bar_controller.h" #include "chrome/browser/find_notification_details.h" #include "chrome/browser/jsmessage_box_client.h" -#include "chrome/browser/password_manager/password_manager.h" +#include "chrome/browser/password_manager/password_manager_delegate.h" #include "chrome/browser/shell_dialogs.h" #include "chrome/browser/renderer_host/render_view_host_delegate.h" #include "chrome/browser/tab_contents/constrained_window.h" @@ -75,6 +75,7 @@ class GeolocationSettingsState; class InfoBarDelegate; class LoadNotificationDetails; class OmniboxSearchHint; +class PasswordManager; class PluginInstaller; class Profile; struct RendererPreferences; @@ -104,7 +105,7 @@ class TabContents : public PageNavigator, public SelectFileDialog::Listener, public JavaScriptMessageBoxClient, public ImageLoadingTracker::Observer, - public PasswordManager::Delegate, + public PasswordManagerDelegate, public TabSpecificContentSettings::Delegate { public: // Flags passed to the TabContentsDelegate.NavigationStateChanged to tell it @@ -697,9 +698,9 @@ class TabContents : public PageNavigator, // state by various UI elements. TabSpecificContentSettings* GetTabSpecificContentSettings() const; - // PasswordManager::Delegate implementation. + // PasswordManagerDelegate implementation. virtual void FillPasswordForm( - const webkit_glue::PasswordFormDomManager::FillData& form_data); + const webkit_glue::PasswordFormFillData& form_data); virtual void AddSavePasswordInfoBar(PasswordFormManager* form_to_save); virtual Profile* GetProfileForPasswordManager(); virtual bool DidLastPageLoadEncounterSSLErrors(); diff --git a/chrome/common/render_messages.h b/chrome/common/render_messages.h index 826703e..08b5518 100644 --- a/chrome/common/render_messages.h +++ b/chrome/common/render_messages.h @@ -1234,8 +1234,8 @@ struct ParamTraits<WebPluginInfo> { // Traits for webkit_glue::PasswordFormDomManager::FillData. template <> -struct ParamTraits<webkit_glue::PasswordFormDomManager::FillData> { - typedef webkit_glue::PasswordFormDomManager::FillData param_type; +struct ParamTraits<webkit_glue::PasswordFormFillData> { + typedef webkit_glue::PasswordFormFillData param_type; static void Write(Message* m, const param_type& p) { WriteParam(m, p.basic_data); WriteParam(m, p.additional_logins); @@ -1248,7 +1248,7 @@ struct ParamTraits<webkit_glue::PasswordFormDomManager::FillData> { ReadParam(m, iter, &r->wait_for_username); } static void Log(const param_type& p, std::wstring* l) { - l->append(L"<PasswordFormDomManager::FillData>"); + l->append(L"<PasswordFormFillData>"); } }; diff --git a/chrome/common/render_messages_internal.h b/chrome/common/render_messages_internal.h index 680fcc9..f4fb2f6 100644 --- a/chrome/common/render_messages_internal.h +++ b/chrome/common/render_messages_internal.h @@ -416,7 +416,7 @@ IPC_BEGIN_MESSAGES(View) // Fill a password form and prepare field autocomplete for multiple // matching logins. IPC_MESSAGE_ROUTED1(ViewMsg_FillPasswordForm, - webkit_glue::PasswordFormDomManager::FillData) + webkit_glue::PasswordFormFillData) // D&d drop target messages. IPC_MESSAGE_ROUTED4(ViewMsg_DragTargetDragEnter, diff --git a/chrome/renderer/password_autocomplete_manager.cc b/chrome/renderer/password_autocomplete_manager.cc index a715a58..f8f10ec 100644 --- a/chrome/renderer/password_autocomplete_manager.cc +++ b/chrome/renderer/password_autocomplete_manager.cc @@ -169,9 +169,12 @@ PasswordAutocompleteManager::PasswordAutocompleteManager( : ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)) { } +PasswordAutocompleteManager::~PasswordAutocompleteManager() { +} + void PasswordAutocompleteManager::ReceivedPasswordFormFillData( WebKit::WebView* view, - const webkit_glue::PasswordFormDomManager::FillData& form_data) { + const webkit_glue::PasswordFormFillData& form_data) { FormElementsList forms; // We own the FormElements* in forms. FindFormElements(view, form_data.basic_data, &forms); @@ -222,7 +225,7 @@ void PasswordAutocompleteManager::TextFieldDidEndEditing( if (iter == login_to_password_info_.end()) return; - const webkit_glue::PasswordFormDomManager::FillData& fill_data = + const webkit_glue::PasswordFormFillData& fill_data = iter->second.fill_data; // If wait_for_username is false, we should have filled when the text changed. @@ -303,7 +306,7 @@ bool PasswordAutocompleteManager::FillPassword( login_to_password_info_.find(user_input); if (iter == login_to_password_info_.end()) return false; - const webkit_glue::PasswordFormDomManager::FillData& fill_data = + const webkit_glue::PasswordFormFillData& fill_data = iter->second.fill_data; WebKit::WebInputElement password = iter->second.password_field; WebKit::WebInputElement non_const_user_input(user_input); @@ -314,7 +317,7 @@ bool PasswordAutocompleteManager::FillPassword( void PasswordAutocompleteManager::PerformInlineAutocomplete( const WebKit::WebInputElement& username_input, const WebKit::WebInputElement& password_input, - const webkit_glue::PasswordFormDomManager::FillData& fill_data) { + const webkit_glue::PasswordFormFillData& fill_data) { DCHECK(!fill_data.wait_for_username); // We need non-const versions of the username and password inputs. @@ -339,13 +342,13 @@ void PasswordAutocompleteManager::PerformInlineAutocomplete( // PasswordAutocompleteManager, private: void PasswordAutocompleteManager::GetSuggestions( - const webkit_glue::PasswordFormDomManager::FillData& fill_data, + const webkit_glue::PasswordFormFillData& fill_data, const string16& input, std::vector<string16>* suggestions) { if (StartsWith(fill_data.basic_data.fields[0].value(), input, false)) suggestions->push_back(fill_data.basic_data.fields[0].value()); - webkit_glue::PasswordFormDomManager::LoginCollection::const_iterator iter; + webkit_glue::PasswordFormFillData::LoginCollection::const_iterator iter; for (iter = fill_data.additional_logins.begin(); iter != fill_data.additional_logins.end(); ++iter) { if (StartsWith(iter->first, input, false)) @@ -354,7 +357,7 @@ void PasswordAutocompleteManager::GetSuggestions( } bool PasswordAutocompleteManager::ShowSuggestionPopup( - const webkit_glue::PasswordFormDomManager::FillData& fill_data, + const webkit_glue::PasswordFormFillData& fill_data, const WebKit::WebInputElement& user_input) { std::vector<string16> suggestions; GetSuggestions(fill_data, user_input.value(), &suggestions); @@ -372,7 +375,7 @@ bool PasswordAutocompleteManager::ShowSuggestionPopup( bool PasswordAutocompleteManager::FillUserNameAndPassword( WebKit::WebInputElement* username_element, WebKit::WebInputElement* password_element, - const webkit_glue::PasswordFormDomManager::FillData& fill_data, + const webkit_glue::PasswordFormFillData& fill_data, bool exact_username_match) { string16 current_username = username_element->value(); // username and password will contain the match found if any. @@ -386,7 +389,7 @@ bool PasswordAutocompleteManager::FillUserNameAndPassword( password = fill_data.basic_data.fields[1].value(); } else { // Scan additional logins for a match. - webkit_glue::PasswordFormDomManager::LoginCollection::const_iterator iter; + webkit_glue::PasswordFormFillData::LoginCollection::const_iterator iter; for (iter = fill_data.additional_logins.begin(); iter != fill_data.additional_logins.end(); ++iter) { if (DoUsernamesMatch(iter->first, current_username, diff --git a/chrome/renderer/password_autocomplete_manager.h b/chrome/renderer/password_autocomplete_manager.h index a931026..5e2eee2 100644 --- a/chrome/renderer/password_autocomplete_manager.h +++ b/chrome/renderer/password_autocomplete_manager.h @@ -23,13 +23,13 @@ class WebView; class PasswordAutocompleteManager { public: explicit PasswordAutocompleteManager(RenderView* render_view); - virtual ~PasswordAutocompleteManager() {} + virtual ~PasswordAutocompleteManager(); // Invoked by the renderer when it receives the password info from the // browser. This triggers a password autocomplete (if wait_for_username is // false on |form_data|). void ReceivedPasswordFormFillData(WebKit::WebView* view, - const webkit_glue::PasswordFormDomManager::FillData& form_data); + const webkit_glue::PasswordFormFillData& form_data); // Invoked when the passed frame is closing. Gives us a chance to clear any // reference we may have to elements in that frame. @@ -46,7 +46,7 @@ class PasswordAutocompleteManager { void PerformInlineAutocomplete( const WebKit::WebInputElement& username, const WebKit::WebInputElement& password, - const webkit_glue::PasswordFormDomManager::FillData& fill_data); + const webkit_glue::PasswordFormFillData& fill_data); // WebViewClient editor related calls forwarded by the RenderView. void TextFieldDidBeginEditing(const WebKit::WebInputElement& element); @@ -58,25 +58,25 @@ class PasswordAutocompleteManager { private: struct PasswordInfo { WebKit::WebInputElement password_field; - webkit_glue::PasswordFormDomManager::FillData fill_data; + webkit_glue::PasswordFormFillData fill_data; bool backspace_pressed_last; PasswordInfo() : backspace_pressed_last(false) {} }; typedef std::map<WebKit::WebElement, PasswordInfo> LoginToPasswordInfoMap; void GetSuggestions( - const webkit_glue::PasswordFormDomManager::FillData& fill_data, + const webkit_glue::PasswordFormFillData& fill_data, const string16& input, std::vector<string16>* suggestions); bool ShowSuggestionPopup( - const webkit_glue::PasswordFormDomManager::FillData& fill_data, + const webkit_glue::PasswordFormFillData& fill_data, const WebKit::WebInputElement& user_input); bool FillUserNameAndPassword( WebKit::WebInputElement* username_element, WebKit::WebInputElement* password_element, - const webkit_glue::PasswordFormDomManager::FillData& fill_data, + const webkit_glue::PasswordFormFillData& fill_data, bool exact_username_match); // The logins we have filled so far with their associated info. diff --git a/chrome/renderer/password_autocomplete_manager_unittest.cc b/chrome/renderer/password_autocomplete_manager_unittest.cc index fc32332..3106704 100644 --- a/chrome/renderer/password_autocomplete_manager_unittest.cc +++ b/chrome/renderer/password_autocomplete_manager_unittest.cc @@ -18,6 +18,7 @@ #include "webkit/glue/form_field.h" using webkit_glue::FormField; +using webkit_glue::PasswordFormFillData; using webkit_glue::PasswordForm; using webkit_glue::PasswordFormDomManager; using WebKit::WebDocument; @@ -53,7 +54,7 @@ class PasswordAutocompleteManagerTest : public RenderViewTest { // We use that so we don't have to make RenderView::OnFillPasswordForm() // protected. void SimulateOnFillPasswordForm( - const PasswordFormDomManager::FillData& fill_data) { + const PasswordFormFillData& fill_data) { ViewMsg_FillPasswordForm msg(0, fill_data); view_->OnMessageReceived(msg); } @@ -141,7 +142,7 @@ class PasswordAutocompleteManagerTest : public RenderViewTest { string16 username2_; string16 password1_; string16 password2_; - PasswordFormDomManager::FillData fill_data_; + PasswordFormFillData fill_data_; WebInputElement username_element_; WebInputElement password_element_; diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc index c725aa4..3d766a3 100644 --- a/chrome/renderer/render_view.cc +++ b/chrome/renderer/render_view.cc @@ -3904,7 +3904,7 @@ void RenderView::OnDragSourceSystemDragEnded() { } void RenderView::OnFillPasswordForm( - const webkit_glue::PasswordFormDomManager::FillData& form_data) { + const webkit_glue::PasswordFormFillData& form_data) { #if defined(WEBKIT_BUG_41283_IS_FIXED) password_autocomplete_manager_.ReceivedPasswordFormFillData(webview(), form_data); diff --git a/chrome/renderer/render_view.h b/chrome/renderer/render_view.h index 5320c52..01fac5b 100644 --- a/chrome/renderer/render_view.h +++ b/chrome/renderer/render_view.h @@ -775,7 +775,7 @@ class RenderView : public RenderWidget, void OnNavigate(const ViewMsg_Navigate_Params& params); void OnNotifyRendererViewType(ViewType::Type view_type); void OnFillPasswordForm( - const webkit_glue::PasswordFormDomManager::FillData& form_data); + const webkit_glue::PasswordFormFillData& form_data); void OnPaste(); void OnPrintingDone(int document_cookie, bool success); void OnPrintPages(); diff --git a/webkit/glue/dom_operations.cc b/webkit/glue/dom_operations.cc index 017c3c6..82e5e3a 100644 --- a/webkit/glue/dom_operations.cc +++ b/webkit/glue/dom_operations.cc @@ -19,6 +19,7 @@ #include "third_party/WebKit/WebKit/chromium/public/WebView.h" #include "webkit/glue/dom_operations.h" #include "webkit/glue/form_data.h" +#include "webkit/glue/password_form_dom_manager.h" #include "webkit/glue/webpasswordautocompletelistener_impl.h" using WebKit::WebAnimationController; @@ -272,7 +273,7 @@ static void FindFormElements(WebView* view, } void FillPasswordForm(WebView* view, - const PasswordFormDomManager::FillData& data) { + const PasswordFormFillData& data) { FormElementsList forms; // We own the FormElements* in forms. FindFormElements(view, data.basic_data, &forms); diff --git a/webkit/glue/dom_operations.h b/webkit/glue/dom_operations.h index b8915be..664add0 100644 --- a/webkit/glue/dom_operations.h +++ b/webkit/glue/dom_operations.h @@ -11,19 +11,23 @@ #include "gfx/size.h" #include "googleurl/src/gurl.h" -#include "webkit/glue/password_form_dom_manager.h" namespace WebKit { +class WebDocument; +class WebElement; +class WebString; class WebView; } // A collection of operations that access the underlying WebKit DOM directly. namespace webkit_glue { +struct PasswordFormFillData; + // Fill matching password forms and trigger autocomplete in the case of multiple // matching logins. void FillPasswordForm(WebKit::WebView* view, - const PasswordFormDomManager::FillData& data); + const PasswordFormFillData& data); // Structure for storage the result of getting all savable resource links // for current page. The consumer of the SavableResourcesResult is responsible diff --git a/webkit/glue/password_form_dom_manager.cc b/webkit/glue/password_form_dom_manager.cc index 5db9138..adbb8dd 100644 --- a/webkit/glue/password_form_dom_manager.cc +++ b/webkit/glue/password_form_dom_manager.cc @@ -15,6 +15,12 @@ using WebKit::WebPasswordFormData; namespace webkit_glue { +PasswordFormFillData::PasswordFormFillData() : wait_for_username(false) { +} + +PasswordFormFillData::~PasswordFormFillData() { +} + PasswordForm* PasswordFormDomManager::CreatePasswordForm( const WebFormElement& webform) { WebPasswordFormData web_password_form(webform); @@ -29,7 +35,7 @@ void PasswordFormDomManager::InitFillData( const PasswordFormMap& matches, const PasswordForm* const preferred_match, bool wait_for_username_before_autofill, - PasswordFormDomManager::FillData* result) { + PasswordFormFillData* result) { DCHECK(preferred_match); // Fill basic form data. result->basic_data.origin = form_on_page.origin; diff --git a/webkit/glue/password_form_dom_manager.h b/webkit/glue/password_form_dom_manager.h index 8704573..63a6f45 100644 --- a/webkit/glue/password_form_dom_manager.h +++ b/webkit/glue/password_form_dom_manager.h @@ -16,27 +16,27 @@ class GURL; namespace webkit_glue { -class PasswordFormDomManager { - public: +// Structure used for autofilling password forms. +// basic_data identifies the HTML form on the page and preferred username/ +// password for login, while +// additional_logins is a list of other matching user/pass pairs for the form. +// wait_for_username tells us whether we need to wait for the user to enter +// a valid username before we autofill the password. By default, this is off +// unless the PasswordManager determined there is an additional risk +// associated with this form. This can happen, for example, if action URI's +// of the observed form and our saved representation don't match up. +struct PasswordFormFillData { typedef std::map<string16, string16> LoginCollection; - // Structure used for autofilling password forms. - // basic_data identifies the HTML form on the page and preferred username/ - // password for login, while - // additional_logins is a list of other matching user/pass pairs for the form. - // wait_for_username tells us whether we need to wait for the user to enter - // a valid username before we autofill the password. By default, this is off - // unless the PasswordManager determined there is an additional risk - // associated with this form. This can happen, for example, if action URI's - // of the observed form and our saved representation don't match up. - struct FillData { - FormData basic_data; - LoginCollection additional_logins; - bool wait_for_username; - FillData() : wait_for_username(false) { - } - }; + FormData basic_data; + LoginCollection additional_logins; + bool wait_for_username; + PasswordFormFillData(); + ~PasswordFormFillData(); +}; +class PasswordFormDomManager { + public: // Create a PasswordForm from DOM form. Webkit doesn't allow storing // custom metadata to DOM nodes, so we have to do this every time an event // happens with a given form and compare against previously Create'd forms @@ -53,7 +53,7 @@ class PasswordFormDomManager { const PasswordFormMap& matches, const PasswordForm* const preferred_match, bool wait_for_username_before_autofill, - FillData* result); + PasswordFormFillData* result); private: DISALLOW_IMPLICIT_CONSTRUCTORS(PasswordFormDomManager); }; diff --git a/webkit/glue/webpasswordautocompletelistener_impl.cc b/webkit/glue/webpasswordautocompletelistener_impl.cc index 5caeae1..6f6e754 100644 --- a/webkit/glue/webpasswordautocompletelistener_impl.cc +++ b/webkit/glue/webpasswordautocompletelistener_impl.cc @@ -74,7 +74,7 @@ void WebInputElementDelegate::RefreshAutofillPopup( WebPasswordAutocompleteListenerImpl::WebPasswordAutocompleteListenerImpl( WebInputElementDelegate* username_delegate, WebInputElementDelegate* password_delegate, - const PasswordFormDomManager::FillData& data) + const PasswordFormFillData& data) : password_delegate_(password_delegate), username_delegate_(username_delegate), data_(data) { @@ -144,7 +144,7 @@ void WebPasswordAutocompleteListenerImpl::performInlineAutocomplete( } // Scan additional logins for a match. - for (PasswordFormDomManager::LoginCollection::iterator it = + for (PasswordFormFillData::LoginCollection::iterator it = data_.additional_logins.begin(); it != data_.additional_logins.end(); ++it) { @@ -185,7 +185,7 @@ void WebPasswordAutocompleteListenerImpl::GetSuggestions( if (StartsWith(data_.basic_data.fields[0].value(), input, false)) suggestions->push_back(data_.basic_data.fields[0].value()); - for (PasswordFormDomManager::LoginCollection::iterator it = + for (PasswordFormFillData::LoginCollection::iterator it = data_.additional_logins.begin(); it != data_.additional_logins.end(); ++it) { diff --git a/webkit/glue/webpasswordautocompletelistener_impl.h b/webkit/glue/webpasswordautocompletelistener_impl.h index ca4604b..4fea455 100644 --- a/webkit/glue/webpasswordautocompletelistener_impl.h +++ b/webkit/glue/webpasswordautocompletelistener_impl.h @@ -19,7 +19,6 @@ using WebKit::WebString; namespace webkit_glue { - // A proxy interface to a WebInputElement for inline autocomplete. The proxy // is overridden by webpasswordautocompletelistener_unittest. class WebInputElementDelegate { @@ -49,7 +48,7 @@ class WebPasswordAutocompleteListenerImpl : WebPasswordAutocompleteListenerImpl( WebInputElementDelegate* username_element, WebInputElementDelegate* password_element, - const PasswordFormDomManager::FillData& data); + const PasswordFormFillData& data); ~WebPasswordAutocompleteListenerImpl() { } @@ -77,7 +76,7 @@ class WebPasswordAutocompleteListenerImpl : scoped_ptr<WebInputElementDelegate> username_delegate_; // Contains the extra logins for matching on delta/blur. - PasswordFormDomManager::FillData data_; + PasswordFormFillData data_; DISALLOW_COPY_AND_ASSIGN(WebPasswordAutocompleteListenerImpl); }; diff --git a/webkit/glue/webpasswordautocompletelistener_unittest.cc b/webkit/glue/webpasswordautocompletelistener_unittest.cc index a07a07e..5a05d46 100644 --- a/webkit/glue/webpasswordautocompletelistener_unittest.cc +++ b/webkit/glue/webpasswordautocompletelistener_unittest.cc @@ -16,6 +16,7 @@ using WebKit::WebString; using webkit_glue::FormField; using webkit_glue::PasswordFormDomManager; +using webkit_glue::PasswordFormFillData; using webkit_glue::WebInputElementDelegate; using webkit_glue::WebPasswordAutocompleteListenerImpl; @@ -124,7 +125,7 @@ class PasswordManagerAutocompleteTests : public testing::Test { string16 password1_; string16 username2_; string16 password2_; - PasswordFormDomManager::FillData data_; + PasswordFormFillData data_; TestWebInputElementDelegate* username_delegate_; TestWebInputElementDelegate* password_delegate_; |