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