blob: f42a0f13f8ec69f6a7e46a1b85e99c8e242ceeec [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
djacobo21e56e02016-07-02 01:14:318#include <string>
9#include <utility>
10#include <vector>
11
[email protected]6684dc8162013-06-03 14:05:0812#include "base/callback.h"
David Benjamin9a5ca912018-03-01 23:23:2913#include "base/memory/scoped_refptr.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"
Jun Caibc561f412018-02-28 18:41:3919#include "content/public/browser/resource_request_info.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;
Giovanni Ortuño Urquidi97f8bd522017-06-16 04:04:3726class WebShareTarget;
tapted712c1b82017-06-08 03:10:0527struct WebApplicationInfo;
[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
anthonyvd3d7f9722016-12-07 18:43:5446namespace payments {
mathpf709499d2017-01-09 20:48:3647class PaymentRequest;
mathpf4bc50e2017-01-24 05:17:5048class PaymentRequestDialog;
Josh Prattf80ffb82019-01-22 07:13:5149} // namespace payments
anthonyvd3d7f9722016-12-07 18:43:5450
alitoe82b14b2017-04-06 23:11:2951namespace safe_browsing {
Ali Tofighf5baba982017-07-21 23:15:2352class ChromeCleanerController;
alitof8f753f62017-04-28 23:04:1053class ChromeCleanerDialogController;
Fabio Tirelo8825aab42017-10-19 13:23:3154class ChromeCleanerRebootDialogController;
Ali Tofigh525f78bdd2017-09-15 15:37:2055class SettingsResetPromptController;
Josh Prattf80ffb82019-01-22 07:13:5156} // namespace safe_browsing
alitoe82b14b2017-04-06 23:11:2957
avi24d693f2016-08-06 18:03:5258namespace task_manager {
nickbb57d2ca2016-07-25 23:08:0459class TaskManagerTableModel;
60}
61
[email protected]20c07f8e2012-05-31 08:43:1462namespace ui {
63class WebDialogDelegate;
Peter Boström2a02a692018-02-22 22:25:4664struct SelectedFileInfo;
Josh Prattf80ffb82019-01-22 07:13:5165} // namespace ui
[email protected]20c07f8e2012-05-31 08:43:1466
[email protected]87586fb72012-07-02 13:15:0267namespace chrome {
[email protected]c96531e82011-01-26 03:11:1468
taptede0eec372016-01-28 02:45:3369// Shows or hides the Task Manager. |browser| can be NULL when called from Ash.
nick399f10662016-05-06 16:20:2670// Returns a pointer to the underlying TableModel, which can be ignored, or used
71// for testing.
avi24d693f2016-08-06 18:03:5272task_manager::TaskManagerTableModel* ShowTaskManager(Browser* browser);
taptede0eec372016-01-28 02:45:3373void HideTaskManager();
74
75#if !defined(OS_MACOSX)
[email protected]d7db4cd2012-06-27 04:58:4476// Creates and shows an HTML dialog with the given delegate and context.
77// The window is automatically destroyed when it is closed.
[email protected]eb2d7902011-02-02 18:19:5678// 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.
andresantosoba3ef5d72014-12-15 20:30:0882gfx::NativeWindow ShowWebDialog(gfx::NativeView parent,
[email protected]6ae4f142012-06-13 19:48:2083 content::BrowserContext* context,
[email protected]20c07f8e2012-05-31 08:43:1484 ui::WebDialogDelegate* delegate);
jamescook1c6343d2016-10-25 16:58:5085#endif // !defined(OS_MACOSX)
[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 =
tapted712c1b82017-06-08 03:10:05100 base::OnceCallback<void(bool, const WebApplicationInfo&)>;
101
102// Shows the Bookmark App bubble.
103// See Extension::InitFromValueFlags::FROM_BOOKMARK for a description of
104// bookmark apps.
105//
106// |web_app_info| is the WebApplicationInfo being converted into an app.
Michael McGreevy556227a52017-11-16 07:47:24107void ShowBookmarkAppDialog(content::WebContents* web_contents,
tapted712c1b82017-06-08 03:10:05108 const WebApplicationInfo& web_app_info,
Michael McGreevy556227a52017-11-16 07:47:24109 AppInstallationAcceptanceCallback callback);
110
Alan Cutter81ac726682018-09-25 00:18:36111// Sets whether |ShowBookmarkAppDialog| should accept immediately without any
112// user interaction.
113void SetAutoAcceptBookmarkAppDialogForTesting(bool auto_accept);
114
Michael McGreevy556227a52017-11-16 07:47:24115// Shows the PWA installation confirmation bubble.
116//
117// |web_app_info| is the WebApplicationInfo to be installed.
118void ShowPWAInstallDialog(content::WebContents* web_contents,
119 const WebApplicationInfo& web_app_info,
120 AppInstallationAcceptanceCallback callback);
tapted712c1b82017-06-08 03:10:05121
Alan Cutter81ac726682018-09-25 00:18:36122// Sets whether |ShowPWAInstallDialog| should accept immediately without any
123// user interaction.
124void SetAutoAcceptPWAInstallDialogForTesting(bool auto_accept);
125
tapted081286e2015-08-10 06:36:30126#if defined(OS_MACOSX)
127
spqchand33344a2016-04-13 02:10:51128// Bridging methods that show/hide the toolkit-views based Task Manager on Mac.
avi24d693f2016-08-06 18:03:52129task_manager::TaskManagerTableModel* ShowTaskManagerViews(Browser* browser);
spqchand33344a2016-04-13 02:10:51130void HideTaskManagerViews();
131
kerrnel28a279f92017-01-27 05:22:26132// Show the Views "Chrome Update" dialog.
133void ShowUpdateChromeDialogViews(gfx::NativeWindow parent);
134
tapted081286e2015-08-10 06:36:30135#endif // OS_MACOSX
136
137#if defined(TOOLKIT_VIEWS)
138
139// Creates a toolkit-views based LoginHandler (e.g. HTTP-Auth dialog).
David Benjamin9a5ca912018-03-01 23:23:29140scoped_refptr<LoginHandler> CreateLoginHandlerViews(
Jun Caibc561f412018-02-28 18:41:39141 net::AuthChallengeInfo* auth_info,
142 content::ResourceRequestInfo::WebContentsGetter web_contents_getter,
Mark Pilgrim7cfcd112018-05-08 00:07:56143 LoginAuthRequiredCallback auth_required_callback);
tapted081286e2015-08-10 06:36:30144
jackhoub42a1f3d2015-08-24 05:53:28145// Shows the toolkit-views based BookmarkEditor.
146void ShowBookmarkEditorViews(gfx::NativeWindow parent_window,
147 Profile* profile,
148 const BookmarkEditor::EditDetails& details,
149 BookmarkEditor::Configuration configuration);
150
mathpf4bc50e2017-01-24 05:17:50151payments::PaymentRequestDialog* CreatePaymentRequestDialog(
152 payments::PaymentRequest* request);
anthonyvd3d7f9722016-12-07 18:43:54153
Giovanni Ortuño Urquidi97f8bd522017-06-16 04:04:37154// Used to return the target the user picked or nullptr if the user cancelled
ortuno928d14102017-05-02 00:09:05155// the share.
156using WebShareTargetPickerCallback =
Giovanni Ortuño Urquidi97f8bd522017-06-16 04:04:37157 base::OnceCallback<void(const WebShareTarget*)>;
ortuno928d14102017-05-02 00:09:05158
mgiuca39e40672017-01-31 04:16:49159// Shows the dialog to choose a share target app. |targets| is a list of app
constantinae4c513e72017-02-07 02:14:10160// title and manifest URL pairs that will be shown in a list. If the user picks
161// a target, this calls |callback| with the manifest URL of the chosen target,
162// or supplies null if the user cancelled the share.
Giovanni Ortuño Urquidi97f8bd522017-06-16 04:04:37163void ShowWebShareTargetPickerDialog(gfx::NativeWindow parent_window,
164 std::vector<WebShareTarget> targets,
165 WebShareTargetPickerCallback callback);
mgiuca39e40672017-01-31 04:16:49166
tapted081286e2015-08-10 06:36:30167#endif // TOOLKIT_VIEWS
168
pdyson7872d6c02017-04-05 23:12:31169// Values used in the Dialog.Creation UMA metric. Each value represents a
170// different type of dialog box.
171// These values are written to logs. New enum values can be added, but existing
172// enums must never be renumbered or deleted and reused.
pdysona8a9ea02017-04-20 00:00:15173enum class DialogIdentifier {
174 UNKNOWN = 0,
175 TRANSLATE = 1,
176 BOOKMARK = 2,
177 BOOKMARK_EDITOR = 3,
178 DESKTOP_MEDIA_PICKER = 4,
179 OUTDATED_UPGRADE = 5,
180 ONE_CLICK_SIGNIN = 6,
181 PROFILE_SIGNIN_CONFIRMATION = 7,
182 HUNG_RENDERER = 8,
183 SESSION_CRASHED = 9,
184 CONFIRM_BUBBLE = 10,
185 UPDATE_RECOMMENDED = 11,
186 CRYPTO_PASSWORD = 12,
187 SAFE_BROWSING_DOWNLOAD_FEEDBACK = 13,
188 FIRST_RUN = 14,
189 NETWORK_SHARE_PROFILE_WARNING = 15,
Patrick Monette66e935a2018-06-12 19:16:10190 // CONFLICTING_MODULE = 16, Deprecated
pdysona8a9ea02017-04-20 00:00:15191 CRITICAL_NOTIFICATION = 17,
192 IME_WARNING = 18,
pdyson106455b22017-04-26 01:21:31193 TOOLBAR_ACTIONS_BAR = 19,
194 GLOBAL_ERROR = 20,
195 EXTENSION_INSTALL = 21,
196 EXTENSION_UNINSTALL = 22,
197 EXTENSION_INSTALLED = 23,
198 PAYMENT_REQUEST = 24,
199 SAVE_CARD = 25,
200 CARD_UNMASK = 26,
pdyson918928e2017-05-04 03:50:12201 SIGN_IN = 27,
202 SIGN_IN_SYNC_CONFIRMATION = 28,
203 SIGN_IN_ERROR = 29,
204 SIGN_IN_EMAIL_CONFIRMATION = 30,
205 PROFILE_CHOOSER = 31,
pdyson7fa1d032017-05-17 23:54:45206 ACCOUNT_CHOOSER = 32,
207 ARC_APP = 33,
208 AUTO_SIGNIN_FIRST_RUN = 34,
209 BOOKMARK_APP_CONFIRMATION = 35,
210 CHOOSER_UI = 36,
211 CHOOSER = 37,
212 COLLECTED_COOKIES = 38,
213 CONSTRAINED_WEB = 39,
214 CONTENT_SETTING_CONTENTS = 40,
215 CREATE_CHROME_APPLICATION_SHORTCUT = 41,
216 DOWNLOAD_DANGER_PROMPT = 42,
217 DOWNLOAD_IN_PROGRESS = 43,
218 ECHO = 44,
219 ENROLLMENT = 45,
220 EXTENSION = 46,
221 EXTENSION_POPUP_AURA = 47,
222 EXTERNAL_PROTOCOL = 48,
223 EXTERNAL_PROTOCOL_CHROMEOS = 49,
224 FIRST_RUN_DIALOG = 50,
225 HOME_PAGE_UNDO = 51,
226 IDLE_ACTION_WARNING = 52,
227 IMPORT_LOCK = 53,
228 INTENT_PICKER = 54,
229 INVERT = 55,
230 JAVA_SCRIPT = 56,
231 JAVA_SCRIPT_APP_MODAL_X11 = 57,
232 LOGIN_HANDLER = 58,
233 MANAGE_PASSWORDS = 59,
234 MEDIA_GALLERIES = 60,
235 MULTIPROFILES_INTRO = 61,
236 MULTIPROFILES_SESSION_ABORTED = 62,
237 NATIVE_CONTAINER = 63,
238 NETWORK_CONFIG = 64,
239 PERMISSIONS = 65,
240 PLATFORM_KEYS_CERTIFICATE_SELECTOR = 66,
241 PLATFORM_VERIFICATION = 67,
242 PROXIMITY_AUTH_ERROR = 68,
243 REQUEST_PIN = 69,
244 SSL_CLIENT_CERTIFICATE_SELECTOR = 70,
245 SIMPLE_MESSAGE_BOX = 71,
246 TAB_MODAL_CONFIRM = 72,
247 TASK_MANAGER = 73,
248 TELEPORT_WARNING = 74,
249 USER_MANAGER = 75,
250 USER_MANAGER_PROFILE = 76,
251 VALIDATION_MESSAGE = 77,
252 WEB_SHARE_TARGET_PICKER = 78,
253 ZOOM = 79,
Toni Barzic069197542017-10-17 22:08:01254 LOCK_SCREEN_NOTE_APP_TOAST = 80,
Michael McGreevy556227a52017-11-16 07:47:24255 PWA_CONFIRMATION = 81,
Greg Thompson875403e02018-02-27 16:22:52256 RELAUNCH_RECOMMENDED = 82,
Timothy Loh74cf13c22018-03-01 06:56:24257 CROSTINI_INSTALLER = 83,
Greg Thompson27aef5f2018-03-05 22:10:37258 RELAUNCH_REQUIRED = 84,
Thomas Tangl9e916b232018-04-18 13:07:48259 UNITY_SYNC_CONSENT_BUMP = 85,
Nicholas Verne26965d82018-05-01 02:07:03260 CROSTINI_UNINSTALLER = 86,
Min Qin7b7cbbbf2018-06-04 21:49:31261 DOWNLOAD_OPEN_CONFIRMATION = 87,
[email protected]ef49be42018-07-12 17:54:12262 ARC_DATA_REMOVAL_CONFIRMATION = 88,
Nicholas Vernebc9185c2018-09-13 06:16:01263 CROSTINI_UPGRADE = 89,
Jeffrey Cohen2e9d01a2018-10-11 17:30:39264 HATS_BUBBLE = 90,
Tim Zhengc36d6a52018-10-27 01:05:38265 CROSTINI_APP_RESTART = 91,
Ramin Halavati83d91ec02018-10-30 08:10:10266 INCOGNITO_WINDOW_COUNTER = 92,
Ian Barkley-Yeung42f06e962018-12-14 03:00:41267 CROSTINI_APP_UNINSTALLER = 93,
Josh Prattf80ffb82019-01-22 07:13:51268 CROSTINI_CONTAINER_UPGRADE = 94,
269 // Add values above this line with a corresponding label in
270 // tools/metrics/histograms/enums.xml
pdysona8a9ea02017-04-20 00:00:15271 MAX_VALUE
272};
pdyson7872d6c02017-04-05 23:12:31273
274// Record an UMA metric counting the creation of a dialog box of this type.
275void RecordDialogCreation(DialogIdentifier identifier);
276
alitoe82b14b2017-04-06 23:11:29277#if defined(OS_WIN)
278
Ali Tofigh525f78bdd2017-09-15 15:37:20279// Shows the settings reset prompt dialog asking the user if they want to reset
280// some of their settings.
281void ShowSettingsResetPrompt(
282 Browser* browser,
283 safe_browsing::SettingsResetPromptController* controller);
284
alitoe82b14b2017-04-06 23:11:29285// Shows the Chrome Cleanup dialog asking the user if they want to clean their
286// system from unwanted software. This is called when unwanted software has been
287// detected on the system.
alitof8f753f62017-04-28 23:04:10288void ShowChromeCleanerPrompt(
289 Browser* browser,
Ali Tofighf5baba982017-07-21 23:15:23290 safe_browsing::ChromeCleanerDialogController* dialog_controller,
291 safe_browsing::ChromeCleanerController* cleaner_controller);
alitoe82b14b2017-04-06 23:11:29292
Fabio Tirelo8825aab42017-10-19 13:23:31293// Shows the Chrome Cleanup reboot dialog asking the user if they want to
294// restart their computer once a cleanup has finished. This is called when the
295// Chrome Cleanup ends in a reboot required state.
296void ShowChromeCleanerRebootPrompt(
297 Browser* browser,
298 safe_browsing::ChromeCleanerRebootDialogController* dialog_controller);
299
alitoe82b14b2017-04-06 23:11:29300#endif // OS_WIN
301
[email protected]87586fb72012-07-02 13:15:02302} // namespace chrome
[email protected]c96531e82011-01-26 03:11:14303
Peter Boström2a02a692018-02-22 22:25:46304void ShowFolderUploadConfirmationDialog(
305 const base::FilePath& path,
306 base::OnceCallback<void(const std::vector<ui::SelectedFileInfo>&)> callback,
307 std::vector<ui::SelectedFileInfo> selected_files,
308 content::WebContents* web_contents);
309
[email protected]c96531e82011-01-26 03:11:14310#endif // CHROME_BROWSER_UI_BROWSER_DIALOGS_H_