OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/ui/webui/constrained_web_dialog_delegate_base.h" | 5 #include "chrome/browser/ui/webui/constrained_web_dialog_delegate_base.h" |
6 | 6 |
7 #import <Cocoa/Cocoa.h> | 7 #import <Cocoa/Cocoa.h> |
8 | 8 |
9 #include "base/mac/scoped_nsobject.h" | 9 #include "base/mac/scoped_nsobject.h" |
10 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_custom_sh
eet.h" | 10 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_custom_sh
eet.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 | 25 |
26 class ConstrainedWebDialogDelegateMac | 26 class ConstrainedWebDialogDelegateMac |
27 : public ConstrainedWebDialogDelegateBase { | 27 : public ConstrainedWebDialogDelegateBase { |
28 public: | 28 public: |
29 ConstrainedWebDialogDelegateMac( | 29 ConstrainedWebDialogDelegateMac( |
30 content::BrowserContext* browser_context, | 30 content::BrowserContext* browser_context, |
31 WebDialogDelegate* delegate) | 31 WebDialogDelegate* delegate) |
32 : ConstrainedWebDialogDelegateBase(browser_context, delegate, NULL) {} | 32 : ConstrainedWebDialogDelegateBase(browser_context, delegate, NULL) {} |
33 | 33 |
34 // WebDialogWebContentsDelegate interface. | 34 // WebDialogWebContentsDelegate interface. |
35 virtual void CloseContents(WebContents* source) OVERRIDE { | 35 virtual void CloseContents(WebContents* source) override { |
36 window_->CloseWebContentsModalDialog(); | 36 window_->CloseWebContentsModalDialog(); |
37 } | 37 } |
38 | 38 |
39 void set_window(ConstrainedWindowMac* window) { window_ = window; } | 39 void set_window(ConstrainedWindowMac* window) { window_ = window; } |
40 ConstrainedWindowMac* window() const { return window_; } | 40 ConstrainedWindowMac* window() const { return window_; } |
41 | 41 |
42 private: | 42 private: |
43 // Weak, owned by ConstrainedWebDialogDelegateViewMac. | 43 // Weak, owned by ConstrainedWebDialogDelegateViewMac. |
44 ConstrainedWindowMac* window_; | 44 ConstrainedWindowMac* window_; |
45 | 45 |
46 DISALLOW_COPY_AND_ASSIGN(ConstrainedWebDialogDelegateMac); | 46 DISALLOW_COPY_AND_ASSIGN(ConstrainedWebDialogDelegateMac); |
47 }; | 47 }; |
48 | 48 |
49 } // namespace | 49 } // namespace |
50 | 50 |
51 class ConstrainedWebDialogDelegateViewMac : | 51 class ConstrainedWebDialogDelegateViewMac : |
52 public ConstrainedWindowMacDelegate, | 52 public ConstrainedWindowMacDelegate, |
53 public ConstrainedWebDialogDelegate { | 53 public ConstrainedWebDialogDelegate { |
54 | 54 |
55 public: | 55 public: |
56 ConstrainedWebDialogDelegateViewMac( | 56 ConstrainedWebDialogDelegateViewMac( |
57 content::BrowserContext* browser_context, | 57 content::BrowserContext* browser_context, |
58 WebDialogDelegate* delegate, | 58 WebDialogDelegate* delegate, |
59 content::WebContents* web_contents); | 59 content::WebContents* web_contents); |
60 virtual ~ConstrainedWebDialogDelegateViewMac() {} | 60 virtual ~ConstrainedWebDialogDelegateViewMac() {} |
61 | 61 |
62 // ConstrainedWebDialogDelegate interface | 62 // ConstrainedWebDialogDelegate interface |
63 virtual const WebDialogDelegate* | 63 virtual const WebDialogDelegate* |
64 GetWebDialogDelegate() const OVERRIDE { | 64 GetWebDialogDelegate() const override { |
65 return impl_->GetWebDialogDelegate(); | 65 return impl_->GetWebDialogDelegate(); |
66 } | 66 } |
67 virtual WebDialogDelegate* GetWebDialogDelegate() OVERRIDE { | 67 virtual WebDialogDelegate* GetWebDialogDelegate() override { |
68 return impl_->GetWebDialogDelegate(); | 68 return impl_->GetWebDialogDelegate(); |
69 } | 69 } |
70 virtual void OnDialogCloseFromWebUI() OVERRIDE { | 70 virtual void OnDialogCloseFromWebUI() override { |
71 return impl_->OnDialogCloseFromWebUI(); | 71 return impl_->OnDialogCloseFromWebUI(); |
72 } | 72 } |
73 virtual void ReleaseWebContentsOnDialogClose() OVERRIDE { | 73 virtual void ReleaseWebContentsOnDialogClose() override { |
74 return impl_->ReleaseWebContentsOnDialogClose(); | 74 return impl_->ReleaseWebContentsOnDialogClose(); |
75 } | 75 } |
76 virtual NativeWebContentsModalDialog GetNativeDialog() OVERRIDE { | 76 virtual NativeWebContentsModalDialog GetNativeDialog() override { |
77 return constrained_window_->GetNativeDialog(); | 77 return constrained_window_->GetNativeDialog(); |
78 } | 78 } |
79 virtual WebContents* GetWebContents() OVERRIDE { | 79 virtual WebContents* GetWebContents() override { |
80 return impl_->GetWebContents(); | 80 return impl_->GetWebContents(); |
81 } | 81 } |
82 | 82 |
83 // ConstrainedWindowMacDelegate interface | 83 // ConstrainedWindowMacDelegate interface |
84 virtual void OnConstrainedWindowClosed( | 84 virtual void OnConstrainedWindowClosed( |
85 ConstrainedWindowMac* window) OVERRIDE { | 85 ConstrainedWindowMac* window) override { |
86 if (!impl_->closed_via_webui()) | 86 if (!impl_->closed_via_webui()) |
87 GetWebDialogDelegate()->OnDialogClosed(""); | 87 GetWebDialogDelegate()->OnDialogClosed(""); |
88 delete this; | 88 delete this; |
89 } | 89 } |
90 | 90 |
91 private: | 91 private: |
92 scoped_ptr<ConstrainedWebDialogDelegateMac> impl_; | 92 scoped_ptr<ConstrainedWebDialogDelegateMac> impl_; |
93 scoped_ptr<ConstrainedWindowMac> constrained_window_; | 93 scoped_ptr<ConstrainedWindowMac> constrained_window_; |
94 base::scoped_nsobject<NSWindow> window_; | 94 base::scoped_nsobject<NSWindow> window_; |
95 | 95 |
(...skipping 26 matching lines...) Expand all Loading... |
122 ConstrainedWebDialogDelegate* CreateConstrainedWebDialog( | 122 ConstrainedWebDialogDelegate* CreateConstrainedWebDialog( |
123 content::BrowserContext* browser_context, | 123 content::BrowserContext* browser_context, |
124 WebDialogDelegate* delegate, | 124 WebDialogDelegate* delegate, |
125 content::WebContents* web_contents) { | 125 content::WebContents* web_contents) { |
126 // Deleted when the dialog closes. | 126 // Deleted when the dialog closes. |
127 ConstrainedWebDialogDelegateViewMac* constrained_delegate = | 127 ConstrainedWebDialogDelegateViewMac* constrained_delegate = |
128 new ConstrainedWebDialogDelegateViewMac( | 128 new ConstrainedWebDialogDelegateViewMac( |
129 browser_context, delegate, web_contents); | 129 browser_context, delegate, web_contents); |
130 return constrained_delegate; | 130 return constrained_delegate; |
131 } | 131 } |
OLD | NEW |