| 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 "base/memory/scoped_nsobject.h" | 10 #include "base/memory/scoped_nsobject.h" |
| 11 #include "chrome/browser/ui/constrained_window.h" | 11 #include "chrome/browser/ui/web_contents_modal_dialog.h" |
| 12 #include "content/public/browser/notification_observer.h" | 12 #include "content/public/browser/notification_observer.h" |
| 13 #include "content/public/browser/notification_registrar.h" | 13 #include "content/public/browser/notification_registrar.h" |
| 14 | 14 |
| 15 namespace content { | 15 namespace content { |
| 16 class WebContents; | 16 class WebContents; |
| 17 } | 17 } |
| 18 class ConstrainedWindowMac; | 18 class ConstrainedWindowMac; |
| 19 @protocol ConstrainedWindowSheet; | 19 @protocol ConstrainedWindowSheet; |
| 20 | 20 |
| 21 // A delegate for a constrained window. The delegate is notified when the | 21 // A delegate for a constrained window. The delegate is notified when the |
| 22 // window closes. | 22 // window closes. |
| 23 class ConstrainedWindowMacDelegate { | 23 class ConstrainedWindowMacDelegate { |
| 24 public: | 24 public: |
| 25 virtual void OnConstrainedWindowClosed(ConstrainedWindowMac* window) = 0; | 25 virtual void OnConstrainedWindowClosed(ConstrainedWindowMac* window) = 0; |
| 26 }; | 26 }; |
| 27 | 27 |
| 28 // Constrained window implementation for Mac. | 28 // Constrained window implementation for Mac. |
| 29 // Normally an instance of this class is owned by the delegate. The delegate | 29 // Normally an instance of this class is owned by the delegate. The delegate |
| 30 // should delete the instance when the window is closed. | 30 // should delete the instance when the window is closed. |
| 31 class ConstrainedWindowMac : public ConstrainedWindow, | 31 class ConstrainedWindowMac : public WebContentsModalDialog, |
| 32 public content::NotificationObserver { | 32 public content::NotificationObserver { |
| 33 public: | 33 public: |
| 34 ConstrainedWindowMac( | 34 ConstrainedWindowMac( |
| 35 ConstrainedWindowMacDelegate* delegate, | 35 ConstrainedWindowMacDelegate* delegate, |
| 36 content::WebContents* web_contents, | 36 content::WebContents* web_contents, |
| 37 id<ConstrainedWindowSheet> sheet); | 37 id<ConstrainedWindowSheet> sheet); |
| 38 virtual ~ConstrainedWindowMac(); | 38 virtual ~ConstrainedWindowMac(); |
| 39 | 39 |
| 40 // ConstrainedWindow implementation. | 40 // WebContentsModalDialog implementation. |
| 41 virtual void ShowConstrainedWindow() OVERRIDE; | 41 virtual void ShowWebContentsModalDialog() OVERRIDE; |
| 42 // Closes the constrained window and deletes this instance. | 42 // Closes the constrained window and deletes this instance. |
| 43 virtual void CloseConstrainedWindow() OVERRIDE; | 43 virtual void CloseWebContentsModalDialog() OVERRIDE; |
| 44 virtual void PulseConstrainedWindow() OVERRIDE; | 44 virtual void PulseWebContentsModalDialog() OVERRIDE; |
| 45 virtual gfx::NativeWindow GetNativeWindow() OVERRIDE; | 45 virtual gfx::NativeWindow GetNativeWindow() OVERRIDE; |
| 46 virtual bool CanShowConstrainedWindow() OVERRIDE; | 46 virtual bool CanShowWebContentsModalDialog() OVERRIDE; |
| 47 | 47 |
| 48 // content::NotificationObserver: | 48 // content::NotificationObserver: |
| 49 virtual void Observe(int type, | 49 virtual void Observe(int type, |
| 50 const content::NotificationSource& source, | 50 const content::NotificationSource& source, |
| 51 const content::NotificationDetails& details) OVERRIDE; | 51 const content::NotificationDetails& details) OVERRIDE; |
| 52 | 52 |
| 53 private: | 53 private: |
| 54 // Gets the parent window of the dialog. | 54 // Gets the parent window of the dialog. |
| 55 NSWindow* GetParentWindow() const; | 55 NSWindow* GetParentWindow() const; |
| 56 | 56 |
| 57 ConstrainedWindowMacDelegate* delegate_; // weak, owns us. | 57 ConstrainedWindowMacDelegate* delegate_; // weak, owns us. |
| 58 | 58 |
| 59 // The WebContents that owns and constrains this ConstrainedWindow. Weak. | 59 // The WebContents that owns and constrains this WebContentsModalDialog. Weak. |
| 60 content::WebContents* web_contents_; | 60 content::WebContents* web_contents_; |
| 61 | 61 |
| 62 scoped_nsprotocol<id<ConstrainedWindowSheet> > sheet_; | 62 scoped_nsprotocol<id<ConstrainedWindowSheet> > sheet_; |
| 63 | 63 |
| 64 // A scoped container for notification registries. | 64 // A scoped container for notification registries. |
| 65 content::NotificationRegistrar registrar_; | 65 content::NotificationRegistrar registrar_; |
| 66 | 66 |
| 67 // This is true if the constrained window is waiting to be shown. | 67 // This is true if the constrained window is waiting to be shown. |
| 68 bool pending_show_; | 68 bool pending_show_; |
| 69 }; | 69 }; |
| 70 | 70 |
| 71 #endif // CHROME_BROWSER_UI_COCOA_CONSTRAINED_WINDOW_CONSTRAINED_WINDOW_MAC_ | 71 #endif // CHROME_BROWSER_UI_COCOA_CONSTRAINED_WINDOW_CONSTRAINED_WINDOW_MAC_ |
| OLD | NEW |