| 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 "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 10 #include "chrome/browser/profiles/profile.h" |
| 10 #include "chrome/browser/ui/browser_dialogs.h" | 11 #include "chrome/browser/ui/browser_dialogs.h" |
| 11 #include "chrome/browser/ui/views/window.h" | 12 #include "chrome/browser/ui/views/window.h" |
| 12 #include "content/browser/tab_contents/tab_contents.h" | 13 #include "content/browser/tab_contents/tab_contents.h" |
| 13 #include "content/public/browser/native_web_keyboard_event.h" | 14 #include "content/public/browser/native_web_keyboard_event.h" |
| 14 #include "content/public/browser/notification_details.h" | 15 #include "content/public/browser/notification_details.h" |
| 15 #include "content/public/browser/notification_source.h" | 16 #include "content/public/browser/notification_source.h" |
| 16 #include "content/public/browser/notification_types.h" | 17 #include "content/public/browser/notification_types.h" |
| 17 #include "ui/base/keycodes/keyboard_codes.h" | 18 #include "ui/base/keycodes/keyboard_codes.h" |
| 18 #include "views/events/event.h" | 19 #include "views/events/event.h" |
| 19 #include "views/widget/root_view.h" | 20 #include "views/widget/root_view.h" |
| 20 #include "views/widget/widget.h" | 21 #include "views/widget/widget.h" |
| 21 | 22 |
| 22 #if defined(TOOLKIT_USES_GTK) | 23 #if defined(TOOLKIT_USES_GTK) |
| 23 #include "views/widget/native_widget_gtk.h" | 24 #include "views/widget/native_widget_gtk.h" |
| 24 #endif | 25 #endif |
| 25 | 26 |
| 26 class RenderWidgetHost; | 27 class RenderWidgetHost; |
| 27 | 28 |
| 28 namespace browser { | 29 namespace browser { |
| 29 | 30 |
| 30 // Declared in browser_dialogs.h so that others don't need to depend on our .h. | 31 // Declared in browser_dialogs.h so that others don't need to depend on our .h. |
| 31 gfx::NativeWindow ShowHtmlDialog(gfx::NativeWindow parent, | 32 gfx::NativeWindow ShowHtmlDialog(gfx::NativeWindow parent, |
| 32 Profile* profile, | 33 Profile* profile, |
| 33 HtmlDialogUIDelegate* delegate) { | 34 HtmlDialogUIDelegate* delegate) { |
| 35 // It's not always safe to display an html dialog with an off the record |
| 36 // profile. If the last browser with that profile is closed it will go |
| 37 // away. |
| 38 DCHECK(!profile->IsOffTheRecord() || delegate->IsDialogModal()); |
| 34 HtmlDialogView* html_view = new HtmlDialogView(profile, delegate); | 39 HtmlDialogView* html_view = new HtmlDialogView(profile, delegate); |
| 35 browser::CreateViewsWindow(parent, html_view); | 40 browser::CreateViewsWindow(parent, html_view); |
| 36 html_view->InitDialog(); | 41 html_view->InitDialog(); |
| 37 html_view->GetWidget()->Show(); | 42 html_view->GetWidget()->Show(); |
| 38 return html_view->GetWidget()->GetNativeWindow(); | 43 return html_view->GetWidget()->GetNativeWindow(); |
| 39 } | 44 } |
| 40 | 45 |
| 41 } // namespace browser | 46 } // namespace browser |
| 42 | 47 |
| 43 //////////////////////////////////////////////////////////////////////////////// | 48 //////////////////////////////////////////////////////////////////////////////// |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 284 break; | 289 break; |
| 285 default: | 290 default: |
| 286 NOTREACHED() << "unknown type" << type; | 291 NOTREACHED() << "unknown type" << type; |
| 287 } | 292 } |
| 288 } | 293 } |
| 289 | 294 |
| 290 void HtmlDialogView::RegisterDialogAccelerators() { | 295 void HtmlDialogView::RegisterDialogAccelerators() { |
| 291 // Pressing the ESC key will close the dialog. | 296 // Pressing the ESC key will close the dialog. |
| 292 AddAccelerator(views::Accelerator(ui::VKEY_ESCAPE, false, false, false)); | 297 AddAccelerator(views::Accelerator(ui::VKEY_ESCAPE, false, false, false)); |
| 293 } | 298 } |
| OLD | NEW |