OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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/chrome_views_delegate.h" | 5 #include "chrome/browser/ui/views/chrome_views_delegate.h" |
6 | 6 |
7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
9 #include "base/prefs/scoped_user_pref_update.h" | 9 #include "base/prefs/scoped_user_pref_update.h" |
10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
11 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
12 #include "base/time/time.h" | 12 #include "base/time/time.h" |
13 #include "chrome/browser/browser_process.h" | 13 #include "chrome/browser/browser_process.h" |
14 #include "chrome/browser/profiles/profile_manager.h" | 14 #include "chrome/browser/profiles/profile_manager.h" |
15 #include "chrome/browser/ui/browser_window_state.h" | 15 #include "chrome/browser/ui/browser_window_state.h" |
16 #include "components/version_info/version_info.h" | 16 #include "components/version_info/version_info.h" |
17 #include "content/public/browser/browser_thread.h" | 17 #include "content/public/browser/browser_thread.h" |
18 #include "content/public/browser/context_factory.h" | 18 #include "content/public/browser/context_factory.h" |
19 #include "grit/chrome_unscaled_resources.h" | 19 #include "grit/chrome_unscaled_resources.h" |
20 #include "ui/base/resource/resource_bundle.h" | 20 #include "ui/base/resource/resource_bundle.h" |
21 #include "ui/base/ui_base_switches.h" | 21 #include "ui/base/ui_base_switches.h" |
22 #include "ui/gfx/geometry/rect.h" | 22 #include "ui/gfx/geometry/rect.h" |
23 #include "ui/gfx/screen.h" | 23 #include "ui/gfx/screen.h" |
| 24 #include "ui/views/controls/menu/menu_controller.h" |
24 #include "ui/views/widget/native_widget.h" | 25 #include "ui/views/widget/native_widget.h" |
25 #include "ui/views/widget/widget.h" | 26 #include "ui/views/widget/widget.h" |
26 | 27 |
27 #if defined(OS_WIN) | 28 #if defined(OS_WIN) |
28 #include <dwmapi.h> | 29 #include <dwmapi.h> |
29 #include <shellapi.h> | 30 #include <shellapi.h> |
30 #include "base/profiler/scoped_tracker.h" | 31 #include "base/profiler/scoped_tracker.h" |
31 #include "base/task_runner_util.h" | 32 #include "base/task_runner_util.h" |
32 #include "base/win/windows_version.h" | 33 #include "base/win/windows_version.h" |
33 #include "chrome/browser/app_icon_win.h" | 34 #include "chrome/browser/app_icon_win.h" |
(...skipping 11 matching lines...) Expand all Loading... |
45 #include "chrome/browser/ui/host_desktop.h" | 46 #include "chrome/browser/ui/host_desktop.h" |
46 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" | 47 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" |
47 #include "ui/views/widget/native_widget_aura.h" | 48 #include "ui/views/widget/native_widget_aura.h" |
48 #endif | 49 #endif |
49 | 50 |
50 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) | 51 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) |
51 #include "ui/views/linux_ui/linux_ui.h" | 52 #include "ui/views/linux_ui/linux_ui.h" |
52 #endif | 53 #endif |
53 | 54 |
54 #if defined(USE_ASH) | 55 #if defined(USE_ASH) |
| 56 #include "ash/accelerators/accelerator_controller.h" |
55 #include "ash/shell.h" | 57 #include "ash/shell.h" |
56 #include "ash/wm/window_state.h" | 58 #include "ash/wm/window_state.h" |
57 #include "chrome/browser/ui/ash/ash_init.h" | 59 #include "chrome/browser/ui/ash/ash_init.h" |
58 #include "chrome/browser/ui/ash/ash_util.h" | 60 #include "chrome/browser/ui/ash/ash_util.h" |
59 #endif | 61 #endif |
60 | 62 |
61 | 63 |
62 // Helpers -------------------------------------------------------------------- | 64 // Helpers -------------------------------------------------------------------- |
63 | 65 |
64 namespace { | 66 namespace { |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 if (MonitorHasTopmostAutohideTaskbarForEdge(ABE_TOP, monitor)) | 121 if (MonitorHasTopmostAutohideTaskbarForEdge(ABE_TOP, monitor)) |
120 edges |= views::ViewsDelegate::EDGE_TOP; | 122 edges |= views::ViewsDelegate::EDGE_TOP; |
121 if (MonitorHasTopmostAutohideTaskbarForEdge(ABE_RIGHT, monitor)) | 123 if (MonitorHasTopmostAutohideTaskbarForEdge(ABE_RIGHT, monitor)) |
122 edges |= views::ViewsDelegate::EDGE_RIGHT; | 124 edges |= views::ViewsDelegate::EDGE_RIGHT; |
123 if (MonitorHasTopmostAutohideTaskbarForEdge(ABE_BOTTOM, monitor)) | 125 if (MonitorHasTopmostAutohideTaskbarForEdge(ABE_BOTTOM, monitor)) |
124 edges |= views::ViewsDelegate::EDGE_BOTTOM; | 126 edges |= views::ViewsDelegate::EDGE_BOTTOM; |
125 return edges; | 127 return edges; |
126 } | 128 } |
127 #endif | 129 #endif |
128 | 130 |
| 131 #if defined(USE_ASH) |
| 132 void ProcessAcceleratorNow(const ui::Accelerator& accelerator) { |
| 133 // TODO(afakhry): See if we need here to send the accelerator to the |
| 134 // FocusManager of the active window in a follow-up CL. |
| 135 ash::Shell::GetInstance()->accelerator_controller()->Process(accelerator); |
| 136 } |
| 137 #endif // defined(USE_ASH) |
| 138 |
129 } // namespace | 139 } // namespace |
130 | 140 |
131 | 141 |
132 // ChromeViewsDelegate -------------------------------------------------------- | 142 // ChromeViewsDelegate -------------------------------------------------------- |
133 | 143 |
134 #if defined(OS_WIN) | 144 #if defined(OS_WIN) |
135 ChromeViewsDelegate::ChromeViewsDelegate() | 145 ChromeViewsDelegate::ChromeViewsDelegate() |
136 : in_autohide_edges_callback_(false), | 146 : in_autohide_edges_callback_(false), |
137 weak_factory_(this) { | 147 weak_factory_(this) { |
138 #else | 148 #else |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 } | 223 } |
214 | 224 |
215 void ChromeViewsDelegate::NotifyAccessibilityEvent( | 225 void ChromeViewsDelegate::NotifyAccessibilityEvent( |
216 views::View* view, ui::AXEvent event_type) { | 226 views::View* view, ui::AXEvent event_type) { |
217 #if defined(USE_AURA) | 227 #if defined(USE_AURA) |
218 AutomationManagerAura::GetInstance()->HandleEvent( | 228 AutomationManagerAura::GetInstance()->HandleEvent( |
219 GetProfileForWindow(view->GetWidget()), view, event_type); | 229 GetProfileForWindow(view->GetWidget()), view, event_type); |
220 #endif | 230 #endif |
221 } | 231 } |
222 | 232 |
| 233 views::ViewsDelegate::ProcessMenuAcceleratorResult |
| 234 ChromeViewsDelegate::ProcessAcceleratorWhileMenuShowing( |
| 235 const ui::Accelerator& accelerator) { |
| 236 #if defined(USE_ASH) |
| 237 ash::AcceleratorController* accelerator_controller = |
| 238 ash::Shell::GetInstance()->accelerator_controller(); |
| 239 |
| 240 accelerator_controller->accelerator_history()->StoreCurrentAccelerator( |
| 241 accelerator); |
| 242 if (accelerator_controller->ShouldCloseMenuAndRepostAccelerator( |
| 243 accelerator)) { |
| 244 base::MessageLoopForUI::current()->PostTask( |
| 245 FROM_HERE, |
| 246 base::Bind(ProcessAcceleratorNow, accelerator)); |
| 247 return views::ViewsDelegate::ProcessMenuAcceleratorResult::CLOSE_MENU; |
| 248 } |
| 249 |
| 250 ProcessAcceleratorNow(accelerator); |
| 251 return views::ViewsDelegate::ProcessMenuAcceleratorResult::LEAVE_MENU_OPEN; |
| 252 #else |
| 253 return views::ViewsDelegate::ProcessMenuAcceleratorResult::LEAVE_MENU_OPEN; |
| 254 #endif // defined(USE_ASH) |
| 255 } |
| 256 |
223 #if defined(OS_WIN) | 257 #if defined(OS_WIN) |
224 HICON ChromeViewsDelegate::GetDefaultWindowIcon() const { | 258 HICON ChromeViewsDelegate::GetDefaultWindowIcon() const { |
225 return GetAppIcon(); | 259 return GetAppIcon(); |
226 } | 260 } |
227 | 261 |
228 HICON ChromeViewsDelegate::GetSmallWindowIcon() const { | 262 HICON ChromeViewsDelegate::GetSmallWindowIcon() const { |
229 return GetSmallAppIcon(); | 263 return GetSmallAppIcon(); |
230 } | 264 } |
231 | 265 |
232 bool ChromeViewsDelegate::IsWindowInMetro(gfx::NativeWindow window) const { | 266 bool ChromeViewsDelegate::IsWindowInMetro(gfx::NativeWindow window) const { |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
434 return content::BrowserThread::GetBlockingPool(); | 468 return content::BrowserThread::GetBlockingPool(); |
435 } | 469 } |
436 | 470 |
437 #if !defined(USE_AURA) && !defined(USE_CHROMEOS) | 471 #if !defined(USE_AURA) && !defined(USE_CHROMEOS) |
438 views::Widget::InitParams::WindowOpacity | 472 views::Widget::InitParams::WindowOpacity |
439 ChromeViewsDelegate::GetOpacityForInitParams( | 473 ChromeViewsDelegate::GetOpacityForInitParams( |
440 const views::Widget::InitParams& params) { | 474 const views::Widget::InitParams& params) { |
441 return views::Widget::InitParams::OPAQUE_WINDOW; | 475 return views::Widget::InitParams::OPAQUE_WINDOW; |
442 } | 476 } |
443 #endif | 477 #endif |
OLD | NEW |