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/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "content/public/browser/browser_context.h" | 10 #include "content/public/browser/browser_context.h" |
11 #include "content/public/browser/native_web_keyboard_event.h" | 11 #include "content/public/browser/native_web_keyboard_event.h" |
12 #include "content/public/browser/notification_details.h" | 12 #include "content/public/browser/notification_details.h" |
13 #include "content/public/browser/notification_source.h" | 13 #include "content/public/browser/notification_source.h" |
14 #include "content/public/browser/notification_types.h" | 14 #include "content/public/browser/notification_types.h" |
15 #include "content/public/browser/render_frame_host.h" | 15 #include "content/public/browser/render_frame_host.h" |
16 #include "content/public/browser/web_contents.h" | 16 #include "content/public/browser/web_contents.h" |
17 #include "ui/events/event.h" | 17 #include "ui/events/event.h" |
18 #include "ui/events/keycodes/keyboard_codes.h" | 18 #include "ui/events/keycodes/keyboard_codes.h" |
19 #include "ui/views/controls/webview/webview.h" | 19 #include "ui/views/controls/webview/webview.h" |
20 #include "ui/views/layout/fill_layout.h" | 20 #include "ui/views/layout/fill_layout.h" |
21 #include "ui/views/widget/native_widget_aura.h" | 21 #include "ui/views/widget/native_widget_private.h" |
22 #include "ui/views/widget/root_view.h" | 22 #include "ui/views/widget/root_view.h" |
23 #include "ui/views/widget/widget.h" | 23 #include "ui/views/widget/widget.h" |
24 #include "ui/web_dialogs/web_dialog_delegate.h" | 24 #include "ui/web_dialogs/web_dialog_delegate.h" |
25 #include "ui/web_dialogs/web_dialog_ui.h" | 25 #include "ui/web_dialogs/web_dialog_ui.h" |
26 | 26 |
27 using content::NativeWebKeyboardEvent; | 27 using content::NativeWebKeyboardEvent; |
28 using content::WebContents; | 28 using content::WebContents; |
29 using content::WebUIMessageHandler; | 29 using content::WebUIMessageHandler; |
30 using ui::WebDialogDelegate; | 30 using ui::WebDialogDelegate; |
31 using ui::WebDialogUI; | 31 using ui::WebDialogUI; |
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 GetWidget()->SetBounds(pos); | 273 GetWidget()->SetBounds(pos); |
274 } | 274 } |
275 | 275 |
276 // A simplified version of BrowserView::HandleKeyboardEvent(). | 276 // A simplified version of BrowserView::HandleKeyboardEvent(). |
277 // We don't handle global keyboard shortcuts here, but that's fine since | 277 // We don't handle global keyboard shortcuts here, but that's fine since |
278 // they're all browser-specific. (This may change in the future.) | 278 // they're all browser-specific. (This may change in the future.) |
279 void WebDialogView::HandleKeyboardEvent(content::WebContents* source, | 279 void WebDialogView::HandleKeyboardEvent(content::WebContents* source, |
280 const NativeWebKeyboardEvent& event) { | 280 const NativeWebKeyboardEvent& event) { |
281 if (!event.os_event) | 281 if (!event.os_event) |
282 return; | 282 return; |
283 ui::KeyEvent aura_event(event.os_event->native_event(), false); | |
284 ui::EventHandler* event_handler = | |
285 GetWidget()->native_widget()->GetEventHandler(); | |
286 | 283 |
287 DCHECK(event_handler); | 284 GetWidget()->native_widget_private()->RepostNativeEvent(event.os_event); |
288 if (event_handler) | |
289 event_handler->OnKeyEvent(&aura_event); | |
290 | |
291 } | 285 } |
292 | 286 |
293 void WebDialogView::CloseContents(WebContents* source) { | 287 void WebDialogView::CloseContents(WebContents* source) { |
294 close_contents_called_ = true; | 288 close_contents_called_ = true; |
295 bool close_dialog = false; | 289 bool close_dialog = false; |
296 OnCloseContents(source, &close_dialog); | 290 OnCloseContents(source, &close_dialog); |
297 if (close_dialog) | 291 if (close_dialog) |
298 OnDialogClosed(closed_via_webui_ ? dialog_close_retval_ : std::string()); | 292 OnDialogClosed(closed_via_webui_ ? dialog_close_retval_ : std::string()); |
299 } | 293 } |
300 | 294 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
348 web_contents->SetDelegate(this); | 342 web_contents->SetDelegate(this); |
349 | 343 |
350 // Set the delegate. This must be done before loading the page. See | 344 // Set the delegate. This must be done before loading the page. See |
351 // the comment above WebDialogUI in its header file for why. | 345 // the comment above WebDialogUI in its header file for why. |
352 WebDialogUI::SetDelegate(web_contents, this); | 346 WebDialogUI::SetDelegate(web_contents, this); |
353 | 347 |
354 web_view_->LoadInitialURL(GetDialogContentURL()); | 348 web_view_->LoadInitialURL(GetDialogContentURL()); |
355 } | 349 } |
356 | 350 |
357 } // namespace views | 351 } // namespace views |
OLD | NEW |