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 "chrome/browser/ui/autofill/autofill_popup_view.h" | 15 #include "chrome/browser/ui/autofill/autofill_popup_view.h" |
| 16 #include "chrome/browser/ui/autofill/autofill_popup_view_helper.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 AutofillPopupViewDelegate; | 24 class AutofillPopupViewDelegate; |
24 | 25 |
| 26 class AutofillPopupViewCocoaDelegate { |
| 27 public: |
| 28 // Returns the bounds of the item at |index| in the popup, relative to |
| 29 // the top left of the popup. |
| 30 virtual gfx::Rect GetRowBounds(size_t index) = 0; |
| 31 |
| 32 // Gets the resource value for the given resource, returning -1 if the |
| 33 // resource isn't recognized. |
| 34 virtual int GetIconResourceID(const base::string16& resource_name) = 0; |
| 35 }; |
| 36 |
25 // Mac implementation of the AutofillPopupView interface. | 37 // Mac implementation of the AutofillPopupView interface. |
26 // Serves as a bridge to an instance of the Objective-C class which actually | 38 // Serves as a bridge to an instance of the Objective-C class which actually |
27 // implements the view. | 39 // implements the view. |
28 class AutofillPopupViewBridge : public AutofillPopupView { | 40 class AutofillPopupViewBridge : public AutofillPopupView, |
| 41 public AutofillPopupViewCocoaDelegate { |
29 public: | 42 public: |
30 explicit AutofillPopupViewBridge(AutofillPopupController* controller); | 43 explicit AutofillPopupViewBridge(AutofillPopupController* controller); |
31 | 44 |
| 45 // AutofillPopupViewBridgeDelegate implementation. |
| 46 gfx::Rect GetRowBounds(size_t index) override; |
| 47 int GetIconResourceID(const base::string16& resource_name) override; |
| 48 |
32 private: | 49 private: |
33 ~AutofillPopupViewBridge() override; | 50 ~AutofillPopupViewBridge() override; |
34 | 51 |
35 // AutofillPopupView implementation. | 52 // AutofillPopupView implementation. |
36 void Hide() override; | 53 void Hide() override; |
37 void Show() override; | 54 void Show() override; |
38 void InvalidateRow(size_t row) override; | 55 void InvalidateRow(size_t row) override; |
39 void UpdateBoundsAndRedrawPopup() override; | 56 void UpdateBoundsAndRedrawPopup() override; |
| 57 void UpdatePopupBounds() override; |
| 58 int GetAvailableWidthForRow(int row, bool with_label) override; |
| 59 int LineFromY(int y) override; |
| 60 gfx::Rect GetPopupBounds() override; |
40 | 61 |
41 // Set the initial bounds of the popup, including its placement. | 62 // Set the initial bounds of the popup, including its placement. |
42 void SetInitialBounds(); | 63 void SetInitialBounds(); |
43 | 64 |
44 // The native Cocoa view. | 65 // The native Cocoa view. |
45 base::scoped_nsobject<AutofillPopupViewCocoa> view_; | 66 base::scoped_nsobject<AutofillPopupViewCocoa> view_; |
46 | 67 |
| 68 AutofillPopupViewHelper view_helper_; |
| 69 |
47 AutofillPopupController* controller_; // Weak. | 70 AutofillPopupController* controller_; // Weak. |
48 | 71 |
49 DISALLOW_COPY_AND_ASSIGN(AutofillPopupViewBridge); | 72 DISALLOW_COPY_AND_ASSIGN(AutofillPopupViewBridge); |
50 }; | 73 }; |
51 | 74 |
52 } // namespace autofill | 75 } // namespace autofill |
53 | 76 |
54 #endif // CHROME_BROWSER_UI_COCOA_AUTOFILL_AUTOFILL_POPUP_VIEW_BRIDGE_H_ | 77 #endif // CHROME_BROWSER_UI_COCOA_AUTOFILL_AUTOFILL_POPUP_VIEW_BRIDGE_H_ |
OLD | NEW |