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/strings/sys_string_conversions.h"
8 #import "chrome/browser/ui/cocoa/browser_window_controller.h"
9 #import "chrome/browser/ui/cocoa/confirm_bubble_cocoa.h"
10 #import "chrome/browser/ui/confirm_bubble_model.h"
11 #include "ui/gfx/geometry/point.h"
12 #include "ui/gfx/image/image.h"
14 @implementation ConfirmBubbleController
16 - (id)initWithParent:(NSView*)parent
17 origin:(CGPoint)origin
18 model:(scoped_ptr<ConfirmBubbleModel>)model {
19 if ((self = [super initWithNibName:nil bundle:nil])) {
22 model_ = model.Pass();
28 [self setView:[[[ConfirmBubbleCocoa alloc] initWithParent:parent_
29 controller:self] autorelease]];
32 - (void)windowWillClose:(NSNotification*)notification {
36 // Accessors. This functions converts the C++ types retrieved from the
37 // ConfirmBubbleModel object to Objective-C types, and return them.
39 return NSPointFromCGPoint(origin_);
43 return base::SysUTF16ToNSString(model_->GetTitle());
46 - (NSString*)messageText {
47 return base::SysUTF16ToNSString(model_->GetMessageText());
50 - (NSString*)linkText {
51 return base::SysUTF16ToNSString(model_->GetLinkText());
54 - (NSString*)okButtonText {
55 return base::SysUTF16ToNSString(
56 model_->GetButtonLabel(ConfirmBubbleModel::BUTTON_OK));
59 - (NSString*)cancelButtonText {
60 return base::SysUTF16ToNSString(
61 model_->GetButtonLabel(ConfirmBubbleModel::BUTTON_CANCEL));
65 return (model_->GetButtons() & ConfirmBubbleModel::BUTTON_OK) ? YES : NO;
68 - (BOOL)hasCancelButton {
69 return (model_->GetButtons() & ConfirmBubbleModel::BUTTON_CANCEL) ? YES : NO;
82 model_->LinkClicked();