Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(91)

Side by Side Diff: chrome/browser/ui/cocoa/omnibox/omnibox_popup_view_mac.h

Issue 1099403005: [AiS] changing mac omnibox suggestions form NSMatrix to NSTableView (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_OMNIBOX_OMNIBOX_POPUP_VIEW_MAC_H_ 5 #ifndef CHROME_BROWSER_UI_COCOA_OMNIBOX_OMNIBOX_POPUP_VIEW_MAC_H_
6 #define CHROME_BROWSER_UI_COCOA_OMNIBOX_OMNIBOX_POPUP_VIEW_MAC_H_ 6 #define CHROME_BROWSER_UI_COCOA_OMNIBOX_OMNIBOX_POPUP_VIEW_MAC_H_
7 7
8 #import <Cocoa/Cocoa.h> 8 #import <Cocoa/Cocoa.h>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/mac/scoped_nsobject.h" 11 #include "base/mac/scoped_nsobject.h"
12 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
13 #import "chrome/browser/ui/cocoa/omnibox/omnibox_popup_matrix.h" 13 #import "chrome/browser/ui/cocoa/omnibox/omnibox_popup_matrix.h"
14 #include "chrome/browser/ui/omnibox/omnibox_popup_view.h" 14 #include "chrome/browser/ui/omnibox/omnibox_popup_view.h"
15 #include "components/omnibox/autocomplete_match.h" 15 #include "components/omnibox/autocomplete_match.h"
16 #include "ui/gfx/font.h" 16 #include "ui/gfx/font.h"
17 17
18 class AutocompleteResult; 18 class AutocompleteResult;
19 class OmniboxEditModel; 19 class OmniboxEditModel;
20 class OmniboxPopupModel; 20 class OmniboxPopupModel;
21 class OmniboxView; 21 class OmniboxView;
22 22
23 // Implements OmniboxPopupView using a raw NSWindow containing an 23 // Implements OmniboxPopupView using a raw NSWindow containing an
24 // NSTableView. 24 // NSTableView.
25 class OmniboxPopupViewMac : public OmniboxPopupView, 25 class OmniboxPopupViewMac : public OmniboxPopupView,
26 public OmniboxPopupMatrixDelegate { 26 public OmniboxPopupTableDelegate {
27 public: 27 public:
28 OmniboxPopupViewMac(OmniboxView* omnibox_view, 28 OmniboxPopupViewMac(OmniboxView* omnibox_view,
29 OmniboxEditModel* edit_model, 29 OmniboxEditModel* edit_model,
30 NSTextField* field); 30 NSTextField* field);
31 ~OmniboxPopupViewMac() override; 31 ~OmniboxPopupViewMac() override;
32 32
33 // Overridden from OmniboxPopupView: 33 // Overridden from OmniboxPopupView:
34 bool IsOpen() const override; 34 bool IsOpen() const override;
35 void InvalidateLine(size_t line) override {} 35 void InvalidateLine(size_t line) override;
36 void UpdatePopupAppearance() override; 36 void UpdatePopupAppearance() override;
37 gfx::Rect GetTargetBounds() override; 37 gfx::Rect GetTargetBounds() override;
38 // This is only called by model in SetSelectedLine() after updating 38 // This is only called by model in SetSelectedLine() after updating
39 // everything. Popup should already be visible. 39 // everything. Popup should already be visible.
40 void PaintUpdatesNow() override; 40 void PaintUpdatesNow() override;
41 void OnDragCanceled() override {} 41 void OnDragCanceled() override {}
42 42
43 // Overridden from OmniboxPopupMatrixDelegate: 43 // Overridden from OmniboxPopupTableDelegate:
44 void OnMatrixRowSelected(OmniboxPopupMatrix* matrix, size_t row) override; 44 void OnTableRowSelected(OmniboxPopupTableView* table_view,
45 void OnMatrixRowClicked(OmniboxPopupMatrix* matrix, size_t row) override; 45 size_t row) override;
46 void OnMatrixRowMiddleClicked(OmniboxPopupMatrix* matrix, 46 void OnTableRowClicked(OmniboxPopupTableView* table_view,
47 size_t row) override; 47 size_t row) override;
48 48 void OnTableRowMiddleClicked(OmniboxPopupTableView* table_view,
49 OmniboxPopupMatrix* matrix() { return matrix_; } 49 size_t row) override;
dschuyler 2015/04/24 18:43:08 This wasn't being used.
50 50
51 protected: 51 protected:
52 // Gets the autocomplete results. This is virtual so that it can be overriden 52 // Gets the autocomplete results. This is virtual so that it can be overriden
53 // by tests. 53 // by tests.
54 virtual const AutocompleteResult& GetResult() const; 54 virtual const AutocompleteResult& GetResult() const;
55 55
56 private: 56 private:
57 // Create the popup_ instance if needed. 57 // Create the popup_ instance if needed.
58 void CreatePopupIfNeeded(); 58 void CreatePopupIfNeeded();
59 59
60 // Calculate the appropriate position for the popup based on the 60 // Calculate the appropriate position for the popup based on the
61 // field's screen position and the given target for the matrix 61 // field's screen position and the given target for the table view
62 // height, and makes the popup visible. Animates to the new frame 62 // height, and makes the popup visible. Animates to the new frame
63 // if the popup shrinks, snaps to the new frame if the popup grows, 63 // if the popup shrinks, snaps to the new frame if the popup grows,
64 // allows existing animations to continue if the size doesn't 64 // allows existing animations to continue if the size doesn't
65 // change. 65 // change.
66 void PositionPopup(const CGFloat matrixHeight); 66 void PositionPopup(const CGFloat tableHeight);
67 67
68 // Returns the NSImage that should be used as an icon for the given match. 68 // Returns the NSImage that should be used as an icon for the given match.
69 NSImage* ImageForMatch(const AutocompleteMatch& match); 69 NSImage* ImageForMatch(const AutocompleteMatch& match);
70 70
71 // Opens the URL at the given row. 71 // Opens the URL at the given row.
72 void OpenURLForRow(size_t row, WindowOpenDisposition disposition); 72 void OpenURLForRow(size_t row, WindowOpenDisposition disposition);
73 73
74 OmniboxView* omnibox_view_; 74 OmniboxView* omnibox_view_;
75 scoped_ptr<OmniboxPopupModel> model_; 75 scoped_ptr<OmniboxPopupModel> model_;
76 NSTextField* field_; // owned by tab controller 76 NSTextField* field_; // owned by tab controller
77 77
78 // Child window containing a matrix which implements the popup. 78 // Child window containing a table view which implements the popup.
79 base::scoped_nsobject<NSWindow> popup_; 79 base::scoped_nsobject<NSWindow> popup_;
80 NSRect target_popup_frame_; 80 NSRect target_popup_frame_;
81 81
82 base::scoped_nsobject<OmniboxPopupMatrix> matrix_; 82 base::scoped_nsobject<OmniboxPopupTableView> table_view_;
83 base::scoped_nsobject<NSView> top_separator_view_; 83 base::scoped_nsobject<NSView> top_separator_view_;
84 base::scoped_nsobject<NSView> bottom_separator_view_; 84 base::scoped_nsobject<NSView> bottom_separator_view_;
85 base::scoped_nsobject<NSBox> background_view_; 85 base::scoped_nsobject<NSBox> background_view_;
86 86
87 DISALLOW_COPY_AND_ASSIGN(OmniboxPopupViewMac); 87 DISALLOW_COPY_AND_ASSIGN(OmniboxPopupViewMac);
88 }; 88 };
89 89
90 #endif // CHROME_BROWSER_UI_COCOA_OMNIBOX_OMNIBOX_POPUP_VIEW_MAC_H_ 90 #endif // CHROME_BROWSER_UI_COCOA_OMNIBOX_OMNIBOX_POPUP_VIEW_MAC_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698