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" | 7 #include "chrome/browser/ui/cocoa/constrained_window/constrained_window_mac.h" |
8 #include "components/web_modal/single_web_contents_dialog_manager.h" | 8 #include "components/web_modal/single_web_contents_dialog_manager.h" |
9 | 9 |
10 using web_modal::NativeWebContentsModalDialog; | 10 using web_modal::NativeWebContentsModalDialog; |
11 | 11 |
12 namespace { | 12 namespace { |
13 | 13 |
14 class NativeWebContentsModalDialogManagerCocoa | 14 class NativeWebContentsModalDialogManagerCocoa |
15 : public web_modal::SingleWebContentsDialogManager { | 15 : public web_modal::SingleWebContentsDialogManager { |
16 public: | 16 public: |
17 NativeWebContentsModalDialogManagerCocoa( | 17 NativeWebContentsModalDialogManagerCocoa( |
18 NativeWebContentsModalDialog dialog) | 18 NativeWebContentsModalDialog dialog) |
19 : dialog_(dialog) { | 19 : dialog_(dialog) { |
20 } | 20 } |
21 | 21 |
22 virtual ~NativeWebContentsModalDialogManagerCocoa() { | 22 virtual ~NativeWebContentsModalDialogManagerCocoa() { |
23 } | 23 } |
24 | 24 |
25 // SingleWebContentsDialogManager overrides | 25 // SingleWebContentsDialogManager overrides |
26 virtual void Show() OVERRIDE { | 26 virtual void Show() override { |
27 GetConstrainedWindowMac(dialog())->ShowWebContentsModalDialog(); | 27 GetConstrainedWindowMac(dialog())->ShowWebContentsModalDialog(); |
28 } | 28 } |
29 | 29 |
30 virtual void Hide() OVERRIDE { | 30 virtual void Hide() override { |
31 } | 31 } |
32 | 32 |
33 virtual void Close() OVERRIDE { | 33 virtual void Close() override { |
34 GetConstrainedWindowMac(dialog())->CloseWebContentsModalDialog(); | 34 GetConstrainedWindowMac(dialog())->CloseWebContentsModalDialog(); |
35 } | 35 } |
36 | 36 |
37 virtual void Focus() OVERRIDE { | 37 virtual void Focus() override { |
38 GetConstrainedWindowMac(dialog())->FocusWebContentsModalDialog(); | 38 GetConstrainedWindowMac(dialog())->FocusWebContentsModalDialog(); |
39 } | 39 } |
40 | 40 |
41 virtual void Pulse() OVERRIDE { | 41 virtual void Pulse() override { |
42 GetConstrainedWindowMac(dialog())->PulseWebContentsModalDialog(); | 42 GetConstrainedWindowMac(dialog())->PulseWebContentsModalDialog(); |
43 } | 43 } |
44 | 44 |
45 virtual void HostChanged( | 45 virtual void HostChanged( |
46 web_modal::WebContentsModalDialogHost* new_host) OVERRIDE { | 46 web_modal::WebContentsModalDialogHost* new_host) override { |
47 } | 47 } |
48 | 48 |
49 virtual NativeWebContentsModalDialog dialog() OVERRIDE { | 49 virtual NativeWebContentsModalDialog dialog() override { |
50 return dialog_; | 50 return dialog_; |
51 } | 51 } |
52 | 52 |
53 private: | 53 private: |
54 static ConstrainedWindowMac* GetConstrainedWindowMac( | 54 static ConstrainedWindowMac* GetConstrainedWindowMac( |
55 NativeWebContentsModalDialog dialog) { | 55 NativeWebContentsModalDialog dialog) { |
56 return static_cast<ConstrainedWindowMac*>(dialog); | 56 return static_cast<ConstrainedWindowMac*>(dialog); |
57 } | 57 } |
58 | 58 |
59 // In mac this is a pointer to a ConstrainedWindowMac. | 59 // In mac this is a pointer to a ConstrainedWindowMac. |
60 // TODO(gbillock): Replace this casting system with a more typesafe call path. | 60 // TODO(gbillock): Replace this casting system with a more typesafe call path. |
61 NativeWebContentsModalDialog dialog_; | 61 NativeWebContentsModalDialog dialog_; |
62 | 62 |
63 DISALLOW_COPY_AND_ASSIGN(NativeWebContentsModalDialogManagerCocoa); | 63 DISALLOW_COPY_AND_ASSIGN(NativeWebContentsModalDialogManagerCocoa); |
64 }; | 64 }; |
65 | 65 |
66 } // namespace | 66 } // namespace |
67 | 67 |
68 namespace web_modal { | 68 namespace web_modal { |
69 | 69 |
70 SingleWebContentsDialogManager* | 70 SingleWebContentsDialogManager* |
71 WebContentsModalDialogManager::CreateNativeWebModalManager( | 71 WebContentsModalDialogManager::CreateNativeWebModalManager( |
72 NativeWebContentsModalDialog dialog, | 72 NativeWebContentsModalDialog dialog, |
73 SingleWebContentsDialogManagerDelegate* native_delegate) { | 73 SingleWebContentsDialogManagerDelegate* native_delegate) { |
74 return new NativeWebContentsModalDialogManagerCocoa(dialog); | 74 return new NativeWebContentsModalDialogManagerCocoa(dialog); |
75 } | 75 } |
76 | 76 |
77 } // namespace web_modal | 77 } // namespace web_modal |
OLD | NEW |