#include "components/javascript_dialogs/app_modal_dialog_manager.h"
#include <algorithm>
#include <utility>
#include "base/functional/bind.h"
#include "base/i18n/rtl.h"
#include "base/metrics/histogram_macros.h"
#include "base/strings/utf_string_conversions.h"
#include "build/build_config.h"
#include "components/javascript_dialogs/app_modal_dialog_manager_delegate.h"
#include "components/javascript_dialogs/app_modal_dialog_queue.h"
#include "components/javascript_dialogs/app_modal_dialog_view.h"
#include "components/javascript_dialogs/extensions_client.h"
#include "components/strings/grit/components_strings.h"
#include "components/url_formatter/elide_url.h"
#include "content/public/browser/web_contents.h"
#include "content/public/common/javascript_dialog_type.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/gfx/font_list.h"
#include "url/origin.h"
namespace javascript_dialogs {
namespace {
class DefaultExtensionsClient : public ExtensionsClient { … };
bool ShouldDisplaySuppressCheckbox(
ChromeJavaScriptDialogExtraData* extra_data) { … }
}
AppModalDialogManager* AppModalDialogManager::GetInstance() { … }
void AppModalDialogManager::SetNativeDialogFactory(
AppModalViewFactory factory) { … }
void AppModalDialogManager::SetExtensionsClient(
std::unique_ptr<ExtensionsClient> extensions_client) { … }
void AppModalDialogManager::SetDelegate(
std::unique_ptr<AppModalDialogManagerDelegate> delegate) { … }
AppModalDialogManager::AppModalDialogManager()
: … { … }
AppModalDialogManager::~AppModalDialogManager() = default;
std::u16string AppModalDialogManager::GetTitle(
content::WebContents* web_contents,
const url::Origin& alerting_frame_origin) { … }
namespace {
url::Origin UnwrapOriginIfOpaque(const url::Origin& origin) { … }
}
std::u16string AppModalDialogManager::GetSiteFrameTitle(
const url::Origin& main_frame_origin,
const url::Origin& alerting_frame_origin) { … }
void AppModalDialogManager::RunJavaScriptDialog(
content::WebContents* web_contents,
content::RenderFrameHost* render_frame_host,
content::JavaScriptDialogType dialog_type,
const std::u16string& message_text,
const std::u16string& default_prompt_text,
DialogClosedCallback callback,
bool* did_suppress_message) { … }
void AppModalDialogManager::RunBeforeUnloadDialog(
content::WebContents* web_contents,
content::RenderFrameHost* render_frame_host,
bool is_reload,
DialogClosedCallback callback) { … }
void AppModalDialogManager::RunBeforeUnloadDialogWithOptions(
content::WebContents* web_contents,
content::RenderFrameHost* render_frame_host,
bool is_reload,
bool is_app,
DialogClosedCallback callback) { … }
bool AppModalDialogManager::HandleJavaScriptDialog(
content::WebContents* web_contents,
bool accept,
const std::u16string* prompt_override) { … }
void AppModalDialogManager::CancelDialogs(content::WebContents* web_contents,
bool reset_state) { … }
void AppModalDialogManager::OnDialogClosed(content::WebContents* web_contents,
DialogClosedCallback callback,
bool success,
const std::u16string& user_input) { … }
}