android_webview
apps
ash
base
build
build_overrides
buildtools
cc
chrome
chromecast
chromeos
cloud_print
components
about_ui
account_id
android_system_error_page
apdu
arc
assist_ranker
autofill
autofill_assistant
autofill_payments_strings_grdp
autofill_strings_grdp
background_task_scheduler
base32
blacklist
bookmark_bar_strings_grdp
bookmarks
browser_sync
browser_ui
browser_watcher
browsing_data
browsing_data_strings_grdp
bubble
captive_portal
cast_certificate
cast_channel
cbor
cdm
certificate_matching
certificate_transparency
chrome_cleaner
chromeos_camera
client_update_protocol
cloud_devices
component_updater
components_strings_grd
consent_auditor
constrained_window
content_capture
content_settings
contextual_search
cookie_config
country_codes
crash
crash_strings_grdp
cronet
crx_file
data_reduction_proxy
data_use_measurement
dbus
device_event_log
discardable_memory
dom_distiller
dom_distiller_strings_grdp
domain_reliability
download
drive
embedder_support
encrypted_messages
error_page
error_page_strings_grdp
exo
external_intents
favicon
favicon_base
feature_engagement
feed
feedback
filename_generation
find_in_page
flags_ui
games
gc
gcm_driver
google
grpc_support
guest_os
guest_view
gwp_asan
handoff
heap_profiling
history
image_fetcher
infobars
invalidation
javascript_dialogs
android
views
BUILD.gn
DEPS
OWNERS
app_modal_dialog_controller.cc
app_modal_dialog_controller.h
app_modal_dialog_manager.cc
app_modal_dialog_manager.h
app_modal_dialog_manager_unittest.cc
app_modal_dialog_queue.cc
app_modal_dialog_queue.h
app_modal_dialog_view.h
extensions_client.h
tab_modal_dialog_manager.cc
tab_modal_dialog_manager.h
tab_modal_dialog_manager_delegate.h
tab_modal_dialog_view.h
javascript_dialogs_strings_grdp
keep_alive_registry
keyed_service
language
language_usage_metrics
leveldb_proto
link_header_util
location
login
lookalikes
management_strings_grdp
media_message_center
metal_util
metrics
metrics_services_manager
minidump_uploader
mirroring
module_installer
nacl
navigation_interception
navigation_metrics
net_log
neterror
network_hints
network_session_configurator
network_time
new_or_sad_tab_strings_grdp
ntp_snippets
ntp_snippets_strings_grdp
ntp_tiles
offline_items_collection
offline_pages
omnibox
omnibox_strings_grdp
onc
open_from_clipboard
openscreen_platform
optimization_guide
os_crypt
ownership
page_image_annotation
page_info
page_info_strings_grdp
page_load_metrics
paint_preview
password_manager
password_manager_strings_grdp
payments
payments_strings_grdp
pdf
pdf_strings_grdp
performance_manager
permissions
permissions_strings_grdp
plugins
policy
policy_strings_grdp
pref_registry
prefs
previews
printing
printing_component_strings_grdp
profile_metrics
proxy_config
pwg_encoder
query_parser
quirks
rappor
reading_list
remote_cocoa
renderer_context_menu
reset_password_strings_grdp
resources
rlz
safe_browsing
safe_search_api
scheduling_metrics
schema_org
search
search_engines
search_provider_logos
security_interstitials
security_interstitials_strings_grdp
security_state
security_state_strings_grdp
send_tab_to_self
send_tab_to_self_strings_grdp
services
session_manager
sessions
signin
soda
spellcheck
sqlite_proto
ssl_errors
ssl_errors_strings_grdp
startup_metric_utils
storage_monitor
strings
subresource_filter
suggestions
sync
sync_bookmarks
sync_device_info
sync_preferences
sync_sessions
sync_ui_strings_grdp
sync_user_events
system_media_controls
tab_count_metrics
tab_groups
tab_groups_strings_grdp
test
timers
tracing
translate
translate_strings_grdp
ui_devtools
ui_metrics
ukm
undo
undo_strings_grdp
unified_consent
update_client
upload_list
url_formatter
url_matcher
url_pattern_index
user_actions_ui
user_manager
user_prefs
variations
vector_icons
version_info
version_ui
version_ui_strings_grdp
visitedlink
viz
web_cache
web_modal
web_resource
webcrypto
webdata
webdata_services
webrtc_logging
wifi
zoom
zucchini
.eslintrc.js
BUILD.gn
DEPS
OWNERS
PRESUBMIT.py
README.md
android_system_error_page_strings.grdp
autofill_assistant_strings.grdp
autofill_payments_strings.grdp
autofill_strings.grdp
bookmark_bar_strings.grdp
bookmark_component_strings.grdp
browsing_data_strings.grdp
components_chromium_strings.grd
components_google_chrome_strings.grd
components_locale_settings.grd
components_settings_strings.grdp
components_strings.grd
crash_strings.grdp
dialog_strings.grdp
dom_distiller_strings.grdp
error_page_strings.grdp
find_in_page_strings.grdp
flags_strings.grdp
history_strings.grdp
javascript_dialogs_strings.grdp
login_dialog_strings.grdp
management_strings.grdp
media_message_center_strings.grdp
new_or_sad_tab_strings.grdp
ntp_snippets_strings.grdp
omnibox_strings.grdp
page_info_strings.grdp
paint_preview_strings.grdp
password_manager_strings.grdp
payments_strings.grdp
pdf_strings.grdp
permissions_strings.grdp
policy_strings.grdp
print_media_strings.grdp
printing_component_strings.grdp
reset_password_strings.grdp
safe_browsing_strings.grdp
security_interstitials_strings.grdp
security_state_strings.grdp
send_tab_to_self_strings.grdp
ssl_errors_strings.grdp
sync_ui_strings.grdp
tab_groups_strings.grdp
translate_strings.grdp
typemaps.gni
undo_strings.grdp
version_ui_strings.grdp
content
courgette
crypto
dbus
device
docs
extensions
fuchsia
gin
google_apis
google_update
gpu
headless
infra
ios
ipc
jingle
media
mojo
native_client_sdk
net
pdf
ppapi
printing
remoting
rlz
sandbox
services
skia
sql
storage
styleguide
testing
third_party
tools
ui
url
weblayer
.clang-format
.clang-tidy
.eslintrc.js
.git-blame-ignore-revs
.gitattributes
.gitignore
.gn
.vpython
.vpython3
.yapfignore
AUTHORS
BUILD.gn
CODE_OF_CONDUCT.md
DEPS
ENG_REVIEW_OWNERS
LICENSE
LICENSE.chromium_os
OWNERS
PRESUBMIT.py
PRESUBMIT_test.py
PRESUBMIT_test_mocks.py
README.md
WATCHLISTS
codereview.settings

