Chromium Code Reviews
|
| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #import "chrome/browser/ui/cocoa/confirm_bubble_controller.h" | |
| 6 | |
| 7 #include "base/mac/mac_util.h" | |
| 8 #include "base/sys_string_conversions.h" | |
| 9 #import "chrome/browser/ui/confirm_bubble_model.h" | |
| 10 #import "chrome/browser/ui/cocoa/confirm_bubble_view.h" | |
| 11 #include "ui/gfx/image/image.h" | |
| 12 #include "ui/gfx/point.h" | |
| 13 | |
| 14 @implementation ConfirmBubbleController | |
| 15 | |
| 16 - (id)initWithParent:(NSView*)parent | |
| 17 origin:(CGPoint)origin | |
| 18 model:(ConfirmBubbleModel*)model { | |
| 19 if ((self = [super initWithNibName:nil | |
| 20 bundle:base::mac::MainAppBundle()])) { | |
|
Mark Mentovai
2011/11/28 14:33:06
I think this is unused if the preceding parameter
Hironori Bono
2011/12/09 11:14:32
Done. Thanks for your explanation.
| |
| 21 parent_ = parent; | |
| 22 origin_ = origin; | |
| 23 model_ = model; | |
| 24 } | |
| 25 return self; | |
| 26 } | |
| 27 | |
| 28 - (void)dealloc { | |
|
Mark Mentovai
2011/11/28 14:33:06
This method isn’t necessary. If you don’t provide
Hironori Bono
2011/12/09 11:14:32
Done. Thanks for noticing it.
| |
| 29 [super dealloc]; | |
| 30 } | |
| 31 | |
| 32 - (void)loadView { | |
| 33 [self setView:[[[ConfirmBubbleView alloc] initWithParent:parent_ | |
| 34 controller:self] autorelease]]; | |
| 35 } | |
| 36 | |
| 37 - (void)windowWillClose:(NSNotification*)notification { | |
| 38 NSLog(@"[ConfirmBubbleController windowWillClose:]"); | |
|
Mark Mentovai
2011/11/28 14:33:06
?
Hironori Bono
2011/12/09 11:14:32
Done. Whoops, I forgot deleting this line before u
| |
| 39 [self autorelease]; | |
| 40 } | |
| 41 | |
| 42 // Accessors. This functions converts the C++ variables retrieved from the | |
| 43 // ConfirmBubbleModel object to Objective-C variables, and return them. | |
| 44 - (NSPoint)origin { | |
| 45 return NSPointFromCGPoint(origin_); | |
| 46 } | |
| 47 | |
| 48 - (NSString*)title { | |
| 49 return base::SysUTF16ToNSString(model_->GetTitle()); | |
| 50 } | |
| 51 | |
| 52 - (NSString*)messageText { | |
| 53 return base::SysUTF16ToNSString(model_->GetMessageText()); | |
| 54 } | |
| 55 | |
| 56 - (NSString*)linkText { | |
| 57 return base::SysUTF16ToNSString(model_->GetLinkText()); | |
| 58 } | |
| 59 | |
| 60 - (NSString*)okButton { | |
| 61 return base::SysUTF16ToNSString( | |
| 62 model_->GetButtonLabel(ConfirmBubbleModel::BUTTON_OK)); | |
| 63 } | |
| 64 | |
| 65 - (NSString*)cancelButton { | |
| 66 return base::SysUTF16ToNSString( | |
| 67 model_->GetButtonLabel(ConfirmBubbleModel::BUTTON_CANCEL)); | |
| 68 } | |
| 69 | |
| 70 - (BOOL)hasOkButton { | |
| 71 return (model_->GetButtons() & ConfirmBubbleModel::BUTTON_OK) ? YES : NO; | |
| 72 } | |
| 73 | |
| 74 - (BOOL)hasCancelButton { | |
| 75 return (model_->GetButtons() & ConfirmBubbleModel::BUTTON_CANCEL) ? YES : NO; | |
| 76 } | |
| 77 | |
| 78 - (NSImage*)icon { | |
| 79 gfx::Image* image = model_->GetIcon(); | |
| 80 return !image ? nil : image->ToNSImage(); | |
| 81 } | |
| 82 | |
| 83 // Action handlers. | |
| 84 - (void)accept { | |
| 85 model_->Accept(); | |
| 86 } | |
| 87 | |
| 88 - (void)cancel { | |
| 89 model_->Cancel(); | |
| 90 } | |
| 91 | |
| 92 - (void)linkClicked { | |
| 93 model_->LinkClicked(); | |
| 94 } | |
| 95 | |
| 96 @end | |
| 97 | |
|
Mark Mentovai
2011/11/28 14:33:06
Remove the blank line at the end of this file.
| |
| OLD | NEW |