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 "base/location.h" | 8 #include "base/location.h" |
9 #include "base/single_thread_task_runner.h" | 9 #include "base/single_thread_task_runner.h" |
10 #include "base/thread_task_runner_handle.h" | 10 #include "base/thread_task_runner_handle.h" |
11 #include "build/build_config.h" | 11 #include "build/build_config.h" |
12 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
13 #include "chrome/browser/themes/theme_service.h" | 13 #include "chrome/browser/themes/theme_service.h" |
14 #include "chrome/browser/themes/theme_service_factory.h" | 14 #include "chrome/browser/themes/theme_service_factory.h" |
15 #include "chrome/browser/ui/layout_constants.h" | 15 #include "chrome/browser/ui/layout_constants.h" |
16 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" | 16 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" |
17 #include "ui/accessibility/ax_view_state.h" | 17 #include "ui/accessibility/ax_view_state.h" |
18 #include "ui/base/l10n/l10n_util.h" | 18 #include "ui/base/l10n/l10n_util.h" |
19 #include "ui/base/material_design/material_design_controller.h" | 19 #include "ui/base/material_design/material_design_controller.h" |
20 #include "ui/base/models/menu_model.h" | 20 #include "ui/base/models/menu_model.h" |
21 #include "ui/base/theme_provider.h" | 21 #include "ui/base/theme_provider.h" |
22 #include "ui/gfx/display.h" | 22 #include "ui/display/display.h" |
23 #include "ui/gfx/screen.h" | 23 #include "ui/display/screen.h" |
24 #include "ui/strings/grit/ui_strings.h" | 24 #include "ui/strings/grit/ui_strings.h" |
25 #include "ui/views/animation/button_ink_drop_delegate.h" | 25 #include "ui/views/animation/button_ink_drop_delegate.h" |
26 #include "ui/views/controls/button/label_button_border.h" | 26 #include "ui/views/controls/button/label_button_border.h" |
27 #include "ui/views/controls/menu/menu_item_view.h" | 27 #include "ui/views/controls/menu/menu_item_view.h" |
28 #include "ui/views/controls/menu/menu_model_adapter.h" | 28 #include "ui/views/controls/menu/menu_model_adapter.h" |
29 #include "ui/views/controls/menu/menu_runner.h" | 29 #include "ui/views/controls/menu/menu_runner.h" |
30 #include "ui/views/widget/widget.h" | 30 #include "ui/views/widget/widget.h" |
31 | 31 |
32 ToolbarButton::ToolbarButton(Profile* profile, | 32 ToolbarButton::ToolbarButton(Profile* profile, |
33 views::ButtonListener* listener, | 33 views::ButtonListener* listener, |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 | 194 |
195 View::ConvertPointToScreen(this, &menu_position); | 195 View::ConvertPointToScreen(this, &menu_position); |
196 | 196 |
197 #if defined(OS_WIN) | 197 #if defined(OS_WIN) |
198 int left_bound = GetSystemMetrics(SM_XVIRTUALSCREEN); | 198 int left_bound = GetSystemMetrics(SM_XVIRTUALSCREEN); |
199 #elif defined(OS_CHROMEOS) | 199 #elif defined(OS_CHROMEOS) |
200 // A window won't overlap between displays on ChromeOS. | 200 // A window won't overlap between displays on ChromeOS. |
201 // Use the left bound of the display on which | 201 // Use the left bound of the display on which |
202 // the menu button exists. | 202 // the menu button exists. |
203 gfx::NativeView view = GetWidget()->GetNativeView(); | 203 gfx::NativeView view = GetWidget()->GetNativeView(); |
204 gfx::Display display = | 204 display::Display display = |
205 gfx::Screen::GetScreen()->GetDisplayNearestWindow(view); | 205 display::Screen::GetScreen()->GetDisplayNearestWindow(view); |
206 int left_bound = display.bounds().x(); | 206 int left_bound = display.bounds().x(); |
207 #else | 207 #else |
208 // The window might be positioned over the edge between two screens. We'll | 208 // The window might be positioned over the edge between two screens. We'll |
209 // want to position the dropdown on the screen the mouse cursor is on. | 209 // want to position the dropdown on the screen the mouse cursor is on. |
210 gfx::Screen* screen = gfx::Screen::GetScreen(); | 210 display::Screen* screen = display::Screen::GetScreen(); |
211 gfx::Display display = screen->GetDisplayNearestPoint( | 211 display::Display display = |
212 screen->GetCursorScreenPoint()); | 212 screen->GetDisplayNearestPoint(screen->GetCursorScreenPoint()); |
213 int left_bound = display.bounds().x(); | 213 int left_bound = display.bounds().x(); |
214 #endif | 214 #endif |
215 if (menu_position.x() < left_bound) | 215 if (menu_position.x() < left_bound) |
216 menu_position.set_x(left_bound); | 216 menu_position.set_x(left_bound); |
217 | 217 |
218 // Make the button look depressed while the menu is open. | 218 // Make the button look depressed while the menu is open. |
219 SetState(STATE_PRESSED); | 219 SetState(STATE_PRESSED); |
220 | 220 |
221 menu_showing_ = true; | 221 menu_showing_ = true; |
222 | 222 |
(...skipping 30 matching lines...) Expand all Loading... |
253 if (state() != STATE_DISABLED) | 253 if (state() != STATE_DISABLED) |
254 SetState(STATE_NORMAL); | 254 SetState(STATE_NORMAL); |
255 | 255 |
256 menu_runner_.reset(); | 256 menu_runner_.reset(); |
257 menu_model_adapter_.reset(); | 257 menu_model_adapter_.reset(); |
258 } | 258 } |
259 | 259 |
260 const char* ToolbarButton::GetClassName() const { | 260 const char* ToolbarButton::GetClassName() const { |
261 return "ToolbarButton"; | 261 return "ToolbarButton"; |
262 } | 262 } |
OLD | NEW |