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/confirm_bubble_cocoa.h" | 5 #import "chrome/browser/ui/cocoa/confirm_bubble_cocoa.h" |
6 | 6 |
7 #include "base/strings/string16.h" | 7 #include "base/strings/string16.h" |
8 #include "chrome/browser/themes/theme_service.h" | 8 #include "chrome/browser/themes/theme_service.h" |
9 #import "chrome/browser/ui/cocoa/confirm_bubble_controller.h" | 9 #import "chrome/browser/ui/cocoa/confirm_bubble_controller.h" |
10 #include "chrome/browser/ui/confirm_bubble.h" | 10 #include "chrome/browser/ui/confirm_bubble.h" |
(...skipping 26 matching lines...) Expand all Loading... |
37 // Vertical spacing between the edge of the window and the | 37 // Vertical spacing between the edge of the window and the |
38 // top or bottom of a button. | 38 // top or bottom of a button. |
39 const int kButtonVEdgeMargin = 6; | 39 const int kButtonVEdgeMargin = 6; |
40 | 40 |
41 // Horizontal spacing between the edge of the window and the | 41 // Horizontal spacing between the edge of the window and the |
42 // left or right of a button. | 42 // left or right of a button. |
43 const int kButtonHEdgeMargin = 7; | 43 const int kButtonHEdgeMargin = 7; |
44 | 44 |
45 namespace chrome { | 45 namespace chrome { |
46 | 46 |
47 void ShowConfirmBubble(gfx::NativeView view, | 47 void ShowConfirmBubble(gfx::NativeWindow window, |
| 48 gfx::NativeView anchor_view, |
48 const gfx::Point& origin, | 49 const gfx::Point& origin, |
49 ConfirmBubbleModel* model) { | 50 ConfirmBubbleModel* model) { |
50 // Create a custom NSViewController that manages a bubble view, and add it to | 51 // Create a custom NSViewController that manages a bubble view, and add it to |
51 // a child to the specified view. This controller will be automatically | 52 // a child to the specified |anchor_view|. This controller will be |
52 // deleted when it loses first-responder status. | 53 // automatically deleted when it loses first-responder status. |
53 ConfirmBubbleController* controller = | 54 ConfirmBubbleController* controller = |
54 [[ConfirmBubbleController alloc] initWithParent:view | 55 [[ConfirmBubbleController alloc] initWithParent:anchor_view |
55 origin:origin.ToCGPoint() | 56 origin:origin.ToCGPoint() |
56 model:model]; | 57 model:model]; |
57 [view addSubview:[controller view] | 58 [anchor_view addSubview:[controller view] |
58 positioned:NSWindowAbove | 59 positioned:NSWindowAbove |
59 relativeTo:nil]; | 60 relativeTo:nil]; |
60 [[view window] makeFirstResponder:[controller view]]; | 61 [[anchor_view window] makeFirstResponder:[controller view]]; |
61 } | 62 } |
62 | 63 |
63 } // namespace chrome | 64 } // namespace chrome |
64 | 65 |
65 // An interface that is derived from NSTextView and does not accept | 66 // An interface that is derived from NSTextView and does not accept |
66 // first-responder status, i.e. a NSTextView-derived class that never becomes | 67 // first-responder status, i.e. a NSTextView-derived class that never becomes |
67 // the first responder. When we click a NSTextView object, it becomes the first | 68 // the first responder. When we click a NSTextView object, it becomes the first |
68 // responder. Unfortunately, we delete the ConfirmBubbleCocoa object anytime | 69 // responder. Unfortunately, we delete the ConfirmBubbleCocoa object anytime |
69 // when it loses first-responder status not to prevent disturbing other | 70 // when it loses first-responder status not to prevent disturbing other |
70 // responders. | 71 // responders. |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
287 | 288 |
288 - (void)clickCancel { | 289 - (void)clickCancel { |
289 [self cancel:self]; | 290 [self cancel:self]; |
290 } | 291 } |
291 | 292 |
292 - (void)clickLink { | 293 - (void)clickLink { |
293 [self textView:messageLabel_.get() clickedOnLink:nil atIndex:0]; | 294 [self textView:messageLabel_.get() clickedOnLink:nil atIndex:0]; |
294 } | 295 } |
295 | 296 |
296 @end | 297 @end |
OLD | NEW |