OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/html_dialog_view.h" | 5 #include "chrome/browser/ui/views/html_dialog_view.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "chrome/browser/ui/browser_dialogs.h" | 9 #include "chrome/browser/ui/browser_dialogs.h" |
10 #include "chrome/browser/ui/views/window.h" | 10 #include "chrome/browser/ui/views/window.h" |
11 #include "content/browser/tab_contents/tab_contents.h" | 11 #include "content/browser/tab_contents/tab_contents.h" |
12 #include "content/common/native_web_keyboard_event.h" | 12 #include "content/common/native_web_keyboard_event.h" |
13 #include "ui/base/keycodes/keyboard_codes.h" | 13 #include "ui/base/keycodes/keyboard_codes.h" |
| 14 #include "views/events/event.h" |
14 #include "views/widget/root_view.h" | 15 #include "views/widget/root_view.h" |
15 #include "views/widget/widget.h" | 16 #include "views/widget/widget.h" |
16 #include "views/window/window.h" | 17 #include "views/window/window.h" |
17 | 18 |
18 #if defined(OS_LINUX) | 19 #if defined(OS_LINUX) |
19 #include "views/window/window_gtk.h" | 20 #include "views/window/window_gtk.h" |
20 #endif | 21 #endif |
21 | 22 |
22 namespace browser { | 23 namespace browser { |
23 | 24 |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 // We don't handle global keyboard shortcuts here, but that's fine since | 184 // We don't handle global keyboard shortcuts here, but that's fine since |
184 // they're all browser-specific. (This may change in the future.) | 185 // they're all browser-specific. (This may change in the future.) |
185 void HtmlDialogView::HandleKeyboardEvent(const NativeWebKeyboardEvent& event) { | 186 void HtmlDialogView::HandleKeyboardEvent(const NativeWebKeyboardEvent& event) { |
186 #if defined(OS_WIN) | 187 #if defined(OS_WIN) |
187 // Any unhandled keyboard/character messages should be defproced. | 188 // Any unhandled keyboard/character messages should be defproced. |
188 // This allows stuff like F10, etc to work correctly. | 189 // This allows stuff like F10, etc to work correctly. |
189 DefWindowProc(event.os_event.hwnd, event.os_event.message, | 190 DefWindowProc(event.os_event.hwnd, event.os_event.message, |
190 event.os_event.wParam, event.os_event.lParam); | 191 event.os_event.wParam, event.os_event.lParam); |
191 #elif defined(OS_LINUX) | 192 #elif defined(OS_LINUX) |
192 views::WindowGtk* window_gtk = static_cast<views::WindowGtk*>(window()); | 193 views::WindowGtk* window_gtk = static_cast<views::WindowGtk*>(window()); |
193 if (event.os_event && !event.skip_in_browser) | 194 if (event.os_event && !event.skip_in_browser) { |
194 window_gtk->HandleKeyboardEvent(event.os_event); | 195 views::KeyEvent views_event(reinterpret_cast<GdkEvent*>(event.os_event)); |
| 196 window_gtk->HandleKeyboardEvent(views_event); |
| 197 } |
195 #endif | 198 #endif |
196 } | 199 } |
197 | 200 |
198 void HtmlDialogView::CloseContents(TabContents* source) { | 201 void HtmlDialogView::CloseContents(TabContents* source) { |
199 bool close_dialog = false; | 202 bool close_dialog = false; |
200 OnCloseContents(source, &close_dialog); | 203 OnCloseContents(source, &close_dialog); |
201 if (close_dialog) | 204 if (close_dialog) |
202 OnDialogClosed(std::string()); | 205 OnDialogClosed(std::string()); |
203 } | 206 } |
204 | 207 |
205 //////////////////////////////////////////////////////////////////////////////// | 208 //////////////////////////////////////////////////////////////////////////////// |
206 // HtmlDialogView: | 209 // HtmlDialogView: |
207 | 210 |
208 void HtmlDialogView::InitDialog() { | 211 void HtmlDialogView::InitDialog() { |
209 // Now Init the DOMView. This view runs in its own process to render the html. | 212 // Now Init the DOMView. This view runs in its own process to render the html. |
210 DOMView::Init(profile(), NULL); | 213 DOMView::Init(profile(), NULL); |
211 | 214 |
212 tab_contents_->set_delegate(this); | 215 tab_contents_->set_delegate(this); |
213 | 216 |
214 // Set the delegate. This must be done before loading the page. See | 217 // Set the delegate. This must be done before loading the page. See |
215 // the comment above HtmlDialogUI in its header file for why. | 218 // the comment above HtmlDialogUI in its header file for why. |
216 HtmlDialogUI::GetPropertyAccessor().SetProperty(tab_contents_->property_bag(), | 219 HtmlDialogUI::GetPropertyAccessor().SetProperty(tab_contents_->property_bag(), |
217 this); | 220 this); |
218 | 221 |
219 // Pressing the ESC key will close the dialog. | 222 // Pressing the ESC key will close the dialog. |
220 AddAccelerator(views::Accelerator(ui::VKEY_ESCAPE, false, false, false)); | 223 AddAccelerator(views::Accelerator(ui::VKEY_ESCAPE, false, false, false)); |
221 | 224 |
222 DOMView::LoadURL(GetDialogContentURL()); | 225 DOMView::LoadURL(GetDialogContentURL()); |
223 } | 226 } |
OLD | NEW |