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 "ui/views/controls/webview/web_dialog_view.h" | 5 #include "ui/views/controls/webview/web_dialog_view.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/property_bag.h" | 9 #include "base/property_bag.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
11 #include "content/public/browser/browser_context.h" | 11 #include "content/public/browser/browser_context.h" |
12 #include "content/public/browser/native_web_keyboard_event.h" | 12 #include "content/public/browser/native_web_keyboard_event.h" |
13 #include "content/public/browser/notification_details.h" | 13 #include "content/public/browser/notification_details.h" |
14 #include "content/public/browser/notification_source.h" | 14 #include "content/public/browser/notification_source.h" |
15 #include "content/public/browser/notification_types.h" | 15 #include "content/public/browser/notification_types.h" |
16 #include "content/public/browser/web_contents.h" | 16 #include "content/public/browser/web_contents.h" |
17 #include "ui/base/keycodes/keyboard_codes.h" | 17 #include "ui/base/keycodes/keyboard_codes.h" |
18 #include "ui/views/controls/webview/webview.h" | 18 #include "ui/views/controls/webview/webview.h" |
19 #include "ui/views/events/event.h" | 19 #include "ui/views/events/event.h" |
20 #include "ui/views/layout/fill_layout.h" | 20 #include "ui/views/layout/fill_layout.h" |
21 #include "ui/views/widget/root_view.h" | 21 #include "ui/views/widget/root_view.h" |
22 #include "ui/views/widget/widget.h" | 22 #include "ui/views/widget/widget.h" |
23 #include "ui/web_dialogs/web_dialog_delegate.h" | 23 #include "ui/web_dialogs/web_dialog_delegate.h" |
24 #include "ui/web_dialogs/web_dialog_ui.h" | 24 #include "ui/web_dialogs/web_dialog_ui.h" |
25 | 25 |
26 #if defined(USE_AURA) | 26 #if defined(USE_AURA) |
27 #include "ui/aura/event.h" | 27 #include "ui/base/event.h" |
28 #include "ui/views/widget/native_widget_aura.h" | 28 #include "ui/views/widget/native_widget_aura.h" |
29 #endif | 29 #endif |
30 | 30 |
31 using content::NativeWebKeyboardEvent; | 31 using content::NativeWebKeyboardEvent; |
32 using content::WebContents; | 32 using content::WebContents; |
33 using content::WebUIMessageHandler; | 33 using content::WebUIMessageHandler; |
34 using ui::WebDialogDelegate; | 34 using ui::WebDialogDelegate; |
35 using ui::WebDialogUI; | 35 using ui::WebDialogUI; |
36 using ui::WebDialogWebContentsDelegate; | 36 using ui::WebDialogWebContentsDelegate; |
37 | 37 |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 // if it's a dialog we know about, we trust it not to be mean to the user. | 242 // if it's a dialog we know about, we trust it not to be mean to the user. |
243 GetWidget()->SetBounds(pos); | 243 GetWidget()->SetBounds(pos); |
244 } | 244 } |
245 | 245 |
246 // A simplified version of BrowserView::HandleKeyboardEvent(). | 246 // A simplified version of BrowserView::HandleKeyboardEvent(). |
247 // We don't handle global keyboard shortcuts here, but that's fine since | 247 // We don't handle global keyboard shortcuts here, but that's fine since |
248 // they're all browser-specific. (This may change in the future.) | 248 // they're all browser-specific. (This may change in the future.) |
249 void WebDialogView::HandleKeyboardEvent(content::WebContents* source, | 249 void WebDialogView::HandleKeyboardEvent(content::WebContents* source, |
250 const NativeWebKeyboardEvent& event) { | 250 const NativeWebKeyboardEvent& event) { |
251 #if defined(USE_AURA) | 251 #if defined(USE_AURA) |
252 aura::KeyEvent aura_event(event.os_event->native_event(), false); | 252 ui::KeyEvent aura_event(event.os_event->native_event(), false); |
253 views::NativeWidgetAura* aura_widget = | 253 views::NativeWidgetAura* aura_widget = |
254 static_cast<views::NativeWidgetAura*>(GetWidget()->native_widget()); | 254 static_cast<views::NativeWidgetAura*>(GetWidget()->native_widget()); |
255 aura_widget->OnKeyEvent(&aura_event); | 255 aura_widget->OnKeyEvent(&aura_event); |
256 #elif defined(OS_WIN) | 256 #elif defined(OS_WIN) |
257 // Any unhandled keyboard/character messages should be defproced. | 257 // Any unhandled keyboard/character messages should be defproced. |
258 // This allows stuff like F10, etc to work correctly. | 258 // This allows stuff like F10, etc to work correctly. |
259 DefWindowProc(event.os_event.hwnd, event.os_event.message, | 259 DefWindowProc(event.os_event.hwnd, event.os_event.message, |
260 event.os_event.wParam, event.os_event.lParam); | 260 event.os_event.wParam, event.os_event.lParam); |
261 #endif | 261 #endif |
262 } | 262 } |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
316 gfx::Size out; | 316 gfx::Size out; |
317 delegate_->GetDialogSize(&out); | 317 delegate_->GetDialogSize(&out); |
318 if (!out.IsEmpty() && GetWidget()) | 318 if (!out.IsEmpty() && GetWidget()) |
319 GetWidget()->CenterWindow(out); | 319 GetWidget()->CenterWindow(out); |
320 } | 320 } |
321 | 321 |
322 web_view_->LoadInitialURL(GetDialogContentURL()); | 322 web_view_->LoadInitialURL(GetDialogContentURL()); |
323 } | 323 } |
324 | 324 |
325 } // namespace views | 325 } // namespace views |
OLD | NEW |