| 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 #import "base/mac/cocoa_protocols.h" | 7 #import "base/mac/cocoa_protocols.h" |
| 8 #include "base/string16.h" | 8 #include "base/string16.h" |
| 9 #include "chrome/browser/themes/theme_service.h" | 9 #include "chrome/browser/themes/theme_service.h" |
| 10 #import "chrome/browser/ui/cocoa/confirm_bubble_controller.h" | 10 #import "chrome/browser/ui/cocoa/confirm_bubble_controller.h" |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 // Vertical spacing between the edge of the window and the | 43 // Vertical spacing between the edge of the window and the |
| 44 // top or bottom of a button. | 44 // top or bottom of a button. |
| 45 const int kButtonVEdgeMargin = 6; | 45 const int kButtonVEdgeMargin = 6; |
| 46 | 46 |
| 47 // Horizontal spacing between the edge of the window and the | 47 // Horizontal spacing between the edge of the window and the |
| 48 // left or right of a button. | 48 // left or right of a button. |
| 49 const int kButtonHEdgeMargin = 7; | 49 const int kButtonHEdgeMargin = 7; |
| 50 | 50 |
| 51 } // namespace | 51 } // namespace |
| 52 | 52 |
| 53 namespace browser { | 53 namespace chrome { |
| 54 | 54 |
| 55 void ShowConfirmBubble(gfx::NativeView view, | 55 void ShowConfirmBubble(gfx::NativeView view, |
| 56 const gfx::Point& origin, | 56 const gfx::Point& origin, |
| 57 ConfirmBubbleModel* model) { | 57 ConfirmBubbleModel* model) { |
| 58 // Create a custom NSViewController that manages a bubble view, and add it to | 58 // Create a custom NSViewController that manages a bubble view, and add it to |
| 59 // a child to the specified view. This controller will be automatically | 59 // a child to the specified view. This controller will be automatically |
| 60 // deleted when it loses first-responder status. | 60 // deleted when it loses first-responder status. |
| 61 ConfirmBubbleController* controller = | 61 ConfirmBubbleController* controller = |
| 62 [[ConfirmBubbleController alloc] initWithParent:view | 62 [[ConfirmBubbleController alloc] initWithParent:view |
| 63 origin:origin.ToCGPoint() | 63 origin:origin.ToCGPoint() |
| 64 model:model]; | 64 model:model]; |
| 65 [view addSubview:[controller view] | 65 [view addSubview:[controller view] |
| 66 positioned:NSWindowAbove | 66 positioned:NSWindowAbove |
| 67 relativeTo:nil]; | 67 relativeTo:nil]; |
| 68 [[view window] makeFirstResponder:[controller view]]; | 68 [[view window] makeFirstResponder:[controller view]]; |
| 69 } | 69 } |
| 70 | 70 |
| 71 } // namespace browser | 71 } // namespace chrome |
| 72 | 72 |
| 73 // An interface that is derived from NSTextView and does not accept | 73 // An interface that is derived from NSTextView and does not accept |
| 74 // first-responder status, i.e. a NSTextView-derived class that never becomes | 74 // first-responder status, i.e. a NSTextView-derived class that never becomes |
| 75 // the first responder. When we click a NSTextView object, it becomes the first | 75 // the first responder. When we click a NSTextView object, it becomes the first |
| 76 // responder. Unfortunately, we delete the ConfirmBubbleCocoa object anytime | 76 // responder. Unfortunately, we delete the ConfirmBubbleCocoa object anytime |
| 77 // when it loses first-responder status not to prevent disturbing other | 77 // when it loses first-responder status not to prevent disturbing other |
| 78 // responders. | 78 // responders. |
| 79 // To prevent text views in this ConfirmBubbleCocoa object from stealing the | 79 // To prevent text views in this ConfirmBubbleCocoa object from stealing the |
| 80 // first-responder status, we use this view in the ConfirmBubbleCocoa object. | 80 // first-responder status, we use this view in the ConfirmBubbleCocoa object. |
| 81 @interface ConfirmBubbleTextView : NSTextView | 81 @interface ConfirmBubbleTextView : NSTextView |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 295 | 295 |
| 296 - (void)clickCancel { | 296 - (void)clickCancel { |
| 297 [self cancel:self]; | 297 [self cancel:self]; |
| 298 } | 298 } |
| 299 | 299 |
| 300 - (void)clickLink { | 300 - (void)clickLink { |
| 301 [self textView:messageLabel_.get() clickedOnLink:nil atIndex:0]; | 301 [self textView:messageLabel_.get() clickedOnLink:nil atIndex:0]; |
| 302 } | 302 } |
| 303 | 303 |
| 304 @end | 304 @end |
| OLD | NEW |