blob: 44c24b0b547cf3ee0ec858a46fc7cbeb6bc930cb [file] [log] [blame]
[email protected]c5e22aee52012-01-19 16:10:511// Copyright (c) 2012 The Chromium Authors. All rights reserved.
[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
David Benjamin78fe5962019-01-29 22:22:388#include <memory>
djacobo21e56e02016-07-02 01:14:319#include <string>
10#include <utility>
11#include <vector>
12
[email protected]6684dc8162013-06-03 14:05:0813#include "base/callback.h"
constantinae4c513e72017-02-07 02:14:1014#include "base/optional.h"
15#include "base/strings/string16.h"
avi655876a2015-12-25 07:18:1516#include "build/build_config.h"
jackhoub42a1f3d2015-08-24 05:53:2817#include "chrome/browser/ui/bookmarks/bookmark_editor.h"
Mark Pilgrim7cfcd112018-05-08 00:07:5618#include "content/public/browser/content_browser_client.h"
[email protected]cb805452013-05-22 15:16:2119#include "third_party/skia/include/core/SkColor.h"
[email protected]08397d52011-02-05 01:53:3820#include "ui/gfx/native_widget_types.h"
[email protected]c96531e82011-01-26 03:11:1421
[email protected]c60e2482011-02-11 23:46:3222class Browser;
Elly Fong-Jonesf260d672020-03-16 14:09:0723class ChooserController;
tapted081286e2015-08-10 06:36:3024class LoginHandler;
[email protected]6684dc8162013-06-03 14:05:0825class Profile;
tapted712c1b82017-06-08 03:10:0526struct WebApplicationInfo;
[email protected]eb2d7902011-02-02 18:19:5627
Peter Boström2a02a692018-02-22 22:25:4628namespace base {
29class FilePath;
30}
31
[email protected]2a6bc3e2011-12-28 23:51:3332namespace content {
[email protected]6ae4f142012-06-13 19:48:2033class BrowserContext;
[email protected]2a6bc3e2011-12-28 23:51:3334class WebContents;
Josh Prattf80ffb82019-01-22 07:13:5135} // namespace content
[email protected]2a6bc3e2011-12-28 23:51:3336
[email protected]1c321ee2012-05-21 03:02:3437namespace extensions {
38class Extension;
39}
40
tapted081286e2015-08-10 06:36:3041namespace net {
42class AuthChallengeInfo;
tapted081286e2015-08-10 06:36:3043}
44
Clark DuVall732778e2020-01-27 18:13:5845namespace permissions {
46enum class PermissionAction;
47}
48
alitoe82b14b2017-04-06 23:11:2949namespace safe_browsing {
Ali Tofighf5baba982017-07-21 23:15:2350class ChromeCleanerController;
alitof8f753f62017-04-28 23:04:1051class ChromeCleanerDialogController;
Fabio Tirelo8825aab42017-10-19 13:23:3152class ChromeCleanerRebootDialogController;
Ali Tofigh525f78bdd2017-09-15 15:37:2053class SettingsResetPromptController;
Josh Prattf80ffb82019-01-22 07:13:5154} // namespace safe_browsing
alitoe82b14b2017-04-06 23:11:2955
avi24d693f2016-08-06 18:03:5256namespace task_manager {
nickbb57d2ca2016-07-25 23:08:0457class TaskManagerTableModel;
58}
59
[email protected]20c07f8e2012-05-31 08:43:1460namespace ui {
61class WebDialogDelegate;
Peter Boström2a02a692018-02-22 22:25:4662struct SelectedFileInfo;
Josh Prattf80ffb82019-01-22 07:13:5163} // namespace ui
[email protected]20c07f8e2012-05-31 08:43:1464
[email protected]87586fb72012-07-02 13:15:0265namespace chrome {
[email protected]c96531e82011-01-26 03:11:1466
taptede0eec372016-01-28 02:45:3367// Shows or hides the Task Manager. |browser| can be NULL when called from Ash.
nick399f10662016-05-06 16:20:2668// Returns a pointer to the underlying TableModel, which can be ignored, or used
69// for testing.
avi24d693f2016-08-06 18:03:5270task_manager::TaskManagerTableModel* ShowTaskManager(Browser* browser);
taptede0eec372016-01-28 02:45:3371void HideTaskManager();
72
[email protected]d7db4cd2012-06-27 04:58:4473// Creates and shows an HTML dialog with the given delegate and context.
74// The window is automatically destroyed when it is closed.
[email protected]eb2d7902011-02-02 18:19:5675// Returns the created window.
76//
77// Make sure to use the returned window only when you know it is safe
78// to do so, i.e. before OnDialogClosed() is called on the delegate.
andresantosoba3ef5d72014-12-15 20:30:0879gfx::NativeWindow ShowWebDialog(gfx::NativeView parent,
[email protected]6ae4f142012-06-13 19:48:2080 content::BrowserContext* context,
[email protected]20c07f8e2012-05-31 08:43:1481 ui::WebDialogDelegate* delegate);
[email protected]eb2d7902011-02-02 18:19:5682
[email protected]497783c2013-10-17 15:54:5783// Shows the create chrome app shortcut dialog box.
[email protected]497783c2013-10-17 15:54:5784// |close_callback| may be null.
[email protected]1148990bb2014-05-02 10:04:0285void ShowCreateChromeAppShortcutsDialog(
86 gfx::NativeWindow parent_window,
87 Profile* profile,
88 const extensions::Extension* app,
89 const base::Callback<void(bool /* created */)>& close_callback);
[email protected]497783c2013-10-17 15:54:5790
Daniel Murphy8e600e582020-04-09 21:41:5791// Shows the create chrome app shortcut dialog box. Same as above but for a
92// WebApp instead of an Extension. |close_callback| may be null.
93void ShowCreateChromeAppShortcutsDialog(
94 gfx::NativeWindow parent_window,
95 Profile* profile,
96 const std::string& web_app_id,
97 const base::Callback<void(bool /* created */)>& close_callback);
98
Michael McGreevy556227a52017-11-16 07:47:2499// Callback used to indicate whether a user has accepted the installation of a
100// web app. The boolean parameter is true when the user accepts the dialog. The
101// WebApplicationInfo parameter contains the information about the app,
102// possibly modified by the user.
103using AppInstallationAcceptanceCallback =
Eric Willigers61bb4da2019-05-10 20:38:45104 base::OnceCallback<void(bool, std::unique_ptr<WebApplicationInfo>)>;
tapted712c1b82017-06-08 03:10:05105
phillisb3f540a52020-05-14 20:00:50106// Shows the Web App install bubble.
tapted712c1b82017-06-08 03:10:05107//
108// |web_app_info| is the WebApplicationInfo being converted into an app.
Eric Willigersb5235c52020-03-03 03:09:13109// |web_app_info.app_url| should contain a start url from a web app manifest
110// (for a Desktop PWA), or the current url (when creating a shortcut app).
phillisb3f540a52020-05-14 20:00:50111void ShowWebAppInstallDialog(content::WebContents* web_contents,
112 std::unique_ptr<WebApplicationInfo> web_app_info,
113 AppInstallationAcceptanceCallback callback);
Michael McGreevy556227a52017-11-16 07:47:24114
Eric Willigersb5235c52020-03-03 03:09:13115// Sets whether |ShowWebAppDialog| should accept immediately without any
Jeevan Shikaramd9491e52019-12-05 04:05:49116// user interaction. |auto_open_in_window| sets whether the open in window
117// checkbox is checked.
Eric Willigersb5235c52020-03-03 03:09:13118void SetAutoAcceptWebAppDialogForTesting(bool auto_accept,
119 bool auto_open_in_window);
Alan Cutter81ac726682018-09-25 00:18:36120
Alan Cutterf0d263f2019-04-16 14:46:16121// Shows the PWA installation confirmation bubble anchored off the PWA install
122// icon in the omnibox.
123//
124// |web_app_info| is the WebApplicationInfo to be installed.
125void ShowPWAInstallBubble(content::WebContents* web_contents,
Eric Willigersbf1e5ed2019-05-14 04:56:17126 std::unique_ptr<WebApplicationInfo> web_app_info,
Alan Cutterf0d263f2019-04-16 14:46:16127 AppInstallationAcceptanceCallback callback);
128
Alan Cuttera0ccba082019-12-20 00:41:34129// Sets whether |ShowPWAInstallBubble| should accept immediately without any
130// user interaction.
Alan Cutterf0d263f2019-04-16 14:46:16131void SetAutoAcceptPWAInstallConfirmationForTesting(bool auto_accept);
Alan Cutter81ac726682018-09-25 00:18:36132
Nikita Podguzov107cccc12020-02-04 17:57:05133#if defined(OS_CHROMEOS)
134
135// Shows the print job confirmation dialog bubble anchored to the toolbar icon
136// for the extension.
137// If there's no toolbar icon, shows a modal dialog using
138// CreateBrowserModalDialogViews(). Note that this dialog is shown up even if we
139// have no |parent| window.
140void ShowPrintJobConfirmationDialog(gfx::NativeWindow parent,
141 const std::string& extension_id,
142 const base::string16& extension_name,
143 const gfx::ImageSkia& extension_icon,
144 const base::string16& print_job_title,
145 const base::string16& printer_name,
146 base::OnceCallback<void(bool)> callback);
147
148#endif // OS_CHROMEOS
149
tapted081286e2015-08-10 06:36:30150#if defined(OS_MACOSX)
151
spqchand33344a2016-04-13 02:10:51152// Bridging methods that show/hide the toolkit-views based Task Manager on Mac.
avi24d693f2016-08-06 18:03:52153task_manager::TaskManagerTableModel* ShowTaskManagerViews(Browser* browser);
spqchand33344a2016-04-13 02:10:51154void HideTaskManagerViews();
155
tapted081286e2015-08-10 06:36:30156#endif // OS_MACOSX
157
158#if defined(TOOLKIT_VIEWS)
159
160// Creates a toolkit-views based LoginHandler (e.g. HTTP-Auth dialog).
David Benjamin78fe5962019-01-29 22:22:38161std::unique_ptr<LoginHandler> CreateLoginHandlerViews(
Emily Starkf2c9bbd2019-04-09 17:08:58162 const net::AuthChallengeInfo& auth_info,
David Benjamin78fe5962019-01-29 22:22:38163 content::WebContents* web_contents,
Mark Pilgrim7cfcd112018-05-08 00:07:56164 LoginAuthRequiredCallback auth_required_callback);
tapted081286e2015-08-10 06:36:30165
tapted081286e2015-08-10 06:36:30166#endif // TOOLKIT_VIEWS
167
pdyson7872d6c02017-04-05 23:12:31168// Values used in the Dialog.Creation UMA metric. Each value represents a
169// different type of dialog box.
170// These values are written to logs. New enum values can be added, but existing
171// enums must never be renumbered or deleted and reused.
pdysona8a9ea02017-04-20 00:00:15172enum class DialogIdentifier {
173 UNKNOWN = 0,
174 TRANSLATE = 1,
175 BOOKMARK = 2,
176 BOOKMARK_EDITOR = 3,
177 DESKTOP_MEDIA_PICKER = 4,
178 OUTDATED_UPGRADE = 5,
179 ONE_CLICK_SIGNIN = 6,
180 PROFILE_SIGNIN_CONFIRMATION = 7,
181 HUNG_RENDERER = 8,
182 SESSION_CRASHED = 9,
183 CONFIRM_BUBBLE = 10,
184 UPDATE_RECOMMENDED = 11,
185 CRYPTO_PASSWORD = 12,
186 SAFE_BROWSING_DOWNLOAD_FEEDBACK = 13,
187 FIRST_RUN = 14,
188 NETWORK_SHARE_PROFILE_WARNING = 15,
Patrick Monette66e935a2018-06-12 19:16:10189 // CONFLICTING_MODULE = 16, Deprecated
pdysona8a9ea02017-04-20 00:00:15190 CRITICAL_NOTIFICATION = 17,
191 IME_WARNING = 18,
pdyson106455b22017-04-26 01:21:31192 TOOLBAR_ACTIONS_BAR = 19,
193 GLOBAL_ERROR = 20,
194 EXTENSION_INSTALL = 21,
195 EXTENSION_UNINSTALL = 22,
196 EXTENSION_INSTALLED = 23,
197 PAYMENT_REQUEST = 24,
198 SAVE_CARD = 25,
199 CARD_UNMASK = 26,
pdyson918928e2017-05-04 03:50:12200 SIGN_IN = 27,
201 SIGN_IN_SYNC_CONFIRMATION = 28,
202 SIGN_IN_ERROR = 29,
203 SIGN_IN_EMAIL_CONFIRMATION = 30,
204 PROFILE_CHOOSER = 31,
pdyson7fa1d032017-05-17 23:54:45205 ACCOUNT_CHOOSER = 32,
206 ARC_APP = 33,
207 AUTO_SIGNIN_FIRST_RUN = 34,
Eric Willigers1e612cf2020-03-04 21:49:47208 WEB_APP_CONFIRMATION = 35,
pdyson7fa1d032017-05-17 23:54:45209 CHOOSER_UI = 36,
210 CHOOSER = 37,
211 COLLECTED_COOKIES = 38,
212 CONSTRAINED_WEB = 39,
213 CONTENT_SETTING_CONTENTS = 40,
214 CREATE_CHROME_APPLICATION_SHORTCUT = 41,
215 DOWNLOAD_DANGER_PROMPT = 42,
216 DOWNLOAD_IN_PROGRESS = 43,
217 ECHO = 44,
218 ENROLLMENT = 45,
219 EXTENSION = 46,
220 EXTENSION_POPUP_AURA = 47,
221 EXTERNAL_PROTOCOL = 48,
222 EXTERNAL_PROTOCOL_CHROMEOS = 49,
223 FIRST_RUN_DIALOG = 50,
224 HOME_PAGE_UNDO = 51,
225 IDLE_ACTION_WARNING = 52,
226 IMPORT_LOCK = 53,
227 INTENT_PICKER = 54,
228 INVERT = 55,
229 JAVA_SCRIPT = 56,
230 JAVA_SCRIPT_APP_MODAL_X11 = 57,
231 LOGIN_HANDLER = 58,
232 MANAGE_PASSWORDS = 59,
233 MEDIA_GALLERIES = 60,
234 MULTIPROFILES_INTRO = 61,
235 MULTIPROFILES_SESSION_ABORTED = 62,
236 NATIVE_CONTAINER = 63,
237 NETWORK_CONFIG = 64,
238 PERMISSIONS = 65,
239 PLATFORM_KEYS_CERTIFICATE_SELECTOR = 66,
240 PLATFORM_VERIFICATION = 67,
241 PROXIMITY_AUTH_ERROR = 68,
242 REQUEST_PIN = 69,
243 SSL_CLIENT_CERTIFICATE_SELECTOR = 70,
244 SIMPLE_MESSAGE_BOX = 71,
245 TAB_MODAL_CONFIRM = 72,
246 TASK_MANAGER = 73,
247 TELEPORT_WARNING = 74,
248 USER_MANAGER = 75,
249 USER_MANAGER_PROFILE = 76,
250 VALIDATION_MESSAGE = 77,
251 WEB_SHARE_TARGET_PICKER = 78,
252 ZOOM = 79,
Toni Barzic069197542017-10-17 22:08:01253 LOCK_SCREEN_NOTE_APP_TOAST = 80,
Michael McGreevy556227a52017-11-16 07:47:24254 PWA_CONFIRMATION = 81,
Greg Thompson875403e02018-02-27 16:22:52255 RELAUNCH_RECOMMENDED = 82,
Timothy Loh74cf13c22018-03-01 06:56:24256 CROSTINI_INSTALLER = 83,
Greg Thompson27aef5f2018-03-05 22:10:37257 RELAUNCH_REQUIRED = 84,
Thomas Tangl9e916b232018-04-18 13:07:48258 UNITY_SYNC_CONSENT_BUMP = 85,
Nicholas Verne26965d82018-05-01 02:07:03259 CROSTINI_UNINSTALLER = 86,
Min Qin7b7cbbbf2018-06-04 21:49:31260 DOWNLOAD_OPEN_CONFIRMATION = 87,
[email protected]ef49be42018-07-12 17:54:12261 ARC_DATA_REMOVAL_CONFIRMATION = 88,
Nicholas Vernebc9185c2018-09-13 06:16:01262 CROSTINI_UPGRADE = 89,
Jeffrey Cohen2e9d01a2018-10-11 17:30:39263 HATS_BUBBLE = 90,
Tim Zhengc36d6a52018-10-27 01:05:38264 CROSTINI_APP_RESTART = 91,
Ramin Halavatief75f6c2019-04-02 19:24:51265 INCOGNITO_WINDOW_COUNT = 92,
Ian Barkley-Yeung42f06e962018-12-14 03:00:41266 CROSTINI_APP_UNINSTALLER = 93,
Josh Prattf80ffb82019-01-22 07:13:51267 CROSTINI_CONTAINER_UPGRADE = 94,
Christian Dullweber10087e02019-08-28 12:23:07268 COOKIE_CONTROLS = 95,
Christopher Gunadi352d90d2019-09-13 16:38:28269 CROSTINI_ANSIBLE_SOFTWARE_CONFIG = 96,
Travis Skareba1cc442019-10-02 22:28:11270 INCOGNITO_MENU = 97,
271 PHONE_CHOOSER = 98,
272 QR_CODE_GENERATOR = 99,
Nicholas Hollingum266cddd2019-10-03 06:12:44273 CROSTINI_FORCE_CLOSE = 100,
nancyd675d042019-10-21 10:37:21274 APP_UNINSTALL = 101,
Nikita Podguzov107cccc12020-02-04 17:57:05275 PRINT_JOB_CONFIRMATION = 102,
Nicholas Verned8863f12020-03-04 23:03:31276 CROSTINI_RECOVERY = 103,
Danan Sf55c1652020-03-05 03:13:32277 PARENT_PERMISSION = 104, // ChromeOS only.
Alex Ilin22e89172020-03-18 15:12:51278 SIGNIN_REAUTH = 105,
Josh Prattf80ffb82019-01-22 07:13:51279 // Add values above this line with a corresponding label in
280 // tools/metrics/histograms/enums.xml
pdysona8a9ea02017-04-20 00:00:15281 MAX_VALUE
282};
pdyson7872d6c02017-04-05 23:12:31283
284// Record an UMA metric counting the creation of a dialog box of this type.
285void RecordDialogCreation(DialogIdentifier identifier);
286
alitoe82b14b2017-04-06 23:11:29287#if defined(OS_WIN)
288
Ali Tofigh525f78bdd2017-09-15 15:37:20289// Shows the settings reset prompt dialog asking the user if they want to reset
290// some of their settings.
291void ShowSettingsResetPrompt(
292 Browser* browser,
293 safe_browsing::SettingsResetPromptController* controller);
294
alitoe82b14b2017-04-06 23:11:29295// Shows the Chrome Cleanup dialog asking the user if they want to clean their
296// system from unwanted software. This is called when unwanted software has been
297// detected on the system.
alitof8f753f62017-04-28 23:04:10298void ShowChromeCleanerPrompt(
299 Browser* browser,
Ali Tofighf5baba982017-07-21 23:15:23300 safe_browsing::ChromeCleanerDialogController* dialog_controller,
301 safe_browsing::ChromeCleanerController* cleaner_controller);
alitoe82b14b2017-04-06 23:11:29302
Fabio Tirelo8825aab42017-10-19 13:23:31303// Shows the Chrome Cleanup reboot dialog asking the user if they want to
304// restart their computer once a cleanup has finished. This is called when the
305// Chrome Cleanup ends in a reboot required state.
306void ShowChromeCleanerRebootPrompt(
307 Browser* browser,
308 safe_browsing::ChromeCleanerRebootDialogController* dialog_controller);
309
alitoe82b14b2017-04-06 23:11:29310#endif // OS_WIN
311
Owen Mind6b9de02020-03-14 00:26:54312// Displays a dialog to notify the user that the extension installation is
313// blocked due to policy. It also show additional information from administrator
314// if it exists.
315void ShowExtensionInstallBlockedDialog(
316 const std::string& extension_name,
317 const base::string16& custom_error_message,
318 const gfx::ImageSkia& icon,
319 content::WebContents* web_contents,
320 base::OnceClosure done_callback);
321
Elly Fong-Jonesf260d672020-03-16 14:09:07322// Returns a OnceClosure that client code can call to close the device chooser.
323// This OnceClosure references the actual dialog as a WeakPtr, so it's safe to
324// call at any point.
325base::OnceClosure ShowDeviceChooserDialog(
326 content::RenderFrameHost* owner,
327 std::unique_ptr<ChooserController> controller);
Guido Urdanetaaf871dc2020-04-16 06:53:20328bool IsDeviceChooserShowingForTesting(Browser* browser);
Elly Fong-Jonesf260d672020-03-16 14:09:07329
[email protected]87586fb72012-07-02 13:15:02330} // namespace chrome
[email protected]c96531e82011-01-26 03:11:14331
Peter Boström2a02a692018-02-22 22:25:46332void ShowFolderUploadConfirmationDialog(
333 const base::FilePath& path,
334 base::OnceCallback<void(const std::vector<ui::SelectedFileInfo>&)> callback,
335 std::vector<ui::SelectedFileInfo> selected_files,
336 content::WebContents* web_contents);
337
[email protected]c96531e82011-01-26 03:11:14338#endif // CHROME_BROWSER_UI_BROWSER_DIALOGS_H_