blob: 1ac16d7b6766090e054936a540774ccf2515078b [file] [log] [blame]
Avi Drissman4a8573c2022-09-09 19:35:541// Copyright 2012 The Chromium Authors
[email protected]c96531e82011-01-26 03:11:142// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef CHROME_BROWSER_UI_BROWSER_DIALOGS_H_
6#define CHROME_BROWSER_UI_BROWSER_DIALOGS_H_
[email protected]c96531e82011-01-26 03:11:147
Dibyajyoti Palc8f07802023-07-21 22:37:338#include <map>
David Benjamin78fe5962019-01-29 22:22:389#include <memory>
djacobo21e56e02016-07-02 01:14:3110#include <string>
11#include <utility>
12#include <vector>
13
Avi Drissman9269d4ed2023-01-07 01:38:0614#include "base/functional/callback.h"
avi655876a2015-12-25 07:18:1515#include "build/build_config.h"
Yuta Hijikata40b891d2020-11-27 09:05:0116#include "build/chromeos_buildflags.h"
jackhoub42a1f3d2015-08-24 05:53:2817#include "chrome/browser/ui/bookmarks/bookmark_editor.h"
Anthony Cui4cf24372023-10-13 19:44:0618#include "components/compose/buildflags.h"
Devlin Cronin5739bf02020-05-15 00:38:3819#include "extensions/buildflags/buildflags.h"
Dibyajyoti Palc8f07802023-07-21 22:37:3320#include "third_party/skia/include/core/SkBitmap.h"
[email protected]cb805452013-05-22 15:16:2121#include "third_party/skia/include/core/SkColor.h"
Peter Boström9a697f9b2021-10-15 23:27:5622#include "ui/base/interaction/element_identifier.h"
Peter Boström0b91d43c2021-10-13 00:57:4523#include "ui/base/models/dialog_model.h"
Anthony Cui4cf24372023-10-13 19:44:0624#include "ui/gfx/geometry/rect_f.h"
[email protected]08397d52011-02-05 01:53:3825#include "ui/gfx/native_widget_types.h"
[email protected]c96531e82011-01-26 03:11:1426
[email protected]c60e2482011-02-11 23:46:3227class Browser;
[email protected]6684dc8162013-06-03 14:05:0828class Profile;
[email protected]eb2d7902011-02-02 18:19:5629
Peter Boström2a02a692018-02-22 22:25:4630namespace base {
31class FilePath;
32}
33
[email protected]2a6bc3e2011-12-28 23:51:3334namespace content {
[email protected]6ae4f142012-06-13 19:48:2035class BrowserContext;
Elly Fong-Jonesfda0aa32021-07-20 22:13:1436class RenderFrameHost;
[email protected]2a6bc3e2011-12-28 23:51:3337class WebContents;
Josh Prattf80ffb82019-01-22 07:13:5138} // namespace content
[email protected]2a6bc3e2011-12-28 23:51:3339
[email protected]1c321ee2012-05-21 03:02:3440namespace extensions {
41class Extension;
42}
43
Clark DuVall732778e2020-01-27 18:13:5844namespace permissions {
Michael van Ouwerkerk12553e22021-05-17 14:20:5845class ChooserController;
Clark DuVall732778e2020-01-27 18:13:5846enum class PermissionAction;
Andrew Rayskiy62ec31a2022-01-24 12:48:3847} // namespace permissions
Clark DuVall732778e2020-01-27 18:13:5848
avi24d693f2016-08-06 18:03:5249namespace task_manager {
nickbb57d2ca2016-07-25 23:08:0450class TaskManagerTableModel;
51}
52
[email protected]20c07f8e2012-05-31 08:43:1453namespace ui {
54class WebDialogDelegate;
Peter Boström2a02a692018-02-22 22:25:4655struct SelectedFileInfo;
Josh Prattf80ffb82019-01-22 07:13:5156} // namespace ui
[email protected]20c07f8e2012-05-31 08:43:1457
Zonghan Xu55320882023-05-09 15:09:4058namespace views {
59class Widget;
60} // namespace views
61
Justin DeWitta5e6ac1e2023-10-19 21:35:0462#if BUILDFLAG(ENABLE_COMPOSE)
63namespace compose {
64class ComposeDialogController;
65} // namespace compose
66#endif
67
[email protected]87586fb72012-07-02 13:15:0268namespace chrome {
[email protected]c96531e82011-01-26 03:11:1469
taptede0eec372016-01-28 02:45:3370// Shows or hides the Task Manager. |browser| can be NULL when called from Ash.
nick399f10662016-05-06 16:20:2671// Returns a pointer to the underlying TableModel, which can be ignored, or used
72// for testing.
avi24d693f2016-08-06 18:03:5273task_manager::TaskManagerTableModel* ShowTaskManager(Browser* browser);
taptede0eec372016-01-28 02:45:3374void HideTaskManager();
75
[email protected]d7db4cd2012-06-27 04:58:4476// Creates and shows an HTML dialog with the given delegate and context.
77// The window is automatically destroyed when it is closed.
[email protected]eb2d7902011-02-02 18:19:5678// Returns the created window.
79//
80// Make sure to use the returned window only when you know it is safe
81// to do so, i.e. before OnDialogClosed() is called on the delegate.
andresantosoba3ef5d72014-12-15 20:30:0882gfx::NativeWindow ShowWebDialog(gfx::NativeView parent,
[email protected]6ae4f142012-06-13 19:48:2083 content::BrowserContext* context,
Xiangdong Kong10ae9f92021-03-23 23:15:1084 ui::WebDialogDelegate* delegate,
85 bool show = true);
[email protected]eb2d7902011-02-02 18:19:5686
Peter Boström0b91d43c2021-10-13 00:57:4587// Show `dialog_model` as a modal dialog to `browser`.
Zonghan Xu55320882023-05-09 15:09:4088views::Widget* ShowBrowserModal(Browser* browser,
89 std::unique_ptr<ui::DialogModel> dialog_model);
Peter Boström0b91d43c2021-10-13 00:57:4590
Peter Boström9a697f9b2021-10-15 23:27:5691// Show `dialog_model` as a bubble anchored to `anchor_element` in `browser`.
92// `anchor_element` must refer to an element currently present in `browser`.
93// TODO(pbos): Make utility functions for querying whether an anchor_element is
94// present in `browser` or `browser_window` and then refer to those here so that
95// a call site can provide fallback options for `anchor_element`.
96void ShowBubble(Browser* browser,
97 ui::ElementIdentifier anchor_element,
98 std::unique_ptr<ui::DialogModel> dialog_model);
99
[email protected]497783c2013-10-17 15:54:57100// Shows the create chrome app shortcut dialog box.
[email protected]497783c2013-10-17 15:54:57101// |close_callback| may be null.
[email protected]1148990bb2014-05-02 10:04:02102void ShowCreateChromeAppShortcutsDialog(
103 gfx::NativeWindow parent_window,
104 Profile* profile,
105 const extensions::Extension* app,
Ella Gec279a6f2021-01-06 07:47:24106 base::OnceCallback<void(bool /* created */)> close_callback);
[email protected]497783c2013-10-17 15:54:57107
Daniel Murphy8e600e582020-04-09 21:41:57108// Shows the create chrome app shortcut dialog box. Same as above but for a
109// WebApp instead of an Extension. |close_callback| may be null.
110void ShowCreateChromeAppShortcutsDialog(
111 gfx::NativeWindow parent_window,
112 Profile* profile,
113 const std::string& web_app_id,
Ella Gec279a6f2021-01-06 07:47:24114 base::OnceCallback<void(bool /* created */)> close_callback);
Daniel Murphy8e600e582020-04-09 21:41:57115
Xiaohan Wange9439fd2022-01-18 21:00:31116#if BUILDFLAG(IS_MAC)
tapted081286e2015-08-10 06:36:30117
spqchand33344a2016-04-13 02:10:51118// Bridging methods that show/hide the toolkit-views based Task Manager on Mac.
avi24d693f2016-08-06 18:03:52119task_manager::TaskManagerTableModel* ShowTaskManagerViews(Browser* browser);
spqchand33344a2016-04-13 02:10:51120void HideTaskManagerViews();
121
Xiaohan Wange9439fd2022-01-18 21:00:31122#endif // BUILDFLAG(IS_MAC)
tapted081286e2015-08-10 06:36:30123
Elly Fong-Jonesf260d672020-03-16 14:09:07124// Returns a OnceClosure that client code can call to close the device chooser.
125// This OnceClosure references the actual dialog as a WeakPtr, so it's safe to
126// call at any point.
Reid Kleckner4d3f21c2021-01-25 22:48:31127#if defined(TOOLKIT_VIEWS)
Elly Fong-Jonesf260d672020-03-16 14:09:07128base::OnceClosure ShowDeviceChooserDialog(
129 content::RenderFrameHost* owner,
Michael van Ouwerkerk12553e22021-05-17 14:20:58130 std::unique_ptr<permissions::ChooserController> controller);
Guido Urdanetaaf871dc2020-04-16 06:53:20131bool IsDeviceChooserShowingForTesting(Browser* browser);
Reid Kleckner4d3f21c2021-01-25 22:48:31132#endif
Elly Fong-Jonesf260d672020-03-16 14:09:07133
Elly Fong-Jones32ead50d2020-09-26 01:19:11134// Show the prompt to set a window name for browser's window, optionally with
135// the given context.
136void ShowWindowNamePrompt(Browser* browser);
Peter Boström0b91d43c2021-10-13 00:57:45137std::unique_ptr<ui::DialogModel> CreateWindowNamePromptDialogModelForTesting(
138 Browser* browser);
Elly Fong-Jones32ead50d2020-09-26 01:19:11139
Anthony Cui4cf24372023-10-13 19:44:06140#if BUILDFLAG(ENABLE_COMPOSE)
Justin DeWitta5e6ac1e2023-10-19 21:35:04141std::unique_ptr<compose::ComposeDialogController> ShowComposeDialog(
142 content::WebContents& web_contents,
143 const gfx::RectF& element_bounds_in_screen);
Anthony Cui4cf24372023-10-13 19:44:06144#endif
145
[email protected]87586fb72012-07-02 13:15:02146} // namespace chrome
[email protected]c96531e82011-01-26 03:11:14147
Peter Boström2a02a692018-02-22 22:25:46148void ShowFolderUploadConfirmationDialog(
149 const base::FilePath& path,
150 base::OnceCallback<void(const std::vector<ui::SelectedFileInfo>&)> callback,
151 std::vector<ui::SelectedFileInfo> selected_files,
152 content::WebContents* web_contents);
153
[email protected]c96531e82011-01-26 03:11:14154#endif // CHROME_BROWSER_UI_BROWSER_DIALOGS_H_