File: constrained_window_views.h

package info (click to toggle)
chromium 139.0.7258.127-1
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 6,122,068 kB
  • sloc: cpp: 35,100,771; ansic: 7,163,530; javascript: 4,103,002; python: 1,436,920; asm: 946,517; xml: 746,709; pascal: 187,653; perl: 88,691; sh: 88,436; objc: 79,953; sql: 51,488; cs: 44,583; fortran: 24,137; makefile: 22,147; tcl: 15,277; php: 13,980; yacc: 8,984; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (129 lines) | stat: -rw-r--r-- 5,216 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
// Copyright 2012 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef COMPONENTS_CONSTRAINED_WINDOW_CONSTRAINED_WINDOW_VIEWS_H_
#define COMPONENTS_CONSTRAINED_WINDOW_CONSTRAINED_WINDOW_VIEWS_H_

#include <memory>

#include "build/build_config.h"
#include "ui/gfx/native_widget_types.h"
#include "ui/views/widget/widget.h"

namespace content {
class WebContents;
}

namespace ui {
class DialogModel;
}

namespace views {
class DialogDelegate;
class WidgetDelegate;
}  // namespace views

namespace web_modal {
class ModalDialogHost;
class WebContentsModalDialogHost;
}  // namespace web_modal

namespace constrained_window {

extern const void* kConstrainedWindowWidgetIdentifier;

class ConstrainedWindowViewsClient;

// -- Helper functions for showing web modals.
// -- Please use tabs::TabDialogManager on desktop platforms.

// Shows the dialog with a new SingleWebContentsDialogManager. The dialog will
// notify via WillClose() when it is being destroyed.
// Please use tabs::TabDialogManager on desktop platforms.
void ShowModalDialog(gfx::NativeWindow dialog,
                     content::WebContents* web_contents);

// Calls CreateWebModalDialogViews, shows the dialog, and returns its widget.
// Please use tabs::TabDialogManager on desktop platforms.
views::Widget* ShowWebModalDialogViews(
    views::WidgetDelegate* dialog,
    content::WebContents* initiator_web_contents);

// As above, but with an owned widget.
// Please use tabs::TabDialogManager on desktop platforms.
std::unique_ptr<views::Widget> ShowWebModalDialogViewsOwned(
    views::WidgetDelegate* dialog,
    content::WebContents* initiator_web_contents,
    views::Widget::InitParams::Ownership expected_ownership);

// Create a widget for |dialog| that is modal to |web_contents|.
// The modal type of |dialog->GetModalType()| must be
// ui::mojom::ModalType::kChild.
// Please use tabs::TabDialogManager on desktop platforms.
views::Widget* CreateWebModalDialogViews(views::WidgetDelegate* dialog,
                                         content::WebContents* web_contents);

// Shows a web/tab-modal dialog based on `dialog_model` and returns its widget.
// Please use tabs::TabDialogManager on desktop platforms.
views::Widget* ShowWebModal(std::unique_ptr<ui::DialogModel> dialog_model,
                            content::WebContents* web_contents);

// -- Helper function for showing browser modals.

// Create a widget for |dialog| that has a modality given by
// |dialog->GetModalType()|.  The modal type must be either
// ui::mojom::ModalType::kSystem or ui::mojom::ModalType::kWindow.  This places
// the dialog appropriately if |parent| is a valid browser window. Currently,
// |parent| may be null for MODAL_TYPE_WINDOW, but that's a bug and callers
// shouldn't rely on that working. See http://crbug.com/657293. Instead of
// calling this function with null |parent| and MODAL_TYPE_WINDOW, consider
// calling views:: DialogDelegate::CreateDialogWidget(dialog, nullptr, nullptr)
// instead. For dialogs that may appear without direct user interaction (i.e.,
// that may appear while a user is busily accomplishing some other task in the
// browser), consider providing an override of GetDefaultDialogButton on
// |dialog| to suppress the normal behavior of choosing a focused-by-default
// button. This is especially important if the action of the default button has
// consequences on the user's task at hand.
views::Widget* CreateBrowserModalDialogViews(
    std::unique_ptr<views::DialogDelegate> dialog,
    gfx::NativeWindow parent);

// TODO(pbos): Transition calls to this to the unique_ptr<> version above.
views::Widget* CreateBrowserModalDialogViews(views::DialogDelegate* dialog,
                                             gfx::NativeWindow parent);

// Shows a browser-modal dialog based on `dialog_model`, returns pointer
// to the created widget.
views::Widget* ShowBrowserModal(std::unique_ptr<ui::DialogModel> dialog_model,
                                gfx::NativeWindow parent);

// -- Other utility functions.

// Sets the ConstrainedWindowClient impl.
void SetConstrainedWindowViewsClient(
    std::unique_ptr<ConstrainedWindowViewsClient> client);

// Update the position of dialog |widget| against |dialog_host|. This is used to
// reposition widgets e.g. when the host dimensions change.
void UpdateWebContentsModalDialogPosition(
    views::Widget* widget,
    web_modal::WebContentsModalDialogHost* dialog_host);

void UpdateWidgetModalDialogPosition(views::Widget* widget,
                                     web_modal::ModalDialogHost* dialog_host);

// Returns the top level WebContents of |initiator_web_contents|.
content::WebContents* GetTopLevelWebContents(
    content::WebContents* initiator_web_contents);

// True if the platform supports global screen coordinates. This is typically
// supported by most platforms except linux-wayland.
bool SupportsGlobalScreenCoordinates();

// True if the platform clips child widgets to their parent's viewport.
bool PlatformClipsChildrenToViewport();

}  // namespace constrained_window

#endif  // COMPONENTS_CONSTRAINED_WINDOW_CONSTRAINED_WINDOW_VIEWS_H_