The code in this component is unique to javascript dialogs, and does not cover all app modals. Further, it has some view code that isn't specifically for app modal javascript dialogs, but is re-used for tab modals. Some tab modal code from //chrome will be moved here soon, so rename from app_modal to javascript_dialogs. Class names reflect whether their use is specific to the app modal control flow. Also, rename some classes to better reflect their roles: . JavaScriptDialogManager (implements content::JavaScriptDialogManager) => AppModalDialogManager . JavaScriptAppModalDialog => AppModalDialogController . NativeAppModalDialog => AppModalDialogView etc. Bug: 1025256 Change-Id: I0a1865ec71897ae6549184bc317ede29cc56438a Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2031936 Reviewed-by: Avi Drissman <avi@chromium.org> Reviewed-by: Scott Violet <sky@chromium.org> Commit-Queue: Evan Stade <estade@chromium.org> Cr-Commit-Position: refs/heads/master@{#737355}
96 lines
3.6 KiB
C++
96 lines
3.6 KiB
C++
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
#ifndef COMPONENTS_JAVASCRIPT_DIALOGS_APP_MODAL_DIALOG_QUEUE_H_
|
|
#define COMPONENTS_JAVASCRIPT_DIALOGS_APP_MODAL_DIALOG_QUEUE_H_
|
|
|
|
#include "base/containers/circular_deque.h"
|
|
#include "base/macros.h"
|
|
|
|
namespace base {
|
|
template <typename T>
|
|
struct DefaultSingletonTraits;
|
|
}
|
|
|
|
namespace javascript_dialogs {
|
|
|
|
class AppModalDialogController;
|
|
|
|
// Keeps a queue of AppModalDialogControllers, making sure only one app modal
|
|
// dialog is shown at a time.
|
|
// This class is a singleton.
|
|
class AppModalDialogQueue {
|
|
public:
|
|
typedef base::circular_deque<AppModalDialogController*>::iterator iterator;
|
|
|
|
// Returns the singleton instance.
|
|
static AppModalDialogQueue* GetInstance();
|
|
|
|
// Adds a modal dialog to the queue. If there are no other dialogs in the
|
|
// queue, the dialog will be shown immediately. Once it is shown, the
|
|
// most recently active browser window (or whichever is currently active)
|
|
// will be app modal, meaning it will be activated if the user tries to
|
|
// activate any other browser windows.
|
|
// Note: The AppModalDialogController |dialog| must be window modal before it
|
|
// can be added as app modal.
|
|
void AddDialog(AppModalDialogController* dialog);
|
|
|
|
// Removes the current dialog in the queue (the one that is being shown).
|
|
// Shows the next dialog in the queue, if any is present. This does not
|
|
// ensure that the currently showing dialog is closed, it just makes it no
|
|
// longer app modal.
|
|
void ShowNextDialog();
|
|
|
|
// Activates and shows the current dialog, if the user clicks on one of the
|
|
// windows disabled by the presence of an app modal dialog. This forces
|
|
// the window to be visible on the display even if desktop manager software
|
|
// opened the dialog on another virtual desktop. Assumes there is currently a
|
|
// dialog being shown. (Call BrowserList::IsShowingAppModalDialog to test
|
|
// this condition).
|
|
void ActivateModalDialog();
|
|
|
|
// Returns true if there is currently an active app modal dialog box.
|
|
bool HasActiveDialog() const;
|
|
|
|
AppModalDialogController* active_dialog() { return active_dialog_; }
|
|
|
|
// Iterators to walk the queue. The queue does not include the currently
|
|
// active app modal dialog box.
|
|
iterator begin() { return app_modal_dialog_queue_.begin(); }
|
|
iterator end() { return app_modal_dialog_queue_.end(); }
|
|
|
|
private:
|
|
friend struct base::DefaultSingletonTraits<AppModalDialogQueue>;
|
|
|
|
AppModalDialogQueue();
|
|
~AppModalDialogQueue();
|
|
|
|
// Shows |dialog| and notifies the BrowserList that a modal dialog is showing.
|
|
void ShowModalDialog(AppModalDialogController* dialog);
|
|
|
|
// Returns the next dialog to show. This removes entries from
|
|
// app_modal_dialog_queue_ until one is valid or the queue is empty. This
|
|
// returns nullptr if there are no more dialogs, or all the dialogs in the
|
|
// queue are not valid.
|
|
AppModalDialogController* GetNextDialog();
|
|
|
|
// Contains all app modal dialogs which are waiting to be shown. The currently
|
|
// active modal dialog is not included.
|
|
base::circular_deque<AppModalDialogController*> app_modal_dialog_queue_;
|
|
|
|
// The currently active app-modal dialog box. nullptr if there is no active
|
|
// app-modal dialog box.
|
|
AppModalDialogController* active_dialog_;
|
|
|
|
// Stores if |ShowModalDialog()| is currently being called on an app-modal
|
|
// dialog.
|
|
bool showing_modal_dialog_;
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(AppModalDialogQueue);
|
|
};
|
|
|
|
} // namespace javascript_dialogs
|
|
|
|
#endif // COMPONENTS_JAVASCRIPT_DIALOGS_APP_MODAL_DIALOG_QUEUE_H_
|