1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "components/web_modal/web_contents_modal_dialog_manager.h"
7 #include "chrome/browser/ui/cocoa/constrained_window/constrained_window_mac.h"
8 #include "components/web_modal/single_web_contents_dialog_manager.h"
10 using web_modal::NativeWebContentsModalDialog;
14 class NativeWebContentsModalDialogManagerCocoa
15 : public web_modal::SingleWebContentsDialogManager {
17 NativeWebContentsModalDialogManagerCocoa(
18 NativeWebContentsModalDialog dialog)
22 virtual ~NativeWebContentsModalDialogManagerCocoa() {
25 // SingleWebContentsDialogManager overrides
26 virtual void Show() OVERRIDE {
27 GetConstrainedWindowMac(dialog())->ShowWebContentsModalDialog();
30 virtual void Hide() OVERRIDE {
33 virtual void Close() OVERRIDE {
34 GetConstrainedWindowMac(dialog())->CloseWebContentsModalDialog();
37 virtual void Focus() OVERRIDE {
38 GetConstrainedWindowMac(dialog())->FocusWebContentsModalDialog();
41 virtual void Pulse() OVERRIDE {
42 GetConstrainedWindowMac(dialog())->PulseWebContentsModalDialog();
45 virtual void HostChanged(
46 web_modal::WebContentsModalDialogHost* new_host) OVERRIDE {
49 virtual NativeWebContentsModalDialog dialog() OVERRIDE {
54 static ConstrainedWindowMac* GetConstrainedWindowMac(
55 NativeWebContentsModalDialog dialog) {
56 return static_cast<ConstrainedWindowMac*>(dialog);
59 // In mac this is a pointer to a ConstrainedWindowMac.
60 // TODO(gbillock): Replace this casting system with a more typesafe call path.
61 NativeWebContentsModalDialog dialog_;
63 DISALLOW_COPY_AND_ASSIGN(NativeWebContentsModalDialogManagerCocoa);
70 SingleWebContentsDialogManager*
71 WebContentsModalDialogManager::CreateNativeWebModalManager(
72 NativeWebContentsModalDialog dialog,
73 SingleWebContentsDialogManagerDelegate* native_delegate) {
74 return new NativeWebContentsModalDialogManagerCocoa(dialog);
77 } // namespace web_modal