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 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_sheet_con
troller.h" | 5 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_sheet_con
troller.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_sheet.h" | 10 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_sheet.h" |
11 #include "chrome/browser/ui/cocoa/constrained_window/constrained_window_sheet_in
fo.h" | 11 #include "chrome/browser/ui/cocoa/constrained_window/constrained_window_sheet_in
fo.h" |
12 #import "chrome/browser/ui/cocoa/tabs/tab_strip_controller.h" | |
13 | 12 |
14 namespace { | 13 namespace { |
15 | 14 |
16 // Maps parent windows to sheet controllers. | 15 // Maps parent windows to sheet controllers. |
17 NSMutableDictionary* g_sheetControllers; | 16 NSMutableDictionary* g_sheetControllers; |
18 | 17 |
19 // Get a value for the given window that can be used as a key in a dictionary. | 18 // Get a value for the given window that can be used as a key in a dictionary. |
20 NSValue* GetKeyForParentWindow(NSWindow* parent_window) { | 19 NSValue* GetKeyForParentWindow(NSWindow* parent_window) { |
21 return [NSValue valueWithNonretainedObject:parent_window]; | 20 return [NSValue valueWithNonretainedObject:parent_window]; |
22 } | 21 } |
23 | 22 |
| 23 // Returns the bounds to use when showing a sheet for a given parent view. This |
| 24 // returns a rect in window coordinates. |
| 25 NSRect GetSheetParentBoundsForParentView(NSView* view) { |
| 26 // If the devtools view is open, it shrinks the size of the WebContents, so go |
| 27 // up the hierarchy to the devtools container view to avoid that. Note that |
| 28 // the devtools view is always in the hierarchy even if it is not open or it |
| 29 // is detached. |
| 30 NSView* devtools_view = [[[view superview] superview] superview]; |
| 31 if (devtools_view) |
| 32 view = devtools_view; |
| 33 return [view convertRect:[view bounds] toView:nil]; |
| 34 } |
| 35 |
24 } // namespace | 36 } // namespace |
25 | 37 |
26 // An invisible overlay window placed on top of the sheet's parent view. | 38 // An invisible overlay window placed on top of the sheet's parent view. |
27 // This window blocks interaction with the underlying view. | 39 // This window blocks interaction with the underlying view. |
28 @interface CWSheetOverlayWindow : NSWindow { | 40 @interface CWSheetOverlayWindow : NSWindow { |
29 base::scoped_nsobject<ConstrainedWindowSheetController> controller_; | 41 base::scoped_nsobject<ConstrainedWindowSheetController> controller_; |
30 } | 42 } |
31 @end | 43 @end |
32 | 44 |
33 @interface ConstrainedWindowSheetController () | 45 @interface ConstrainedWindowSheetController () |
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
293 name:NSWindowDidResizeNotification | 305 name:NSWindowDidResizeNotification |
294 object:parentWindow_]; | 306 object:parentWindow_]; |
295 | 307 |
296 [parentWindow_ removeChildWindow:[info overlayWindow]]; | 308 [parentWindow_ removeChildWindow:[info overlayWindow]]; |
297 [[info sheet] closeSheetWithAnimation:withAnimation]; | 309 [[info sheet] closeSheetWithAnimation:withAnimation]; |
298 [[info overlayWindow] close]; | 310 [[info overlayWindow] close]; |
299 [sheets_ removeObject:info]; | 311 [sheets_ removeObject:info]; |
300 } | 312 } |
301 | 313 |
302 @end | 314 @end |
OLD | NEW |