OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_VIEWS_INFOBARS_INFOBAR_VIEW_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_INFOBARS_INFOBAR_VIEW_H_ |
6 #define CHROME_BROWSER_UI_VIEWS_INFOBARS_INFOBAR_VIEW_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_INFOBARS_INFOBAR_VIEW_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
11 #include "chrome/browser/tab_contents/infobar.h" | 11 #include "chrome/browser/tab_contents/infobar.h" |
12 #include "chrome/browser/tab_contents/infobar_container.h" | 12 #include "chrome/browser/tab_contents/infobar_container.h" |
13 #include "third_party/skia/include/core/SkPath.h" | 13 #include "third_party/skia/include/core/SkPath.h" |
14 #include "views/controls/button/button.h" | 14 #include "views/controls/button/button.h" |
| 15 #include "views/controls/menu/menu_item_view.h" |
15 #include "views/focus/focus_manager.h" | 16 #include "views/focus/focus_manager.h" |
16 | 17 |
| 18 namespace ui { |
| 19 class MenuModel; |
| 20 } |
17 namespace views { | 21 namespace views { |
18 class ExternalFocusTracker; | 22 class ExternalFocusTracker; |
19 class ImageButton; | 23 class ImageButton; |
20 class ImageView; | 24 class ImageView; |
21 class Label; | 25 class Label; |
22 class Link; | 26 class Link; |
23 class LinkListener; | 27 class LinkListener; |
24 class MenuButton; | 28 class MenuButton; |
| 29 class MenuRunner; |
25 class TextButton; | 30 class TextButton; |
26 class ViewMenuDelegate; | 31 class ViewMenuDelegate; |
27 } | 32 } |
28 | 33 |
29 class InfoBarView : public InfoBar, | 34 class InfoBarView : public InfoBar, |
30 public views::View, | 35 public views::View, |
31 public views::ButtonListener, | 36 public views::ButtonListener, |
32 public views::FocusChangeListener { | 37 public views::FocusChangeListener { |
33 public: | 38 public: |
34 InfoBarView(TabContentsWrapper* owner, InfoBarDelegate* delegate); | 39 InfoBarView(TabContentsWrapper* owner, InfoBarDelegate* delegate); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 virtual int ContentMinimumWidth() const; | 81 virtual int ContentMinimumWidth() const; |
77 | 82 |
78 // These return x coordinates delimiting the usable area for subclasses to lay | 83 // These return x coordinates delimiting the usable area for subclasses to lay |
79 // out their controls. | 84 // out their controls. |
80 int StartX() const; | 85 int StartX() const; |
81 int EndX() const; | 86 int EndX() const; |
82 | 87 |
83 // Convenience getter. | 88 // Convenience getter. |
84 const InfoBarContainer::Delegate* container_delegate() const; | 89 const InfoBarContainer::Delegate* container_delegate() const; |
85 | 90 |
| 91 // Show a menu at the specified position. By invoking this InfobarView ensures |
| 92 // the menu is destroyed at the appropriate time. |
| 93 void RunMenuAt(ui::MenuModel* menu_model, |
| 94 views::MenuButton* button, |
| 95 views::MenuItemView::AnchorPosition anchor); |
| 96 |
86 private: | 97 private: |
87 static const int kHorizontalPadding; | 98 static const int kHorizontalPadding; |
88 | 99 |
89 // InfoBar: | 100 // InfoBar: |
90 virtual void PlatformSpecificShow(bool animate) OVERRIDE; | 101 virtual void PlatformSpecificShow(bool animate) OVERRIDE; |
91 virtual void PlatformSpecificHide(bool animate) OVERRIDE; | 102 virtual void PlatformSpecificHide(bool animate) OVERRIDE; |
92 virtual void PlatformSpecificOnHeightsRecalculated() OVERRIDE; | 103 virtual void PlatformSpecificOnHeightsRecalculated() OVERRIDE; |
93 | 104 |
94 // views::View: | 105 // views::View: |
95 virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; | 106 virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; |
(...skipping 12 matching lines...) Expand all Loading... |
108 | 119 |
109 // Tracks and stores the last focused view which is not the InfoBar or any of | 120 // Tracks and stores the last focused view which is not the InfoBar or any of |
110 // its children. Used to restore focus once the InfoBar is closed. | 121 // its children. Used to restore focus once the InfoBar is closed. |
111 scoped_ptr<views::ExternalFocusTracker> focus_tracker_; | 122 scoped_ptr<views::ExternalFocusTracker> focus_tracker_; |
112 | 123 |
113 // The paths for the InfoBarBackground to draw, sized according to the heights | 124 // The paths for the InfoBarBackground to draw, sized according to the heights |
114 // above. | 125 // above. |
115 SkPath fill_path_; | 126 SkPath fill_path_; |
116 SkPath stroke_path_; | 127 SkPath stroke_path_; |
117 | 128 |
| 129 // Used to run the menu. |
| 130 scoped_ptr<views::MenuRunner> menu_runner_; |
| 131 |
118 DISALLOW_COPY_AND_ASSIGN(InfoBarView); | 132 DISALLOW_COPY_AND_ASSIGN(InfoBarView); |
119 }; | 133 }; |
120 | 134 |
121 #endif // CHROME_BROWSER_UI_VIEWS_INFOBARS_INFOBAR_VIEW_H_ | 135 #endif // CHROME_BROWSER_UI_VIEWS_INFOBARS_INFOBAR_VIEW_H_ |
OLD | NEW |