File: browser_dialogs.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 (174 lines) | stat: -rw-r--r-- 6,184 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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
// 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 CHROME_BROWSER_UI_BROWSER_DIALOGS_H_
#define CHROME_BROWSER_UI_BROWSER_DIALOGS_H_

#include <map>
#include <memory>
#include <string>
#include <utility>
#include <vector>

#include "base/functional/callback.h"
#include "build/build_config.h"
#include "chrome/browser/task_manager/task_manager_metrics_recorder.h"
#include "chrome/browser/ui/bookmarks/bookmark_editor.h"
#include "components/autofill/core/common/unique_ids.h"
#include "components/compose/buildflags.h"
#include "components/compose/core/browser/compose_client.h"
#include "extensions/buildflags/buildflags.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "third_party/skia/include/core/SkColor.h"
#include "ui/base/interaction/element_identifier.h"
#include "ui/base/models/dialog_model.h"
#include "ui/gfx/geometry/rect_f.h"
#include "ui/gfx/native_widget_types.h"

class Browser;
class Profile;

namespace base {
class FilePath;
}

namespace content {
class BrowserContext;
class RenderFrameHost;
class WebContents;
}  // namespace content

namespace extensions {
class Extension;
}

namespace permissions {
class ChooserController;
enum class PermissionAction;
}  // namespace permissions

namespace task_manager {
class TaskManagerTableModel;
}

namespace ui {
class WebDialogDelegate;
struct SelectedFileInfo;
}  // namespace ui

namespace views {
class Widget;
}  // namespace views

#if BUILDFLAG(ENABLE_COMPOSE)
namespace compose {
class ComposeDialogController;
}  // namespace compose
#endif

namespace chrome {

// Shows or hides the Task Manager. |browser| can be NULL when called from Ash.
// Returns a pointer to the underlying TableModel, which can be ignored, or used
// for testing.
task_manager::TaskManagerTableModel* ShowTaskManager(
    Browser* browser,
    task_manager::StartAction start_action = task_manager::StartAction::kOther);
void HideTaskManager();

// Show `dialog_model` as a modal dialog to `browser`.
views::Widget* ShowBrowserModal(Browser* browser,
                                std::unique_ptr<ui::DialogModel> dialog_model);

// Show `dialog_model` as a bubble anchored to `anchor_element` in `browser`.
// `anchor_element` must refer to an element currently present in `browser`.
// TODO(pbos): Make utility functions for querying whether an anchor_element is
// present in `browser` or `browser_window` and then refer to those here so that
// a call site can provide fallback options for `anchor_element`.
void ShowBubble(ui::ElementContext element_context,
                ui::ElementIdentifier anchor_element,
                std::unique_ptr<ui::DialogModel> dialog_model);

// Shows the create chrome app shortcut dialog box.
// |close_callback| may be null.
void ShowCreateChromeAppShortcutsDialog(
    gfx::NativeWindow parent_window,
    Profile* profile,
    const extensions::Extension* app,
    base::OnceCallback<void(bool /* created */)> close_callback);

// Shows the create chrome app shortcut dialog box. Same as above but for a
// WebApp instead of an Extension. |close_callback| may be null.
void ShowCreateChromeAppShortcutsDialog(
    gfx::NativeWindow parent_window,
    Profile* profile,
    const std::string& web_app_id,
    base::OnceCallback<void(bool /* created */)> close_callback);

// Shows a tab modal dialog based on `dialog_model`.
// Please use tabs::TabDialogManager for showing dialogs on desktop platforms.
void ShowTabModal(std::unique_ptr<ui::DialogModel> dialog_model,
                  content::WebContents* web_contents);

// Creates and shows an HTML dialog with the given delegate and context.
// The window is automatically destroyed when it is closed.
// Returns the created window.
//
// Make sure to use the returned window only when you know it is safe
// to do so, i.e. before OnDialogClosed() is called on the delegate.
//
// Please use tabs::TabDialogManager for showing dialogs on desktop platforms.
gfx::NativeWindow ShowWebDialog(gfx::NativeView parent,
                                content::BrowserContext* context,
                                ui::WebDialogDelegate* delegate,
                                bool show = true);

#if BUILDFLAG(IS_MAC)

// Bridging methods that show/hide the toolkit-views based Task Manager on Mac.
task_manager::TaskManagerTableModel* ShowTaskManagerViews(
    Browser* browser,
    task_manager::StartAction start_action = task_manager::StartAction::kOther);
void HideTaskManagerViews();

#endif  // BUILDFLAG(IS_MAC)

// Returns a OnceClosure that client code can call to close the device chooser.
// This OnceClosure references the actual dialog as a WeakPtr, so it's safe to
// call at any point.
#if defined(TOOLKIT_VIEWS)
base::OnceClosure ShowDeviceChooserDialog(
    content::RenderFrameHost* owner,
    std::unique_ptr<permissions::ChooserController> controller);
bool IsDeviceChooserShowingForTesting(Browser* browser);
#endif

// Show the prompt to set a window name for browser's window, optionally with
// the given context.
void ShowWindowNamePrompt(Browser* browser);
std::unique_ptr<ui::DialogModel> CreateWindowNamePromptDialogModelForTesting(
    Browser* browser);

#if BUILDFLAG(ENABLE_COMPOSE)
std::unique_ptr<compose::ComposeDialogController> ShowComposeDialog(
    content::WebContents& web_contents,
    const gfx::RectF& element_bounds_in_screen,
    compose::ComposeClient::FieldIdentifier field_ids);
#endif

// Shows the 'Create Shortcut' dialog to create fire and forget entities on the
// desktop of the OS. Before the dialog is shown, the necessary metadata is
// gathered from the browser's active WebContents.
// Triggered from the three-dot menu on Chrome, Save & Share > Create Shortcut.
void CreateDesktopShortcutForActiveWebContents(Browser* browser);

}  // namespace chrome

void ShowFolderUploadConfirmationDialog(
    const base::FilePath& path,
    base::OnceCallback<void(const std::vector<ui::SelectedFileInfo>&)> callback,
    std::vector<ui::SelectedFileInfo> selected_files,
    content::WebContents* web_contents);

#endif  // CHROME_BROWSER_UI_BROWSER_DIALOGS_H_