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
3 // found in the LICENSE file.
5 #import "chrome/browser/ui/cocoa/confirm_bubble_controller.h"
7 #include "base/mac/mac_util.h"
8 #include "base/strings/sys_string_conversions.h"
9 #import "chrome/browser/ui/cocoa/browser_window_controller.h"
10 #import "chrome/browser/ui/cocoa/confirm_bubble_cocoa.h"
11 #import "chrome/browser/ui/confirm_bubble_model.h"
12 #include "ui/gfx/image/image.h"
13 #include "ui/gfx/point.h"
15 @implementation ConfirmBubbleController
17 - (id)initWithParent:(NSView*)parent
18 origin:(CGPoint)origin
19 model:(ConfirmBubbleModel*)model {
20 if ((self = [super initWithNibName:nil bundle:nil])) {
29 [self setView:[[[ConfirmBubbleCocoa alloc] initWithParent:parent_
30 controller:self] autorelease]];
33 - (void)windowWillClose:(NSNotification*)notification {
37 // Accessors. This functions converts the C++ types retrieved from the
38 // ConfirmBubbleModel object to Objective-C types, and return them.
40 return NSPointFromCGPoint(origin_);
44 return base::SysUTF16ToNSString(model_->GetTitle());
47 - (NSString*)messageText {
48 return base::SysUTF16ToNSString(model_->GetMessageText());
51 - (NSString*)linkText {
52 return base::SysUTF16ToNSString(model_->GetLinkText());
55 - (NSString*)okButtonText {
56 return base::SysUTF16ToNSString(
57 model_->GetButtonLabel(ConfirmBubbleModel::BUTTON_OK));
60 - (NSString*)cancelButtonText {
61 return base::SysUTF16ToNSString(
62 model_->GetButtonLabel(ConfirmBubbleModel::BUTTON_CANCEL));
66 return (model_->GetButtons() & ConfirmBubbleModel::BUTTON_OK) ? YES : NO;
69 - (BOOL)hasCancelButton {
70 return (model_->GetButtons() & ConfirmBubbleModel::BUTTON_CANCEL) ? YES : NO;
74 gfx::Image* image = model_->GetIcon();
75 return !image ? nil : image->ToNSImage();
88 model_->LinkClicked();