blob: cde104d98234000bc8464041baf20a032faf4052 [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"
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;
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
anthonyvd3d7f9722016-12-07 18:43:5445namespace payments {
mathpf709499d2017-01-09 20:48:3646class PaymentRequest;
mathpf4bc50e2017-01-24 05:17:5047class PaymentRequestDialog;
Josh Prattf80ffb82019-01-22 07:13:5148} // namespace payments
anthonyvd3d7f9722016-12-07 18:43:5449
alitoe82b14b2017-04-06 23:11:2950namespace safe_browsing {
Ali Tofighf5baba982017-07-21 23:15:2351class ChromeCleanerController;
alitof8f753f62017-04-28 23:04:1052class ChromeCleanerDialogController;
Fabio Tirelo8825aab42017-10-19 13:23:3153class ChromeCleanerRebootDialogController;
Ali Tofigh525f78bdd2017-09-15 15:37:2054class SettingsResetPromptController;
Josh Prattf80ffb82019-01-22 07:13:5155} // namespace safe_browsing
alitoe82b14b2017-04-06 23:11:2956
avi24d693f2016-08-06 18:03:5257namespace task_manager {
nickbb57d2ca2016-07-25 23:08:0458class TaskManagerTableModel;
59}
60
[email protected]20c07f8e2012-05-31 08:43:1461namespace ui {
62class WebDialogDelegate;
Peter Boström2a02a692018-02-22 22:25:4663struct SelectedFileInfo;
Josh Prattf80ffb82019-01-22 07:13:5164} // namespace ui
[email protected]20c07f8e2012-05-31 08:43:1465
[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
74#if !defined(OS_MACOSX)
[email protected]d7db4cd2012-06-27 04:58:4475// Creates and shows an HTML dialog with the given delegate and context.
76// The window is automatically destroyed when it is closed.
[email protected]eb2d7902011-02-02 18:19:5677// Returns the created window.
78//
79// Make sure to use the returned window only when you know it is safe
80// to do so, i.e. before OnDialogClosed() is called on the delegate.
andresantosoba3ef5d72014-12-15 20:30:0881gfx::NativeWindow ShowWebDialog(gfx::NativeView parent,
[email protected]6ae4f142012-06-13 19:48:2082 content::BrowserContext* context,
[email protected]20c07f8e2012-05-31 08:43:1483 ui::WebDialogDelegate* delegate);
jamescook1c6343d2016-10-25 16:58:5084#endif // !defined(OS_MACOSX)
[email protected]eb2d7902011-02-02 18:19:5685
[email protected]497783c2013-10-17 15:54:5786// Shows the create chrome app shortcut dialog box.
[email protected]497783c2013-10-17 15:54:5787// |close_callback| may be null.
[email protected]1148990bb2014-05-02 10:04:0288void ShowCreateChromeAppShortcutsDialog(
89 gfx::NativeWindow parent_window,
90 Profile* profile,
91 const extensions::Extension* app,
92 const base::Callback<void(bool /* created */)>& close_callback);
[email protected]497783c2013-10-17 15:54:5793
Michael McGreevy556227a52017-11-16 07:47:2494// Callback used to indicate whether a user has accepted the installation of a
95// web app. The boolean parameter is true when the user accepts the dialog. The
96// WebApplicationInfo parameter contains the information about the app,
97// possibly modified by the user.
98using AppInstallationAcceptanceCallback =
Eric Willigers61bb4da2019-05-10 20:38:4599 base::OnceCallback<void(bool, std::unique_ptr<WebApplicationInfo>)>;
tapted712c1b82017-06-08 03:10:05100
101// Shows the Bookmark App bubble.
102// See Extension::InitFromValueFlags::FROM_BOOKMARK for a description of
103// bookmark apps.
104//
105// |web_app_info| is the WebApplicationInfo being converted into an app.
Michael McGreevy556227a52017-11-16 07:47:24106void ShowBookmarkAppDialog(content::WebContents* web_contents,
tapted712c1b82017-06-08 03:10:05107 const WebApplicationInfo& web_app_info,
Michael McGreevy556227a52017-11-16 07:47:24108 AppInstallationAcceptanceCallback callback);
109
Alan Cutter81ac726682018-09-25 00:18:36110// Sets whether |ShowBookmarkAppDialog| should accept immediately without any
111// user interaction.
112void SetAutoAcceptBookmarkAppDialogForTesting(bool auto_accept);
113
Alan Cutterf0d263f2019-04-16 14:46:16114// Shows the PWA installation confirmation modal dialog.
Michael McGreevy556227a52017-11-16 07:47:24115//
116// |web_app_info| is the WebApplicationInfo to be installed.
117void ShowPWAInstallDialog(content::WebContents* web_contents,
118 const WebApplicationInfo& web_app_info,
119 AppInstallationAcceptanceCallback callback);
tapted712c1b82017-06-08 03:10:05120
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,
126 const WebApplicationInfo& web_app_info,
127 AppInstallationAcceptanceCallback callback);
128
129// Sets whether |ShowPWAInstallDialog| and |ShowPWAInstallBubble| should accept
130// immediately without any user interaction.
131void SetAutoAcceptPWAInstallConfirmationForTesting(bool auto_accept);
Alan Cutter81ac726682018-09-25 00:18:36132
tapted081286e2015-08-10 06:36:30133#if defined(OS_MACOSX)
134
spqchand33344a2016-04-13 02:10:51135// Bridging methods that show/hide the toolkit-views based Task Manager on Mac.
avi24d693f2016-08-06 18:03:52136task_manager::TaskManagerTableModel* ShowTaskManagerViews(Browser* browser);
spqchand33344a2016-04-13 02:10:51137void HideTaskManagerViews();
138
kerrnel28a279f92017-01-27 05:22:26139// Show the Views "Chrome Update" dialog.
140void ShowUpdateChromeDialogViews(gfx::NativeWindow parent);
141
tapted081286e2015-08-10 06:36:30142#endif // OS_MACOSX
143
144#if defined(TOOLKIT_VIEWS)
145
146// Creates a toolkit-views based LoginHandler (e.g. HTTP-Auth dialog).
David Benjamin78fe5962019-01-29 22:22:38147std::unique_ptr<LoginHandler> CreateLoginHandlerViews(
Emily Starkf2c9bbd2019-04-09 17:08:58148 const net::AuthChallengeInfo& auth_info,
David Benjamin78fe5962019-01-29 22:22:38149 content::WebContents* web_contents,
Mark Pilgrim7cfcd112018-05-08 00:07:56150 LoginAuthRequiredCallback auth_required_callback);
tapted081286e2015-08-10 06:36:30151
jackhoub42a1f3d2015-08-24 05:53:28152// Shows the toolkit-views based BookmarkEditor.
153void ShowBookmarkEditorViews(gfx::NativeWindow parent_window,
154 Profile* profile,
155 const BookmarkEditor::EditDetails& details,
156 BookmarkEditor::Configuration configuration);
157
mathpf4bc50e2017-01-24 05:17:50158payments::PaymentRequestDialog* CreatePaymentRequestDialog(
159 payments::PaymentRequest* request);
anthonyvd3d7f9722016-12-07 18:43:54160
tapted081286e2015-08-10 06:36:30161#endif // TOOLKIT_VIEWS
162
pdyson7872d6c02017-04-05 23:12:31163// Values used in the Dialog.Creation UMA metric. Each value represents a
164// different type of dialog box.
165// These values are written to logs. New enum values can be added, but existing
166// enums must never be renumbered or deleted and reused.
pdysona8a9ea02017-04-20 00:00:15167enum class DialogIdentifier {
168 UNKNOWN = 0,
169 TRANSLATE = 1,
170 BOOKMARK = 2,
171 BOOKMARK_EDITOR = 3,
172 DESKTOP_MEDIA_PICKER = 4,
173 OUTDATED_UPGRADE = 5,
174 ONE_CLICK_SIGNIN = 6,
175 PROFILE_SIGNIN_CONFIRMATION = 7,
176 HUNG_RENDERER = 8,
177 SESSION_CRASHED = 9,
178 CONFIRM_BUBBLE = 10,
179 UPDATE_RECOMMENDED = 11,
180 CRYPTO_PASSWORD = 12,
181 SAFE_BROWSING_DOWNLOAD_FEEDBACK = 13,
182 FIRST_RUN = 14,
183 NETWORK_SHARE_PROFILE_WARNING = 15,
Patrick Monette66e935a2018-06-12 19:16:10184 // CONFLICTING_MODULE = 16, Deprecated
pdysona8a9ea02017-04-20 00:00:15185 CRITICAL_NOTIFICATION = 17,
186 IME_WARNING = 18,
pdyson106455b22017-04-26 01:21:31187 TOOLBAR_ACTIONS_BAR = 19,
188 GLOBAL_ERROR = 20,
189 EXTENSION_INSTALL = 21,
190 EXTENSION_UNINSTALL = 22,
191 EXTENSION_INSTALLED = 23,
192 PAYMENT_REQUEST = 24,
193 SAVE_CARD = 25,
194 CARD_UNMASK = 26,
pdyson918928e2017-05-04 03:50:12195 SIGN_IN = 27,
196 SIGN_IN_SYNC_CONFIRMATION = 28,
197 SIGN_IN_ERROR = 29,
198 SIGN_IN_EMAIL_CONFIRMATION = 30,
199 PROFILE_CHOOSER = 31,
pdyson7fa1d032017-05-17 23:54:45200 ACCOUNT_CHOOSER = 32,
201 ARC_APP = 33,
202 AUTO_SIGNIN_FIRST_RUN = 34,
203 BOOKMARK_APP_CONFIRMATION = 35,
204 CHOOSER_UI = 36,
205 CHOOSER = 37,
206 COLLECTED_COOKIES = 38,
207 CONSTRAINED_WEB = 39,
208 CONTENT_SETTING_CONTENTS = 40,
209 CREATE_CHROME_APPLICATION_SHORTCUT = 41,
210 DOWNLOAD_DANGER_PROMPT = 42,
211 DOWNLOAD_IN_PROGRESS = 43,
212 ECHO = 44,
213 ENROLLMENT = 45,
214 EXTENSION = 46,
215 EXTENSION_POPUP_AURA = 47,
216 EXTERNAL_PROTOCOL = 48,
217 EXTERNAL_PROTOCOL_CHROMEOS = 49,
218 FIRST_RUN_DIALOG = 50,
219 HOME_PAGE_UNDO = 51,
220 IDLE_ACTION_WARNING = 52,
221 IMPORT_LOCK = 53,
222 INTENT_PICKER = 54,
223 INVERT = 55,
224 JAVA_SCRIPT = 56,
225 JAVA_SCRIPT_APP_MODAL_X11 = 57,
226 LOGIN_HANDLER = 58,
227 MANAGE_PASSWORDS = 59,
228 MEDIA_GALLERIES = 60,
229 MULTIPROFILES_INTRO = 61,
230 MULTIPROFILES_SESSION_ABORTED = 62,
231 NATIVE_CONTAINER = 63,
232 NETWORK_CONFIG = 64,
233 PERMISSIONS = 65,
234 PLATFORM_KEYS_CERTIFICATE_SELECTOR = 66,
235 PLATFORM_VERIFICATION = 67,
236 PROXIMITY_AUTH_ERROR = 68,
237 REQUEST_PIN = 69,
238 SSL_CLIENT_CERTIFICATE_SELECTOR = 70,
239 SIMPLE_MESSAGE_BOX = 71,
240 TAB_MODAL_CONFIRM = 72,
241 TASK_MANAGER = 73,
242 TELEPORT_WARNING = 74,
243 USER_MANAGER = 75,
244 USER_MANAGER_PROFILE = 76,
245 VALIDATION_MESSAGE = 77,
246 WEB_SHARE_TARGET_PICKER = 78,
247 ZOOM = 79,
Toni Barzic069197542017-10-17 22:08:01248 LOCK_SCREEN_NOTE_APP_TOAST = 80,
Michael McGreevy556227a52017-11-16 07:47:24249 PWA_CONFIRMATION = 81,
Greg Thompson875403e02018-02-27 16:22:52250 RELAUNCH_RECOMMENDED = 82,
Timothy Loh74cf13c22018-03-01 06:56:24251 CROSTINI_INSTALLER = 83,
Greg Thompson27aef5f2018-03-05 22:10:37252 RELAUNCH_REQUIRED = 84,
Thomas Tangl9e916b232018-04-18 13:07:48253 UNITY_SYNC_CONSENT_BUMP = 85,
Nicholas Verne26965d82018-05-01 02:07:03254 CROSTINI_UNINSTALLER = 86,
Min Qin7b7cbbbf2018-06-04 21:49:31255 DOWNLOAD_OPEN_CONFIRMATION = 87,
[email protected]ef49be42018-07-12 17:54:12256 ARC_DATA_REMOVAL_CONFIRMATION = 88,
Nicholas Vernebc9185c2018-09-13 06:16:01257 CROSTINI_UPGRADE = 89,
Jeffrey Cohen2e9d01a2018-10-11 17:30:39258 HATS_BUBBLE = 90,
Tim Zhengc36d6a52018-10-27 01:05:38259 CROSTINI_APP_RESTART = 91,
Ramin Halavatief75f6c2019-04-02 19:24:51260 INCOGNITO_WINDOW_COUNT = 92,
Ian Barkley-Yeung42f06e962018-12-14 03:00:41261 CROSTINI_APP_UNINSTALLER = 93,
Josh Prattf80ffb82019-01-22 07:13:51262 CROSTINI_CONTAINER_UPGRADE = 94,
263 // Add values above this line with a corresponding label in
264 // tools/metrics/histograms/enums.xml
pdysona8a9ea02017-04-20 00:00:15265 MAX_VALUE
266};
pdyson7872d6c02017-04-05 23:12:31267
268// Record an UMA metric counting the creation of a dialog box of this type.
269void RecordDialogCreation(DialogIdentifier identifier);
270
alitoe82b14b2017-04-06 23:11:29271#if defined(OS_WIN)
272
Ali Tofigh525f78bdd2017-09-15 15:37:20273// Shows the settings reset prompt dialog asking the user if they want to reset
274// some of their settings.
275void ShowSettingsResetPrompt(
276 Browser* browser,
277 safe_browsing::SettingsResetPromptController* controller);
278
alitoe82b14b2017-04-06 23:11:29279// Shows the Chrome Cleanup dialog asking the user if they want to clean their
280// system from unwanted software. This is called when unwanted software has been
281// detected on the system.
alitof8f753f62017-04-28 23:04:10282void ShowChromeCleanerPrompt(
283 Browser* browser,
Ali Tofighf5baba982017-07-21 23:15:23284 safe_browsing::ChromeCleanerDialogController* dialog_controller,
285 safe_browsing::ChromeCleanerController* cleaner_controller);
alitoe82b14b2017-04-06 23:11:29286
Fabio Tirelo8825aab42017-10-19 13:23:31287// Shows the Chrome Cleanup reboot dialog asking the user if they want to
288// restart their computer once a cleanup has finished. This is called when the
289// Chrome Cleanup ends in a reboot required state.
290void ShowChromeCleanerRebootPrompt(
291 Browser* browser,
292 safe_browsing::ChromeCleanerRebootDialogController* dialog_controller);
293
alitoe82b14b2017-04-06 23:11:29294#endif // OS_WIN
295
[email protected]87586fb72012-07-02 13:15:02296} // namespace chrome
[email protected]c96531e82011-01-26 03:11:14297
Peter Boström2a02a692018-02-22 22:25:46298void ShowFolderUploadConfirmationDialog(
299 const base::FilePath& path,
300 base::OnceCallback<void(const std::vector<ui::SelectedFileInfo>&)> callback,
301 std::vector<ui::SelectedFileInfo> selected_files,
302 content::WebContents* web_contents);
303
[email protected]c96531e82011-01-26 03:11:14304#endif // CHROME_BROWSER_UI_BROWSER_DIALOGS_H_