Cleanup: Update the path to insets and point headers.
[chromium-blink-merge.git] / chrome / browser / ui / cocoa / confirm_bubble_controller.mm
blob95c4a73986d2caf33a6d43a2b7c661386786e9fd
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])) {
20     parent_ = parent;
21     origin_ = origin;
22     model_ = model.Pass();
23   }
24   return self;
27 - (void)loadView {
28   [self setView:[[[ConfirmBubbleCocoa alloc] initWithParent:parent_
29                                                  controller:self] autorelease]];
32 - (void)windowWillClose:(NSNotification*)notification {
33   [self autorelease];
36 // Accessors. This functions converts the C++ types retrieved from the
37 // ConfirmBubbleModel object to Objective-C types, and return them.
38 - (NSPoint)origin {
39   return NSPointFromCGPoint(origin_);
42 - (NSString*)title {
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));
64 - (BOOL)hasOkButton {
65   return (model_->GetButtons() & ConfirmBubbleModel::BUTTON_OK) ? YES : NO;
68 - (BOOL)hasCancelButton {
69   return (model_->GetButtons() & ConfirmBubbleModel::BUTTON_CANCEL) ? YES : NO;
72 - (NSImage*)icon {
73   gfx::Image* image = model_->GetIcon();
74   return !image ? nil : image->ToNSImage();
77 // Action handlers.
78 - (void)accept {
79   model_->Accept();
82 - (void)cancel {
83   model_->Cancel();
86 - (void)linkClicked {
87   model_->LinkClicked();
90 @end