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 scoped_ptr<views::LabelButtonBorder> |
| 133 ToolbarButton::CreateDefaultBorder() const { |
| 134 scoped_ptr<views::LabelButtonBorder> border = |
| 135 LabelButton::CreateDefaultBorder(); |
| 136 |
| 137 ui::ThemeProvider* provider = GetThemeProvider(); |
| 138 if (provider && provider->UsingSystemTheme()) { |
| 139 // We set smaller insets here to accommodate the slightly larger GTK+ |
| 140 // icons. |
| 141 border->set_insets(gfx::Insets(2, 2, 2, 2)); |
| 142 } |
| 143 |
| 144 return border.Pass(); |
| 145 } |
| 146 |
131 void ToolbarButton::ShowContextMenuForView(View* source, | 147 void ToolbarButton::ShowContextMenuForView(View* source, |
132 const gfx::Point& point, | 148 const gfx::Point& point, |
133 ui::MenuSourceType source_type) { | 149 ui::MenuSourceType source_type) { |
134 if (!enabled()) | 150 if (!enabled()) |
135 return; | 151 return; |
136 | 152 |
137 show_menu_factory_.InvalidateWeakPtrs(); | 153 show_menu_factory_.InvalidateWeakPtrs(); |
138 ShowDropDownMenu(source_type); | 154 ShowDropDownMenu(source_type); |
139 } | 155 } |
140 | 156 |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 | 242 |
227 // Need to explicitly clear mouse handler so that events get sent | 243 // 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 | 244 // 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. | 245 // the first click to other parts of the UI is eaten. |
230 SetMouseHandler(NULL); | 246 SetMouseHandler(NULL); |
231 | 247 |
232 // Set the state back to normal after the drop down menu is closed. | 248 // Set the state back to normal after the drop down menu is closed. |
233 if (state_ != STATE_DISABLED) | 249 if (state_ != STATE_DISABLED) |
234 SetState(STATE_NORMAL); | 250 SetState(STATE_NORMAL); |
235 } | 251 } |
OLD | NEW |