[iOS Blink] Add dummy implementations for Javascript dialogs
This CL adds dummy implementations to support the javascript dialogs like alert, confirm, and prompt popup boxes on Blink for iOS. This CL introduces new files as below, - tab_modal_dialog_view_ios.h/mm - javascript_tab_modal_dialog_manager_deletate_ios.h/mm The following CLs will implement the missing implementations. Bug: 361215210 Change-Id: Id7088d3f1458304a3cda549b6acaafb3248180d1 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5837321 Reviewed-by: Ted Choc <tedchoc@chromium.org> Commit-Queue: Gyuyoung Kim <gyuyoung@igalia.com> Reviewed-by: Dave Tapuska <dtapuska@chromium.org> Reviewed-by: Ali Juma <ajuma@chromium.org> Reviewed-by: Avi Drissman <avi@chromium.org> Cr-Commit-Position: refs/heads/main@{#1352857}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
4fbe682556
commit
561a14bf24
components/javascript_dialogs
ios/web/content
@ -75,6 +75,13 @@ static_library("javascript_dialogs") {
|
||||
"//ui/android",
|
||||
]
|
||||
}
|
||||
|
||||
if (is_ios) {
|
||||
sources += [
|
||||
"ios/tab_modal_dialog_view_ios.h",
|
||||
"ios/tab_modal_dialog_view_ios.mm",
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
source_set("unit_tests") {
|
||||
|
2
components/javascript_dialogs/ios/OWNERS
Normal file
2
components/javascript_dialogs/ios/OWNERS
Normal file
@ -0,0 +1,2 @@
|
||||
file://ios/web/content/OWNERS
|
||||
gyuyoung@igalia.com
|
@ -0,0 +1,63 @@
|
||||
// Copyright 2024 The Chromium Authors
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef COMPONENTS_JAVASCRIPT_DIALOGS_IOS_TAB_MODAL_DIALOG_VIEW_IOS_H_
|
||||
#define COMPONENTS_JAVASCRIPT_DIALOGS_IOS_TAB_MODAL_DIALOG_VIEW_IOS_H_
|
||||
|
||||
#import <memory>
|
||||
|
||||
#import "base/functional/callback.h"
|
||||
#import "base/memory/weak_ptr.h"
|
||||
#import "components/javascript_dialogs/tab_modal_dialog_view.h"
|
||||
#import "content/public/browser/javascript_dialog_manager.h"
|
||||
|
||||
namespace javascript_dialogs {
|
||||
|
||||
// An iOS version of the JavaScript dialog referring to the Android
|
||||
// implementation.
|
||||
class TabModalDialogViewIOS : public TabModalDialogView {
|
||||
public:
|
||||
TabModalDialogViewIOS(const TabModalDialogViewIOS&) = delete;
|
||||
TabModalDialogViewIOS& operator=(const TabModalDialogViewIOS&) = delete;
|
||||
|
||||
~TabModalDialogViewIOS() override;
|
||||
|
||||
static base::WeakPtr<TabModalDialogViewIOS> Create(
|
||||
content::WebContents* parent_web_contents,
|
||||
content::WebContents* alerting_web_contents,
|
||||
const std::u16string& title,
|
||||
content::JavaScriptDialogType dialog_type,
|
||||
const std::u16string& message_text,
|
||||
const std::u16string& default_prompt_text,
|
||||
content::JavaScriptDialogManager::DialogClosedCallback
|
||||
callback_on_button_clicked,
|
||||
base::OnceClosure callback_on_cancelled);
|
||||
|
||||
// TabModalDialogView:
|
||||
void CloseDialogWithoutCallback() override;
|
||||
std::u16string GetUserInput() override;
|
||||
|
||||
private:
|
||||
TabModalDialogViewIOS(content::WebContents* parent_web_contents,
|
||||
content::WebContents* alerting_web_contents,
|
||||
const std::u16string& title,
|
||||
content::JavaScriptDialogType dialog_type,
|
||||
const std::u16string& message_text,
|
||||
const std::u16string& default_prompt_text,
|
||||
content::JavaScriptDialogManager::DialogClosedCallback
|
||||
callback_on_button_clicked,
|
||||
base::OnceClosure callback_on_cancelled);
|
||||
|
||||
std::unique_ptr<TabModalDialogViewIOS> dialog_;
|
||||
|
||||
content::JavaScriptDialogManager::DialogClosedCallback
|
||||
callback_on_button_clicked_;
|
||||
base::OnceClosure callback_on_cancelled_;
|
||||
|
||||
base::WeakPtrFactory<TabModalDialogViewIOS> weak_factory_{this};
|
||||
};
|
||||
|
||||
} // namespace javascript_dialogs
|
||||
|
||||
#endif // COMPONENTS_JAVASCRIPT_DIALOGS_IOS_TAB_MODAL_DIALOG_VIEW_IOS_H_
|
@ -0,0 +1,57 @@
|
||||
// Copyright 2024 The Chromium Authors
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#import "components/javascript_dialogs/ios/tab_modal_dialog_view_ios.h"
|
||||
|
||||
#import "content/public/browser/browser_thread.h"
|
||||
#import "content/public/browser/web_contents.h"
|
||||
|
||||
namespace javascript_dialogs {
|
||||
|
||||
// static
|
||||
base::WeakPtr<TabModalDialogViewIOS> TabModalDialogViewIOS::Create(
|
||||
content::WebContents* parent_web_contents,
|
||||
content::WebContents* alerting_web_contents,
|
||||
const std::u16string& title,
|
||||
content::JavaScriptDialogType dialog_type,
|
||||
const std::u16string& message_text,
|
||||
const std::u16string& default_prompt_text,
|
||||
content::JavaScriptDialogManager::DialogClosedCallback
|
||||
callback_on_button_clicked,
|
||||
base::OnceClosure callback_on_cancelled) {
|
||||
return (new TabModalDialogViewIOS(parent_web_contents, alerting_web_contents,
|
||||
title, dialog_type, message_text,
|
||||
default_prompt_text,
|
||||
std::move(callback_on_button_clicked),
|
||||
std::move(callback_on_cancelled)))
|
||||
->weak_factory_.GetWeakPtr();
|
||||
}
|
||||
|
||||
// TabModalDialogViewIOS:
|
||||
TabModalDialogViewIOS::~TabModalDialogViewIOS() {}
|
||||
|
||||
void TabModalDialogViewIOS::CloseDialogWithoutCallback() {
|
||||
delete this;
|
||||
}
|
||||
|
||||
std::u16string TabModalDialogViewIOS::GetUserInput() {
|
||||
return std::u16string();
|
||||
}
|
||||
|
||||
TabModalDialogViewIOS::TabModalDialogViewIOS(
|
||||
content::WebContents* parent_web_contents,
|
||||
content::WebContents* alerting_web_contents,
|
||||
const std::u16string& title,
|
||||
content::JavaScriptDialogType dialog_type,
|
||||
const std::u16string& message_text,
|
||||
const std::u16string& default_prompt_text,
|
||||
content::JavaScriptDialogManager::DialogClosedCallback
|
||||
callback_on_button_clicked,
|
||||
base::OnceClosure callback_on_cancelled)
|
||||
: callback_on_button_clicked_(std::move(callback_on_button_clicked)),
|
||||
callback_on_cancelled_(std::move(callback_on_cancelled)) {
|
||||
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
|
||||
}
|
||||
|
||||
} // namespace javascript_dialogs
|
@ -41,6 +41,7 @@ source_set("content") {
|
||||
"//base",
|
||||
"//build:blink_buildflags",
|
||||
"//components/embedder_support/ios:web_contents_delegate",
|
||||
"//components/javascript_dialogs",
|
||||
"//components/js_injection/browser",
|
||||
"//content/public/browser",
|
||||
"//ios/web/annotations",
|
||||
@ -79,6 +80,8 @@ source_set("ui") {
|
||||
sources = [
|
||||
"ui/content_context_menu_controller.h",
|
||||
"ui/content_context_menu_controller.mm",
|
||||
"ui/javascript_dialogs/javascript_tab_modal_dialog_manager_delegate_ios.h",
|
||||
"ui/javascript_dialogs/javascript_tab_modal_dialog_manager_delegate_ios.mm",
|
||||
"ui/web_contents_view_delegate_impl.h",
|
||||
"ui/web_contents_view_delegate_impl.mm",
|
||||
]
|
||||
@ -86,6 +89,7 @@ source_set("ui") {
|
||||
deps = [
|
||||
":content",
|
||||
"//base",
|
||||
"//components/javascript_dialogs",
|
||||
"//content/public/browser",
|
||||
"//ios/web/public:public",
|
||||
"//ios/web/public/ui:ui",
|
||||
|
@ -1,6 +1,7 @@
|
||||
include_rules = [
|
||||
"+content/public/browser",
|
||||
"+components/crash/core/common",
|
||||
"+components/javascript_dialogs",
|
||||
"+components/js_injection",
|
||||
]
|
||||
specific_include_rules = {
|
||||
|
47
ios/web/content/ui/javascript_dialogs/javascript_tab_modal_dialog_manager_delegate_ios.h
Normal file
47
ios/web/content/ui/javascript_dialogs/javascript_tab_modal_dialog_manager_delegate_ios.h
Normal file
@ -0,0 +1,47 @@
|
||||
// Copyright 2024 The Chromium Authors
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef IOS_WEB_CONTENT_UI_JAVASCRIPT_DIALOGS_JAVASCRIPT_TAB_MODAL_DIALOG_MANAGER_DELEGATE_IOS_H_
|
||||
#define IOS_WEB_CONTENT_UI_JAVASCRIPT_DIALOGS_JAVASCRIPT_TAB_MODAL_DIALOG_MANAGER_DELEGATE_IOS_H_
|
||||
|
||||
#import "base/functional/callback.h"
|
||||
#import "base/memory/raw_ptr.h"
|
||||
#import "components/javascript_dialogs/tab_modal_dialog_manager_delegate.h"
|
||||
|
||||
namespace content {
|
||||
class WebContents;
|
||||
}
|
||||
|
||||
class JavaScriptTabModalDialogManagerDelegateIOS
|
||||
: public javascript_dialogs::TabModalDialogManagerDelegate {
|
||||
public:
|
||||
explicit JavaScriptTabModalDialogManagerDelegateIOS(
|
||||
content::WebContents* web_contents);
|
||||
~JavaScriptTabModalDialogManagerDelegateIOS() override;
|
||||
|
||||
JavaScriptTabModalDialogManagerDelegateIOS(
|
||||
const JavaScriptTabModalDialogManagerDelegateIOS& other) = delete;
|
||||
JavaScriptTabModalDialogManagerDelegateIOS& operator=(
|
||||
const JavaScriptTabModalDialogManagerDelegateIOS& other) = delete;
|
||||
|
||||
// javascript_dialogs::TabModalDialogManagerDelegate:
|
||||
base::WeakPtr<javascript_dialogs::TabModalDialogView> CreateNewDialog(
|
||||
content::WebContents* alerting_web_contents,
|
||||
const std::u16string& title,
|
||||
content::JavaScriptDialogType dialog_type,
|
||||
const std::u16string& message_text,
|
||||
const std::u16string& default_prompt_text,
|
||||
content::JavaScriptDialogManager::DialogClosedCallback dialog_callback,
|
||||
base::OnceClosure dialog_closed_callback) override;
|
||||
void WillRunDialog() override;
|
||||
void DidCloseDialog() override;
|
||||
void SetTabNeedsAttention(bool attention) override;
|
||||
bool IsWebContentsForemost() override;
|
||||
bool IsApp() override;
|
||||
|
||||
private:
|
||||
raw_ptr<content::WebContents> web_contents_;
|
||||
};
|
||||
|
||||
#endif // IOS_WEB_CONTENT_UI_JAVASCRIPT_DIALOGS_JAVASCRIPT_TAB_MODAL_DIALOG_MANAGER_DELEGATE_IOS_H_
|
47
ios/web/content/ui/javascript_dialogs/javascript_tab_modal_dialog_manager_delegate_ios.mm
Normal file
47
ios/web/content/ui/javascript_dialogs/javascript_tab_modal_dialog_manager_delegate_ios.mm
Normal file
@ -0,0 +1,47 @@
|
||||
// Copyright 2024 The Chromium Authors
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#import "ios/web/content/ui/javascript_dialogs/javascript_tab_modal_dialog_manager_delegate_ios.h"
|
||||
|
||||
#import "components/javascript_dialogs/ios/tab_modal_dialog_view_ios.h"
|
||||
#import "content/public/browser/javascript_dialog_manager.h"
|
||||
|
||||
JavaScriptTabModalDialogManagerDelegateIOS::
|
||||
JavaScriptTabModalDialogManagerDelegateIOS(
|
||||
content::WebContents* web_contents)
|
||||
: web_contents_(web_contents) {}
|
||||
|
||||
JavaScriptTabModalDialogManagerDelegateIOS::
|
||||
~JavaScriptTabModalDialogManagerDelegateIOS() = default;
|
||||
|
||||
base::WeakPtr<javascript_dialogs::TabModalDialogView>
|
||||
JavaScriptTabModalDialogManagerDelegateIOS::CreateNewDialog(
|
||||
content::WebContents* alerting_web_contents,
|
||||
const std::u16string& title,
|
||||
content::JavaScriptDialogType dialog_type,
|
||||
const std::u16string& message_text,
|
||||
const std::u16string& default_prompt_text,
|
||||
content::JavaScriptDialogManager::DialogClosedCallback
|
||||
callback_on_button_clicked,
|
||||
base::OnceClosure callback_on_cancelled) {
|
||||
return javascript_dialogs::TabModalDialogViewIOS::Create(
|
||||
web_contents_, alerting_web_contents, title, dialog_type, message_text,
|
||||
default_prompt_text, std::move(callback_on_button_clicked),
|
||||
std::move(callback_on_cancelled));
|
||||
}
|
||||
|
||||
void JavaScriptTabModalDialogManagerDelegateIOS::WillRunDialog() {}
|
||||
|
||||
void JavaScriptTabModalDialogManagerDelegateIOS::DidCloseDialog() {}
|
||||
|
||||
void JavaScriptTabModalDialogManagerDelegateIOS::SetTabNeedsAttention(
|
||||
bool attention) {}
|
||||
|
||||
bool JavaScriptTabModalDialogManagerDelegateIOS::IsWebContentsForemost() {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool JavaScriptTabModalDialogManagerDelegateIOS::IsApp() {
|
||||
return false;
|
||||
}
|
@ -6,15 +6,22 @@
|
||||
|
||||
#import <memory>
|
||||
|
||||
#import "components/javascript_dialogs/tab_modal_dialog_manager.h"
|
||||
#import "content/public/browser/context_menu_params.h"
|
||||
#import "content/public/browser/render_frame_host.h"
|
||||
#import "content/public/browser/web_contents.h"
|
||||
#import "content/public/browser/web_contents_view_delegate.h"
|
||||
#import "ios/web/content/ui/content_context_menu_controller.h"
|
||||
#import "ios/web/content/ui/javascript_dialogs/javascript_tab_modal_dialog_manager_delegate_ios.h"
|
||||
|
||||
WebContentsViewDelegateImpl::WebContentsViewDelegateImpl(
|
||||
content::WebContents* web_contents)
|
||||
: web_contents_(web_contents) {}
|
||||
: web_contents_(web_contents) {
|
||||
javascript_dialogs::TabModalDialogManager::CreateForWebContents(
|
||||
web_contents_.get(),
|
||||
std::make_unique<JavaScriptTabModalDialogManagerDelegateIOS>(
|
||||
web_contents_.get()));
|
||||
}
|
||||
|
||||
WebContentsViewDelegateImpl::~WebContentsViewDelegateImpl() {}
|
||||
|
||||
|
@ -37,6 +37,7 @@ class FileChooserParams;
|
||||
|
||||
namespace content {
|
||||
class FileSelectListener;
|
||||
class JavaScriptDialogManager;
|
||||
class NavigationEntry;
|
||||
class NavigationHandle;
|
||||
class RenderFrameHost;
|
||||
@ -224,6 +225,9 @@ class ContentWebState : public WebState,
|
||||
scoped_refptr<content::FileSelectListener> listener,
|
||||
const blink::mojom::FileChooserParams& params) override;
|
||||
|
||||
content::JavaScriptDialogManager* GetJavaScriptDialogManager(
|
||||
content::WebContents* source) override;
|
||||
|
||||
private:
|
||||
// Helper method to register notification observers.
|
||||
void RegisterNotificationObservers();
|
||||
|
@ -9,7 +9,9 @@
|
||||
#import "base/strings/utf_string_conversions.h"
|
||||
#import "components/embedder_support/ios/delegate/color_chooser/color_chooser_ios.h"
|
||||
#import "components/embedder_support/ios/delegate/file_chooser/file_select_helper_ios.h"
|
||||
#import "components/javascript_dialogs/tab_modal_dialog_manager.h"
|
||||
#import "content/public/browser/file_select_listener.h"
|
||||
#import "content/public/browser/javascript_dialog_manager.h"
|
||||
#import "content/public/browser/navigation_entry.h"
|
||||
#import "content/public/browser/visibility.h"
|
||||
#import "content/public/browser/web_contents.h"
|
||||
@ -836,4 +838,11 @@ void ContentWebState::RunFileChooser(
|
||||
render_frame_host, listener, params);
|
||||
}
|
||||
|
||||
content::JavaScriptDialogManager* ContentWebState::GetJavaScriptDialogManager(
|
||||
content::WebContents* source) {
|
||||
content::JavaScriptDialogManager* dialog =
|
||||
javascript_dialogs::TabModalDialogManager::FromWebContents(source);
|
||||
return dialog;
|
||||
}
|
||||
|
||||
} // namespace web
|
||||
|
Reference in New Issue
Block a user