Commit e890f893 authored by Nico Weber's avatar Nico Weber Committed by Commit Bot

mac: Remove unused SingleWebContentsDialogManagerViewsMac.

Also removes a layering violation between components/ and chrome/.

Bug: 832676
Change-Id: Id894be95a9ac589da59b7a8f5587a3f4a09307cf
Reviewed-on: https://chromium-review.googlesource.com/1244017
Commit-Queue: Nico Weber <thakis@chromium.org>
Reviewed-by: default avatarMike Wittman <wittman@chromium.org>
Reviewed-by: default avatarRobert Sesek <rsesek@chromium.org>
Cr-Commit-Position: refs/heads/master@{#594071}
parent 3ce09fc0
...@@ -104,7 +104,6 @@ jumbo_split_static_library("ui") { ...@@ -104,7 +104,6 @@ jumbo_split_static_library("ui") {
"cocoa/constrained_window/constrained_window_sheet_info.mm", "cocoa/constrained_window/constrained_window_sheet_info.mm",
"cocoa/constrained_window/constrained_window_web_dialog_sheet.h", "cocoa/constrained_window/constrained_window_web_dialog_sheet.h",
"cocoa/constrained_window/constrained_window_web_dialog_sheet.mm", "cocoa/constrained_window/constrained_window_web_dialog_sheet.mm",
"cocoa/create_native_web_modal_manager_cocoa.mm",
"cocoa/drag_util.h", "cocoa/drag_util.h",
"cocoa/drag_util.mm", "cocoa/drag_util.mm",
"cocoa/extensions/extension_keybinding_registry_cocoa.h", "cocoa/extensions/extension_keybinding_registry_cocoa.h",
...@@ -224,8 +223,6 @@ jumbo_split_static_library("ui") { ...@@ -224,8 +223,6 @@ jumbo_split_static_library("ui") {
"cocoa/view_id_util.h", "cocoa/view_id_util.h",
"cocoa/view_id_util.mm", "cocoa/view_id_util.mm",
"cocoa/view_resizer.h", "cocoa/view_resizer.h",
"cocoa/web_contents_modal_dialog_manager_views_mac.h",
"cocoa/web_contents_modal_dialog_manager_views_mac.mm",
# TODO(estade): this class should be deleted in favor of a combobox model. # TODO(estade): this class should be deleted in favor of a combobox model.
# See crbug.com/590850 # See crbug.com/590850
......
// Copyright 2015 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.
#import "chrome/browser/ui/cocoa/web_contents_modal_dialog_manager_views_mac.h"
#include "components/web_modal/web_contents_modal_dialog_manager.h"
namespace web_modal {
SingleWebContentsDialogManager*
WebContentsModalDialogManager::CreateNativeWebModalManager(
gfx::NativeWindow dialog,
web_modal::SingleWebContentsDialogManagerDelegate* delegate) {
return new SingleWebContentsDialogManagerViewsMac(dialog, delegate);
}
} // namespace web_modal
// Copyright 2015 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 CHROME_BROWSER_UI_COCOA_WEB_CONTENTS_MODAL_DIALOG_MANAGER_VIEWS_MAC_H_
#define CHROME_BROWSER_UI_COCOA_WEB_CONTENTS_MODAL_DIALOG_MANAGER_VIEWS_MAC_H_
#import "base/mac/scoped_nsobject.h"
#include "base/macros.h"
#include "components/web_modal/single_web_contents_dialog_manager.h"
#include "ui/views/widget/widget_observer.h"
@class NSWindow;
@class WrappedConstrainedWindowSheet;
// WebContents dialog manager for a toolkit-views dialog parented off a Cocoa
// browser window. Most of the modality behavior is still performed by the Cocoa
// based ConstrainedWindowSheetController. This class bridges the expectations
// of a toolkit-views dialog to the Cocoa ConstrainedWindowSheetController.
// Note that this is not a web_modal::ModalDialogHostObserver. This is because
// tabs in a Cocoa browser can't be dragged off their window if they have a tab-
// modal dialog open, so the ModalDialogHost is only used by the views plumbing
// when creating the dialog.
class SingleWebContentsDialogManagerViewsMac
: public web_modal::SingleWebContentsDialogManager,
public views::WidgetObserver {
public:
SingleWebContentsDialogManagerViewsMac(
NSWindow* dialog,
web_modal::SingleWebContentsDialogManagerDelegate* delegate);
~SingleWebContentsDialogManagerViewsMac() override;
// SingleWebContentsDialogManager:
void Show() override;
void Hide() override;
void Close() override;
void Focus() override;
void Pulse() override;
void HostChanged(web_modal::WebContentsModalDialogHost* new_host) override;
gfx::NativeWindow dialog() override;
// views::WidgetObserver:
void OnWidgetClosing(views::Widget* widget) override;
void OnWidgetDestroying(views::Widget* widget) override;
private:
base::scoped_nsobject<WrappedConstrainedWindowSheet> sheet_;
// Weak. Owns this.
web_modal::SingleWebContentsDialogManagerDelegate* delegate_;
// Weak. Owned by parent window.
web_modal::WebContentsModalDialogHost* host_;
views::Widget* widget_; // Weak. Deletes |this| when closing.
bool was_shown_ = false;
DISALLOW_COPY_AND_ASSIGN(SingleWebContentsDialogManagerViewsMac);
};
#endif // CHROME_BROWSER_UI_COCOA_WEB_CONTENTS_MODAL_DIALOG_MANAGER_VIEWS_MAC_H_
// Copyright 2015 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.
#import "chrome/browser/ui/cocoa/web_contents_modal_dialog_manager_views_mac.h"
#import <Cocoa/Cocoa.h>
#import "base/mac/foundation_util.h"
#import "chrome/browser/ui/cocoa/constrained_window/constrained_window_sheet.h"
#import "chrome/browser/ui/cocoa/constrained_window/constrained_window_sheet_controller.h"
#include "content/public/browser/web_contents.h"
#include "components/web_modal/web_contents_modal_dialog_host.h"
#import "ui/base/cocoa/constrained_window/constrained_window_animation.h"
#include "ui/views/widget/widget.h"
// A wrapper for a views::Widget dialog to interact with a Cocoa browser's
// ContrainedWindowSheetController. Similar to CustomConstrainedWindowSheet, but
// since Widgets of dialog type animate themselves, and also manage their own
// parenting, there's not much to do except position properly.
@interface WrappedConstrainedWindowSheet : NSObject<ConstrainedWindowSheet> {
@private
base::scoped_nsobject<NSWindow> customWindow_;
}
- (id)initWithCustomWindow:(NSWindow*)customWindow;
@end
@implementation WrappedConstrainedWindowSheet
- (id)initWithCustomWindow:(NSWindow*)customWindow {
if ((self = [super init])) {
customWindow_.reset([customWindow retain]);
}
return self;
}
// ConstrainedWindowSheet implementation.
- (void)showSheetForWindow:(NSWindow*)window {
// This is only called for the initial show, then calls go to unhideSheet.
// Since Widget::Show() will be called, just update the position.
[self updateSheetPosition];
}
- (void)closeSheetWithAnimation:(BOOL)withAnimation {
// Nothing to do here. Either SingleWebContentsDialogManagerViewsMac::Close()
// was called or Widget::Close(). Both cases ending up in OnWidgetClosing() to
// call [ConstrainedWindowSheetController closeSheet:], which calls this.
// However, the Widget is already closing in those cases.
// OnWidgetClosing() is also the _only_ trigger. The exception would be
// -[ConstrainedWindowSheetController onParentWindowWillClose:] which also
// calls closeSheetWithAnimation:, but a Widget never gets there because
// WebContentsModalDialogManager::CloseAllDialogs() is triggered from
// -[BrowserWindowController windowShouldClose:], but the notification that
// calls onParentWindowWillClose always happens once that has returned YES.
// So, since onParentWindowWillClose never calls this, we can assert that
// withAnimation is YES, otherwise there's some code path that might not be
// catered for.
DCHECK(withAnimation);
}
- (void)hideSheet {
// Hide the sheet window by setting the alpha to 0. This technique is used
// instead of -orderOut: because that may cause a Spaces change or window
// ordering change.
[customWindow_ setAlphaValue:0.0];
// TODO(tapted): Support child windows.
DCHECK_EQ(0u, [[customWindow_ childWindows] count]);
}
- (void)unhideSheet {
[customWindow_ setAlphaValue:1.0];
DCHECK_EQ(0u, [[customWindow_ childWindows] count]);
}
- (void)pulseSheet {
base::scoped_nsobject<NSAnimation> animation(
[[ConstrainedWindowAnimationPulse alloc] initWithWindow:customWindow_]);
[animation startAnimation];
}
- (void)makeSheetKeyAndOrderFront {
// If the window is not visible, do nothing. Widget::Show() is responsible for
// showing, and it may want to animate it.
if ([customWindow_ isVisible])
[customWindow_ makeKeyAndOrderFront:nil];
}
- (void)updateSheetPosition {
ConstrainedWindowSheetController* controller =
[ConstrainedWindowSheetController controllerForSheet:self];
NSPoint origin = [controller originForSheet:self
withWindowSize:[customWindow_ frame].size];
[customWindow_ setFrameOrigin:origin];
}
- (void)resizeWithNewSize:(NSSize)size {
// NOOP
}
- (NSWindow*)sheetWindow {
return customWindow_;
}
@end
SingleWebContentsDialogManagerViewsMac::SingleWebContentsDialogManagerViewsMac(
NSWindow* dialog,
web_modal::SingleWebContentsDialogManagerDelegate* delegate)
: delegate_(delegate), host_(nullptr) {
sheet_.reset(
[[WrappedConstrainedWindowSheet alloc] initWithCustomWindow:dialog]);
widget_ = views::Widget::GetWidgetForNativeWindow(dialog);
DCHECK(widget_);
widget_->AddObserver(this);
}
SingleWebContentsDialogManagerViewsMac::
~SingleWebContentsDialogManagerViewsMac() {
DCHECK(!widget_->HasObserver(this));
}
void SingleWebContentsDialogManagerViewsMac::Show() {
DCHECK(host_);
NSView* parent_view = host_->GetHostView();
// Note that simply [parent_view window] for an inactive tab is nil. However,
// the following should always be non-nil for all WebContents containers.
NSWindow* parent_window =
delegate_->GetWebContents()->GetTopLevelNativeWindow();
// Register with the ConstrainedWindowSheetController. This ensures that, e.g.
// the NSView that overlays the Cocoa WebContents to intercept clicks is
// installed and managed.
[[ConstrainedWindowSheetController controllerForParentWindow:parent_window]
showSheet:sheet_
forParentView:parent_view];
if (!widget_->IsVisible()) {
if (was_shown_) {
// Disable animations when switching tabs.
widget_->SetVisibilityChangedAnimationsEnabled(false);
}
widget_->Show();
widget_->SetVisibilityChangedAnimationsEnabled(true);
was_shown_ = true;
}
}
void SingleWebContentsDialogManagerViewsMac::Hide() {
NSWindow* parent_window =
delegate_->GetWebContents()->GetTopLevelNativeWindow();
[[ConstrainedWindowSheetController controllerForParentWindow:parent_window]
hideSheet:sheet_];
widget_->Hide();
}
void SingleWebContentsDialogManagerViewsMac::Close() {
// When the WebContents is destroyed, WebContentsModalDialogManager
// ::CloseAllDialogs will call this. Close the Widget in the same manner as
// the dialogs so that codepaths are consistent.
widget_->SetVisibilityChangedAnimationsEnabled(false);
widget_->Close(); // Note: Synchronously calls OnWidgetClosing() below.
}
void SingleWebContentsDialogManagerViewsMac::Focus() {
[sheet_ makeSheetKeyAndOrderFront];
}
void SingleWebContentsDialogManagerViewsMac::Pulse() {
// Handled by ConstrainedWindowSheetController.
}
void SingleWebContentsDialogManagerViewsMac::HostChanged(
web_modal::WebContentsModalDialogHost* new_host) {
// No need to observe the host. For Cocoa, the constrained window controller
// will reposition the dialog when necessary. The host can also never change.
// Tabs showing a dialog can not be dragged off a Cocoa browser window.
// However, closing a tab with a dialog open will set the host back to null.
DCHECK_NE(!!host_, !!new_host);
host_ = new_host;
}
gfx::NativeWindow SingleWebContentsDialogManagerViewsMac::dialog() {
return [sheet_ sheetWindow];
}
// views::WidgetObserver:
void SingleWebContentsDialogManagerViewsMac::OnWidgetClosing(
views::Widget* widget) {
DCHECK_EQ(widget, widget_);
widget->RemoveObserver(this);
[[ConstrainedWindowSheetController controllerForSheet:sheet_]
closeSheet:sheet_];
delegate_->WillClose(dialog()); // Deletes |this|.
}
void SingleWebContentsDialogManagerViewsMac::OnWidgetDestroying(
views::Widget* widget) {
// On Mac, this would only be reached if something called -[NSWindow close]
// on the dialog without going through Widget::Close or CloseNow(). In this
// case (only), OnWidgetClosing() is skipped, so invoke it here. Note: since
// dialogs have no titlebar, it "shouldn't" happen, but crashes in
// https://crbug.com/825809 suggest it can. Possibly this occurs via code
// injection or a third party tool.
OnWidgetClosing(widget); // Deletes |this|.
}
// Copyright 2015 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.
#import "chrome/browser/ui/cocoa/web_contents_modal_dialog_manager_views_mac.h"
#import <Cocoa/Cocoa.h>
#include "base/location.h"
#include "base/macros.h"
#include "base/run_loop.h"
#include "base/single_thread_task_runner.h"
#include "base/test/test_timeouts.h"
#include "base/threading/thread_task_runner_handle.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/views/scoped_macviews_browser_mode.h"
#include "components/constrained_window/constrained_window_views.h"
#include "ui/views/widget/widget.h"
#include "ui/views/widget/widget_observer.h"
#include "ui/views/window/dialog_delegate.h"
#include "url/gurl.h"
using views::Widget;
namespace {
class WebContentsModalDialogManagerViewsMacTest : public InProcessBrowserTest,
public views::WidgetObserver {
public:
WebContentsModalDialogManagerViewsMacTest() {}
Widget* ShowViewsDialogOn(int web_contents_index, bool activate) {
if (activate)
browser()->tab_strip_model()->ActivateTabAt(web_contents_index, true);
content::WebContents* web_contents =
browser()->tab_strip_model()->GetWebContentsAt(web_contents_index);
DCHECK(web_contents);
// Show a dialog as a constrained window modal to the current tab.
Widget* widget = constrained_window::ShowWebModalDialogViews(new TestDialog,
web_contents);
widget->AddObserver(this);
return widget;
}
void WaitForClose() {
last_destroyed_ = nullptr;
base::RunLoop run_loop;
run_loop_ = &run_loop;
base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
FROM_HERE, run_loop.QuitClosure(), TestTimeouts::action_timeout());
run_loop.Run();
run_loop_ = nullptr;
}
// views::WidgetObserver:
void OnWidgetDestroying(views::Widget* widget) override {
destroy_count_++;
widget->RemoveObserver(this);
last_destroyed_ = widget;
if (run_loop_)
run_loop_->Quit();
}
class TestDialog : public views::DialogDelegateView {
public:
TestDialog() {}
// WidgetDelegate:
ui::ModalType GetModalType() const override { return ui::MODAL_TYPE_CHILD; }
private:
DISALLOW_COPY_AND_ASSIGN(TestDialog);
};
protected:
int destroy_count_ = 0;
Widget* last_destroyed_ = nullptr;
base::RunLoop* run_loop_ = nullptr;
private:
test::ScopedMacViewsBrowserMode cocoa_browser_mode_{false};
DISALLOW_COPY_AND_ASSIGN(WebContentsModalDialogManagerViewsMacTest);
};
} // namespace
// Basic test for showing and dismissing the dialog in a single tab.
IN_PROC_BROWSER_TEST_F(WebContentsModalDialogManagerViewsMacTest, Basic) {
NSArray* children = [browser()->window()->GetNativeWindow() childWindows];
EXPECT_EQ(0u, [children count]);
Widget* dialog = ShowViewsDialogOn(0, true);
EXPECT_TRUE(dialog->IsVisible());
// The browser window will get two child windows: a transparent overlay, and
// the views::Widget dialog. Ensure the dialog is on top.
children = [browser()->window()->GetNativeWindow() childWindows];
EXPECT_EQ(2u, [children count]);
EXPECT_EQ(dialog->GetNativeWindow(), [children objectAtIndex:1]);
// Toolkit-views dialogs use GetWidget()->Close() to dismiss themselves.
dialog->Close();
EXPECT_EQ(0, destroy_count_);
WaitForClose();
EXPECT_EQ(dialog, last_destroyed_);
EXPECT_EQ(1, destroy_count_);
}
// Test for some code injection or third party tool invoking -[NSWindow close].
IN_PROC_BROWSER_TEST_F(WebContentsModalDialogManagerViewsMacTest, NativeClose) {
NSArray* children = [browser()->window()->GetNativeWindow() childWindows];
EXPECT_EQ(0u, [children count]);
Widget* dialog = ShowViewsDialogOn(0, true);
EXPECT_TRUE(dialog->IsVisible());
// Chrome code never does this, but ensure the codepaths are robust to it.
// Invoking this will jump to SingleWebContentsDialogManagerViewsMac::
// OnWidgetDestroying() without first encountering OnWidgetClosing().
[dialog->GetNativeWindow() close];
EXPECT_EQ(1, destroy_count_);
EXPECT_EQ(dialog, last_destroyed_);
}
// Test showing dialogs in two tabs, switch tabs, then close the background tab,
// then close the browser window.
IN_PROC_BROWSER_TEST_F(WebContentsModalDialogManagerViewsMacTest,
TwoDialogsThenCloseTabs) {
// Add a second tab, then show a dialog on each while the tab is active.
AddTabAtIndex(1, GURL("about:blank"), ui::PAGE_TRANSITION_LINK);
Widget* dialog1 = ShowViewsDialogOn(1, true);
Widget* dialog0 = ShowViewsDialogOn(0, true);
// Tab 0 is active, so only |dialog0| should become visible.
EXPECT_TRUE(dialog0->IsVisible());
EXPECT_FALSE(dialog1->IsVisible());
// The inactive, second dialog will also be fully transparent.
EXPECT_EQ(0.0, [dialog1->GetNativeWindow() alphaValue]);
EXPECT_EQ(1.0, [dialog0->GetNativeWindow() alphaValue]);
// Activate the second tab, visibility should switch.
browser()->tab_strip_model()->ActivateTabAt(1, true);
EXPECT_EQ(1.0, [dialog1->GetNativeWindow() alphaValue]);
EXPECT_EQ(0.0, [dialog0->GetNativeWindow() alphaValue]);
EXPECT_FALSE(dialog0->IsVisible());
EXPECT_TRUE(dialog1->IsVisible());
// Close the background tab.
browser()->tab_strip_model()->CloseWebContentsAt(
0, TabStripModel::CLOSE_USER_GESTURE);
// Close is asynchronous, so nothing happens until a run loop is spun up.
EXPECT_EQ(0, destroy_count_);
WaitForClose();
EXPECT_EQ(dialog0, last_destroyed_);
EXPECT_EQ(1, destroy_count_);
// Close the window. But first close all tabs. Otherwise before-unload
// handlers have an opportunity to run, which is asynchronous.
browser()->tab_strip_model()->CloseAllTabs();
// Since the parent NSWindow goes away, close happens immediately.
browser()->window()->Close();
EXPECT_EQ(dialog1, last_destroyed_);
EXPECT_EQ(2, destroy_count_);
}
// Test showing in a dialog in an inactive tab. For these, the WebContentsView
// will be detached from the view hierarchy.
IN_PROC_BROWSER_TEST_F(WebContentsModalDialogManagerViewsMacTest,
DialogInBackgroundTab) {
// Add a second tab. It should start active.
AddTabAtIndex(1, GURL("about:blank"), ui::PAGE_TRANSITION_LINK);
EXPECT_TRUE(browser()->tab_strip_model()->IsTabSelected(1));
// Showing shouldn't change the active tab, and the dialog shouldn't be shown
// at all yet.
Widget* dialog0 = ShowViewsDialogOn(0, false);
EXPECT_TRUE(browser()->tab_strip_model()->IsTabSelected(1));
EXPECT_FALSE(dialog0->IsVisible());
// But switching to the tab should show (and animate) it.
browser()->tab_strip_model()->ActivateTabAt(0, true);
EXPECT_TRUE(browser()->tab_strip_model()->IsTabSelected(0));
EXPECT_TRUE(dialog0->IsVisible());
// Leave the dialog open for a change to ensure shutdown is clean.
}
...@@ -1972,7 +1972,6 @@ test("browser_tests") { ...@@ -1972,7 +1972,6 @@ test("browser_tests") {
"../browser/ui/cocoa/touchbar/browser_window_touch_bar_controller_browsertest.mm", "../browser/ui/cocoa/touchbar/browser_window_touch_bar_controller_browsertest.mm",
"../browser/ui/cocoa/touchbar/text_suggestions_touch_bar_controller_browsertest.mm", "../browser/ui/cocoa/touchbar/text_suggestions_touch_bar_controller_browsertest.mm",
"../browser/ui/cocoa/view_id_util_browsertest.mm", "../browser/ui/cocoa/view_id_util_browsertest.mm",
"../browser/ui/cocoa/web_contents_modal_dialog_manager_views_mac_browsertest.mm",
## TODO(crbug/845389): Re-Enable the following, which were temporarily ## TODO(crbug/845389): Re-Enable the following, which were temporarily
## omitted from the build, but still in use by the Cocoa browser. ## omitted from the build, but still in use by the Cocoa browser.
......
...@@ -14,17 +14,9 @@ static_library("constrained_window") { ...@@ -14,17 +14,9 @@ static_library("constrained_window") {
"native_web_contents_modal_dialog_manager_views.h", "native_web_contents_modal_dialog_manager_views.h",
"native_web_contents_modal_dialog_manager_views_mac.h", "native_web_contents_modal_dialog_manager_views_mac.h",
"native_web_contents_modal_dialog_manager_views_mac.mm", "native_web_contents_modal_dialog_manager_views_mac.mm",
"show_modal_dialog_views.cc",
] ]
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" ]
}
deps = [ deps = [
"//components/guest_view/browser", "//components/guest_view/browser",
"//components/web_modal", "//components/web_modal",
...@@ -52,10 +44,6 @@ source_set("unit_tests") { ...@@ -52,10 +44,6 @@ source_set("unit_tests") {
"constrained_window_views_unittest.cc", "constrained_window_views_unittest.cc",
] ]
if (is_mac) {
sources += [ "test_create_native_web_modal_manager_cocoa.cc" ]
}
deps = [ deps = [
":constrained_window", ":constrained_window",
"//components/web_modal:test_support", "//components/web_modal:test_support",
......
// Copyright 2016 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.
#include <memory>
#include "components/constrained_window/constrained_window_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_features.h"
#include "ui/gfx/native_widget_types.h"
// TODO(patricialor): This is a layering violation and should be deleted.
// Currently it's needed because on Cocoa, the dialog needs to be shown with a
// SingleWebContentsDialogManagerViewsMac, which depends on things inside
// chrome/browser/ui/cocoa/constrained_window/* and thus can't be moved out into
// components/constrained_window/*. Instead, to get this to work, the
// CreateNativeWebModalManager() method is declared in the web_modal component,
// but defined outside of that in c/b/u/cocoa/.
namespace constrained_window {
void ShowModalDialogCocoa(gfx::NativeWindow dialog,
content::WebContents* initiator_web_contents) {
web_modal::WebContentsModalDialogManager* manager =
web_modal::WebContentsModalDialogManager::FromWebContents(
initiator_web_contents);
std::unique_ptr<web_modal::SingleWebContentsDialogManager> dialog_manager(
web_modal::WebContentsModalDialogManager::CreateNativeWebModalManager(
dialog, manager));
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
...@@ -10,17 +10,12 @@ ...@@ -10,17 +10,12 @@
#include "components/web_modal/single_web_contents_dialog_manager.h" #include "components/web_modal/single_web_contents_dialog_manager.h"
#include "components/web_modal/web_contents_modal_dialog_manager.h" #include "components/web_modal/web_contents_modal_dialog_manager.h"
#include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents.h"
#include "ui/base/ui_base_features.h"
#include "ui/gfx/native_widget_types.h" #include "ui/gfx/native_widget_types.h"
namespace constrained_window { namespace constrained_window {
void ShowModalDialog(gfx::NativeWindow dialog, void ShowModalDialog(gfx::NativeWindow dialog,
content::WebContents* web_contents) { content::WebContents* web_contents) {
#if defined(OS_MACOSX)
if (features::IsViewsBrowserCocoa())
return ShowModalDialogCocoa(dialog, web_contents);
#endif
web_modal::WebContentsModalDialogManager* manager = web_modal::WebContentsModalDialogManager* manager =
web_modal::WebContentsModalDialogManager::FromWebContents(web_contents); web_modal::WebContentsModalDialogManager::FromWebContents(web_contents);
DCHECK(manager); DCHECK(manager);
......
// Copyright 2016 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.
#include "components/web_modal/web_contents_modal_dialog_manager.h"
namespace web_modal {
SingleWebContentsDialogManager*
WebContentsModalDialogManager::CreateNativeWebModalManager(
gfx::NativeWindow dialog,
web_modal::SingleWebContentsDialogManagerDelegate* delegate) {
return nullptr;
}
} // namespace web_modal
...@@ -30,14 +30,6 @@ class WebContentsModalDialogManager ...@@ -30,14 +30,6 @@ class WebContentsModalDialogManager
WebContentsModalDialogManagerDelegate* delegate() const { return delegate_; } WebContentsModalDialogManagerDelegate* delegate() const { return delegate_; }
void SetDelegate(WebContentsModalDialogManagerDelegate* d); void SetDelegate(WebContentsModalDialogManagerDelegate* d);
#if defined(OS_MACOSX)
// Note: This method is not defined inside components/web_modal/ as its
// definition (needed for Cocoa builds) depends on chrome/browser/ui/cocoa/.
static SingleWebContentsDialogManager* CreateNativeWebModalManager(
gfx::NativeWindow dialog,
SingleWebContentsDialogManagerDelegate* native_delegate);
#endif
// Allow clients to supply their own native dialog manager. Suitable for // Allow clients to supply their own native dialog manager. Suitable for
// bubble clients. // bubble clients.
void ShowDialogWithManager( void ShowDialogWithManager(
......
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