blob: fb010fa29b984cf71b2e8261b88c0fd43659be71 [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;
Marijn Kruisselbrinkff958102019-07-01 20:14:1127enum class PermissionAction;
[email protected]eb2d7902011-02-02 18:19:5628
Peter Boström2a02a692018-02-22 22:25:4629namespace base {
30class FilePath;
31}
32
[email protected]2a6bc3e2011-12-28 23:51:3333namespace content {
[email protected]6ae4f142012-06-13 19:48:2034class BrowserContext;
[email protected]2a6bc3e2011-12-28 23:51:3335class WebContents;
Josh Prattf80ffb82019-01-22 07:13:5136} // namespace content
[email protected]2a6bc3e2011-12-28 23:51:3337
[email protected]1c321ee2012-05-21 03:02:3438namespace extensions {
39class Extension;
40}
41
tapted081286e2015-08-10 06:36:3042namespace net {
43class AuthChallengeInfo;
tapted081286e2015-08-10 06:36:3044}
45
alitoe82b14b2017-04-06 23:11:2946namespace safe_browsing {
Ali Tofighf5baba982017-07-21 23:15:2347class ChromeCleanerController;
alitof8f753f62017-04-28 23:04:1048class ChromeCleanerDialogController;
Fabio Tirelo8825aab42017-10-19 13:23:3149class ChromeCleanerRebootDialogController;
Ali Tofigh525f78bdd2017-09-15 15:37:2050class SettingsResetPromptController;
Josh Prattf80ffb82019-01-22 07:13:5151} // namespace safe_browsing
alitoe82b14b2017-04-06 23:11:2952
avi24d693f2016-08-06 18:03:5253namespace task_manager {
nickbb57d2ca2016-07-25 23:08:0454class TaskManagerTableModel;
55}
56
[email protected]20c07f8e2012-05-31 08:43:1457namespace ui {
58class WebDialogDelegate;
Peter Boström2a02a692018-02-22 22:25:4659struct SelectedFileInfo;
Josh Prattf80ffb82019-01-22 07:13:5160} // namespace ui
[email protected]20c07f8e2012-05-31 08:43:1461
Marijn Kruisselbrinkff958102019-07-01 20:14:1162namespace url {
63class Origin;
64} // namespace url
65
[email protected]87586fb72012-07-02 13:15:0266namespace chrome {
[email protected]c96531e82011-01-26 03:11:1467
taptede0eec372016-01-28 02:45:3368// Shows or hides the Task Manager. |browser| can be NULL when called from Ash.
nick399f10662016-05-06 16:20:2669// Returns a pointer to the underlying TableModel, which can be ignored, or used
70// for testing.
avi24d693f2016-08-06 18:03:5271task_manager::TaskManagerTableModel* ShowTaskManager(Browser* browser);
taptede0eec372016-01-28 02:45:3372void HideTaskManager();
73
[email protected]d7db4cd2012-06-27 04:58:4474// Creates and shows an HTML dialog with the given delegate and context.
75// The window is automatically destroyed when it is closed.
[email protected]eb2d7902011-02-02 18:19:5676// Returns the created window.
77//
78// Make sure to use the returned window only when you know it is safe
79// to do so, i.e. before OnDialogClosed() is called on the delegate.
andresantosoba3ef5d72014-12-15 20:30:0880gfx::NativeWindow ShowWebDialog(gfx::NativeView parent,
[email protected]6ae4f142012-06-13 19:48:2081 content::BrowserContext* context,
[email protected]20c07f8e2012-05-31 08:43:1482 ui::WebDialogDelegate* delegate);
[email protected]eb2d7902011-02-02 18:19:5683
[email protected]497783c2013-10-17 15:54:5784// Shows the create chrome app shortcut dialog box.
[email protected]497783c2013-10-17 15:54:5785// |close_callback| may be null.
[email protected]1148990bb2014-05-02 10:04:0286void ShowCreateChromeAppShortcutsDialog(
87 gfx::NativeWindow parent_window,
88 Profile* profile,
89 const extensions::Extension* app,
90 const base::Callback<void(bool /* created */)>& close_callback);
[email protected]497783c2013-10-17 15:54:5791
Michael McGreevy556227a52017-11-16 07:47:2492// Callback used to indicate whether a user has accepted the installation of a
93// web app. The boolean parameter is true when the user accepts the dialog. The
94// WebApplicationInfo parameter contains the information about the app,
95// possibly modified by the user.
96using AppInstallationAcceptanceCallback =
Eric Willigers61bb4da2019-05-10 20:38:4597 base::OnceCallback<void(bool, std::unique_ptr<WebApplicationInfo>)>;
tapted712c1b82017-06-08 03:10:0598
99// Shows the Bookmark App bubble.
100// See Extension::InitFromValueFlags::FROM_BOOKMARK for a description of
101// bookmark apps.
102//
103// |web_app_info| is the WebApplicationInfo being converted into an app.
Michael McGreevy556227a52017-11-16 07:47:24104void ShowBookmarkAppDialog(content::WebContents* web_contents,
Eric Willigersbf1e5ed2019-05-14 04:56:17105 std::unique_ptr<WebApplicationInfo> web_app_info,
Michael McGreevy556227a52017-11-16 07:47:24106 AppInstallationAcceptanceCallback callback);
107
Alan Cutter81ac726682018-09-25 00:18:36108// Sets whether |ShowBookmarkAppDialog| should accept immediately without any
109// user interaction.
110void SetAutoAcceptBookmarkAppDialogForTesting(bool auto_accept);
111
Alan Cutterf0d263f2019-04-16 14:46:16112// Shows the PWA installation confirmation modal dialog.
Michael McGreevy556227a52017-11-16 07:47:24113//
114// |web_app_info| is the WebApplicationInfo to be installed.
115void ShowPWAInstallDialog(content::WebContents* web_contents,
Eric Willigersbf1e5ed2019-05-14 04:56:17116 std::unique_ptr<WebApplicationInfo> web_app_info,
Michael McGreevy556227a52017-11-16 07:47:24117 AppInstallationAcceptanceCallback callback);
tapted712c1b82017-06-08 03:10:05118
Alan Cutterf0d263f2019-04-16 14:46:16119// Shows the PWA installation confirmation bubble anchored off the PWA install
120// icon in the omnibox.
121//
122// |web_app_info| is the WebApplicationInfo to be installed.
123void ShowPWAInstallBubble(content::WebContents* web_contents,
Eric Willigersbf1e5ed2019-05-14 04:56:17124 std::unique_ptr<WebApplicationInfo> web_app_info,
Alan Cutterf0d263f2019-04-16 14:46:16125 AppInstallationAcceptanceCallback callback);
126
127// Sets whether |ShowPWAInstallDialog| and |ShowPWAInstallBubble| should accept
128// immediately without any user interaction.
129void SetAutoAcceptPWAInstallConfirmationForTesting(bool auto_accept);
Alan Cutter81ac726682018-09-25 00:18:36130
tapted081286e2015-08-10 06:36:30131#if defined(OS_MACOSX)
132
spqchand33344a2016-04-13 02:10:51133// Bridging methods that show/hide the toolkit-views based Task Manager on Mac.
avi24d693f2016-08-06 18:03:52134task_manager::TaskManagerTableModel* ShowTaskManagerViews(Browser* browser);
spqchand33344a2016-04-13 02:10:51135void HideTaskManagerViews();
136
tapted081286e2015-08-10 06:36:30137#endif // OS_MACOSX
138
139#if defined(TOOLKIT_VIEWS)
140
141// Creates a toolkit-views based LoginHandler (e.g. HTTP-Auth dialog).
David Benjamin78fe5962019-01-29 22:22:38142std::unique_ptr<LoginHandler> CreateLoginHandlerViews(
Emily Starkf2c9bbd2019-04-09 17:08:58143 const net::AuthChallengeInfo& auth_info,
David Benjamin78fe5962019-01-29 22:22:38144 content::WebContents* web_contents,
Mark Pilgrim7cfcd112018-05-08 00:07:56145 LoginAuthRequiredCallback auth_required_callback);
tapted081286e2015-08-10 06:36:30146
tapted081286e2015-08-10 06:36:30147#endif // TOOLKIT_VIEWS
148
pdyson7872d6c02017-04-05 23:12:31149// Values used in the Dialog.Creation UMA metric. Each value represents a
150// different type of dialog box.
151// These values are written to logs. New enum values can be added, but existing
152// enums must never be renumbered or deleted and reused.
pdysona8a9ea02017-04-20 00:00:15153enum class DialogIdentifier {
154 UNKNOWN = 0,
155 TRANSLATE = 1,
156 BOOKMARK = 2,
157 BOOKMARK_EDITOR = 3,
158 DESKTOP_MEDIA_PICKER = 4,
159 OUTDATED_UPGRADE = 5,
160 ONE_CLICK_SIGNIN = 6,
161 PROFILE_SIGNIN_CONFIRMATION = 7,
162 HUNG_RENDERER = 8,
163 SESSION_CRASHED = 9,
164 CONFIRM_BUBBLE = 10,
165 UPDATE_RECOMMENDED = 11,
166 CRYPTO_PASSWORD = 12,
167 SAFE_BROWSING_DOWNLOAD_FEEDBACK = 13,
168 FIRST_RUN = 14,
169 NETWORK_SHARE_PROFILE_WARNING = 15,
Patrick Monette66e935a2018-06-12 19:16:10170 // CONFLICTING_MODULE = 16, Deprecated
pdysona8a9ea02017-04-20 00:00:15171 CRITICAL_NOTIFICATION = 17,
172 IME_WARNING = 18,
pdyson106455b22017-04-26 01:21:31173 TOOLBAR_ACTIONS_BAR = 19,
174 GLOBAL_ERROR = 20,
175 EXTENSION_INSTALL = 21,
176 EXTENSION_UNINSTALL = 22,
177 EXTENSION_INSTALLED = 23,
178 PAYMENT_REQUEST = 24,
179 SAVE_CARD = 25,
180 CARD_UNMASK = 26,
pdyson918928e2017-05-04 03:50:12181 SIGN_IN = 27,
182 SIGN_IN_SYNC_CONFIRMATION = 28,
183 SIGN_IN_ERROR = 29,
184 SIGN_IN_EMAIL_CONFIRMATION = 30,
185 PROFILE_CHOOSER = 31,
pdyson7fa1d032017-05-17 23:54:45186 ACCOUNT_CHOOSER = 32,
187 ARC_APP = 33,
188 AUTO_SIGNIN_FIRST_RUN = 34,
189 BOOKMARK_APP_CONFIRMATION = 35,
190 CHOOSER_UI = 36,
191 CHOOSER = 37,
192 COLLECTED_COOKIES = 38,
193 CONSTRAINED_WEB = 39,
194 CONTENT_SETTING_CONTENTS = 40,
195 CREATE_CHROME_APPLICATION_SHORTCUT = 41,
196 DOWNLOAD_DANGER_PROMPT = 42,
197 DOWNLOAD_IN_PROGRESS = 43,
198 ECHO = 44,
199 ENROLLMENT = 45,
200 EXTENSION = 46,
201 EXTENSION_POPUP_AURA = 47,
202 EXTERNAL_PROTOCOL = 48,
203 EXTERNAL_PROTOCOL_CHROMEOS = 49,
204 FIRST_RUN_DIALOG = 50,
205 HOME_PAGE_UNDO = 51,
206 IDLE_ACTION_WARNING = 52,
207 IMPORT_LOCK = 53,
208 INTENT_PICKER = 54,
209 INVERT = 55,
210 JAVA_SCRIPT = 56,
211 JAVA_SCRIPT_APP_MODAL_X11 = 57,
212 LOGIN_HANDLER = 58,
213 MANAGE_PASSWORDS = 59,
214 MEDIA_GALLERIES = 60,
215 MULTIPROFILES_INTRO = 61,
216 MULTIPROFILES_SESSION_ABORTED = 62,
217 NATIVE_CONTAINER = 63,
218 NETWORK_CONFIG = 64,
219 PERMISSIONS = 65,
220 PLATFORM_KEYS_CERTIFICATE_SELECTOR = 66,
221 PLATFORM_VERIFICATION = 67,
222 PROXIMITY_AUTH_ERROR = 68,
223 REQUEST_PIN = 69,
224 SSL_CLIENT_CERTIFICATE_SELECTOR = 70,
225 SIMPLE_MESSAGE_BOX = 71,
226 TAB_MODAL_CONFIRM = 72,
227 TASK_MANAGER = 73,
228 TELEPORT_WARNING = 74,
229 USER_MANAGER = 75,
230 USER_MANAGER_PROFILE = 76,
231 VALIDATION_MESSAGE = 77,
232 WEB_SHARE_TARGET_PICKER = 78,
233 ZOOM = 79,
Toni Barzic069197542017-10-17 22:08:01234 LOCK_SCREEN_NOTE_APP_TOAST = 80,
Michael McGreevy556227a52017-11-16 07:47:24235 PWA_CONFIRMATION = 81,
Greg Thompson875403e02018-02-27 16:22:52236 RELAUNCH_RECOMMENDED = 82,
Timothy Loh74cf13c22018-03-01 06:56:24237 CROSTINI_INSTALLER = 83,
Greg Thompson27aef5f2018-03-05 22:10:37238 RELAUNCH_REQUIRED = 84,
Thomas Tangl9e916b232018-04-18 13:07:48239 UNITY_SYNC_CONSENT_BUMP = 85,
Nicholas Verne26965d82018-05-01 02:07:03240 CROSTINI_UNINSTALLER = 86,
Min Qin7b7cbbbf2018-06-04 21:49:31241 DOWNLOAD_OPEN_CONFIRMATION = 87,
[email protected]ef49be42018-07-12 17:54:12242 ARC_DATA_REMOVAL_CONFIRMATION = 88,
Nicholas Vernebc9185c2018-09-13 06:16:01243 CROSTINI_UPGRADE = 89,
Jeffrey Cohen2e9d01a2018-10-11 17:30:39244 HATS_BUBBLE = 90,
Tim Zhengc36d6a52018-10-27 01:05:38245 CROSTINI_APP_RESTART = 91,
Ramin Halavatief75f6c2019-04-02 19:24:51246 INCOGNITO_WINDOW_COUNT = 92,
Ian Barkley-Yeung42f06e962018-12-14 03:00:41247 CROSTINI_APP_UNINSTALLER = 93,
Josh Prattf80ffb82019-01-22 07:13:51248 CROSTINI_CONTAINER_UPGRADE = 94,
Christian Dullweber10087e02019-08-28 12:23:07249 COOKIE_CONTROLS = 95,
Christopher Gunadi352d90d2019-09-13 16:38:28250 CROSTINI_ANSIBLE_SOFTWARE_CONFIG = 96,
Josh Prattf80ffb82019-01-22 07:13:51251 // Add values above this line with a corresponding label in
252 // tools/metrics/histograms/enums.xml
pdysona8a9ea02017-04-20 00:00:15253 MAX_VALUE
254};
pdyson7872d6c02017-04-05 23:12:31255
256// Record an UMA metric counting the creation of a dialog box of this type.
257void RecordDialogCreation(DialogIdentifier identifier);
258
alitoe82b14b2017-04-06 23:11:29259#if defined(OS_WIN)
260
Ali Tofigh525f78bdd2017-09-15 15:37:20261// Shows the settings reset prompt dialog asking the user if they want to reset
262// some of their settings.
263void ShowSettingsResetPrompt(
264 Browser* browser,
265 safe_browsing::SettingsResetPromptController* controller);
266
alitoe82b14b2017-04-06 23:11:29267// Shows the Chrome Cleanup dialog asking the user if they want to clean their
268// system from unwanted software. This is called when unwanted software has been
269// detected on the system.
alitof8f753f62017-04-28 23:04:10270void ShowChromeCleanerPrompt(
271 Browser* browser,
Ali Tofighf5baba982017-07-21 23:15:23272 safe_browsing::ChromeCleanerDialogController* dialog_controller,
273 safe_browsing::ChromeCleanerController* cleaner_controller);
alitoe82b14b2017-04-06 23:11:29274
Fabio Tirelo8825aab42017-10-19 13:23:31275// Shows the Chrome Cleanup reboot dialog asking the user if they want to
276// restart their computer once a cleanup has finished. This is called when the
277// Chrome Cleanup ends in a reboot required state.
278void ShowChromeCleanerRebootPrompt(
279 Browser* browser,
280 safe_browsing::ChromeCleanerRebootDialogController* dialog_controller);
281
alitoe82b14b2017-04-06 23:11:29282#endif // OS_WIN
283
[email protected]87586fb72012-07-02 13:15:02284} // namespace chrome
[email protected]c96531e82011-01-26 03:11:14285
Peter Boström2a02a692018-02-22 22:25:46286void ShowFolderUploadConfirmationDialog(
287 const base::FilePath& path,
288 base::OnceCallback<void(const std::vector<ui::SelectedFileInfo>&)> callback,
289 std::vector<ui::SelectedFileInfo> selected_files,
290 content::WebContents* web_contents);
291
Marijn Kruisselbrinkff958102019-07-01 20:14:11292// Displays a dialog to ask for write access to the given file or directory for
293// the native file system API.
294void ShowNativeFileSystemPermissionDialog(
295 const url::Origin& origin,
296 const base::FilePath& path,
297 bool is_directory,
298 base::OnceCallback<void(PermissionAction result)> callback,
299 content::WebContents* web_contents);
300
Mike Wasserman51906e22019-08-22 23:24:32301// Displays a dialog to inform the user that the |path| they picked using the
302// native file system API is blocked by chrome. |is_directory| is true if the
303// user was selecting a directory, otherwise the user was selecting files within
304// a directory. |callback| is called when the user has dismissed the dialog.
Marijn Kruisselbrink041f6b62019-07-10 22:13:05305void ShowNativeFileSystemRestrictedDirectoryDialog(
306 const url::Origin& origin,
307 const base::FilePath& path,
Mike Wasserman51906e22019-08-22 23:24:32308 bool is_directory,
Marijn Kruisselbrink1e99484f2019-07-22 21:00:53309 base::OnceCallback<void(
310 content::NativeFileSystemPermissionContext::SensitiveDirectoryResult)>
311 callback,
Marijn Kruisselbrink041f6b62019-07-10 22:13:05312 content::WebContents* web_contents);
313
Marijn Kruisselbrink5a86cf42019-07-10 23:39:12314// Displays a dialog to confirm that the user intended to give read access to a
315// specific directory. Similar to ShowFolderUploadConfirmationDialog above,
316// except for use by the Native File System API.
317void ShowNativeFileSystemDirectoryAccessConfirmationDialog(
318 const url::Origin& origin,
319 const base::FilePath& path,
320 base::OnceCallback<void(PermissionAction result)> callback,
321 content::WebContents* web_contents);
322
[email protected]c96531e82011-01-26 03:11:14323#endif // CHROME_BROWSER_UI_BROWSER_DIALOGS_H_