| 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_COCOA_AUTOFILL_AUTOFILL_POPUP_VIEW_BRIDGE_H_ | 5 #ifndef CHROME_BROWSER_UI_COCOA_AUTOFILL_AUTOFILL_POPUP_VIEW_BRIDGE_H_ |
| 6 #define CHROME_BROWSER_UI_COCOA_AUTOFILL_AUTOFILL_POPUP_VIEW_BRIDGE_H_ | 6 #define CHROME_BROWSER_UI_COCOA_AUTOFILL_AUTOFILL_POPUP_VIEW_BRIDGE_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
| 13 #include "base/mac/scoped_nsobject.h" | 13 #include "base/mac/scoped_nsobject.h" |
| 14 #include "base/macros.h" | 14 #include "base/macros.h" |
| 15 #include "base/optional.h" |
| 15 #include "chrome/browser/ui/autofill/autofill_popup_view.h" | 16 #include "chrome/browser/ui/autofill/autofill_popup_view.h" |
| 16 #include "chrome/browser/ui/cocoa/autofill/autofill_popup_view_cocoa.h" | 17 #include "chrome/browser/ui/cocoa/autofill/autofill_popup_view_cocoa.h" |
| 17 | 18 |
| 18 @class AutofillPopupViewCocoa; | 19 @class AutofillPopupViewCocoa; |
| 19 @class NSWindow; | 20 @class NSWindow; |
| 20 | 21 |
| 21 namespace autofill { | 22 namespace autofill { |
| 22 | 23 |
| 23 class AutofillPopupViewCocoaDelegate { | 24 class AutofillPopupViewCocoaDelegate { |
| 24 public: | 25 public: |
| 25 // Returns the bounds of the item at |index| in the popup, relative to | 26 // Returns the bounds of the item at |index| in the popup, relative to |
| 26 // the top left of the popup. | 27 // the top left of the popup. |
| 27 virtual gfx::Rect GetRowBounds(size_t index) = 0; | 28 virtual gfx::Rect GetRowBounds(int index) = 0; |
| 28 | 29 |
| 29 // Gets the resource value for the given resource, returning -1 if the | 30 // Gets the resource value for the given resource, returning -1 if the |
| 30 // resource isn't recognized. | 31 // resource isn't recognized. |
| 31 virtual int GetIconResourceID(const base::string16& resource_name) = 0; | 32 virtual int GetIconResourceID(const base::string16& resource_name) = 0; |
| 32 }; | 33 }; |
| 33 | 34 |
| 34 // Mac implementation of the AutofillPopupView interface. | 35 // Mac implementation of the AutofillPopupView interface. |
| 35 // Serves as a bridge to an instance of the Objective-C class which actually | 36 // Serves as a bridge to an instance of the Objective-C class which actually |
| 36 // implements the view. | 37 // implements the view. |
| 37 class AutofillPopupViewBridge : public AutofillPopupView, | 38 class AutofillPopupViewBridge : public AutofillPopupView, |
| 38 public AutofillPopupViewCocoaDelegate { | 39 public AutofillPopupViewCocoaDelegate { |
| 39 public: | 40 public: |
| 40 explicit AutofillPopupViewBridge(AutofillPopupController* controller); | 41 explicit AutofillPopupViewBridge(AutofillPopupController* controller); |
| 41 | 42 |
| 42 // AutofillPopupViewCocoaDelegate implementation. | 43 // AutofillPopupViewCocoaDelegate implementation. |
| 43 gfx::Rect GetRowBounds(size_t index) override; | 44 gfx::Rect GetRowBounds(int index) override; |
| 44 int GetIconResourceID(const base::string16& resource_name) override; | 45 int GetIconResourceID(const base::string16& resource_name) override; |
| 45 | 46 |
| 46 private: | 47 private: |
| 47 ~AutofillPopupViewBridge() override; | 48 ~AutofillPopupViewBridge() override; |
| 48 | 49 |
| 49 // AutofillPopupView implementation. | 50 // AutofillPopupView implementation. |
| 50 void Hide() override; | 51 void Hide() override; |
| 51 void Show() override; | 52 void Show() override; |
| 52 void InvalidateRow(size_t row) override; | 53 void OnSelectedRowChanged(base::Optional<int> previous_row_selection, |
| 53 void UpdateBoundsAndRedrawPopup() override; | 54 base::Optional<int> current_row_selection) override; |
| 55 void OnSuggestionsChanged() override; |
| 54 | 56 |
| 55 // Set the initial bounds of the popup, including its placement. | 57 // Set the initial bounds of the popup, including its placement. |
| 56 void SetInitialBounds(); | 58 void SetInitialBounds(); |
| 57 | 59 |
| 58 // The native Cocoa view. | 60 // The native Cocoa view. |
| 59 base::scoped_nsobject<AutofillPopupViewCocoa> view_; | 61 base::scoped_nsobject<AutofillPopupViewCocoa> view_; |
| 60 | 62 |
| 61 AutofillPopupController* controller_; // Weak. | 63 AutofillPopupController* controller_; // Weak. |
| 62 | 64 |
| 63 DISALLOW_COPY_AND_ASSIGN(AutofillPopupViewBridge); | 65 DISALLOW_COPY_AND_ASSIGN(AutofillPopupViewBridge); |
| 64 }; | 66 }; |
| 65 | 67 |
| 66 } // namespace autofill | 68 } // namespace autofill |
| 67 | 69 |
| 68 #endif // CHROME_BROWSER_UI_COCOA_AUTOFILL_AUTOFILL_POPUP_VIEW_BRIDGE_H_ | 70 #endif // CHROME_BROWSER_UI_COCOA_AUTOFILL_AUTOFILL_POPUP_VIEW_BRIDGE_H_ |
| OLD | NEW |