Chromium Code Reviews| 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_BROWSER_UI_AUTOFILL_AUTOFILL_POPUP_CONTROLLER_IMPL_H_ | 5 #ifndef CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_POPUP_CONTROLLER_IMPL_H_ |
| 6 #define CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_POPUP_CONTROLLER_IMPL_H_ | 6 #define CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_POPUP_CONTROLLER_IMPL_H_ |
| 7 | 7 |
| 8 #include "base/gtest_prod_util.h" | 8 #include "base/gtest_prod_util.h" |
| 9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
| 10 #include "base/string16.h" | 10 #include "base/string16.h" |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 33 class AutofillPopupControllerImpl : public AutofillPopupController, | 33 class AutofillPopupControllerImpl : public AutofillPopupController, |
| 34 public content::KeyboardListener { | 34 public content::KeyboardListener { |
| 35 public: | 35 public: |
| 36 // Creates a new |AutofillPopupControllerImpl|, or reuses |previous| if | 36 // Creates a new |AutofillPopupControllerImpl|, or reuses |previous| if |
| 37 // the construction arguments are the same. |previous| may be invalidated by | 37 // the construction arguments are the same. |previous| may be invalidated by |
| 38 // this call. | 38 // this call. |
| 39 static base::WeakPtr<AutofillPopupControllerImpl> GetOrCreate( | 39 static base::WeakPtr<AutofillPopupControllerImpl> GetOrCreate( |
| 40 base::WeakPtr<AutofillPopupControllerImpl> previous, | 40 base::WeakPtr<AutofillPopupControllerImpl> previous, |
| 41 base::WeakPtr<AutofillPopupDelegate> delegate, | 41 base::WeakPtr<AutofillPopupDelegate> delegate, |
| 42 gfx::NativeView container_view, | 42 gfx::NativeView container_view, |
| 43 const gfx::RectF& element_bounds); | 43 const gfx::RectF& element_bounds, |
| 44 bool is_rtl); | |
| 44 | 45 |
| 45 // Shows the popup, or updates the existing popup with the given values. | 46 // Shows the popup, or updates the existing popup with the given values. |
| 46 void Show(const std::vector<string16>& names, | 47 void Show(const std::vector<string16>& names, |
| 47 const std::vector<string16>& subtexts, | 48 const std::vector<string16>& subtexts, |
| 48 const std::vector<string16>& icons, | 49 const std::vector<string16>& icons, |
| 49 const std::vector<int>& identifiers); | 50 const std::vector<int>& identifiers); |
| 50 | 51 |
| 51 // Hides the popup and destroys the controller. This also invalidates | 52 // Hides the popup and destroys the controller. This also invalidates |
| 52 // |delegate_|. | 53 // |delegate_|. |
| 53 virtual void Hide() OVERRIDE; | 54 virtual void Hide() OVERRIDE; |
| 54 | 55 |
| 55 // Invoked when the view was destroyed by by someone other than this class. | 56 // Invoked when the view was destroyed by by someone other than this class. |
| 56 virtual void ViewDestroyed() OVERRIDE; | 57 virtual void ViewDestroyed() OVERRIDE; |
| 57 | 58 |
| 58 // KeyboardListener implementation. | 59 // KeyboardListener implementation. |
| 59 virtual bool HandleKeyPressEvent( | 60 virtual bool HandleKeyPressEvent( |
| 60 const content::NativeWebKeyboardEvent& event) OVERRIDE; | 61 const content::NativeWebKeyboardEvent& event) OVERRIDE; |
| 61 | 62 |
| 62 protected: | 63 protected: |
| 63 FRIEND_TEST_ALL_PREFIXES(AutofillExternalDelegateBrowserTest, | 64 FRIEND_TEST_ALL_PREFIXES(AutofillExternalDelegateBrowserTest, |
| 64 CloseWidgetAndNoLeaking); | 65 CloseWidgetAndNoLeaking); |
| 65 FRIEND_TEST_ALL_PREFIXES(AutofillPopupControllerUnitTest, | 66 FRIEND_TEST_ALL_PREFIXES(AutofillPopupControllerUnitTest, |
| 66 ProperlyResetController); | 67 ProperlyResetController); |
| 67 | 68 |
| 68 AutofillPopupControllerImpl(base::WeakPtr<AutofillPopupDelegate> delegate, | 69 AutofillPopupControllerImpl(base::WeakPtr<AutofillPopupDelegate> delegate, |
| 69 gfx::NativeView container_view, | 70 gfx::NativeView container_view, |
| 70 const gfx::RectF& element_bounds); | 71 const gfx::RectF& element_bounds, |
| 72 bool is_rtl); | |
|
Ilya Sherman
2013/06/06 09:04:04
Please pass a value from base::i18n::TextDirection
csharp
2013/06/06 14:13:53
Done.
| |
| 71 virtual ~AutofillPopupControllerImpl(); | 73 virtual ~AutofillPopupControllerImpl(); |
| 72 | 74 |
| 73 // AutofillPopupController implementation. | 75 // AutofillPopupController implementation. |
| 74 virtual void UpdateBoundsAndRedrawPopup() OVERRIDE; | 76 virtual void UpdateBoundsAndRedrawPopup() OVERRIDE; |
| 75 virtual void MouseHovered(int x, int y) OVERRIDE; | 77 virtual void MouseHovered(int x, int y) OVERRIDE; |
| 76 virtual void MouseClicked(int x, int y) OVERRIDE; | 78 virtual void MouseClicked(int x, int y) OVERRIDE; |
| 77 virtual void MouseExitedPopup() OVERRIDE; | 79 virtual void MouseExitedPopup() OVERRIDE; |
| 78 virtual void AcceptSuggestion(size_t index) OVERRIDE; | 80 virtual void AcceptSuggestion(size_t index) OVERRIDE; |
| 79 virtual int GetIconResourceID(const string16& resource_name) OVERRIDE; | 81 virtual int GetIconResourceID(const string16& resource_name) OVERRIDE; |
| 80 virtual bool CanDelete(size_t index) const OVERRIDE; | 82 virtual bool CanDelete(size_t index) const OVERRIDE; |
| 81 virtual gfx::Rect GetRowBounds(size_t index) OVERRIDE; | 83 virtual gfx::Rect GetRowBounds(size_t index) OVERRIDE; |
| 82 virtual void SetPopupBounds(const gfx::Rect& bounds) OVERRIDE; | 84 virtual void SetPopupBounds(const gfx::Rect& bounds) OVERRIDE; |
| 83 virtual const gfx::Rect& popup_bounds() const OVERRIDE; | 85 virtual const gfx::Rect& popup_bounds() const OVERRIDE; |
| 84 virtual gfx::NativeView container_view() const OVERRIDE; | 86 virtual gfx::NativeView container_view() const OVERRIDE; |
| 85 virtual const gfx::RectF& element_bounds() const OVERRIDE; | 87 virtual const gfx::RectF& element_bounds() const OVERRIDE; |
| 88 virtual bool is_rtl() const OVERRIDE; | |
| 86 | 89 |
| 87 virtual const std::vector<string16>& names() const OVERRIDE; | 90 virtual const std::vector<string16>& names() const OVERRIDE; |
| 88 virtual const std::vector<string16>& subtexts() const OVERRIDE; | 91 virtual const std::vector<string16>& subtexts() const OVERRIDE; |
| 89 virtual const std::vector<string16>& icons() const OVERRIDE; | 92 virtual const std::vector<string16>& icons() const OVERRIDE; |
| 90 virtual const std::vector<int>& identifiers() const OVERRIDE; | 93 virtual const std::vector<int>& identifiers() const OVERRIDE; |
| 91 #if !defined(OS_ANDROID) | 94 #if !defined(OS_ANDROID) |
| 92 virtual const gfx::Font& GetNameFontForRow(size_t index) const OVERRIDE; | 95 virtual const gfx::Font& GetNameFontForRow(size_t index) const OVERRIDE; |
| 93 virtual const gfx::Font& subtext_font() const OVERRIDE; | 96 virtual const gfx::Font& subtext_font() const OVERRIDE; |
| 94 #endif | 97 #endif |
| 95 virtual int selected_line() const OVERRIDE; | 98 virtual int selected_line() const OVERRIDE; |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 184 base::WeakPtr<AutofillPopupDelegate> delegate_; | 187 base::WeakPtr<AutofillPopupDelegate> delegate_; |
| 185 gfx::NativeView container_view_; // Weak reference. | 188 gfx::NativeView container_view_; // Weak reference. |
| 186 | 189 |
| 187 // The bounds of the text element that is the focus of the Autofill. | 190 // The bounds of the text element that is the focus of the Autofill. |
| 188 // These coordinates are in screen space. | 191 // These coordinates are in screen space. |
| 189 const gfx::RectF element_bounds_; | 192 const gfx::RectF element_bounds_; |
| 190 | 193 |
| 191 // The bounds of the Autofill popup. | 194 // The bounds of the Autofill popup. |
| 192 gfx::Rect popup_bounds_; | 195 gfx::Rect popup_bounds_; |
| 193 | 196 |
| 197 // If the popup should be displayed RTL. | |
| 198 bool is_rtl_; | |
| 199 | |
| 194 // The current Autofill query values. | 200 // The current Autofill query values. |
| 195 std::vector<string16> names_; | 201 std::vector<string16> names_; |
| 196 std::vector<string16> subtexts_; | 202 std::vector<string16> subtexts_; |
| 197 std::vector<string16> icons_; | 203 std::vector<string16> icons_; |
| 198 std::vector<int> identifiers_; | 204 std::vector<int> identifiers_; |
| 199 | 205 |
| 200 // Since names_ can be elided to ensure that it fits on the screen, we need to | 206 // Since names_ can be elided to ensure that it fits on the screen, we need to |
| 201 // keep an unelided copy of the names to be able to pass to the delegate. | 207 // keep an unelided copy of the names to be able to pass to the delegate. |
| 202 std::vector<string16> full_names_; | 208 std::vector<string16> full_names_; |
| 203 | 209 |
| 204 #if !defined(OS_ANDROID) | 210 #if !defined(OS_ANDROID) |
| 205 // The fonts for the popup text. | 211 // The fonts for the popup text. |
| 206 gfx::Font name_font_; | 212 gfx::Font name_font_; |
| 207 gfx::Font subtext_font_; | 213 gfx::Font subtext_font_; |
| 208 gfx::Font warning_font_; | 214 gfx::Font warning_font_; |
| 209 #endif | 215 #endif |
| 210 | 216 |
| 211 // The line that is currently selected by the user. | 217 // The line that is currently selected by the user. |
| 212 // |kNoSelection| indicates that no line is currently selected. | 218 // |kNoSelection| indicates that no line is currently selected. |
| 213 int selected_line_; | 219 int selected_line_; |
| 214 | 220 |
| 215 base::WeakPtrFactory<AutofillPopupControllerImpl> weak_ptr_factory_; | 221 base::WeakPtrFactory<AutofillPopupControllerImpl> weak_ptr_factory_; |
| 216 }; | 222 }; |
| 217 | 223 |
| 218 } // namespace autofill | 224 } // namespace autofill |
| 219 | 225 |
| 220 #endif // CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_POPUP_CONTROLLER_IMPL_H_ | 226 #endif // CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_POPUP_CONTROLLER_IMPL_H_ |
| OLD | NEW |