OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #include "chrome/browser/ui/views/toolbar/toolbar_button.h" | 5 #include "chrome/browser/ui/views/toolbar/toolbar_button.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" | 8 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" |
9 #include "grit/theme_resources.h" | 9 #include "grit/theme_resources.h" |
10 #include "grit/ui_strings.h" | 10 #include "grit/ui_strings.h" |
11 #include "ui/accessibility/ax_view_state.h" | 11 #include "ui/accessibility/ax_view_state.h" |
12 #include "ui/base/l10n/l10n_util.h" | 12 #include "ui/base/l10n/l10n_util.h" |
13 #include "ui/base/models/menu_model.h" | 13 #include "ui/base/models/menu_model.h" |
14 #include "ui/base/theme_provider.h" | |
14 #include "ui/gfx/display.h" | 15 #include "ui/gfx/display.h" |
15 #include "ui/gfx/screen.h" | 16 #include "ui/gfx/screen.h" |
16 #include "ui/views/controls/button/label_button_border.h" | 17 #include "ui/views/controls/button/label_button_border.h" |
17 #include "ui/views/controls/menu/menu_item_view.h" | 18 #include "ui/views/controls/menu/menu_item_view.h" |
18 #include "ui/views/controls/menu/menu_model_adapter.h" | 19 #include "ui/views/controls/menu/menu_model_adapter.h" |
19 #include "ui/views/controls/menu/menu_runner.h" | 20 #include "ui/views/controls/menu/menu_runner.h" |
20 #include "ui/views/widget/widget.h" | 21 #include "ui/views/widget/widget.h" |
21 | 22 |
22 ToolbarButton::ToolbarButton(views::ButtonListener* listener, | 23 ToolbarButton::ToolbarButton(views::ButtonListener* listener, |
23 ui::MenuModel* model) | 24 ui::MenuModel* model) |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
121 LabelButton::OnGestureEvent(event); | 122 LabelButton::OnGestureEvent(event); |
122 } | 123 } |
123 | 124 |
124 void ToolbarButton::GetAccessibleState(ui::AXViewState* state) { | 125 void ToolbarButton::GetAccessibleState(ui::AXViewState* state) { |
125 CustomButton::GetAccessibleState(state); | 126 CustomButton::GetAccessibleState(state); |
126 state->role = ui::AX_ROLE_BUTTON_DROP_DOWN; | 127 state->role = ui::AX_ROLE_BUTTON_DROP_DOWN; |
127 state->default_action = l10n_util::GetStringUTF16(IDS_APP_ACCACTION_PRESS); | 128 state->default_action = l10n_util::GetStringUTF16(IDS_APP_ACCACTION_PRESS); |
128 state->AddStateFlag(ui::AX_STATE_HASPOPUP); | 129 state->AddStateFlag(ui::AX_STATE_HASPOPUP); |
129 } | 130 } |
130 | 131 |
132 void ToolbarButton::SetDefaultBorderInsets(views::LabelButtonBorder* border) { | |
133 ui::ThemeProvider* provider = GetThemeProvider(); | |
134 if (provider && provider->UsingSystemTheme()) { | |
msw
2014/05/21 22:57:14
nit: remove curly braces.
| |
135 border->set_insets(gfx::Insets(2, 2, 2, 2)); | |
msw
2014/05/21 22:57:14
Can you document where these inset values come fro
| |
136 } | |
137 } | |
138 | |
131 void ToolbarButton::ShowContextMenuForView(View* source, | 139 void ToolbarButton::ShowContextMenuForView(View* source, |
132 const gfx::Point& point, | 140 const gfx::Point& point, |
133 ui::MenuSourceType source_type) { | 141 ui::MenuSourceType source_type) { |
134 if (!enabled()) | 142 if (!enabled()) |
135 return; | 143 return; |
136 | 144 |
137 show_menu_factory_.InvalidateWeakPtrs(); | 145 show_menu_factory_.InvalidateWeakPtrs(); |
138 ShowDropDownMenu(source_type); | 146 ShowDropDownMenu(source_type); |
139 } | 147 } |
140 | 148 |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
226 | 234 |
227 // Need to explicitly clear mouse handler so that events get sent | 235 // Need to explicitly clear mouse handler so that events get sent |
228 // properly after the menu finishes running. If we don't do this, then | 236 // properly after the menu finishes running. If we don't do this, then |
229 // the first click to other parts of the UI is eaten. | 237 // the first click to other parts of the UI is eaten. |
230 SetMouseHandler(NULL); | 238 SetMouseHandler(NULL); |
231 | 239 |
232 // Set the state back to normal after the drop down menu is closed. | 240 // Set the state back to normal after the drop down menu is closed. |
233 if (state_ != STATE_DISABLED) | 241 if (state_ != STATE_DISABLED) |
234 SetState(STATE_NORMAL); | 242 SetState(STATE_NORMAL); |
235 } | 243 } |
OLD | NEW |