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" |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 return std::string(); | 141 return std::string(); |
142 } | 142 } |
143 | 143 |
144 void HtmlDialogView::OnDialogClosed(const std::string& json_retval) { | 144 void HtmlDialogView::OnDialogClosed(const std::string& json_retval) { |
145 HtmlDialogTabContentsDelegate::Detach(); | 145 HtmlDialogTabContentsDelegate::Detach(); |
146 if (delegate_) { | 146 if (delegate_) { |
147 HtmlDialogUIDelegate* dialog_delegate = delegate_; | 147 HtmlDialogUIDelegate* dialog_delegate = delegate_; |
148 delegate_ = NULL; // We will not communicate further with the delegate. | 148 delegate_ = NULL; // We will not communicate further with the delegate. |
149 dialog_delegate->OnDialogClosed(json_retval); | 149 dialog_delegate->OnDialogClosed(json_retval); |
150 } | 150 } |
151 window()->CloseWindow(); | 151 window()->Close(); |
152 } | 152 } |
153 | 153 |
154 void HtmlDialogView::OnWindowClosed() { | 154 void HtmlDialogView::OnWindowClosed() { |
155 if (delegate_) | 155 if (delegate_) |
156 delegate_->OnWindowClosed(); | 156 delegate_->OnWindowClosed(); |
157 } | 157 } |
158 | 158 |
159 void HtmlDialogView::OnCloseContents(TabContents* source, | 159 void HtmlDialogView::OnCloseContents(TabContents* source, |
160 bool* out_close_dialog) { | 160 bool* out_close_dialog) { |
161 if (delegate_) | 161 if (delegate_) |
(...skipping 24 matching lines...) Expand all Loading... |
186 // A simplified version of BrowserView::HandleKeyboardEvent(). | 186 // A simplified version of BrowserView::HandleKeyboardEvent(). |
187 // We don't handle global keyboard shortcuts here, but that's fine since | 187 // We don't handle global keyboard shortcuts here, but that's fine since |
188 // they're all browser-specific. (This may change in the future.) | 188 // they're all browser-specific. (This may change in the future.) |
189 void HtmlDialogView::HandleKeyboardEvent(const NativeWebKeyboardEvent& event) { | 189 void HtmlDialogView::HandleKeyboardEvent(const NativeWebKeyboardEvent& event) { |
190 #if defined(OS_WIN) | 190 #if defined(OS_WIN) |
191 // Any unhandled keyboard/character messages should be defproced. | 191 // Any unhandled keyboard/character messages should be defproced. |
192 // This allows stuff like F10, etc to work correctly. | 192 // This allows stuff like F10, etc to work correctly. |
193 DefWindowProc(event.os_event.hwnd, event.os_event.message, | 193 DefWindowProc(event.os_event.hwnd, event.os_event.message, |
194 event.os_event.wParam, event.os_event.lParam); | 194 event.os_event.wParam, event.os_event.lParam); |
195 #elif defined(TOOLKIT_USES_GTK) | 195 #elif defined(TOOLKIT_USES_GTK) |
196 views::WindowGtk* window_gtk = static_cast<views::WindowGtk*>(window()); | 196 views::WindowGtk* window_gtk = |
| 197 static_cast<views::WindowGtk*>(window()->native_window()); |
197 if (event.os_event && !event.skip_in_browser) { | 198 if (event.os_event && !event.skip_in_browser) { |
198 views::KeyEvent views_event(reinterpret_cast<GdkEvent*>(event.os_event)); | 199 views::KeyEvent views_event(reinterpret_cast<GdkEvent*>(event.os_event)); |
199 window_gtk->HandleKeyboardEvent(views_event); | 200 window_gtk->HandleKeyboardEvent(views_event); |
200 } | 201 } |
201 #endif | 202 #endif |
202 } | 203 } |
203 | 204 |
204 void HtmlDialogView::CloseContents(TabContents* source) { | 205 void HtmlDialogView::CloseContents(TabContents* source) { |
205 bool close_dialog = false; | 206 bool close_dialog = false; |
206 OnCloseContents(source, &close_dialog); | 207 OnCloseContents(source, &close_dialog); |
(...skipping 13 matching lines...) Expand all Loading... |
220 // Set the delegate. This must be done before loading the page. See | 221 // Set the delegate. This must be done before loading the page. See |
221 // the comment above HtmlDialogUI in its header file for why. | 222 // the comment above HtmlDialogUI in its header file for why. |
222 HtmlDialogUI::GetPropertyAccessor().SetProperty(tab_contents_->property_bag(), | 223 HtmlDialogUI::GetPropertyAccessor().SetProperty(tab_contents_->property_bag(), |
223 this); | 224 this); |
224 | 225 |
225 // Pressing the ESC key will close the dialog. | 226 // Pressing the ESC key will close the dialog. |
226 AddAccelerator(views::Accelerator(ui::VKEY_ESCAPE, false, false, false)); | 227 AddAccelerator(views::Accelerator(ui::VKEY_ESCAPE, false, false, false)); |
227 | 228 |
228 DOMView::LoadURL(GetDialogContentURL()); | 229 DOMView::LoadURL(GetDialogContentURL()); |
229 } | 230 } |
OLD | NEW |