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

Side by Side Diff: chrome/browser/ui/views/toolbar_view.h

Issue 71743002: [Toolbar Views] Move toolbar files to a new subdirectory. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 1 month 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 | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_UI_VIEWS_TOOLBAR_VIEW_H_
6 #define CHROME_BROWSER_UI_VIEWS_TOOLBAR_VIEW_H_
7
8 #include <set>
9 #include <string>
10
11 #include "base/memory/scoped_ptr.h"
12 #include "base/observer_list.h"
13 #include "base/prefs/pref_member.h"
14 #include "chrome/browser/command_observer.h"
15 #include "chrome/browser/ui/toolbar/back_forward_menu_model.h"
16 #include "chrome/browser/ui/views/location_bar/location_bar_view.h"
17 #include "chrome/browser/ui/views/reload_button.h"
18 #include "ui/base/accelerators/accelerator.h"
19 #include "ui/views/accessible_pane_view.h"
20 #include "ui/views/controls/button/menu_button.h"
21 #include "ui/views/controls/button/menu_button_listener.h"
22 #include "ui/views/view.h"
23
24 class BrowserActionsContainer;
25 class Browser;
26 class HomeImageButton;
27 class WrenchMenu;
28 class WrenchMenuModel;
29 class WrenchToolbarButton;
30
31 namespace views {
32 class MenuListener;
33 }
34
35 // The Browser Window's toolbar.
36 class ToolbarView : public views::AccessiblePaneView,
37 public views::MenuButtonListener,
38 public ui::AcceleratorProvider,
39 public LocationBarView::Delegate,
40 public content::NotificationObserver,
41 public CommandObserver,
42 public views::ButtonListener,
43 public views::WidgetObserver {
44 public:
45 // The view class name.
46 static const char kViewClassName[];
47
48 explicit ToolbarView(Browser* browser);
49 virtual ~ToolbarView();
50
51 // Create the contents of the Browser Toolbar.
52 void Init();
53
54 // Forces the toolbar (and transitively the location bar) to update its
55 // current state. If |tab| is non-NULL, we're switching (back?) to this tab
56 // and should restore any previous location bar state (such as user editing)
57 // as well.
58 void Update(content::WebContents* tab);
59
60 // Set focus to the toolbar with complete keyboard access, with the
61 // focus initially set to the app menu. Focus will be restored
62 // to the last focused view if the user escapes.
63 void SetPaneFocusAndFocusAppMenu();
64
65 // Returns true if the app menu is focused.
66 bool IsAppMenuFocused();
67
68 // Add a listener to receive a callback when the menu opens.
69 void AddMenuListener(views::MenuListener* listener);
70
71 // Remove a menu listener.
72 void RemoveMenuListener(views::MenuListener* listener);
73
74 virtual bool GetAcceleratorInfo(int id, ui::Accelerator* accel);
75
76 // Returns the view to which the bookmark bubble should be anchored.
77 views::View* GetBookmarkBubbleAnchor();
78
79 // Returns the view to which the Translate bubble should be anchored.
80 views::View* GetTranslateBubbleAnchor();
81
82 // Accessors...
83 Browser* browser() const { return browser_; }
84 BrowserActionsContainer* browser_actions() const { return browser_actions_; }
85 ReloadButton* reload_button() const { return reload_; }
86 LocationBarView* location_bar() const { return location_bar_; }
87 views::MenuButton* app_menu() const;
88
89 // Overridden from AccessiblePaneView
90 virtual bool SetPaneFocus(View* initial_focus) OVERRIDE;
91 virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE;
92
93 // Overridden from views::MenuButtonListener:
94 virtual void OnMenuButtonClicked(views::View* source,
95 const gfx::Point& point) OVERRIDE;
96
97 // Overridden from LocationBarView::Delegate:
98 virtual content::WebContents* GetWebContents() OVERRIDE;
99 virtual ToolbarModel* GetToolbarModel() OVERRIDE;
100 virtual const ToolbarModel* GetToolbarModel() const OVERRIDE;
101 virtual InstantController* GetInstant() OVERRIDE;
102 virtual views::Widget* CreateViewsBubble(
103 views::BubbleDelegateView* bubble_delegate) OVERRIDE;
104 virtual PageActionImageView* CreatePageActionImageView(
105 LocationBarView* owner, ExtensionAction* action) OVERRIDE;
106 virtual ContentSettingBubbleModelDelegate*
107 GetContentSettingBubbleModelDelegate() OVERRIDE;
108 virtual void ShowWebsiteSettings(content::WebContents* web_contents,
109 const GURL& url,
110 const content::SSLStatus& ssl) OVERRIDE;
111
112 // Overridden from CommandObserver:
113 virtual void EnabledStateChangedForCommand(int id, bool enabled) OVERRIDE;
114
115 // Overridden from views::ButtonListener:
116 virtual void ButtonPressed(views::Button* sender,
117 const ui::Event& event) OVERRIDE;
118
119 // Overridden from content::NotificationObserver:
120 virtual void Observe(int type,
121 const content::NotificationSource& source,
122 const content::NotificationDetails& details) OVERRIDE;
123
124 // Overridden from ui::AcceleratorProvider:
125 virtual bool GetAcceleratorForCommandId(
126 int command_id, ui::Accelerator* accelerator) OVERRIDE;
127
128 // Overridden from views::View:
129 virtual gfx::Size GetPreferredSize() OVERRIDE;
130 virtual void Layout() OVERRIDE;
131 virtual bool HitTestRect(const gfx::Rect& rect) const OVERRIDE;
132 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE;
133 virtual bool GetDropFormats(
134 int* formats,
135 std::set<OSExchangeData::CustomFormat>* custom_formats) OVERRIDE;
136 virtual bool CanDrop(const ui::OSExchangeData& data) OVERRIDE;
137 virtual int OnDragUpdated(const ui::DropTargetEvent& event) OVERRIDE;
138 virtual int OnPerformDrop(const ui::DropTargetEvent& event) OVERRIDE;
139 virtual void OnThemeChanged() OVERRIDE;
140 virtual const char* GetClassName() const OVERRIDE;
141 virtual bool AcceleratorPressed(const ui::Accelerator& acc) OVERRIDE;
142
143 // Whether the wrench/hotdogs menu is currently showing.
144 bool IsWrenchMenuShowing() const;
145
146 // Whether the toolbar view needs its background painted by the
147 // BrowserNonClientFrameView.
148 bool ShouldPaintBackground() const;
149
150 // The apparent horizontal space between most items, and the vertical padding
151 // above and below them.
152 static const int kStandardSpacing;
153 // The top of the toolbar has an edge we have to skip over in addition to the
154 // standard spacing.
155 static const int kVertSpacing;
156
157 protected:
158 // Overridden from AccessiblePaneView
159 virtual bool SetPaneFocusAndFocusDefault() OVERRIDE;
160 virtual void RemovePaneFocus() OVERRIDE;
161
162 private:
163 // Types of display mode this toolbar can have.
164 enum DisplayMode {
165 DISPLAYMODE_NORMAL, // Normal toolbar with buttons, etc.
166 DISPLAYMODE_LOCATION // Slimline toolbar showing only compact location
167 // bar, used for popups.
168 };
169
170 // Returns true if we should show the upgrade recommended dot.
171 bool ShouldShowUpgradeRecommended();
172
173 // Returns true if we should show the background page badge.
174 bool ShouldShowBackgroundPageBadge();
175
176 // Returns true if we should show the warning for incompatible software.
177 bool ShouldShowIncompatibilityWarning();
178
179 // Returns the number of pixels above the location bar in non-normal display.
180 int PopupTopSpacing() const;
181
182 // Loads the images for all the child views.
183 void LoadImages();
184
185 bool is_display_mode_normal() const {
186 return display_mode_ == DISPLAYMODE_NORMAL;
187 }
188
189 // Shows the critical notification bubble against the wrench menu.
190 void ShowCriticalNotification();
191
192 // Shows the outdated install notification bubble against the wrench menu.
193 void ShowOutdatedInstallNotification();
194
195 // Updates the badge and the accessible name of the app menu (Wrench).
196 void UpdateAppMenuState();
197
198 // Updates the severity level on the wrench menu button.
199 void UpdateWrenchButtonSeverity();
200
201 void OnShowHomeButtonChanged();
202
203 int content_shadow_height() const;
204
205 // Controls
206 views::ImageButton* back_;
207 views::ImageButton* forward_;
208 ReloadButton* reload_;
209 HomeImageButton* home_;
210 LocationBarView* location_bar_;
211 BrowserActionsContainer* browser_actions_;
212 WrenchToolbarButton* app_menu_;
213 Browser* browser_;
214
215 // Controls whether or not a home button should be shown on the toolbar.
216 BooleanPrefMember show_home_button_;
217
218 // The display mode used when laying out the toolbar.
219 DisplayMode display_mode_;
220
221 // Wrench model and menu.
222 // Note that the menu should be destroyed before the model it uses, so the
223 // menu should be listed later.
224 scoped_ptr<WrenchMenuModel> wrench_menu_model_;
225 scoped_ptr<WrenchMenu> wrench_menu_;
226
227 // A list of listeners to call when the menu opens.
228 ObserverList<views::MenuListener> menu_listeners_;
229
230 content::NotificationRegistrar registrar_;
231
232 DISALLOW_IMPLICIT_CONSTRUCTORS(ToolbarView);
233 };
234
235 #endif // CHROME_BROWSER_UI_VIEWS_TOOLBAR_VIEW_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698