| OLD | NEW | 
|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be | 
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. | 
| 4 | 4 | 
| 5 #ifndef CHROME_RENDERER_AUTOFILL_PASSWORD_AUTOFILL_MANAGER_H_ | 5 #ifndef CHROME_RENDERER_AUTOFILL_PASSWORD_AUTOFILL_MANAGER_H_ | 
| 6 #define CHROME_RENDERER_AUTOFILL_PASSWORD_AUTOFILL_MANAGER_H_ | 6 #define CHROME_RENDERER_AUTOFILL_PASSWORD_AUTOFILL_MANAGER_H_ | 
| 7 | 7 | 
| 8 #include <map> | 8 #include <map> | 
| 9 #include <vector> | 9 #include <vector> | 
| 10 | 10 | 
| 11 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" | 
|  | 12 #include "chrome/common/password_form_fill_data.h" | 
| 12 #include "chrome/renderer/page_click_listener.h" | 13 #include "chrome/renderer/page_click_listener.h" | 
| 13 #include "content/public/renderer/render_view_observer.h" | 14 #include "content/public/renderer/render_view_observer.h" | 
| 14 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputElement.h" | 15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputElement.h" | 
| 15 #include "webkit/forms/password_form_dom_manager.h" |  | 
| 16 | 16 | 
| 17 namespace WebKit { | 17 namespace WebKit { | 
| 18 class WebInputElement; | 18 class WebInputElement; | 
| 19 class WebKeyboardEvent; | 19 class WebKeyboardEvent; | 
| 20 } | 20 } | 
| 21 | 21 | 
| 22 namespace autofill { | 22 namespace autofill { | 
| 23 | 23 | 
| 24 // This class is responsible for filling password forms. | 24 // This class is responsible for filling password forms. | 
| 25 // There is one PasswordAutofillManager per RenderView. | 25 // There is one PasswordAutofillManager per RenderView. | 
| (...skipping 21 matching lines...) Expand all  Loading... | 
| 47   // A no-op.  Password forms are not previewed, so they do not need to be | 47   // A no-op.  Password forms are not previewed, so they do not need to be | 
| 48   // cleared when the selection changes.  However, this method returns | 48   // cleared when the selection changes.  However, this method returns | 
| 49   // true when |node| is fillable by password Autofill. | 49   // true when |node| is fillable by password Autofill. | 
| 50   bool DidClearAutofillSelection(const WebKit::WebNode& node); | 50   bool DidClearAutofillSelection(const WebKit::WebNode& node); | 
| 51 | 51 | 
| 52  private: | 52  private: | 
| 53   friend class PasswordAutofillManagerTest; | 53   friend class PasswordAutofillManagerTest; | 
| 54 | 54 | 
| 55   struct PasswordInfo { | 55   struct PasswordInfo { | 
| 56     WebKit::WebInputElement password_field; | 56     WebKit::WebInputElement password_field; | 
| 57     webkit::forms::PasswordFormFillData fill_data; | 57     PasswordFormFillData fill_data; | 
| 58     bool backspace_pressed_last; | 58     bool backspace_pressed_last; | 
| 59     PasswordInfo() : backspace_pressed_last(false) {} | 59     PasswordInfo() : backspace_pressed_last(false) {} | 
| 60   }; | 60   }; | 
| 61   typedef std::map<WebKit::WebElement, PasswordInfo> LoginToPasswordInfoMap; | 61   typedef std::map<WebKit::WebElement, PasswordInfo> LoginToPasswordInfoMap; | 
| 62 | 62 | 
| 63   // RenderViewObserver: | 63   // RenderViewObserver: | 
| 64   virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 64   virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 
| 65   virtual void DidFinishDocumentLoad(WebKit::WebFrame* frame) OVERRIDE; | 65   virtual void DidFinishDocumentLoad(WebKit::WebFrame* frame) OVERRIDE; | 
| 66   virtual void DidFinishLoad(WebKit::WebFrame* frame) OVERRIDE; | 66   virtual void DidFinishLoad(WebKit::WebFrame* frame) OVERRIDE; | 
| 67   virtual void FrameDetached(WebKit::WebFrame* frame) OVERRIDE; | 67   virtual void FrameDetached(WebKit::WebFrame* frame) OVERRIDE; | 
| 68   virtual void FrameWillClose(WebKit::WebFrame* frame) OVERRIDE; | 68   virtual void FrameWillClose(WebKit::WebFrame* frame) OVERRIDE; | 
| 69 | 69 | 
| 70   // PageClickListener: | 70   // PageClickListener: | 
| 71   virtual bool InputElementClicked(const WebKit::WebInputElement& element, | 71   virtual bool InputElementClicked(const WebKit::WebInputElement& element, | 
| 72                                    bool was_focused, | 72                                    bool was_focused, | 
| 73                                    bool is_focused) OVERRIDE; | 73                                    bool is_focused) OVERRIDE; | 
| 74   virtual bool InputElementLostFocus() OVERRIDE; | 74   virtual bool InputElementLostFocus() OVERRIDE; | 
| 75 | 75 | 
| 76   // RenderView IPC handlers: | 76   // RenderView IPC handlers: | 
| 77   void OnFillPasswordForm(const webkit::forms::PasswordFormFillData& form_data, | 77   void OnFillPasswordForm(const PasswordFormFillData& form_data, | 
| 78                           bool disable_popup); | 78                           bool disable_popup); | 
| 79 | 79 | 
| 80   // Scans the given frame for password forms and sends them up to the browser. | 80   // Scans the given frame for password forms and sends them up to the browser. | 
| 81   // If |only_visible| is true, only forms visible in the layout are sent. | 81   // If |only_visible| is true, only forms visible in the layout are sent. | 
| 82   void SendPasswordForms(WebKit::WebFrame* frame, bool only_visible); | 82   void SendPasswordForms(WebKit::WebFrame* frame, bool only_visible); | 
| 83 | 83 | 
| 84   void GetSuggestions(const webkit::forms::PasswordFormFillData& fill_data, | 84   void GetSuggestions(const PasswordFormFillData& fill_data, | 
| 85                       const string16& input, | 85                       const string16& input, | 
| 86                       std::vector<string16>* suggestions); | 86                       std::vector<string16>* suggestions); | 
| 87 | 87 | 
| 88   bool ShowSuggestionPopup(const webkit::forms::PasswordFormFillData& fill_data, | 88   bool ShowSuggestionPopup(const PasswordFormFillData& fill_data, | 
| 89                            const WebKit::WebInputElement& user_input); | 89                            const WebKit::WebInputElement& user_input); | 
| 90 | 90 | 
| 91   bool FillUserNameAndPassword( | 91   bool FillUserNameAndPassword( | 
| 92       WebKit::WebInputElement* username_element, | 92       WebKit::WebInputElement* username_element, | 
| 93       WebKit::WebInputElement* password_element, | 93       WebKit::WebInputElement* password_element, | 
| 94       const webkit::forms::PasswordFormFillData& fill_data, | 94       const PasswordFormFillData& fill_data, | 
| 95       bool exact_username_match, | 95       bool exact_username_match, | 
| 96       bool set_selection); | 96       bool set_selection); | 
| 97 | 97 | 
| 98   // Fills |login_input| and |password| with the most relevant suggestion from | 98   // Fills |login_input| and |password| with the most relevant suggestion from | 
| 99   // |fill_data| and shows a popup with other suggestions. | 99   // |fill_data| and shows a popup with other suggestions. | 
| 100   void PerformInlineAutocomplete( | 100   void PerformInlineAutocomplete( | 
| 101       const WebKit::WebInputElement& username, | 101       const WebKit::WebInputElement& username, | 
| 102       const WebKit::WebInputElement& password, | 102       const WebKit::WebInputElement& password, | 
| 103       const webkit::forms::PasswordFormFillData& fill_data); | 103       const PasswordFormFillData& fill_data); | 
| 104 | 104 | 
| 105   // Invoked when the passed frame is closing.  Gives us a chance to clear any | 105   // Invoked when the passed frame is closing.  Gives us a chance to clear any | 
| 106   // reference we may have to elements in that frame. | 106   // reference we may have to elements in that frame. | 
| 107   void FrameClosing(const WebKit::WebFrame* frame); | 107   void FrameClosing(const WebKit::WebFrame* frame); | 
| 108 | 108 | 
| 109   // Finds login information for a |node| that was previously filled. | 109   // Finds login information for a |node| that was previously filled. | 
| 110   bool FindLoginInfo(const WebKit::WebNode& node, | 110   bool FindLoginInfo(const WebKit::WebNode& node, | 
| 111                      WebKit::WebInputElement* found_input, | 111                      WebKit::WebInputElement* found_input, | 
| 112                      PasswordInfo* found_password); | 112                      PasswordInfo* found_password); | 
| 113 | 113 | 
| 114   // The logins we have filled so far with their associated info. | 114   // The logins we have filled so far with their associated info. | 
| 115   LoginToPasswordInfoMap login_to_password_info_; | 115   LoginToPasswordInfoMap login_to_password_info_; | 
| 116 | 116 | 
| 117   // Used to disable and hide the popup. | 117   // Used to disable and hide the popup. | 
| 118   bool disable_popup_; | 118   bool disable_popup_; | 
| 119 | 119 | 
| 120   base::WeakPtrFactory<PasswordAutofillManager> weak_ptr_factory_; | 120   base::WeakPtrFactory<PasswordAutofillManager> weak_ptr_factory_; | 
| 121 | 121 | 
| 122   DISALLOW_COPY_AND_ASSIGN(PasswordAutofillManager); | 122   DISALLOW_COPY_AND_ASSIGN(PasswordAutofillManager); | 
| 123 }; | 123 }; | 
| 124 | 124 | 
| 125 }  // namespace autofill | 125 }  // namespace autofill | 
| 126 | 126 | 
| 127 #endif  // CHROME_RENDERER_AUTOFILL_PASSWORD_AUTOFILL_MANAGER_H_ | 127 #endif  // CHROME_RENDERER_AUTOFILL_PASSWORD_AUTOFILL_MANAGER_H_ | 
| OLD | NEW | 
|---|