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 #ifndef CHROME_BROWSER_UI_COCOA_CONSTRAINED_WINDOW_CONSTRAINED_WINDOW_MAC_ | 5 #ifndef CHROME_BROWSER_UI_COCOA_CONSTRAINED_WINDOW_CONSTRAINED_WINDOW_MAC_ |
6 #define CHROME_BROWSER_UI_COCOA_CONSTRAINED_WINDOW_CONSTRAINED_WINDOW_MAC_ | 6 #define CHROME_BROWSER_UI_COCOA_CONSTRAINED_WINDOW_CONSTRAINED_WINDOW_MAC_ |
7 | 7 |
8 #import <Cocoa/Cocoa.h> | 8 #import <Cocoa/Cocoa.h> |
9 | 9 |
10 #include "components/web_modal/web_contents_modal_dialog_manager.h" | |
11 | |
10 namespace content { | 12 namespace content { |
11 class WebContents; | 13 class WebContents; |
12 } | 14 } |
13 class ConstrainedWindowMac; | 15 class ConstrainedWindowMac; |
14 class SingleWebContentsDialogManagerCocoa; | 16 class SingleWebContentsDialogManagerCocoa; |
15 @protocol ConstrainedWindowSheet; | 17 @protocol ConstrainedWindowSheet; |
16 | 18 |
17 // A delegate for a constrained window. The delegate is notified when the | 19 // A delegate for a constrained window. The delegate is notified when the |
18 // window closes. | 20 // window closes. |
19 class ConstrainedWindowMacDelegate { | 21 class ConstrainedWindowMacDelegate { |
20 public: | 22 public: |
21 virtual void OnConstrainedWindowClosed(ConstrainedWindowMac* window) = 0; | 23 virtual void OnConstrainedWindowClosed(ConstrainedWindowMac* window) = 0; |
22 }; | 24 }; |
23 | 25 |
26 // Creates a ConstrainedWindowMac, shows the dialog, and returns it. | |
27 ConstrainedWindowMac* CreateAndShowWebModalDialogMac( | |
28 ConstrainedWindowMacDelegate* delegate, | |
29 content::WebContents* web_contents, | |
30 id<ConstrainedWindowSheet> sheet); | |
31 | |
32 // Creates a ConstrainedWindowMac and returns it. | |
33 ConstrainedWindowMac* CreateWebModalDialogMac( | |
34 ConstrainedWindowMacDelegate* delegate, | |
35 content::WebContents* web_contents, | |
36 id<ConstrainedWindowSheet> sheet); | |
37 | |
24 // Constrained window implementation for Mac. | 38 // Constrained window implementation for Mac. |
25 // Normally an instance of this class is owned by the delegate. The delegate | 39 // Normally an instance of this class is owned by the delegate. The delegate |
26 // should delete the instance when the window is closed. | 40 // should delete the instance when the window is closed. |
27 class ConstrainedWindowMac { | 41 class ConstrainedWindowMac { |
28 public: | 42 public: |
29 ConstrainedWindowMac(ConstrainedWindowMacDelegate* delegate, | 43 ConstrainedWindowMac(ConstrainedWindowMacDelegate* delegate, |
30 content::WebContents* web_contents, | 44 content::WebContents* web_contents, |
31 id<ConstrainedWindowSheet> sheet); | 45 id<ConstrainedWindowSheet> sheet); |
32 ~ConstrainedWindowMac(); | 46 ~ConstrainedWindowMac(); |
33 | 47 |
48 // Shows the constrained window. | |
49 void ShowWebContentsModalDialog(); | |
50 | |
34 // Closes the constrained window. | 51 // Closes the constrained window. |
35 void CloseWebContentsModalDialog(); | 52 void CloseWebContentsModalDialog(); |
36 | 53 |
37 SingleWebContentsDialogManagerCocoa* manager() const { return manager_; } | 54 SingleWebContentsDialogManagerCocoa* manager() const { return manager_; } |
38 void set_manager(SingleWebContentsDialogManagerCocoa* manager) { | 55 void set_manager(SingleWebContentsDialogManagerCocoa* manager) { |
39 manager_ = manager; | 56 manager_ = manager; |
40 } | 57 } |
58 id<ConstrainedWindowSheet> sheet() const { return sheet_; } | |
41 | 59 |
42 // Called by |manager_| when the dialog is closing. | 60 // Called by |manager_| when the dialog is closing. |
43 void OnDialogClosing(); | 61 void OnDialogClosing(); |
44 | 62 |
63 // Gets the dialog manager for |web_contents_|. | |
64 web_modal::WebContentsModalDialogManager* GetDialogManager(); | |
65 | |
45 private: | 66 private: |
46 ConstrainedWindowMacDelegate* delegate_; // weak, owns us. | 67 ConstrainedWindowMacDelegate* delegate_; // weak, owns us. |
47 SingleWebContentsDialogManagerCocoa* manager_; // weak, owned by WCMDM. | 68 SingleWebContentsDialogManagerCocoa* manager_; // weak, owned by WCMDM. |
69 content::WebContents* web_contents_; // weak, owned by dialog initiator. | |
70 id<ConstrainedWindowSheet> sheet_; | |
erikchen
2015/11/12 18:31:27
Instead of using an id (raw pointer), use a scoped
apacible
2015/11/12 21:57:42
Done.
| |
71 scoped_ptr<SingleWebContentsDialogManagerCocoa> native_manager_; | |
48 }; | 72 }; |
49 | 73 |
50 #endif // CHROME_BROWSER_UI_COCOA_CONSTRAINED_WINDOW_CONSTRAINED_WINDOW_MAC_ | 74 #endif // CHROME_BROWSER_UI_COCOA_CONSTRAINED_WINDOW_CONSTRAINED_WINDOW_MAC_ |
OLD | NEW |