OLD | NEW |
---|---|
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "components/web_modal/web_contents_modal_dialog_manager.h" | 5 #include "components/web_modal/web_contents_modal_dialog_manager.h" |
6 | 6 |
7 #include "chrome/browser/ui/cocoa/constrained_window/constrained_window_mac.h" | |
8 #include "components/web_modal/single_web_contents_dialog_manager.h" | |
9 | |
10 using web_modal::NativeWebContentsModalDialog; | 7 using web_modal::NativeWebContentsModalDialog; |
11 | 8 |
12 namespace { | |
13 | |
14 class NativeWebContentsModalDialogManagerCocoa | |
15 : public web_modal::SingleWebContentsDialogManager { | |
16 public: | |
17 NativeWebContentsModalDialogManagerCocoa( | |
18 NativeWebContentsModalDialog dialog) | |
19 : dialog_(dialog) { | |
20 } | |
21 | |
22 ~NativeWebContentsModalDialogManagerCocoa() override {} | |
23 | |
24 // SingleWebContentsDialogManager overrides | |
25 void Show() override { | |
26 GetConstrainedWindowMac(dialog())->ShowWebContentsModalDialog(); | |
27 } | |
28 | |
29 void Hide() override {} | |
30 | |
31 void Close() override { | |
32 GetConstrainedWindowMac(dialog())->CloseWebContentsModalDialog(); | |
33 } | |
34 | |
35 void Focus() override { | |
36 GetConstrainedWindowMac(dialog())->FocusWebContentsModalDialog(); | |
37 } | |
38 | |
39 void Pulse() override { | |
40 GetConstrainedWindowMac(dialog())->PulseWebContentsModalDialog(); | |
41 } | |
42 | |
43 void HostChanged(web_modal::WebContentsModalDialogHost* new_host) override {} | |
44 | |
45 NativeWebContentsModalDialog dialog() override { return dialog_; } | |
46 | |
47 private: | |
48 static ConstrainedWindowMac* GetConstrainedWindowMac( | |
49 NativeWebContentsModalDialog dialog) { | |
50 return static_cast<ConstrainedWindowMac*>(dialog); | |
51 } | |
52 | |
53 // In mac this is a pointer to a ConstrainedWindowMac. | |
54 // TODO(gbillock): Replace this casting system with a more typesafe call path. | |
55 NativeWebContentsModalDialog dialog_; | |
56 | |
57 DISALLOW_COPY_AND_ASSIGN(NativeWebContentsModalDialogManagerCocoa); | |
58 }; | |
59 | |
60 } // namespace | |
61 | |
62 namespace web_modal { | 9 namespace web_modal { |
63 | 10 |
64 SingleWebContentsDialogManager* | 11 SingleWebContentsDialogManager* |
65 WebContentsModalDialogManager::CreateNativeWebModalManager( | 12 WebContentsModalDialogManager::CreateNativeWebModalManager( |
66 NativeWebContentsModalDialog dialog, | 13 NativeWebContentsModalDialog dialog, |
67 SingleWebContentsDialogManagerDelegate* native_delegate) { | 14 SingleWebContentsDialogManagerDelegate* native_delegate) { |
68 return new NativeWebContentsModalDialogManagerCocoa(dialog); | 15 NOTREACHED(); |
tapted
2015/02/23 22:33:36
Perhaps not for this CL... but if we want to keep
| |
16 return nullptr; | |
69 } | 17 } |
70 | 18 |
71 } // namespace web_modal | 19 } // namespace web_modal |
OLD | NEW |