| OLD | NEW |
| 1 // Copyright (c) 2009 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/ui/cocoa/constrained_window_mac.h" | 5 #include "chrome/browser/ui/cocoa/constrained_window_mac.h" |
| 6 | 6 |
| 7 #include "chrome/browser/tab_contents/tab_contents.h" | 7 #include "chrome/browser/tab_contents/tab_contents.h" |
| 8 #include "chrome/browser/tab_contents/tab_contents_view.h" | 8 #include "chrome/browser/tab_contents/tab_contents_view.h" |
| 9 #import "chrome/browser/ui/cocoa/browser_window_controller.h" | 9 #import "chrome/browser/ui/cocoa/browser_window_controller.h" |
| 10 #import "third_party/GTM/AppKit/GTMWindowSheetController.h" | 10 #import "third_party/GTM/AppKit/GTMWindowSheetController.h" |
| 11 | 11 |
| 12 ConstrainedWindowMacDelegate::~ConstrainedWindowMacDelegate() {} | 12 ConstrainedWindowMacDelegateSystemSheet:: |
| 13 ConstrainedWindowMacDelegateSystemSheet(id delegate, SEL didEndSelector) |
| 14 : systemSheet_(nil), |
| 15 delegate_([delegate retain]), |
| 16 didEndSelector_(didEndSelector) {} |
| 17 |
| 18 ConstrainedWindowMacDelegateSystemSheet:: |
| 19 ~ConstrainedWindowMacDelegateSystemSheet() {} |
| 20 |
| 21 void ConstrainedWindowMacDelegateSystemSheet::set_sheet(id sheet) { |
| 22 systemSheet_.reset([sheet retain]); |
| 23 } |
| 13 | 24 |
| 14 NSArray* ConstrainedWindowMacDelegateSystemSheet::GetSheetParameters( | 25 NSArray* ConstrainedWindowMacDelegateSystemSheet::GetSheetParameters( |
| 15 id delegate, | 26 id delegate, |
| 16 SEL didEndSelector) { | 27 SEL didEndSelector) { |
| 17 return [NSArray arrayWithObjects: | 28 return [NSArray arrayWithObjects: |
| 18 [NSNull null], // window, must be [NSNull null] | 29 [NSNull null], // window, must be [NSNull null] |
| 19 delegate, | 30 delegate, |
| 20 [NSValue valueWithPointer:didEndSelector], | 31 [NSValue valueWithPointer:didEndSelector], |
| 21 [NSValue valueWithPointer:NULL], // context info for didEndSelector_. | 32 [NSValue valueWithPointer:NULL], // context info for didEndSelector_. |
| 22 nil]; | 33 nil]; |
| 23 } | 34 } |
| 24 | 35 |
| 25 void ConstrainedWindowMacDelegateSystemSheet::RunSheet( | 36 void ConstrainedWindowMacDelegateSystemSheet::RunSheet( |
| 26 GTMWindowSheetController* sheetController, | 37 GTMWindowSheetController* sheetController, |
| 27 NSView* view) { | 38 NSView* view) { |
| 28 NSArray* params = GetSheetParameters(delegate_.get(), didEndSelector_); | 39 NSArray* params = GetSheetParameters(delegate_.get(), didEndSelector_); |
| 29 [sheetController beginSystemSheet:systemSheet_ | 40 [sheetController beginSystemSheet:systemSheet_ |
| 30 modalForView:view | 41 modalForView:view |
| 31 withParameters:params]; | 42 withParameters:params]; |
| 32 } | 43 } |
| 33 | 44 |
| 45 ConstrainedWindowMacDelegateCustomSheet:: |
| 46 ConstrainedWindowMacDelegateCustomSheet() |
| 47 : customSheet_(nil), |
| 48 delegate_(nil), |
| 49 didEndSelector_(NULL) {} |
| 50 |
| 51 ConstrainedWindowMacDelegateCustomSheet:: |
| 52 ConstrainedWindowMacDelegateCustomSheet(id delegate, SEL didEndSelector) |
| 53 : customSheet_(nil), |
| 54 delegate_([delegate retain]), |
| 55 didEndSelector_(didEndSelector) {} |
| 56 |
| 57 ConstrainedWindowMacDelegateCustomSheet:: |
| 58 ~ConstrainedWindowMacDelegateCustomSheet() {} |
| 59 |
| 60 void ConstrainedWindowMacDelegateCustomSheet::init(NSWindow* sheet, |
| 61 id delegate, |
| 62 SEL didEndSelector) { |
| 63 DCHECK(!delegate_.get()); |
| 64 DCHECK(!didEndSelector_); |
| 65 customSheet_.reset([sheet retain]); |
| 66 delegate_.reset([delegate retain]); |
| 67 didEndSelector_ = didEndSelector; |
| 68 DCHECK(delegate_.get()); |
| 69 DCHECK(didEndSelector_); |
| 70 } |
| 71 |
| 72 void ConstrainedWindowMacDelegateCustomSheet::set_sheet(NSWindow* sheet) { |
| 73 customSheet_.reset([sheet retain]); |
| 74 } |
| 75 |
| 34 void ConstrainedWindowMacDelegateCustomSheet::RunSheet( | 76 void ConstrainedWindowMacDelegateCustomSheet::RunSheet( |
| 35 GTMWindowSheetController* sheetController, | 77 GTMWindowSheetController* sheetController, |
| 36 NSView* view) { | 78 NSView* view) { |
| 37 [sheetController beginSheet:customSheet_.get() | 79 [sheetController beginSheet:customSheet_.get() |
| 38 modalForView:view | 80 modalForView:view |
| 39 modalDelegate:delegate_.get() | 81 modalDelegate:delegate_.get() |
| 40 didEndSelector:didEndSelector_ | 82 didEndSelector:didEndSelector_ |
| 41 contextInfo:NULL]; | 83 contextInfo:NULL]; |
| 42 } | 84 } |
| 43 | 85 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 return; | 137 return; |
| 96 } | 138 } |
| 97 DCHECK(controller != nil); | 139 DCHECK(controller != nil); |
| 98 | 140 |
| 99 // Remember the controller we're adding ourselves to, so that we can later | 141 // Remember the controller we're adding ourselves to, so that we can later |
| 100 // remove us from it. | 142 // remove us from it. |
| 101 controller_ = controller; | 143 controller_ = controller; |
| 102 [controller_ attachConstrainedWindow:this]; | 144 [controller_ attachConstrainedWindow:this]; |
| 103 delegate_->set_sheet_open(true); | 145 delegate_->set_sheet_open(true); |
| 104 } | 146 } |
| OLD | NEW |