| 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 COMPONENTS_AUTOFILL_BROWSER_AUTOFILL_EXTERNAL_DELEGATE_H_ | 5 #ifndef COMPONENTS_AUTOFILL_BROWSER_AUTOFILL_EXTERNAL_DELEGATE_H_ |
| 6 #define COMPONENTS_AUTOFILL_BROWSER_AUTOFILL_EXTERNAL_DELEGATE_H_ | 6 #define COMPONENTS_AUTOFILL_BROWSER_AUTOFILL_EXTERNAL_DELEGATE_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| 11 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
| 12 #include "base/strings/string16.h" | 12 #include "base/strings/string16.h" |
| 13 #include "components/autofill/browser/autofill_popup_delegate.h" | 13 #include "components/autofill/browser/autofill_popup_delegate.h" |
| 14 #include "components/autofill/browser/password_autofill_manager.h" | 14 #include "components/autofill/browser/password_autofill_manager.h" |
| 15 #include "components/autofill/common/form_data.h" | 15 #include "components/autofill/common/form_data.h" |
| 16 #include "components/autofill/common/form_field_data.h" | 16 #include "components/autofill/common/form_field_data.h" |
| 17 #include "components/autofill/common/password_form_fill_data.h" | 17 #include "components/autofill/common/password_form_fill_data.h" |
| 18 #include "content/public/browser/notification_observer.h" | 18 #include "content/public/browser/notification_observer.h" |
| 19 #include "content/public/browser/notification_registrar.h" | 19 #include "content/public/browser/notification_registrar.h" |
| 20 #include "content/public/browser/web_contents_user_data.h" | |
| 21 #include "ui/gfx/rect.h" | 20 #include "ui/gfx/rect.h" |
| 22 | 21 |
| 23 namespace gfx { | 22 namespace gfx { |
| 24 class Rect; | 23 class Rect; |
| 25 } | 24 } |
| 26 | 25 |
| 27 namespace content { | 26 namespace content { |
| 27 class RenderViewHost; |
| 28 class WebContents; | 28 class WebContents; |
| 29 } | 29 } |
| 30 | 30 |
| 31 namespace autofill { | 31 namespace autofill { |
| 32 | 32 |
| 33 class AutofillManager; | 33 class AutofillManager; |
| 34 | 34 |
| 35 // TODO(csharp): A lot of the logic in this class is copied from autofillagent. | 35 // TODO(csharp): A lot of the logic in this class is copied from autofillagent. |
| 36 // Once Autofill is moved out of WebKit this class should be the only home for | 36 // Once Autofill is moved out of WebKit this class should be the only home for |
| 37 // this logic. See http://crbug.com/51644 | 37 // this logic. See http://crbug.com/51644 |
| 38 | 38 |
| 39 // Delegate for in-browser Autocomplete and Autofill display and selection. | 39 // Delegate for in-browser Autocomplete and Autofill display and selection. |
| 40 class AutofillExternalDelegate | 40 class AutofillExternalDelegate |
| 41 : public content::WebContentsUserData<AutofillExternalDelegate>, | 41 : public content::NotificationObserver, |
| 42 public content::NotificationObserver, | |
| 43 public AutofillPopupDelegate { | 42 public AutofillPopupDelegate { |
| 44 public: | 43 public: |
| 45 // Creates an AutofillExternalDelegate and attaches it to the specified | 44 // Creates an AutofillExternalDelegate for the specified contents; the second |
| 46 // contents; the second argument is an AutofillManager managing Autofill for | 45 // argument is an AutofillManager managing Autofill for that WebContents. |
| 47 // that WebContents. | 46 AutofillExternalDelegate(content::WebContents* web_contents, |
| 48 static void CreateForWebContentsAndManager(content::WebContents* web_contents, | 47 AutofillManager* autofill_manager); |
| 49 AutofillManager* autofill_manager); | 48 virtual ~AutofillExternalDelegate(); |
| 50 | 49 |
| 51 // AutofillPopupDelegate implementation. | 50 // AutofillPopupDelegate implementation. |
| 52 virtual void OnPopupShown(content::KeyboardListener* listener) OVERRIDE; | 51 virtual void OnPopupShown(content::KeyboardListener* listener) OVERRIDE; |
| 53 virtual void OnPopupHidden(content::KeyboardListener* listener) OVERRIDE; | 52 virtual void OnPopupHidden(content::KeyboardListener* listener) OVERRIDE; |
| 54 virtual void DidSelectSuggestion(int identifier) OVERRIDE; | 53 virtual void DidSelectSuggestion(int identifier) OVERRIDE; |
| 55 virtual void DidAcceptSuggestion(const base::string16& value, | 54 virtual void DidAcceptSuggestion(const base::string16& value, |
| 56 int identifier) OVERRIDE; | 55 int identifier) OVERRIDE; |
| 57 virtual void RemoveSuggestion(const base::string16& value, | 56 virtual void RemoveSuggestion(const base::string16& value, |
| 58 int identifier) OVERRIDE; | 57 int identifier) OVERRIDE; |
| 59 virtual void ClearPreviewedForm() OVERRIDE; | 58 virtual void ClearPreviewedForm() OVERRIDE; |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 // Returns the delegate to its starting state by removing any page specific | 98 // Returns the delegate to its starting state by removing any page specific |
| 100 // values or settings. | 99 // values or settings. |
| 101 void Reset(); | 100 void Reset(); |
| 102 | 101 |
| 103 // Inform the Password Manager of a filled form. | 102 // Inform the Password Manager of a filled form. |
| 104 void AddPasswordFormMapping( | 103 void AddPasswordFormMapping( |
| 105 const FormFieldData& form, | 104 const FormFieldData& form, |
| 106 const PasswordFormFillData& fill_data); | 105 const PasswordFormFillData& fill_data); |
| 107 | 106 |
| 108 protected: | 107 protected: |
| 109 friend class content::WebContentsUserData<AutofillExternalDelegate>; | |
| 110 AutofillExternalDelegate(content::WebContents* web_contents, | |
| 111 AutofillManager* autofill_manager); | |
| 112 virtual ~AutofillExternalDelegate(); | |
| 113 | |
| 114 content::WebContents* web_contents() { return web_contents_; } | 108 content::WebContents* web_contents() { return web_contents_; } |
| 115 | 109 |
| 116 base::WeakPtr<AutofillExternalDelegate> GetWeakPtr(); | 110 base::WeakPtr<AutofillExternalDelegate> GetWeakPtr(); |
| 117 | 111 |
| 118 private: | 112 private: |
| 119 // Fills the form with the Autofill data corresponding to |unique_id|. | 113 // Fills the form with the Autofill data corresponding to |unique_id|. |
| 120 // If |is_preview| is true then this is just a preview to show the user what | 114 // If |is_preview| is true then this is just a preview to show the user what |
| 121 // would be selected and if |is_preview| is false then the user has selected | 115 // would be selected and if |is_preview| is false then the user has selected |
| 122 // this data. | 116 // this data. |
| 123 void FillAutofillFormData(int unique_id, bool is_preview); | 117 void FillAutofillFormData(int unique_id, bool is_preview); |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 std::vector<int> data_list_unique_ids_; | 184 std::vector<int> data_list_unique_ids_; |
| 191 | 185 |
| 192 base::WeakPtrFactory<AutofillExternalDelegate> weak_ptr_factory_; | 186 base::WeakPtrFactory<AutofillExternalDelegate> weak_ptr_factory_; |
| 193 | 187 |
| 194 DISALLOW_COPY_AND_ASSIGN(AutofillExternalDelegate); | 188 DISALLOW_COPY_AND_ASSIGN(AutofillExternalDelegate); |
| 195 }; | 189 }; |
| 196 | 190 |
| 197 } // namespace autofill | 191 } // namespace autofill |
| 198 | 192 |
| 199 #endif // COMPONENTS_AUTOFILL_BROWSER_AUTOFILL_EXTERNAL_DELEGATE_H_ | 193 #endif // COMPONENTS_AUTOFILL_BROWSER_AUTOFILL_EXTERNAL_DELEGATE_H_ |
| OLD | NEW |