blob: 56e3ce4202421833df59c39bcd1456d943983594 [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"
Marijn Kruisselbrink1e99484f2019-07-22 21:00:5319#include "content/public/browser/native_file_system_permission_context.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;
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
Marijn Kruisselbrinkff958102019-07-01 20:14:1165namespace url {
66class Origin;
67} // namespace url
68
[email protected]87586fb72012-07-02 13:15:0269namespace chrome {
[email protected]c96531e82011-01-26 03:11:1470
taptede0eec372016-01-28 02:45:3371// Shows or hides the Task Manager. |browser| can be NULL when called from Ash.
nick399f10662016-05-06 16:20:2672// Returns a pointer to the underlying TableModel, which can be ignored, or used
73// for testing.
avi24d693f2016-08-06 18:03:5274task_manager::TaskManagerTableModel* ShowTaskManager(Browser* browser);
taptede0eec372016-01-28 02:45:3375void HideTaskManager();
76
[email protected]d7db4cd2012-06-27 04:58:4477// Creates and shows an HTML dialog with the given delegate and context.
78// The window is automatically destroyed when it is closed.
[email protected]eb2d7902011-02-02 18:19:5679// Returns the created window.
80//
81// Make sure to use the returned window only when you know it is safe
82// to do so, i.e. before OnDialogClosed() is called on the delegate.
andresantosoba3ef5d72014-12-15 20:30:0883gfx::NativeWindow ShowWebDialog(gfx::NativeView parent,
[email protected]6ae4f142012-06-13 19:48:2084 content::BrowserContext* context,
[email protected]20c07f8e2012-05-31 08:43:1485 ui::WebDialogDelegate* delegate);
[email protected]eb2d7902011-02-02 18:19:5686
[email protected]497783c2013-10-17 15:54:5787// Shows the create chrome app shortcut dialog box.
[email protected]497783c2013-10-17 15:54:5788// |close_callback| may be null.
[email protected]1148990bb2014-05-02 10:04:0289void ShowCreateChromeAppShortcutsDialog(
90 gfx::NativeWindow parent_window,
91 Profile* profile,
92 const extensions::Extension* app,
93 const base::Callback<void(bool /* created */)>& close_callback);
[email protected]497783c2013-10-17 15:54:5794
Michael McGreevy556227a52017-11-16 07:47:2495// Callback used to indicate whether a user has accepted the installation of a
96// web app. The boolean parameter is true when the user accepts the dialog. The
97// WebApplicationInfo parameter contains the information about the app,
98// possibly modified by the user.
99using AppInstallationAcceptanceCallback =
Eric Willigers61bb4da2019-05-10 20:38:45100 base::OnceCallback<void(bool, std::unique_ptr<WebApplicationInfo>)>;
tapted712c1b82017-06-08 03:10:05101
Eric Willigersb5235c52020-03-03 03:09:13102// Shows the Web App bubble.
tapted712c1b82017-06-08 03:10:05103//
104// |web_app_info| is the WebApplicationInfo being converted into an app.
Eric Willigersb5235c52020-03-03 03:09:13105// |web_app_info.app_url| should contain a start url from a web app manifest
106// (for a Desktop PWA), or the current url (when creating a shortcut app).
107void ShowWebAppDialog(content::WebContents* web_contents,
108 std::unique_ptr<WebApplicationInfo> web_app_info,
109 AppInstallationAcceptanceCallback callback);
Michael McGreevy556227a52017-11-16 07:47:24110
Eric Willigersb5235c52020-03-03 03:09:13111// Sets whether |ShowWebAppDialog| should accept immediately without any
Jeevan Shikaramd9491e52019-12-05 04:05:49112// user interaction. |auto_open_in_window| sets whether the open in window
113// checkbox is checked.
Eric Willigersb5235c52020-03-03 03:09:13114void SetAutoAcceptWebAppDialogForTesting(bool auto_accept,
115 bool auto_open_in_window);
Alan Cutter81ac726682018-09-25 00:18:36116
Alan Cutterf0d263f2019-04-16 14:46:16117// Shows the PWA installation confirmation bubble anchored off the PWA install
118// icon in the omnibox.
119//
120// |web_app_info| is the WebApplicationInfo to be installed.
121void ShowPWAInstallBubble(content::WebContents* web_contents,
Eric Willigersbf1e5ed2019-05-14 04:56:17122 std::unique_ptr<WebApplicationInfo> web_app_info,
Alan Cutterf0d263f2019-04-16 14:46:16123 AppInstallationAcceptanceCallback callback);
124
Alan Cuttera0ccba082019-12-20 00:41:34125// Sets whether |ShowPWAInstallBubble| should accept immediately without any
126// user interaction.
Alan Cutterf0d263f2019-04-16 14:46:16127void SetAutoAcceptPWAInstallConfirmationForTesting(bool auto_accept);
Alan Cutter81ac726682018-09-25 00:18:36128
Nikita Podguzov107cccc12020-02-04 17:57:05129#if defined(OS_CHROMEOS)
130
131// Shows the print job confirmation dialog bubble anchored to the toolbar icon
132// for the extension.
133// If there's no toolbar icon, shows a modal dialog using
134// CreateBrowserModalDialogViews(). Note that this dialog is shown up even if we
135// have no |parent| window.
136void ShowPrintJobConfirmationDialog(gfx::NativeWindow parent,
137 const std::string& extension_id,
138 const base::string16& extension_name,
139 const gfx::ImageSkia& extension_icon,
140 const base::string16& print_job_title,
141 const base::string16& printer_name,
142 base::OnceCallback<void(bool)> callback);
143
144#endif // OS_CHROMEOS
145
tapted081286e2015-08-10 06:36:30146#if defined(OS_MACOSX)
147
spqchand33344a2016-04-13 02:10:51148// Bridging methods that show/hide the toolkit-views based Task Manager on Mac.
avi24d693f2016-08-06 18:03:52149task_manager::TaskManagerTableModel* ShowTaskManagerViews(Browser* browser);
spqchand33344a2016-04-13 02:10:51150void HideTaskManagerViews();
151
tapted081286e2015-08-10 06:36:30152#endif // OS_MACOSX
153
154#if defined(TOOLKIT_VIEWS)
155
156// Creates a toolkit-views based LoginHandler (e.g. HTTP-Auth dialog).
David Benjamin78fe5962019-01-29 22:22:38157std::unique_ptr<LoginHandler> CreateLoginHandlerViews(
Emily Starkf2c9bbd2019-04-09 17:08:58158 const net::AuthChallengeInfo& auth_info,
David Benjamin78fe5962019-01-29 22:22:38159 content::WebContents* web_contents,
Mark Pilgrim7cfcd112018-05-08 00:07:56160 LoginAuthRequiredCallback auth_required_callback);
tapted081286e2015-08-10 06:36:30161
tapted081286e2015-08-10 06:36:30162#endif // TOOLKIT_VIEWS
163
pdyson7872d6c02017-04-05 23:12:31164// Values used in the Dialog.Creation UMA metric. Each value represents a
165// different type of dialog box.
166// These values are written to logs. New enum values can be added, but existing
167// enums must never be renumbered or deleted and reused.
pdysona8a9ea02017-04-20 00:00:15168enum class DialogIdentifier {
169 UNKNOWN = 0,
170 TRANSLATE = 1,
171 BOOKMARK = 2,
172 BOOKMARK_EDITOR = 3,
173 DESKTOP_MEDIA_PICKER = 4,
174 OUTDATED_UPGRADE = 5,
175 ONE_CLICK_SIGNIN = 6,
176 PROFILE_SIGNIN_CONFIRMATION = 7,
177 HUNG_RENDERER = 8,
178 SESSION_CRASHED = 9,
179 CONFIRM_BUBBLE = 10,
180 UPDATE_RECOMMENDED = 11,
181 CRYPTO_PASSWORD = 12,
182 SAFE_BROWSING_DOWNLOAD_FEEDBACK = 13,
183 FIRST_RUN = 14,
184 NETWORK_SHARE_PROFILE_WARNING = 15,
Patrick Monette66e935a2018-06-12 19:16:10185 // CONFLICTING_MODULE = 16, Deprecated
pdysona8a9ea02017-04-20 00:00:15186 CRITICAL_NOTIFICATION = 17,
187 IME_WARNING = 18,
pdyson106455b22017-04-26 01:21:31188 TOOLBAR_ACTIONS_BAR = 19,
189 GLOBAL_ERROR = 20,
190 EXTENSION_INSTALL = 21,
191 EXTENSION_UNINSTALL = 22,
192 EXTENSION_INSTALLED = 23,
193 PAYMENT_REQUEST = 24,
194 SAVE_CARD = 25,
195 CARD_UNMASK = 26,
pdyson918928e2017-05-04 03:50:12196 SIGN_IN = 27,
197 SIGN_IN_SYNC_CONFIRMATION = 28,
198 SIGN_IN_ERROR = 29,
199 SIGN_IN_EMAIL_CONFIRMATION = 30,
200 PROFILE_CHOOSER = 31,
pdyson7fa1d032017-05-17 23:54:45201 ACCOUNT_CHOOSER = 32,
202 ARC_APP = 33,
203 AUTO_SIGNIN_FIRST_RUN = 34,
Eric Willigers1e612cf2020-03-04 21:49:47204 WEB_APP_CONFIRMATION = 35,
pdyson7fa1d032017-05-17 23:54:45205 CHOOSER_UI = 36,
206 CHOOSER = 37,
207 COLLECTED_COOKIES = 38,
208 CONSTRAINED_WEB = 39,
209 CONTENT_SETTING_CONTENTS = 40,
210 CREATE_CHROME_APPLICATION_SHORTCUT = 41,
211 DOWNLOAD_DANGER_PROMPT = 42,
212 DOWNLOAD_IN_PROGRESS = 43,
213 ECHO = 44,
214 ENROLLMENT = 45,
215 EXTENSION = 46,
216 EXTENSION_POPUP_AURA = 47,
217 EXTERNAL_PROTOCOL = 48,
218 EXTERNAL_PROTOCOL_CHROMEOS = 49,
219 FIRST_RUN_DIALOG = 50,
220 HOME_PAGE_UNDO = 51,
221 IDLE_ACTION_WARNING = 52,
222 IMPORT_LOCK = 53,
223 INTENT_PICKER = 54,
224 INVERT = 55,
225 JAVA_SCRIPT = 56,
226 JAVA_SCRIPT_APP_MODAL_X11 = 57,
227 LOGIN_HANDLER = 58,
228 MANAGE_PASSWORDS = 59,
229 MEDIA_GALLERIES = 60,
230 MULTIPROFILES_INTRO = 61,
231 MULTIPROFILES_SESSION_ABORTED = 62,
232 NATIVE_CONTAINER = 63,
233 NETWORK_CONFIG = 64,
234 PERMISSIONS = 65,
235 PLATFORM_KEYS_CERTIFICATE_SELECTOR = 66,
236 PLATFORM_VERIFICATION = 67,
237 PROXIMITY_AUTH_ERROR = 68,
238 REQUEST_PIN = 69,
239 SSL_CLIENT_CERTIFICATE_SELECTOR = 70,
240 SIMPLE_MESSAGE_BOX = 71,
241 TAB_MODAL_CONFIRM = 72,
242 TASK_MANAGER = 73,
243 TELEPORT_WARNING = 74,
244 USER_MANAGER = 75,
245 USER_MANAGER_PROFILE = 76,
246 VALIDATION_MESSAGE = 77,
247 WEB_SHARE_TARGET_PICKER = 78,
248 ZOOM = 79,
Toni Barzic069197542017-10-17 22:08:01249 LOCK_SCREEN_NOTE_APP_TOAST = 80,
Michael McGreevy556227a52017-11-16 07:47:24250 PWA_CONFIRMATION = 81,
Greg Thompson875403e02018-02-27 16:22:52251 RELAUNCH_RECOMMENDED = 82,
Timothy Loh74cf13c22018-03-01 06:56:24252 CROSTINI_INSTALLER = 83,
Greg Thompson27aef5f2018-03-05 22:10:37253 RELAUNCH_REQUIRED = 84,
Thomas Tangl9e916b232018-04-18 13:07:48254 UNITY_SYNC_CONSENT_BUMP = 85,
Nicholas Verne26965d82018-05-01 02:07:03255 CROSTINI_UNINSTALLER = 86,
Min Qin7b7cbbbf2018-06-04 21:49:31256 DOWNLOAD_OPEN_CONFIRMATION = 87,
[email protected]ef49be42018-07-12 17:54:12257 ARC_DATA_REMOVAL_CONFIRMATION = 88,
Nicholas Vernebc9185c2018-09-13 06:16:01258 CROSTINI_UPGRADE = 89,
Jeffrey Cohen2e9d01a2018-10-11 17:30:39259 HATS_BUBBLE = 90,
Tim Zhengc36d6a52018-10-27 01:05:38260 CROSTINI_APP_RESTART = 91,
Ramin Halavatief75f6c2019-04-02 19:24:51261 INCOGNITO_WINDOW_COUNT = 92,
Ian Barkley-Yeung42f06e962018-12-14 03:00:41262 CROSTINI_APP_UNINSTALLER = 93,
Josh Prattf80ffb82019-01-22 07:13:51263 CROSTINI_CONTAINER_UPGRADE = 94,
Christian Dullweber10087e02019-08-28 12:23:07264 COOKIE_CONTROLS = 95,
Christopher Gunadi352d90d2019-09-13 16:38:28265 CROSTINI_ANSIBLE_SOFTWARE_CONFIG = 96,
Travis Skareba1cc442019-10-02 22:28:11266 INCOGNITO_MENU = 97,
267 PHONE_CHOOSER = 98,
268 QR_CODE_GENERATOR = 99,
Nicholas Hollingum266cddd2019-10-03 06:12:44269 CROSTINI_FORCE_CLOSE = 100,
nancyd675d042019-10-21 10:37:21270 APP_UNINSTALL = 101,
Nikita Podguzov107cccc12020-02-04 17:57:05271 PRINT_JOB_CONFIRMATION = 102,
Nicholas Verned8863f12020-03-04 23:03:31272 CROSTINI_RECOVERY = 103,
Danan Sf55c1652020-03-05 03:13:32273 PARENT_PERMISSION = 104, // ChromeOS only.
Josh Prattf80ffb82019-01-22 07:13:51274 // Add values above this line with a corresponding label in
275 // tools/metrics/histograms/enums.xml
pdysona8a9ea02017-04-20 00:00:15276 MAX_VALUE
277};
pdyson7872d6c02017-04-05 23:12:31278
279// Record an UMA metric counting the creation of a dialog box of this type.
280void RecordDialogCreation(DialogIdentifier identifier);
281
alitoe82b14b2017-04-06 23:11:29282#if defined(OS_WIN)
283
Ali Tofigh525f78bdd2017-09-15 15:37:20284// Shows the settings reset prompt dialog asking the user if they want to reset
285// some of their settings.
286void ShowSettingsResetPrompt(
287 Browser* browser,
288 safe_browsing::SettingsResetPromptController* controller);
289
alitoe82b14b2017-04-06 23:11:29290// Shows the Chrome Cleanup dialog asking the user if they want to clean their
291// system from unwanted software. This is called when unwanted software has been
292// detected on the system.
alitof8f753f62017-04-28 23:04:10293void ShowChromeCleanerPrompt(
294 Browser* browser,
Ali Tofighf5baba982017-07-21 23:15:23295 safe_browsing::ChromeCleanerDialogController* dialog_controller,
296 safe_browsing::ChromeCleanerController* cleaner_controller);
alitoe82b14b2017-04-06 23:11:29297
Fabio Tirelo8825aab42017-10-19 13:23:31298// Shows the Chrome Cleanup reboot dialog asking the user if they want to
299// restart their computer once a cleanup has finished. This is called when the
300// Chrome Cleanup ends in a reboot required state.
301void ShowChromeCleanerRebootPrompt(
302 Browser* browser,
303 safe_browsing::ChromeCleanerRebootDialogController* dialog_controller);
304
alitoe82b14b2017-04-06 23:11:29305#endif // OS_WIN
306
[email protected]87586fb72012-07-02 13:15:02307} // namespace chrome
[email protected]c96531e82011-01-26 03:11:14308
Peter Boström2a02a692018-02-22 22:25:46309void ShowFolderUploadConfirmationDialog(
310 const base::FilePath& path,
311 base::OnceCallback<void(const std::vector<ui::SelectedFileInfo>&)> callback,
312 std::vector<ui::SelectedFileInfo> selected_files,
313 content::WebContents* web_contents);
314
Marijn Kruisselbrinkff958102019-07-01 20:14:11315// Displays a dialog to ask for write access to the given file or directory for
316// the native file system API.
317void ShowNativeFileSystemPermissionDialog(
318 const url::Origin& origin,
319 const base::FilePath& path,
320 bool is_directory,
Clark DuVall732778e2020-01-27 18:13:58321 base::OnceCallback<void(permissions::PermissionAction result)> callback,
Marijn Kruisselbrinkff958102019-07-01 20:14:11322 content::WebContents* web_contents);
323
Mike Wasserman51906e22019-08-22 23:24:32324// Displays a dialog to inform the user that the |path| they picked using the
325// native file system API is blocked by chrome. |is_directory| is true if the
326// user was selecting a directory, otherwise the user was selecting files within
327// a directory. |callback| is called when the user has dismissed the dialog.
Marijn Kruisselbrink041f6b62019-07-10 22:13:05328void ShowNativeFileSystemRestrictedDirectoryDialog(
329 const url::Origin& origin,
330 const base::FilePath& path,
Mike Wasserman51906e22019-08-22 23:24:32331 bool is_directory,
Marijn Kruisselbrink1e99484f2019-07-22 21:00:53332 base::OnceCallback<void(
333 content::NativeFileSystemPermissionContext::SensitiveDirectoryResult)>
334 callback,
Marijn Kruisselbrink041f6b62019-07-10 22:13:05335 content::WebContents* web_contents);
336
Marijn Kruisselbrink5a86cf42019-07-10 23:39:12337// Displays a dialog to confirm that the user intended to give read access to a
338// specific directory. Similar to ShowFolderUploadConfirmationDialog above,
339// except for use by the Native File System API.
340void ShowNativeFileSystemDirectoryAccessConfirmationDialog(
341 const url::Origin& origin,
342 const base::FilePath& path,
Clark DuVall732778e2020-01-27 18:13:58343 base::OnceCallback<void(permissions::PermissionAction result)> callback,
Marijn Kruisselbrink5a86cf42019-07-10 23:39:12344 content::WebContents* web_contents);
345
[email protected]c96531e82011-01-26 03:11:14346#endif // CHROME_BROWSER_UI_BROWSER_DIALOGS_H_