OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/cocoa/constrained_window_mac.h" | 5 #include "chrome/browser/cocoa/constrained_window_mac.h" |
6 | 6 |
| 7 #include "base/logging.h" |
7 #import "chrome/browser/cocoa/browser_window_controller.h" | 8 #import "chrome/browser/cocoa/browser_window_controller.h" |
8 #include "chrome/browser/tab_contents/tab_contents.h" | 9 #include "chrome/browser/tab_contents/tab_contents.h" |
9 #include "chrome/browser/tab_contents/tab_contents_view.h" | 10 #include "chrome/browser/tab_contents/tab_contents_view.h" |
10 #import "third_party/GTM/AppKit/GTMWindowSheetController.h" | 11 #import "third_party/GTM/AppKit/GTMWindowSheetController.h" |
11 | 12 |
12 ConstrainedWindowMacDelegate::~ConstrainedWindowMacDelegate() {} | 13 ConstrainedWindowMacDelegate::~ConstrainedWindowMacDelegate() {} |
13 | 14 |
14 NSArray* ConstrainedWindowMacDelegateSystemSheet::GetSheetParameters( | 15 NSArray* ConstrainedWindowMacDelegateSystemSheet::GetSheetParameters( |
15 id delegate, | 16 id delegate, |
16 SEL didEndSelector) { | 17 SEL didEndSelector) { |
(...skipping 17 matching lines...) Expand all Loading... |
34 void ConstrainedWindowMacDelegateCustomSheet::RunSheet( | 35 void ConstrainedWindowMacDelegateCustomSheet::RunSheet( |
35 GTMWindowSheetController* sheetController, | 36 GTMWindowSheetController* sheetController, |
36 NSView* view) { | 37 NSView* view) { |
37 [sheetController beginSheet:customSheet_.get() | 38 [sheetController beginSheet:customSheet_.get() |
38 modalForView:view | 39 modalForView:view |
39 modalDelegate:delegate_.get() | 40 modalDelegate:delegate_.get() |
40 didEndSelector:didEndSelector_ | 41 didEndSelector:didEndSelector_ |
41 contextInfo:NULL]; | 42 contextInfo:NULL]; |
42 } | 43 } |
43 | 44 |
| 45 void ConstrainedWindowMacDelegateCustomSheet::init(NSWindow* sheet, |
| 46 id delegate, SEL didEndSelector) { |
| 47 DCHECK(!delegate_.get()); |
| 48 DCHECK(!didEndSelector_); |
| 49 customSheet_.reset([sheet retain]); |
| 50 delegate_.reset([delegate retain]); |
| 51 didEndSelector_ = didEndSelector; |
| 52 DCHECK(delegate_.get()); |
| 53 DCHECK(didEndSelector_); |
| 54 } |
| 55 |
44 // static | 56 // static |
45 ConstrainedWindow* ConstrainedWindow::CreateConstrainedDialog( | 57 ConstrainedWindow* ConstrainedWindow::CreateConstrainedDialog( |
46 TabContents* parent, | 58 TabContents* parent, |
47 ConstrainedWindowMacDelegate* delegate) { | 59 ConstrainedWindowMacDelegate* delegate) { |
48 return new ConstrainedWindowMac(parent, delegate); | 60 return new ConstrainedWindowMac(parent, delegate); |
49 } | 61 } |
50 | 62 |
51 ConstrainedWindowMac::ConstrainedWindowMac( | 63 ConstrainedWindowMac::ConstrainedWindowMac( |
52 TabContents* owner, ConstrainedWindowMacDelegate* delegate) | 64 TabContents* owner, ConstrainedWindowMacDelegate* delegate) |
53 : owner_(owner), | 65 : owner_(owner), |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 return; | 104 return; |
93 } | 105 } |
94 DCHECK(controller != nil); | 106 DCHECK(controller != nil); |
95 | 107 |
96 // Remember the controller we're adding ourselves to, so that we can later | 108 // Remember the controller we're adding ourselves to, so that we can later |
97 // remove us from it. | 109 // remove us from it. |
98 controller_ = controller; | 110 controller_ = controller; |
99 [controller_ attachConstrainedWindow:this]; | 111 [controller_ attachConstrainedWindow:this]; |
100 delegate_->set_sheet_open(true); | 112 delegate_->set_sheet_open(true); |
101 } | 113 } |
OLD | NEW |