Chromium Code Reviews| Index: chrome/browser/ui/cocoa/confirm_bubble_controller.mm |
| =================================================================== |
| --- chrome/browser/ui/cocoa/confirm_bubble_controller.mm (revision 0) |
| +++ chrome/browser/ui/cocoa/confirm_bubble_controller.mm (revision 0) |
| @@ -0,0 +1,97 @@ |
| +// Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#import "chrome/browser/ui/cocoa/confirm_bubble_controller.h" |
| + |
| +#include "base/mac/mac_util.h" |
| +#include "base/sys_string_conversions.h" |
| +#import "chrome/browser/ui/confirm_bubble_model.h" |
| +#import "chrome/browser/ui/cocoa/confirm_bubble_view.h" |
| +#include "ui/gfx/image/image.h" |
| +#include "ui/gfx/point.h" |
| + |
| +@implementation ConfirmBubbleController |
| + |
| +- (id)initWithParent:(NSView*)parent |
| + origin:(CGPoint)origin |
| + model:(ConfirmBubbleModel*)model { |
| + if ((self = [super initWithNibName:nil |
| + 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.
|
| + parent_ = parent; |
| + origin_ = origin; |
| + model_ = model; |
| + } |
| + return self; |
| +} |
| + |
| +- (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.
|
| + [super dealloc]; |
| +} |
| + |
| +- (void)loadView { |
| + [self setView:[[[ConfirmBubbleView alloc] initWithParent:parent_ |
| + controller:self] autorelease]]; |
| +} |
| + |
| +- (void)windowWillClose:(NSNotification*)notification { |
| + 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
|
| + [self autorelease]; |
| +} |
| + |
| +// Accessors. This functions converts the C++ variables retrieved from the |
| +// ConfirmBubbleModel object to Objective-C variables, and return them. |
| +- (NSPoint)origin { |
| + return NSPointFromCGPoint(origin_); |
| +} |
| + |
| +- (NSString*)title { |
| + return base::SysUTF16ToNSString(model_->GetTitle()); |
| +} |
| + |
| +- (NSString*)messageText { |
| + return base::SysUTF16ToNSString(model_->GetMessageText()); |
| +} |
| + |
| +- (NSString*)linkText { |
| + return base::SysUTF16ToNSString(model_->GetLinkText()); |
| +} |
| + |
| +- (NSString*)okButton { |
| + return base::SysUTF16ToNSString( |
| + model_->GetButtonLabel(ConfirmBubbleModel::BUTTON_OK)); |
| +} |
| + |
| +- (NSString*)cancelButton { |
| + return base::SysUTF16ToNSString( |
| + model_->GetButtonLabel(ConfirmBubbleModel::BUTTON_CANCEL)); |
| +} |
| + |
| +- (BOOL)hasOkButton { |
| + return (model_->GetButtons() & ConfirmBubbleModel::BUTTON_OK) ? YES : NO; |
| +} |
| + |
| +- (BOOL)hasCancelButton { |
| + return (model_->GetButtons() & ConfirmBubbleModel::BUTTON_CANCEL) ? YES : NO; |
| +} |
| + |
| +- (NSImage*)icon { |
| + gfx::Image* image = model_->GetIcon(); |
| + return !image ? nil : image->ToNSImage(); |
| +} |
| + |
| +// Action handlers. |
| +- (void)accept { |
| + model_->Accept(); |
| +} |
| + |
| +- (void)cancel { |
| + model_->Cancel(); |
| +} |
| + |
| +- (void)linkClicked { |
| + model_->LinkClicked(); |
| +} |
| + |
| +@end |
| + |
|
Mark Mentovai
2011/11/28 14:33:06
Remove the blank line at the end of this file.
|
| Property changes on: chrome/browser/ui/cocoa/confirm_bubble_controller.mm |
| ___________________________________________________________________ |
| Added: svn:eol-style |
| + LF |