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/frame/browser_view.h" | 5 #include "chrome/browser/ui/views/frame/browser_view.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
95 #include "ui/views/events/event.h" | 95 #include "ui/views/events/event.h" |
96 #include "ui/views/focus/external_focus_tracker.h" | 96 #include "ui/views/focus/external_focus_tracker.h" |
97 #include "ui/views/focus/view_storage.h" | 97 #include "ui/views/focus/view_storage.h" |
98 #include "ui/views/layout/grid_layout.h" | 98 #include "ui/views/layout/grid_layout.h" |
99 #include "ui/views/widget/native_widget.h" | 99 #include "ui/views/widget/native_widget.h" |
100 #include "ui/views/widget/root_view.h" | 100 #include "ui/views/widget/root_view.h" |
101 #include "ui/views/widget/widget.h" | 101 #include "ui/views/widget/widget.h" |
102 #include "ui/views/window/dialog_delegate.h" | 102 #include "ui/views/window/dialog_delegate.h" |
103 | 103 |
104 #if defined(USE_ASH) | 104 #if defined(USE_ASH) |
105 #include "ash/accelerators/accelerator_controller.h" | |
105 #include "ash/launcher/launcher.h" | 106 #include "ash/launcher/launcher.h" |
106 #include "ash/launcher/launcher_model.h" | 107 #include "ash/launcher/launcher_model.h" |
107 #include "ash/shell.h" | 108 #include "ash/shell.h" |
108 #include "chrome/browser/ui/views/ash/chrome_shell_delegate.h" | 109 #include "chrome/browser/ui/views/ash/chrome_shell_delegate.h" |
109 #include "chrome/browser/ui/views/ash/launcher/launcher_updater.h" | 110 #include "chrome/browser/ui/views/ash/launcher/launcher_updater.h" |
110 #include "chrome/browser/ui/views/ash/window_positioner.h" | 111 #include "chrome/browser/ui/views/ash/window_positioner.h" |
111 #elif defined(OS_WIN) | 112 #elif defined(OS_WIN) |
112 #include "base/win/metro.h" | 113 #include "base/win/metro.h" |
113 #include "chrome/browser/aeropeek_manager.h" | 114 #include "chrome/browser/aeropeek_manager.h" |
114 #include "chrome/browser/jumplist_win.h" | 115 #include "chrome/browser/jumplist_win.h" |
115 #include "ui/views/widget/native_widget_win.h" | 116 #include "ui/views/widget/native_widget_win.h" |
116 #endif | 117 #endif |
117 | 118 |
118 #if defined(USE_AURA) | 119 #if defined(USE_AURA) |
119 #include "chrome/browser/ui/views/accelerator_table.h" | 120 #include "chrome/browser/ui/views/accelerator_table.h" |
121 #include "ui/aura/event.h" | |
120 #include "ui/gfx/screen.h" | 122 #include "ui/gfx/screen.h" |
121 #endif | 123 #endif |
122 | 124 |
123 #if defined(OS_CHROMEOS) | 125 #if defined(OS_CHROMEOS) |
124 #include "chrome/browser/ui/views/keyboard_overlay_dialog_view.h" | 126 #include "chrome/browser/ui/views/keyboard_overlay_dialog_view.h" |
125 #endif | 127 #endif |
126 | 128 |
127 #if defined(ENABLE_ONE_CLICK_SIGNIN) | 129 #if defined(ENABLE_ONE_CLICK_SIGNIN) |
128 #include "chrome/browser/ui/views/sync/one_click_signin_bubble_view.h" | 130 #include "chrome/browser/ui/views/sync/one_click_signin_bubble_view.h" |
129 #endif | 131 #endif |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
181 ::GetProcAddress(metro, "SetFrameWindow")); | 183 ::GetProcAddress(metro, "SetFrameWindow")); |
182 set_frame_window(frame->GetNativeWindow()); | 184 set_frame_window(frame->GetNativeWindow()); |
183 return true; | 185 return true; |
184 } | 186 } |
185 #else | 187 #else |
186 bool AdjustFrameForImmersiveMode(BrowserFrame* frame) { | 188 bool AdjustFrameForImmersiveMode(BrowserFrame* frame) { |
187 return false; | 189 return false; |
188 } | 190 } |
189 #endif | 191 #endif |
190 | 192 |
193 #if defined(USE_ASH) | |
194 // Do not call this function directly. | |
195 bool ProcessAshAcceleratorInternal(const NativeWebKeyboardEvent& event, | |
Ben Goodger (Google)
2012/05/01 16:00:37
Can we move this back to src/ash?
I don't like ha
Yusuke Sato
2012/05/02 16:40:11
Thanks for the suggestion. Migrated to Ash-only so
| |
196 bool check_only) { | |
197 ui::Accelerator accelerator( | |
198 static_cast<ui::KeyboardCode>(event.windowsKeyCode), | |
199 (event.modifiers & NativeWebKeyboardEvent::ShiftKey) == | |
200 NativeWebKeyboardEvent::ShiftKey, | |
201 (event.modifiers & NativeWebKeyboardEvent::ControlKey) == | |
202 NativeWebKeyboardEvent::ControlKey, | |
203 (event.modifiers & NativeWebKeyboardEvent::AltKey) == | |
204 NativeWebKeyboardEvent::AltKey); | |
205 | |
206 if (event.type == WebKit::WebInputEvent::KeyUp) | |
207 accelerator.set_type(ui::ET_KEY_RELEASED); | |
208 else if (event.type != WebKit::WebInputEvent::RawKeyDown) | |
209 return false; | |
210 | |
211 const aura::KeyEvent* aura_event = | |
212 static_cast<const aura::KeyEvent*>(event.os_event); | |
213 ash::AcceleratorController* accelerator_controller = | |
214 ash::Shell::GetInstance()->accelerator_controller(); | |
215 | |
216 // |aura_event| could be NULL when the keyboard |event| is a fabricated one. | |
217 // See RenderWidgetHostViewAura::OnKeyEvent() for details. | |
218 if (!aura_event || !accelerator_controller) | |
219 return false; | |
220 | |
221 if (check_only && accelerator_controller->IsAccelerator(accelerator)) | |
222 return true; | |
223 if (!check_only && accelerator_controller->Process(accelerator)) | |
224 return true; | |
225 | |
226 return false; | |
227 } | |
228 | |
229 bool ProcessAshAccelerator(const NativeWebKeyboardEvent& event) { | |
230 return ProcessAshAcceleratorInternal(event, false); | |
231 } | |
232 | |
233 bool IsAshAccelerator(const NativeWebKeyboardEvent& event) { | |
234 return ProcessAshAcceleratorInternal(event, true); | |
235 } | |
236 | |
237 #endif | |
238 | |
191 } // namespace | 239 } // namespace |
192 | 240 |
193 // Returned from BrowserView::GetClassName. | 241 // Returned from BrowserView::GetClassName. |
194 const char BrowserView::kViewClassName[] = "browser/ui/views/BrowserView"; | 242 const char BrowserView::kViewClassName[] = "browser/ui/views/BrowserView"; |
195 | 243 |
196 /////////////////////////////////////////////////////////////////////////////// | 244 /////////////////////////////////////////////////////////////////////////////// |
197 // BookmarkExtensionBackground, private: | 245 // BookmarkExtensionBackground, private: |
198 // This object serves as the views::Background object which is used to layout | 246 // This object serves as the views::Background object which is used to layout |
199 // and paint the bookmark bar. | 247 // and paint the bookmark bar. |
200 class BookmarkExtensionBackground : public views::Background { | 248 class BookmarkExtensionBackground : public views::Background { |
(...skipping 982 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1183 const content::SSLStatus& ssl, | 1231 const content::SSLStatus& ssl, |
1184 bool show_history) { | 1232 bool show_history) { |
1185 } | 1233 } |
1186 | 1234 |
1187 void BrowserView::ShowAppMenu() { | 1235 void BrowserView::ShowAppMenu() { |
1188 toolbar_->app_menu()->Activate(); | 1236 toolbar_->app_menu()->Activate(); |
1189 } | 1237 } |
1190 | 1238 |
1191 bool BrowserView::PreHandleKeyboardEvent(const NativeWebKeyboardEvent& event, | 1239 bool BrowserView::PreHandleKeyboardEvent(const NativeWebKeyboardEvent& event, |
1192 bool* is_keyboard_shortcut) { | 1240 bool* is_keyboard_shortcut) { |
1241 #if defined(USE_ASH) | |
1242 if (!browser_->is_app() && ProcessAshAccelerator(event)) | |
1243 return true; | |
1244 if (browser_->is_app() && IsAshAccelerator(event)) { | |
1245 *is_keyboard_shortcut = true; | |
1246 return false; | |
1247 } | |
1248 #endif | |
1249 | |
1193 if (event.type != WebKit::WebInputEvent::RawKeyDown) | 1250 if (event.type != WebKit::WebInputEvent::RawKeyDown) |
1194 return false; | 1251 return false; |
1195 | 1252 |
1196 #if defined(OS_WIN) && !defined(USE_AURA) | 1253 #if defined(OS_WIN) && !defined(USE_AURA) |
1197 // As Alt+F4 is the close-app keyboard shortcut, it needs processing | 1254 // As Alt+F4 is the close-app keyboard shortcut, it needs processing |
1198 // immediately. | 1255 // immediately. |
1199 if (event.windowsKeyCode == ui::VKEY_F4 && | 1256 if (event.windowsKeyCode == ui::VKEY_F4 && |
1200 event.modifiers == NativeWebKeyboardEvent::AltKey) { | 1257 event.modifiers == NativeWebKeyboardEvent::AltKey) { |
1201 DefWindowProc(event.os_event.hwnd, event.os_event.message, | 1258 DefWindowProc(event.os_event.hwnd, event.os_event.message, |
1202 event.os_event.wParam, event.os_event.lParam); | 1259 event.os_event.wParam, event.os_event.lParam); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1245 return browser_->ExecuteCommandIfEnabled(id); | 1302 return browser_->ExecuteCommandIfEnabled(id); |
1246 } | 1303 } |
1247 | 1304 |
1248 DCHECK(is_keyboard_shortcut != NULL); | 1305 DCHECK(is_keyboard_shortcut != NULL); |
1249 *is_keyboard_shortcut = true; | 1306 *is_keyboard_shortcut = true; |
1250 | 1307 |
1251 return false; | 1308 return false; |
1252 } | 1309 } |
1253 | 1310 |
1254 void BrowserView::HandleKeyboardEvent(const NativeWebKeyboardEvent& event) { | 1311 void BrowserView::HandleKeyboardEvent(const NativeWebKeyboardEvent& event) { |
1312 #if defined(USE_ASH) | |
1313 if (browser_->is_app() && ProcessAshAccelerator(event)) | |
1314 return; | |
1315 #endif | |
1255 unhandled_keyboard_event_handler_.HandleKeyboardEvent(event, | 1316 unhandled_keyboard_event_handler_.HandleKeyboardEvent(event, |
1256 GetFocusManager()); | 1317 GetFocusManager()); |
1257 } | 1318 } |
1258 | 1319 |
1259 // TODO(devint): http://b/issue?id=1117225 Cut, Copy, and Paste are always | 1320 // TODO(devint): http://b/issue?id=1117225 Cut, Copy, and Paste are always |
1260 // enabled in the page menu regardless of whether the command will do | 1321 // enabled in the page menu regardless of whether the command will do |
1261 // anything. When someone selects the menu item, we just act as if they hit | 1322 // anything. When someone selects the menu item, we just act as if they hit |
1262 // the keyboard shortcut for the command by sending the associated key press | 1323 // the keyboard shortcut for the command by sending the associated key press |
1263 // to windows. The real fix to this bug is to disable the commands when they | 1324 // to windows. The real fix to this bug is to disable the commands when they |
1264 // won't do anything. We'll need something like an overall clipboard command | 1325 // won't do anything. We'll need something like an overall clipboard command |
(...skipping 1207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2472 return; | 2533 return; |
2473 | 2534 |
2474 PasswordGenerationBubbleView* bubble = | 2535 PasswordGenerationBubbleView* bubble = |
2475 new PasswordGenerationBubbleView(bounds, | 2536 new PasswordGenerationBubbleView(bounds, |
2476 this, | 2537 this, |
2477 web_contents->GetRenderViewHost()); | 2538 web_contents->GetRenderViewHost()); |
2478 views::BubbleDelegateView::CreateBubble(bubble); | 2539 views::BubbleDelegateView::CreateBubble(bubble); |
2479 bubble->SetAlignment(views::BubbleBorder::ALIGN_EDGE_TO_ANCHOR_EDGE); | 2540 bubble->SetAlignment(views::BubbleBorder::ALIGN_EDGE_TO_ANCHOR_EDGE); |
2480 bubble->Show(); | 2541 bubble->Show(); |
2481 } | 2542 } |
OLD | NEW |