Avi Drissman | 4a8573c | 2022-09-09 19:35:54 | [diff] [blame] | 1 | // Copyright 2012 The Chromium Authors |
[email protected] | c96531e8 | 2011-01-26 03:11:14 | [diff] [blame] | 2 | // 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] | c96531e8 | 2011-01-26 03:11:14 | [diff] [blame] | 7 | |
Dibyajyoti Pal | c8f0780 | 2023-07-21 22:37:33 | [diff] [blame] | 8 | #include <map> |
David Benjamin | 78fe596 | 2019-01-29 22:22:38 | [diff] [blame] | 9 | #include <memory> |
djacobo | 21e56e0 | 2016-07-02 01:14:31 | [diff] [blame] | 10 | #include <string> |
| 11 | #include <utility> |
| 12 | #include <vector> |
| 13 | |
Avi Drissman | 9269d4ed | 2023-01-07 01:38:06 | [diff] [blame] | 14 | #include "base/functional/callback.h" |
avi | 655876a | 2015-12-25 07:18:15 | [diff] [blame] | 15 | #include "build/build_config.h" |
Yuta Hijikata | 40b891d | 2020-11-27 09:05:01 | [diff] [blame] | 16 | #include "build/chromeos_buildflags.h" |
jackhou | b42a1f3d | 2015-08-24 05:53:28 | [diff] [blame] | 17 | #include "chrome/browser/ui/bookmarks/bookmark_editor.h" |
Anthony Cui | 4cf2437 | 2023-10-13 19:44:06 | [diff] [blame] | 18 | #include "components/compose/buildflags.h" |
Devlin Cronin | 5739bf0 | 2020-05-15 00:38:38 | [diff] [blame] | 19 | #include "extensions/buildflags/buildflags.h" |
Dibyajyoti Pal | c8f0780 | 2023-07-21 22:37:33 | [diff] [blame] | 20 | #include "third_party/skia/include/core/SkBitmap.h" |
[email protected] | cb80545 | 2013-05-22 15:16:21 | [diff] [blame] | 21 | #include "third_party/skia/include/core/SkColor.h" |
Peter Boström | 9a697f9b | 2021-10-15 23:27:56 | [diff] [blame] | 22 | #include "ui/base/interaction/element_identifier.h" |
Peter Boström | 0b91d43c | 2021-10-13 00:57:45 | [diff] [blame] | 23 | #include "ui/base/models/dialog_model.h" |
Anthony Cui | 4cf2437 | 2023-10-13 19:44:06 | [diff] [blame] | 24 | #include "ui/gfx/geometry/rect_f.h" |
[email protected] | 08397d5 | 2011-02-05 01:53:38 | [diff] [blame] | 25 | #include "ui/gfx/native_widget_types.h" |
[email protected] | c96531e8 | 2011-01-26 03:11:14 | [diff] [blame] | 26 | |
[email protected] | c60e248 | 2011-02-11 23:46:32 | [diff] [blame] | 27 | class Browser; |
[email protected] | 6684dc816 | 2013-06-03 14:05:08 | [diff] [blame] | 28 | class Profile; |
[email protected] | eb2d790 | 2011-02-02 18:19:56 | [diff] [blame] | 29 | |
Peter Boström | 2a02a69 | 2018-02-22 22:25:46 | [diff] [blame] | 30 | namespace base { |
| 31 | class FilePath; |
| 32 | } |
| 33 | |
[email protected] | 2a6bc3e | 2011-12-28 23:51:33 | [diff] [blame] | 34 | namespace content { |
[email protected] | 6ae4f14 | 2012-06-13 19:48:20 | [diff] [blame] | 35 | class BrowserContext; |
Elly Fong-Jones | fda0aa3 | 2021-07-20 22:13:14 | [diff] [blame] | 36 | class RenderFrameHost; |
[email protected] | 2a6bc3e | 2011-12-28 23:51:33 | [diff] [blame] | 37 | class WebContents; |
Josh Pratt | f80ffb8 | 2019-01-22 07:13:51 | [diff] [blame] | 38 | } // namespace content |
[email protected] | 2a6bc3e | 2011-12-28 23:51:33 | [diff] [blame] | 39 | |
[email protected] | 1c321ee | 2012-05-21 03:02:34 | [diff] [blame] | 40 | namespace extensions { |
| 41 | class Extension; |
| 42 | } |
| 43 | |
Clark DuVall | 732778e | 2020-01-27 18:13:58 | [diff] [blame] | 44 | namespace permissions { |
Michael van Ouwerkerk | 12553e2 | 2021-05-17 14:20:58 | [diff] [blame] | 45 | class ChooserController; |
Clark DuVall | 732778e | 2020-01-27 18:13:58 | [diff] [blame] | 46 | enum class PermissionAction; |
Andrew Rayskiy | 62ec31a | 2022-01-24 12:48:38 | [diff] [blame] | 47 | } // namespace permissions |
Clark DuVall | 732778e | 2020-01-27 18:13:58 | [diff] [blame] | 48 | |
avi | 24d693f | 2016-08-06 18:03:52 | [diff] [blame] | 49 | namespace task_manager { |
nick | bb57d2ca | 2016-07-25 23:08:04 | [diff] [blame] | 50 | class TaskManagerTableModel; |
| 51 | } |
| 52 | |
[email protected] | 20c07f8e | 2012-05-31 08:43:14 | [diff] [blame] | 53 | namespace ui { |
| 54 | class WebDialogDelegate; |
Peter Boström | 2a02a69 | 2018-02-22 22:25:46 | [diff] [blame] | 55 | struct SelectedFileInfo; |
Josh Pratt | f80ffb8 | 2019-01-22 07:13:51 | [diff] [blame] | 56 | } // namespace ui |
[email protected] | 20c07f8e | 2012-05-31 08:43:14 | [diff] [blame] | 57 | |
Zonghan Xu | 5532088 | 2023-05-09 15:09:40 | [diff] [blame] | 58 | namespace views { |
| 59 | class Widget; |
| 60 | } // namespace views |
| 61 | |
Justin DeWitt | a5e6ac1e | 2023-10-19 21:35:04 | [diff] [blame^] | 62 | #if BUILDFLAG(ENABLE_COMPOSE) |
| 63 | namespace compose { |
| 64 | class ComposeDialogController; |
| 65 | } // namespace compose |
| 66 | #endif |
| 67 | |
[email protected] | 87586fb7 | 2012-07-02 13:15:02 | [diff] [blame] | 68 | namespace chrome { |
[email protected] | c96531e8 | 2011-01-26 03:11:14 | [diff] [blame] | 69 | |
tapted | e0eec37 | 2016-01-28 02:45:33 | [diff] [blame] | 70 | // Shows or hides the Task Manager. |browser| can be NULL when called from Ash. |
nick | 399f1066 | 2016-05-06 16:20:26 | [diff] [blame] | 71 | // Returns a pointer to the underlying TableModel, which can be ignored, or used |
| 72 | // for testing. |
avi | 24d693f | 2016-08-06 18:03:52 | [diff] [blame] | 73 | task_manager::TaskManagerTableModel* ShowTaskManager(Browser* browser); |
tapted | e0eec37 | 2016-01-28 02:45:33 | [diff] [blame] | 74 | void HideTaskManager(); |
| 75 | |
[email protected] | d7db4cd | 2012-06-27 04:58:44 | [diff] [blame] | 76 | // Creates and shows an HTML dialog with the given delegate and context. |
| 77 | // The window is automatically destroyed when it is closed. |
[email protected] | eb2d790 | 2011-02-02 18:19:56 | [diff] [blame] | 78 | // 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. |
andresantoso | ba3ef5d7 | 2014-12-15 20:30:08 | [diff] [blame] | 82 | gfx::NativeWindow ShowWebDialog(gfx::NativeView parent, |
[email protected] | 6ae4f14 | 2012-06-13 19:48:20 | [diff] [blame] | 83 | content::BrowserContext* context, |
Xiangdong Kong | 10ae9f9 | 2021-03-23 23:15:10 | [diff] [blame] | 84 | ui::WebDialogDelegate* delegate, |
| 85 | bool show = true); |
[email protected] | eb2d790 | 2011-02-02 18:19:56 | [diff] [blame] | 86 | |
Peter Boström | 0b91d43c | 2021-10-13 00:57:45 | [diff] [blame] | 87 | // Show `dialog_model` as a modal dialog to `browser`. |
Zonghan Xu | 5532088 | 2023-05-09 15:09:40 | [diff] [blame] | 88 | views::Widget* ShowBrowserModal(Browser* browser, |
| 89 | std::unique_ptr<ui::DialogModel> dialog_model); |
Peter Boström | 0b91d43c | 2021-10-13 00:57:45 | [diff] [blame] | 90 | |
Peter Boström | 9a697f9b | 2021-10-15 23:27:56 | [diff] [blame] | 91 | // 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`. |
| 96 | void ShowBubble(Browser* browser, |
| 97 | ui::ElementIdentifier anchor_element, |
| 98 | std::unique_ptr<ui::DialogModel> dialog_model); |
| 99 | |
[email protected] | 497783c | 2013-10-17 15:54:57 | [diff] [blame] | 100 | // Shows the create chrome app shortcut dialog box. |
[email protected] | 497783c | 2013-10-17 15:54:57 | [diff] [blame] | 101 | // |close_callback| may be null. |
[email protected] | 1148990bb | 2014-05-02 10:04:02 | [diff] [blame] | 102 | void ShowCreateChromeAppShortcutsDialog( |
| 103 | gfx::NativeWindow parent_window, |
| 104 | Profile* profile, |
| 105 | const extensions::Extension* app, |
Ella Ge | c279a6f | 2021-01-06 07:47:24 | [diff] [blame] | 106 | base::OnceCallback<void(bool /* created */)> close_callback); |
[email protected] | 497783c | 2013-10-17 15:54:57 | [diff] [blame] | 107 | |
Daniel Murphy | 8e600e58 | 2020-04-09 21:41:57 | [diff] [blame] | 108 | // 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. |
| 110 | void ShowCreateChromeAppShortcutsDialog( |
| 111 | gfx::NativeWindow parent_window, |
| 112 | Profile* profile, |
| 113 | const std::string& web_app_id, |
Ella Ge | c279a6f | 2021-01-06 07:47:24 | [diff] [blame] | 114 | base::OnceCallback<void(bool /* created */)> close_callback); |
Daniel Murphy | 8e600e58 | 2020-04-09 21:41:57 | [diff] [blame] | 115 | |
Xiaohan Wang | e9439fd | 2022-01-18 21:00:31 | [diff] [blame] | 116 | #if BUILDFLAG(IS_MAC) |
tapted | 081286e | 2015-08-10 06:36:30 | [diff] [blame] | 117 | |
spqchan | d33344a | 2016-04-13 02:10:51 | [diff] [blame] | 118 | // Bridging methods that show/hide the toolkit-views based Task Manager on Mac. |
avi | 24d693f | 2016-08-06 18:03:52 | [diff] [blame] | 119 | task_manager::TaskManagerTableModel* ShowTaskManagerViews(Browser* browser); |
spqchan | d33344a | 2016-04-13 02:10:51 | [diff] [blame] | 120 | void HideTaskManagerViews(); |
| 121 | |
Xiaohan Wang | e9439fd | 2022-01-18 21:00:31 | [diff] [blame] | 122 | #endif // BUILDFLAG(IS_MAC) |
tapted | 081286e | 2015-08-10 06:36:30 | [diff] [blame] | 123 | |
Elly Fong-Jones | f260d67 | 2020-03-16 14:09:07 | [diff] [blame] | 124 | // 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 Kleckner | 4d3f21c | 2021-01-25 22:48:31 | [diff] [blame] | 127 | #if defined(TOOLKIT_VIEWS) |
Elly Fong-Jones | f260d67 | 2020-03-16 14:09:07 | [diff] [blame] | 128 | base::OnceClosure ShowDeviceChooserDialog( |
| 129 | content::RenderFrameHost* owner, |
Michael van Ouwerkerk | 12553e2 | 2021-05-17 14:20:58 | [diff] [blame] | 130 | std::unique_ptr<permissions::ChooserController> controller); |
Guido Urdaneta | af871dc | 2020-04-16 06:53:20 | [diff] [blame] | 131 | bool IsDeviceChooserShowingForTesting(Browser* browser); |
Reid Kleckner | 4d3f21c | 2021-01-25 22:48:31 | [diff] [blame] | 132 | #endif |
Elly Fong-Jones | f260d67 | 2020-03-16 14:09:07 | [diff] [blame] | 133 | |
Elly Fong-Jones | 32ead50d | 2020-09-26 01:19:11 | [diff] [blame] | 134 | // Show the prompt to set a window name for browser's window, optionally with |
| 135 | // the given context. |
| 136 | void ShowWindowNamePrompt(Browser* browser); |
Peter Boström | 0b91d43c | 2021-10-13 00:57:45 | [diff] [blame] | 137 | std::unique_ptr<ui::DialogModel> CreateWindowNamePromptDialogModelForTesting( |
| 138 | Browser* browser); |
Elly Fong-Jones | 32ead50d | 2020-09-26 01:19:11 | [diff] [blame] | 139 | |
Anthony Cui | 4cf2437 | 2023-10-13 19:44:06 | [diff] [blame] | 140 | #if BUILDFLAG(ENABLE_COMPOSE) |
Justin DeWitt | a5e6ac1e | 2023-10-19 21:35:04 | [diff] [blame^] | 141 | std::unique_ptr<compose::ComposeDialogController> ShowComposeDialog( |
| 142 | content::WebContents& web_contents, |
| 143 | const gfx::RectF& element_bounds_in_screen); |
Anthony Cui | 4cf2437 | 2023-10-13 19:44:06 | [diff] [blame] | 144 | #endif |
| 145 | |
[email protected] | 87586fb7 | 2012-07-02 13:15:02 | [diff] [blame] | 146 | } // namespace chrome |
[email protected] | c96531e8 | 2011-01-26 03:11:14 | [diff] [blame] | 147 | |
Peter Boström | 2a02a69 | 2018-02-22 22:25:46 | [diff] [blame] | 148 | void 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] | c96531e8 | 2011-01-26 03:11:14 | [diff] [blame] | 154 | #endif // CHROME_BROWSER_UI_BROWSER_DIALOGS_H_ |