| 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 #ifndef COMPONENTS_CONSTRAINED_WINDOW_CONSTRAINED_WINDOW_VIEWS_H_ | 5 #ifndef COMPONENTS_CONSTRAINED_WINDOW_CONSTRAINED_WINDOW_VIEWS_H_ |
| 6 #define COMPONENTS_CONSTRAINED_WINDOW_CONSTRAINED_WINDOW_VIEWS_H_ | 6 #define COMPONENTS_CONSTRAINED_WINDOW_CONSTRAINED_WINDOW_VIEWS_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "ui/base/accelerators/accelerator.h" |
| 10 #include "ui/gfx/native_widget_types.h" | 11 #include "ui/gfx/native_widget_types.h" |
| 11 | 12 |
| 12 namespace content { | 13 namespace content { |
| 13 class WebContents; | 14 class WebContents; |
| 14 } | 15 } |
| 15 | 16 |
| 16 namespace views { | 17 namespace views { |
| 17 class DialogDelegate; | 18 class DialogDelegate; |
| 18 class Widget; | 19 class Widget; |
| 19 class WidgetDelegate; | 20 class WidgetDelegate; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 44 | 45 |
| 45 // Returns the top level WebContents of |initiator_web_contents|. | 46 // Returns the top level WebContents of |initiator_web_contents|. |
| 46 content::WebContents* GetTopLevelWebContents( | 47 content::WebContents* GetTopLevelWebContents( |
| 47 content::WebContents* initiator_web_contents); | 48 content::WebContents* initiator_web_contents); |
| 48 | 49 |
| 49 // Shows the dialog with a new SingleWebContentsDialogManager. The dialog will | 50 // Shows the dialog with a new SingleWebContentsDialogManager. The dialog will |
| 50 // notify via WillClose() when it is being destroyed. | 51 // notify via WillClose() when it is being destroyed. |
| 51 void ShowModalDialog(gfx::NativeWindow dialog, | 52 void ShowModalDialog(gfx::NativeWindow dialog, |
| 52 content::WebContents* web_contents); | 53 content::WebContents* web_contents); |
| 53 | 54 |
| 54 // Calls CreateWebModalDialogViews, shows the dialog, and returns its widget. | 55 // Shows the dialog with a new SingleWebContentsDialogManager as a top level |
| 56 // dialog. The dialog is top level but will not block events to the dialog host |
| 57 // window. The dialog will be a transient child of the host window (Windows) or |
| 58 // of its parent (Linux/CrOS). The dialog will notify via WillClose() when it is |
| 59 // being destroyed. |target| will be attached to the host window as a handler |
| 60 // for accelerators. Note that unlike ShowTopLevelWebModalDialogViews, |dialog| |
| 61 // should already have a widget before this is called. |
| 62 void ShowTopLevelModalDialog(gfx::NativeWindow dialog, |
| 63 content::WebContents* web_contents, |
| 64 ui::AcceleratorTarget *target); |
| 65 |
| 66 // If |dialog| is child modal, calls CreateWebModalDialogViews, shows the |
| 67 // dialog, and returns its widget. If |dialog| is not child modal, create a |
| 68 // widget for |dialog| and show the dialog as a top level dialog without |
| 69 // blocking events to the top level dialog host window for |web_contents|. The |
| 70 // modal type will be the same as that of |dialog|. For Mac, which uses sheets, |
| 71 // this has the same behavior as ShowWebModalDialogViews. If non-null and |
| 72 // if |dialog| is not child modal, |target| will be attached to the host window |
| 73 // as a handler for accelerators. |
| 74 views::Widget* ShowWebModalDialogViews( |
| 75 views::WidgetDelegate* dialog, |
| 76 content::WebContents* initiator_web_contents, |
| 77 ui::AcceleratorTarget* target); |
| 78 |
| 79 // Calls the function above with |target| = nullptr. |dialog| should be child |
| 80 // modal. |
| 55 views::Widget* ShowWebModalDialogViews( | 81 views::Widget* ShowWebModalDialogViews( |
| 56 views::WidgetDelegate* dialog, | 82 views::WidgetDelegate* dialog, |
| 57 content::WebContents* initiator_web_contents); | 83 content::WebContents* initiator_web_contents); |
| 58 | 84 |
| 59 #if defined(OS_MACOSX) | 85 #if defined(OS_MACOSX) |
| 60 // Like ShowWebModalDialogViews, but used to show a native dialog "sheet" on | 86 // Like ShowWebModalDialogViews, but used to show a native dialog "sheet" on |
| 61 // Mac. Sheets are always modal to their parent window. To make them tab-modal, | 87 // Mac. Sheets are always modal to their parent window. To make them tab-modal, |
| 62 // this provides an invisible tab-modal overlay window managed by | 88 // this provides an invisible tab-modal overlay window managed by |
| 63 // WebContentsModalDialogManager, which can host a dialog sheet. | 89 // WebContentsModalDialogManager, which can host a dialog sheet. |
| 64 views::Widget* ShowWebModalDialogWithOverlayViews( | 90 views::Widget* ShowWebModalDialogWithOverlayViews( |
| (...skipping 11 matching lines...) Expand all Loading... |
| 76 // ui::MODAL_TYPE_SYSTEM or ui::MODAL_TYPE_WINDOW. This places the dialog | 102 // ui::MODAL_TYPE_SYSTEM or ui::MODAL_TYPE_WINDOW. This places the dialog |
| 77 // appropriately if |parent| is a valid browser window. Currently, |parent| may | 103 // appropriately if |parent| is a valid browser window. Currently, |parent| may |
| 78 // be null for MODAL_TYPE_WINDOW, but that's a bug and callers shouldn't rely on | 104 // be null for MODAL_TYPE_WINDOW, but that's a bug and callers shouldn't rely on |
| 79 // that working. See http://crbug.com/657293. | 105 // that working. See http://crbug.com/657293. |
| 80 views::Widget* CreateBrowserModalDialogViews(views::DialogDelegate* dialog, | 106 views::Widget* CreateBrowserModalDialogViews(views::DialogDelegate* dialog, |
| 81 gfx::NativeWindow parent); | 107 gfx::NativeWindow parent); |
| 82 | 108 |
| 83 } // namespace constrained_window | 109 } // namespace constrained_window |
| 84 | 110 |
| 85 #endif // COMPONENTS_CONSTRAINED_WINDOW_CONSTRAINED_WINDOW_VIEWS_H_ | 111 #endif // COMPONENTS_CONSTRAINED_WINDOW_CONSTRAINED_WINDOW_VIEWS_H_ |
| OLD | NEW |