blob: 975aeb61b2256613610dfbfc63a15602e7d3eb41 [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"
Devlin Cronin5739bf02020-05-15 00:38:3819#include "extensions/buildflags/buildflags.h"
[email protected]cb805452013-05-22 15:16:2120#include "third_party/skia/include/core/SkColor.h"
[email protected]08397d52011-02-05 01:53:3821#include "ui/gfx/native_widget_types.h"
[email protected]c96531e82011-01-26 03:11:1422
[email protected]c60e2482011-02-11 23:46:3223class Browser;
Elly Fong-Jonesf260d672020-03-16 14:09:0724class ChooserController;
tapted081286e2015-08-10 06:36:3025class LoginHandler;
[email protected]6684dc8162013-06-03 14:05:0826class Profile;
tapted712c1b82017-06-08 03:10:0527struct WebApplicationInfo;
[email protected]eb2d7902011-02-02 18:19:5628
Devlin Cronin5739bf02020-05-15 00:38:3829#if BUILDFLAG(ENABLE_EXTENSIONS)
30class SettingsOverriddenDialogController;
31#endif
32
Peter Boström2a02a692018-02-22 22:25:4633namespace base {
34class FilePath;
35}
36
[email protected]2a6bc3e2011-12-28 23:51:3337namespace content {
[email protected]6ae4f142012-06-13 19:48:2038class BrowserContext;
[email protected]2a6bc3e2011-12-28 23:51:3339class WebContents;
Josh Prattf80ffb82019-01-22 07:13:5140} // namespace content
[email protected]2a6bc3e2011-12-28 23:51:3341
[email protected]1c321ee2012-05-21 03:02:3442namespace extensions {
43class Extension;
44}
45
tapted081286e2015-08-10 06:36:3046namespace net {
47class AuthChallengeInfo;
tapted081286e2015-08-10 06:36:3048}
49
Clark DuVall732778e2020-01-27 18:13:5850namespace permissions {
51enum class PermissionAction;
52}
53
alitoe82b14b2017-04-06 23:11:2954namespace safe_browsing {
Ali Tofighf5baba982017-07-21 23:15:2355class ChromeCleanerController;
alitof8f753f62017-04-28 23:04:1056class ChromeCleanerDialogController;
Fabio Tirelo8825aab42017-10-19 13:23:3157class ChromeCleanerRebootDialogController;
Ali Tofigh525f78bdd2017-09-15 15:37:2058class SettingsResetPromptController;
Josh Prattf80ffb82019-01-22 07:13:5159} // namespace safe_browsing
alitoe82b14b2017-04-06 23:11:2960
avi24d693f2016-08-06 18:03:5261namespace task_manager {
nickbb57d2ca2016-07-25 23:08:0462class TaskManagerTableModel;
63}
64
[email protected]20c07f8e2012-05-31 08:43:1465namespace ui {
66class WebDialogDelegate;
Peter Boström2a02a692018-02-22 22:25:4667struct SelectedFileInfo;
Josh Prattf80ffb82019-01-22 07:13:5168} // namespace ui
[email protected]20c07f8e2012-05-31 08:43:1469
[email protected]87586fb72012-07-02 13:15:0270namespace chrome {
[email protected]c96531e82011-01-26 03:11:1471
taptede0eec372016-01-28 02:45:3372// Shows or hides the Task Manager. |browser| can be NULL when called from Ash.
nick399f10662016-05-06 16:20:2673// Returns a pointer to the underlying TableModel, which can be ignored, or used
74// for testing.
avi24d693f2016-08-06 18:03:5275task_manager::TaskManagerTableModel* ShowTaskManager(Browser* browser);
taptede0eec372016-01-28 02:45:3376void HideTaskManager();
77
[email protected]d7db4cd2012-06-27 04:58:4478// Creates and shows an HTML dialog with the given delegate and context.
79// The window is automatically destroyed when it is closed.
[email protected]eb2d7902011-02-02 18:19:5680// Returns the created window.
81//
82// Make sure to use the returned window only when you know it is safe
83// to do so, i.e. before OnDialogClosed() is called on the delegate.
andresantosoba3ef5d72014-12-15 20:30:0884gfx::NativeWindow ShowWebDialog(gfx::NativeView parent,
[email protected]6ae4f142012-06-13 19:48:2085 content::BrowserContext* context,
[email protected]20c07f8e2012-05-31 08:43:1486 ui::WebDialogDelegate* delegate);
[email protected]eb2d7902011-02-02 18:19:5687
[email protected]497783c2013-10-17 15:54:5788// Shows the create chrome app shortcut dialog box.
[email protected]497783c2013-10-17 15:54:5789// |close_callback| may be null.
[email protected]1148990bb2014-05-02 10:04:0290void ShowCreateChromeAppShortcutsDialog(
91 gfx::NativeWindow parent_window,
92 Profile* profile,
93 const extensions::Extension* app,
94 const base::Callback<void(bool /* created */)>& close_callback);
[email protected]497783c2013-10-17 15:54:5795
Daniel Murphy8e600e582020-04-09 21:41:5796// Shows the create chrome app shortcut dialog box. Same as above but for a
97// WebApp instead of an Extension. |close_callback| may be null.
98void ShowCreateChromeAppShortcutsDialog(
99 gfx::NativeWindow parent_window,
100 Profile* profile,
101 const std::string& web_app_id,
102 const base::Callback<void(bool /* created */)>& close_callback);
103
Michael McGreevy556227a52017-11-16 07:47:24104// Callback used to indicate whether a user has accepted the installation of a
105// web app. The boolean parameter is true when the user accepts the dialog. The
106// WebApplicationInfo parameter contains the information about the app,
107// possibly modified by the user.
108using AppInstallationAcceptanceCallback =
Eric Willigers61bb4da2019-05-10 20:38:45109 base::OnceCallback<void(bool, std::unique_ptr<WebApplicationInfo>)>;
tapted712c1b82017-06-08 03:10:05110
phillisb3f540a52020-05-14 20:00:50111// Shows the Web App install bubble.
tapted712c1b82017-06-08 03:10:05112//
113// |web_app_info| is the WebApplicationInfo being converted into an app.
Eric Willigersb5235c52020-03-03 03:09:13114// |web_app_info.app_url| should contain a start url from a web app manifest
115// (for a Desktop PWA), or the current url (when creating a shortcut app).
phillisb3f540a52020-05-14 20:00:50116void ShowWebAppInstallDialog(content::WebContents* web_contents,
117 std::unique_ptr<WebApplicationInfo> web_app_info,
118 AppInstallationAcceptanceCallback callback);
Michael McGreevy556227a52017-11-16 07:47:24119
Eric Willigersb5235c52020-03-03 03:09:13120// Sets whether |ShowWebAppDialog| should accept immediately without any
Jeevan Shikaramd9491e52019-12-05 04:05:49121// user interaction. |auto_open_in_window| sets whether the open in window
122// checkbox is checked.
Eric Willigersb5235c52020-03-03 03:09:13123void SetAutoAcceptWebAppDialogForTesting(bool auto_accept,
124 bool auto_open_in_window);
Alan Cutter81ac726682018-09-25 00:18:36125
Alan Cutterf0d263f2019-04-16 14:46:16126// Shows the PWA installation confirmation bubble anchored off the PWA install
127// icon in the omnibox.
128//
129// |web_app_info| is the WebApplicationInfo to be installed.
130void ShowPWAInstallBubble(content::WebContents* web_contents,
Eric Willigersbf1e5ed2019-05-14 04:56:17131 std::unique_ptr<WebApplicationInfo> web_app_info,
Alan Cutterf0d263f2019-04-16 14:46:16132 AppInstallationAcceptanceCallback callback);
133
Alan Cuttera0ccba082019-12-20 00:41:34134// Sets whether |ShowPWAInstallBubble| should accept immediately without any
135// user interaction.
Alan Cutterf0d263f2019-04-16 14:46:16136void SetAutoAcceptPWAInstallConfirmationForTesting(bool auto_accept);
Alan Cutter81ac726682018-09-25 00:18:36137
Nikita Podguzov107cccc12020-02-04 17:57:05138#if defined(OS_CHROMEOS)
139
140// Shows the print job confirmation dialog bubble anchored to the toolbar icon
141// for the extension.
142// If there's no toolbar icon, shows a modal dialog using
143// CreateBrowserModalDialogViews(). Note that this dialog is shown up even if we
144// have no |parent| window.
145void ShowPrintJobConfirmationDialog(gfx::NativeWindow parent,
146 const std::string& extension_id,
147 const base::string16& extension_name,
148 const gfx::ImageSkia& extension_icon,
149 const base::string16& print_job_title,
150 const base::string16& printer_name,
151 base::OnceCallback<void(bool)> callback);
152
153#endif // OS_CHROMEOS
154
tapted081286e2015-08-10 06:36:30155#if defined(OS_MACOSX)
156
spqchand33344a2016-04-13 02:10:51157// Bridging methods that show/hide the toolkit-views based Task Manager on Mac.
avi24d693f2016-08-06 18:03:52158task_manager::TaskManagerTableModel* ShowTaskManagerViews(Browser* browser);
spqchand33344a2016-04-13 02:10:51159void HideTaskManagerViews();
160
tapted081286e2015-08-10 06:36:30161#endif // OS_MACOSX
162
163#if defined(TOOLKIT_VIEWS)
164
165// Creates a toolkit-views based LoginHandler (e.g. HTTP-Auth dialog).
David Benjamin78fe5962019-01-29 22:22:38166std::unique_ptr<LoginHandler> CreateLoginHandlerViews(
Emily Starkf2c9bbd2019-04-09 17:08:58167 const net::AuthChallengeInfo& auth_info,
David Benjamin78fe5962019-01-29 22:22:38168 content::WebContents* web_contents,
Mark Pilgrim7cfcd112018-05-08 00:07:56169 LoginAuthRequiredCallback auth_required_callback);
tapted081286e2015-08-10 06:36:30170
tapted081286e2015-08-10 06:36:30171#endif // TOOLKIT_VIEWS
172
pdyson7872d6c02017-04-05 23:12:31173// Values used in the Dialog.Creation UMA metric. Each value represents a
174// different type of dialog box.
175// These values are written to logs. New enum values can be added, but existing
176// enums must never be renumbered or deleted and reused.
pdysona8a9ea02017-04-20 00:00:15177enum class DialogIdentifier {
178 UNKNOWN = 0,
179 TRANSLATE = 1,
180 BOOKMARK = 2,
181 BOOKMARK_EDITOR = 3,
182 DESKTOP_MEDIA_PICKER = 4,
183 OUTDATED_UPGRADE = 5,
184 ONE_CLICK_SIGNIN = 6,
185 PROFILE_SIGNIN_CONFIRMATION = 7,
186 HUNG_RENDERER = 8,
187 SESSION_CRASHED = 9,
188 CONFIRM_BUBBLE = 10,
189 UPDATE_RECOMMENDED = 11,
190 CRYPTO_PASSWORD = 12,
191 SAFE_BROWSING_DOWNLOAD_FEEDBACK = 13,
192 FIRST_RUN = 14,
193 NETWORK_SHARE_PROFILE_WARNING = 15,
Patrick Monette66e935a2018-06-12 19:16:10194 // CONFLICTING_MODULE = 16, Deprecated
pdysona8a9ea02017-04-20 00:00:15195 CRITICAL_NOTIFICATION = 17,
196 IME_WARNING = 18,
pdyson106455b22017-04-26 01:21:31197 TOOLBAR_ACTIONS_BAR = 19,
198 GLOBAL_ERROR = 20,
199 EXTENSION_INSTALL = 21,
200 EXTENSION_UNINSTALL = 22,
201 EXTENSION_INSTALLED = 23,
202 PAYMENT_REQUEST = 24,
203 SAVE_CARD = 25,
204 CARD_UNMASK = 26,
pdyson918928e2017-05-04 03:50:12205 SIGN_IN = 27,
206 SIGN_IN_SYNC_CONFIRMATION = 28,
207 SIGN_IN_ERROR = 29,
208 SIGN_IN_EMAIL_CONFIRMATION = 30,
209 PROFILE_CHOOSER = 31,
pdyson7fa1d032017-05-17 23:54:45210 ACCOUNT_CHOOSER = 32,
211 ARC_APP = 33,
212 AUTO_SIGNIN_FIRST_RUN = 34,
Eric Willigers1e612cf2020-03-04 21:49:47213 WEB_APP_CONFIRMATION = 35,
pdyson7fa1d032017-05-17 23:54:45214 CHOOSER_UI = 36,
215 CHOOSER = 37,
216 COLLECTED_COOKIES = 38,
217 CONSTRAINED_WEB = 39,
218 CONTENT_SETTING_CONTENTS = 40,
219 CREATE_CHROME_APPLICATION_SHORTCUT = 41,
220 DOWNLOAD_DANGER_PROMPT = 42,
221 DOWNLOAD_IN_PROGRESS = 43,
222 ECHO = 44,
223 ENROLLMENT = 45,
224 EXTENSION = 46,
225 EXTENSION_POPUP_AURA = 47,
226 EXTERNAL_PROTOCOL = 48,
227 EXTERNAL_PROTOCOL_CHROMEOS = 49,
228 FIRST_RUN_DIALOG = 50,
229 HOME_PAGE_UNDO = 51,
230 IDLE_ACTION_WARNING = 52,
231 IMPORT_LOCK = 53,
232 INTENT_PICKER = 54,
233 INVERT = 55,
234 JAVA_SCRIPT = 56,
235 JAVA_SCRIPT_APP_MODAL_X11 = 57,
236 LOGIN_HANDLER = 58,
237 MANAGE_PASSWORDS = 59,
238 MEDIA_GALLERIES = 60,
239 MULTIPROFILES_INTRO = 61,
240 MULTIPROFILES_SESSION_ABORTED = 62,
241 NATIVE_CONTAINER = 63,
242 NETWORK_CONFIG = 64,
243 PERMISSIONS = 65,
244 PLATFORM_KEYS_CERTIFICATE_SELECTOR = 66,
245 PLATFORM_VERIFICATION = 67,
246 PROXIMITY_AUTH_ERROR = 68,
247 REQUEST_PIN = 69,
248 SSL_CLIENT_CERTIFICATE_SELECTOR = 70,
249 SIMPLE_MESSAGE_BOX = 71,
250 TAB_MODAL_CONFIRM = 72,
251 TASK_MANAGER = 73,
252 TELEPORT_WARNING = 74,
253 USER_MANAGER = 75,
254 USER_MANAGER_PROFILE = 76,
255 VALIDATION_MESSAGE = 77,
256 WEB_SHARE_TARGET_PICKER = 78,
257 ZOOM = 79,
Toni Barzic069197542017-10-17 22:08:01258 LOCK_SCREEN_NOTE_APP_TOAST = 80,
Michael McGreevy556227a52017-11-16 07:47:24259 PWA_CONFIRMATION = 81,
Greg Thompson875403e02018-02-27 16:22:52260 RELAUNCH_RECOMMENDED = 82,
Timothy Loh74cf13c22018-03-01 06:56:24261 CROSTINI_INSTALLER = 83,
Greg Thompson27aef5f2018-03-05 22:10:37262 RELAUNCH_REQUIRED = 84,
Thomas Tangl9e916b232018-04-18 13:07:48263 UNITY_SYNC_CONSENT_BUMP = 85,
Nicholas Verne26965d82018-05-01 02:07:03264 CROSTINI_UNINSTALLER = 86,
Min Qin7b7cbbbf2018-06-04 21:49:31265 DOWNLOAD_OPEN_CONFIRMATION = 87,
[email protected]ef49be42018-07-12 17:54:12266 ARC_DATA_REMOVAL_CONFIRMATION = 88,
Nicholas Vernebc9185c2018-09-13 06:16:01267 CROSTINI_UPGRADE = 89,
Jeffrey Cohen2e9d01a2018-10-11 17:30:39268 HATS_BUBBLE = 90,
Tim Zhengc36d6a52018-10-27 01:05:38269 CROSTINI_APP_RESTART = 91,
Ramin Halavatief75f6c2019-04-02 19:24:51270 INCOGNITO_WINDOW_COUNT = 92,
Ian Barkley-Yeung42f06e962018-12-14 03:00:41271 CROSTINI_APP_UNINSTALLER = 93,
Josh Prattf80ffb82019-01-22 07:13:51272 CROSTINI_CONTAINER_UPGRADE = 94,
Christian Dullweber10087e02019-08-28 12:23:07273 COOKIE_CONTROLS = 95,
Christopher Gunadi352d90d2019-09-13 16:38:28274 CROSTINI_ANSIBLE_SOFTWARE_CONFIG = 96,
Travis Skareba1cc442019-10-02 22:28:11275 INCOGNITO_MENU = 97,
276 PHONE_CHOOSER = 98,
277 QR_CODE_GENERATOR = 99,
Nicholas Hollingum266cddd2019-10-03 06:12:44278 CROSTINI_FORCE_CLOSE = 100,
nancyd675d042019-10-21 10:37:21279 APP_UNINSTALL = 101,
Nikita Podguzov107cccc12020-02-04 17:57:05280 PRINT_JOB_CONFIRMATION = 102,
Nicholas Verned8863f12020-03-04 23:03:31281 CROSTINI_RECOVERY = 103,
Danan Sf55c1652020-03-05 03:13:32282 PARENT_PERMISSION = 104, // ChromeOS only.
Alex Ilin22e89172020-03-18 15:12:51283 SIGNIN_REAUTH = 105,
Josh Prattf80ffb82019-01-22 07:13:51284 // Add values above this line with a corresponding label in
285 // tools/metrics/histograms/enums.xml
pdysona8a9ea02017-04-20 00:00:15286 MAX_VALUE
287};
pdyson7872d6c02017-04-05 23:12:31288
289// Record an UMA metric counting the creation of a dialog box of this type.
290void RecordDialogCreation(DialogIdentifier identifier);
291
alitoe82b14b2017-04-06 23:11:29292#if defined(OS_WIN)
293
Ali Tofigh525f78bdd2017-09-15 15:37:20294// Shows the settings reset prompt dialog asking the user if they want to reset
295// some of their settings.
296void ShowSettingsResetPrompt(
297 Browser* browser,
298 safe_browsing::SettingsResetPromptController* controller);
299
alitoe82b14b2017-04-06 23:11:29300// Shows the Chrome Cleanup dialog asking the user if they want to clean their
301// system from unwanted software. This is called when unwanted software has been
302// detected on the system.
alitof8f753f62017-04-28 23:04:10303void ShowChromeCleanerPrompt(
304 Browser* browser,
Ali Tofighf5baba982017-07-21 23:15:23305 safe_browsing::ChromeCleanerDialogController* dialog_controller,
306 safe_browsing::ChromeCleanerController* cleaner_controller);
alitoe82b14b2017-04-06 23:11:29307
Fabio Tirelo8825aab42017-10-19 13:23:31308// Shows the Chrome Cleanup reboot dialog asking the user if they want to
309// restart their computer once a cleanup has finished. This is called when the
310// Chrome Cleanup ends in a reboot required state.
311void ShowChromeCleanerRebootPrompt(
312 Browser* browser,
313 safe_browsing::ChromeCleanerRebootDialogController* dialog_controller);
314
alitoe82b14b2017-04-06 23:11:29315#endif // OS_WIN
316
Owen Mind6b9de02020-03-14 00:26:54317// Displays a dialog to notify the user that the extension installation is
318// blocked due to policy. It also show additional information from administrator
319// if it exists.
320void ShowExtensionInstallBlockedDialog(
321 const std::string& extension_name,
322 const base::string16& custom_error_message,
323 const gfx::ImageSkia& icon,
324 content::WebContents* web_contents,
325 base::OnceClosure done_callback);
326
Devlin Cronin5739bf02020-05-15 00:38:38327// TODO(devlin): Put more extension-y bits in this block - currently they're
328// unguarded.
329#if BUILDFLAG(ENABLE_EXTENSIONS)
330// Shows the dialog indicating that an extension has overridden a setting.
331void ShowExtensionSettingsOverriddenDialog(
332 std::unique_ptr<SettingsOverriddenDialogController> controller,
333 Browser* browser);
334#endif
335
Elly Fong-Jonesf260d672020-03-16 14:09:07336// Returns a OnceClosure that client code can call to close the device chooser.
337// This OnceClosure references the actual dialog as a WeakPtr, so it's safe to
338// call at any point.
339base::OnceClosure ShowDeviceChooserDialog(
340 content::RenderFrameHost* owner,
341 std::unique_ptr<ChooserController> controller);
Guido Urdanetaaf871dc2020-04-16 06:53:20342bool IsDeviceChooserShowingForTesting(Browser* browser);
Elly Fong-Jonesf260d672020-03-16 14:09:07343
[email protected]87586fb72012-07-02 13:15:02344} // namespace chrome
[email protected]c96531e82011-01-26 03:11:14345
Peter Boström2a02a692018-02-22 22:25:46346void ShowFolderUploadConfirmationDialog(
347 const base::FilePath& path,
348 base::OnceCallback<void(const std::vector<ui::SelectedFileInfo>&)> callback,
349 std::vector<ui::SelectedFileInfo> selected_files,
350 content::WebContents* web_contents);
351
[email protected]c96531e82011-01-26 03:11:14352#endif // CHROME_BROWSER_UI_BROWSER_DIALOGS_H_