Chromium Code Reviews| 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* ShowWebModalDialogMac( | |
|
erikchen
2015/11/11 21:22:30
s/Show/CreateAndShow/
apacible
2015/11/12 02:02:24
Done.
| |
| 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: |
| 43 ConstrainedWindowMac(ConstrainedWindowMacDelegate* delegate); | |
|
erikchen
2015/11/11 21:22:30
explicit
apacible
2015/11/12 02:02:24
Done.
| |
| 29 ConstrainedWindowMac(ConstrainedWindowMacDelegate* delegate, | 44 ConstrainedWindowMac(ConstrainedWindowMacDelegate* delegate, |
| 30 content::WebContents* web_contents, | 45 content::WebContents* web_contents, |
| 31 id<ConstrainedWindowSheet> sheet); | 46 id<ConstrainedWindowSheet> sheet); |
|
erikchen
2015/11/11 21:22:30
The public interface for ConstrainedWindowMac is c
apacible
2015/11/12 02:02:24
Cleaned up:
- Back to one constructor.
- One ShowD
| |
| 32 ~ConstrainedWindowMac(); | 47 ~ConstrainedWindowMac(); |
| 33 | 48 |
| 49 void ShowDialog(content::WebContents* web_contents, | |
| 50 id<ConstrainedWindowSheet> sheet); | |
| 51 void ShowDialog(); | |
| 52 | |
| 34 // Closes the constrained window. | 53 // Closes the constrained window. |
| 35 void CloseWebContentsModalDialog(); | 54 void CloseWebContentsModalDialog(); |
| 36 | 55 |
| 37 SingleWebContentsDialogManagerCocoa* manager() const { return manager_; } | 56 SingleWebContentsDialogManagerCocoa* manager() const { return manager_; } |
| 38 void set_manager(SingleWebContentsDialogManagerCocoa* manager) { | 57 void set_manager(SingleWebContentsDialogManagerCocoa* manager) { |
| 39 manager_ = manager; | 58 manager_ = manager; |
| 40 } | 59 } |
| 60 id<ConstrainedWindowSheet> sheet() const { return sheet_; } | |
| 41 | 61 |
| 42 // Called by |manager_| when the dialog is closing. | 62 // Called by |manager_| when the dialog is closing. |
| 43 void OnDialogClosing(); | 63 void OnDialogClosing(); |
| 44 | 64 |
| 45 private: | 65 private: |
| 46 ConstrainedWindowMacDelegate* delegate_; // weak, owns us. | 66 ConstrainedWindowMacDelegate* delegate_; // weak, owns us. |
| 47 SingleWebContentsDialogManagerCocoa* manager_; // weak, owned by WCMDM. | 67 SingleWebContentsDialogManagerCocoa* manager_; // weak, owned by WCMDM. |
| 68 | |
| 69 id<ConstrainedWindowSheet> sheet_; | |
|
erikchen
2015/11/11 21:22:30
What are the expected/required lifetime semantics
apacible
2015/11/12 02:02:24
Ownership should be passed to the WebContentsModal
| |
| 70 scoped_ptr<SingleWebContentsDialogManagerCocoa> native_manager_; | |
| 71 web_modal::WebContentsModalDialogManager* dialog_manager_; | |
|
erikchen
2015/11/11 21:22:30
What are you expected/required lifetime semantics
apacible
2015/11/12 02:02:24
Correct, it's tied to web_contents. Updated to dyn
| |
| 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 |