Commit 989dbd8f authored by Leonard Grey's avatar Leonard Grey Committed by Commit Bot

MacViews: reland 'Shim |ShowModalDialog| for Polychrome'

This was originally https://chromium-review.googlesource.com/c/chromium/src/+/929942
but was reverted because of the hacky way it implemented a components/ function
in Chrome.

It's now rebased on https://chromium-review.googlesource.com/c/chromium/src/+/949362
which made that behavior unnecessary.

Background:
Polychrome is an intermediate step to shipping MacViews browser.
Currently, switching between Cocoa browser and MacViews browser requires
a buildflag. Polychrome builds both Cocoa and MacViews into the same
binary and allows switching between them based on a feature flag.
More details at crbug.com/802257

As Cocoa and (much of) Views were not typically built together,
some symbols were reused. With Polychrome, these are duplicate symbols.
This CL resolves the issue by renaming the Cocoa symbols, and then
shimming them for the (regular, not Polychrome) Cocoa build.

Bug: 808017
Change-Id: Ia42c202e474614c97759aab28c88f580bc0ffabd
Reviewed-on: https://chromium-review.googlesource.com/950063Reviewed-by: default avatarMike Wittman <wittman@chromium.org>
Reviewed-by: default avatarElly Fong-Jones <ellyjones@chromium.org>
Commit-Queue: Leonard Grey <lgrey@chromium.org>
Cr-Commit-Position: refs/heads/master@{#541500}
parent 8e49dd7b
......@@ -16,8 +16,11 @@ static_library("constrained_window") {
"native_web_contents_modal_dialog_manager_views_mac.mm",
]
if (is_mac && !mac_views_browser) {
if (is_mac) {
sources += [ "show_modal_dialog_cocoa.cc" ]
if (mac_views_browser) {
sources += [ "show_modal_dialog_views.cc" ]
}
} else {
sources += [ "show_modal_dialog_views.cc" ]
}
......
......@@ -7,6 +7,7 @@
#include <memory>
#include "build/build_config.h"
#include "ui/gfx/native_widget_types.h"
namespace content {
......@@ -50,6 +51,12 @@ content::WebContents* GetTopLevelWebContents(
// notify via WillClose() when it is being destroyed.
void ShowModalDialog(gfx::NativeWindow dialog,
content::WebContents* web_contents);
#if defined(OS_MACOSX)
// Temporary shim for Polychrome. See bottom of first comment in
// https://crbug.com/804950 for details.
void ShowModalDialogCocoa(gfx::NativeWindow dialog,
content::WebContents* web_contents);
#endif
// Calls CreateWebModalDialogViews, shows the dialog, and returns its widget.
views::Widget* ShowWebModalDialogViews(
......
......@@ -8,6 +8,7 @@
#include "components/web_modal/single_web_contents_dialog_manager.h"
#include "components/web_modal/web_contents_modal_dialog_manager.h"
#include "content/public/browser/web_contents.h"
#include "ui/base/ui_features.h"
#include "ui/gfx/native_widget_types.h"
// TODO(patricialor): This is a layering violation and should be deleted.
......@@ -20,8 +21,8 @@
namespace constrained_window {
void ShowModalDialog(gfx::NativeWindow dialog,
content::WebContents* initiator_web_contents) {
void ShowModalDialogCocoa(gfx::NativeWindow dialog,
content::WebContents* initiator_web_contents) {
web_modal::WebContentsModalDialogManager* manager =
web_modal::WebContentsModalDialogManager::FromWebContents(
initiator_web_contents);
......@@ -31,4 +32,11 @@ void ShowModalDialog(gfx::NativeWindow dialog,
manager->ShowDialogWithManager(dialog, std::move(dialog_manager));
}
#if !BUILDFLAG(MAC_VIEWS_BROWSER)
void ShowModalDialog(gfx::NativeWindow dialog,
content::WebContents* initiator_web_contents) {
ShowModalDialogCocoa(dialog, initiator_web_contents);
}
#endif
} // namespace constrained_window
......@@ -4,17 +4,23 @@
#include <memory>
#include "build/build_config.h"
#include "components/constrained_window/constrained_window_views.h"
#include "components/constrained_window/native_web_contents_modal_dialog_manager_views.h"
#include "components/web_modal/single_web_contents_dialog_manager.h"
#include "components/web_modal/web_contents_modal_dialog_manager.h"
#include "content/public/browser/web_contents.h"
#include "ui/base/ui_base_features.h"
#include "ui/gfx/native_widget_types.h"
namespace constrained_window {
void ShowModalDialog(gfx::NativeWindow dialog,
content::WebContents* web_contents) {
#if defined(OS_MACOSX)
if (features::IsViewsBrowserCocoa())
return ShowModalDialogCocoa(dialog, web_contents);
#endif
web_modal::WebContentsModalDialogManager* manager =
web_modal::WebContentsModalDialogManager::FromWebContents(web_contents);
DCHECK(manager);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment