| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_AUTOCOMPLETE_AUTOCOMPLETE_POPUP_VIEW_MAC_H_ | 5 #ifndef CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_POPUP_VIEW_MAC_H_ |
| 6 #define CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_POPUP_VIEW_MAC_H_ | 6 #define CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_POPUP_VIEW_MAC_H_ |
| 7 | 7 |
| 8 #import <Cocoa/Cocoa.h> | 8 #import <Cocoa/Cocoa.h> |
| 9 | 9 |
| 10 #include <string> | 10 #include <string> |
| 11 #include <map> |
| 11 | 12 |
| 12 #include "base/basictypes.h" | 13 #include "base/basictypes.h" |
| 13 #include "base/scoped_ptr.h" | 14 #include "base/scoped_ptr.h" |
| 14 #include "base/scoped_nsobject.h" | 15 #include "base/scoped_nsobject.h" |
| 15 #include "chrome/browser/autocomplete/autocomplete.h" | 16 #include "chrome/browser/autocomplete/autocomplete.h" |
| 16 #include "chrome/browser/autocomplete/autocomplete_popup_view.h" | 17 #include "chrome/browser/autocomplete/autocomplete_popup_view.h" |
| 17 #include "gfx/font.h" | 18 #include "gfx/font.h" |
| 18 #include "webkit/glue/window_open_disposition.h" | 19 #include "webkit/glue/window_open_disposition.h" |
| 19 | 20 |
| 20 class AutocompletePopupModel; | 21 class AutocompletePopupModel; |
| 21 class AutocompleteEditModel; | 22 class AutocompleteEditModel; |
| 22 class AutocompleteEditViewMac; | 23 class AutocompleteEditViewMac; |
| 24 @class NSImage; |
| 23 class Profile; | 25 class Profile; |
| 26 class SkBitmap; |
| 24 | 27 |
| 25 // Implements AutocompletePopupView using a raw NSWindow containing an | 28 // Implements AutocompletePopupView using a raw NSWindow containing an |
| 26 // NSTableView. | 29 // NSTableView. |
| 27 // | 30 // |
| 28 // TODO(rohitrao): This class is set up in a way that makes testing hard. | 31 // TODO(rohitrao): This class is set up in a way that makes testing hard. |
| 29 // Refactor and write unittests. http://crbug.com/9977 | 32 // Refactor and write unittests. http://crbug.com/9977 |
| 30 | 33 |
| 31 class AutocompletePopupViewMac : public AutocompletePopupView { | 34 class AutocompletePopupViewMac : public AutocompletePopupView { |
| 32 public: | 35 public: |
| 33 AutocompletePopupViewMac(AutocompleteEditViewMac* edit_view, | 36 AutocompletePopupViewMac(AutocompleteEditViewMac* edit_view, |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 void CreatePopupIfNeeded(); | 110 void CreatePopupIfNeeded(); |
| 108 | 111 |
| 109 // Calculate the appropriate position for the popup based on the | 112 // Calculate the appropriate position for the popup based on the |
| 110 // field's screen position and the given target for the matrix | 113 // field's screen position and the given target for the matrix |
| 111 // height, and makes the popup visible. Animates to the new frame | 114 // height, and makes the popup visible. Animates to the new frame |
| 112 // if the popup shrinks, snaps to the new frame if the popup grows, | 115 // if the popup shrinks, snaps to the new frame if the popup grows, |
| 113 // allows existing animations to continue if the size doesn't | 116 // allows existing animations to continue if the size doesn't |
| 114 // change. | 117 // change. |
| 115 void PositionPopup(const CGFloat matrixHeight); | 118 void PositionPopup(const CGFloat matrixHeight); |
| 116 | 119 |
| 120 // Returns the NSImage that should be used as an icon for the given match. |
| 121 NSImage* ImageForMatch(const AutocompleteMatch& match); |
| 122 |
| 117 scoped_ptr<AutocompletePopupModel> model_; | 123 scoped_ptr<AutocompletePopupModel> model_; |
| 118 AutocompleteEditViewMac* edit_view_; | 124 AutocompleteEditViewMac* edit_view_; |
| 119 NSTextField* field_; // owned by tab controller | 125 NSTextField* field_; // owned by tab controller |
| 120 | 126 |
| 121 // Child window containing a matrix which implements the popup. | 127 // Child window containing a matrix which implements the popup. |
| 122 scoped_nsobject<NSWindow> popup_; | 128 scoped_nsobject<NSWindow> popup_; |
| 123 NSRect targetPopupFrame_; | 129 NSRect targetPopupFrame_; |
| 124 | 130 |
| 125 DISALLOW_COPY_AND_ASSIGN(AutocompletePopupViewMac); | 131 DISALLOW_COPY_AND_ASSIGN(AutocompletePopupViewMac); |
| 126 }; | 132 }; |
| 127 | 133 |
| 128 #endif // CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_POPUP_VIEW_MAC_H_ | 134 #endif // CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_POPUP_VIEW_MAC_H_ |
| OLD | NEW |