BookmarkManager: Fix 'new folder text field size changes on clicking it' issue.
[chromium-blink-merge.git] / chrome / browser / ui / cocoa / confirm_bubble_controller.mm
blobdb62ce0395effb437f401f6e3db8017772c67e4a
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 // Action handlers.
73 - (void)accept {
74   model_->Accept();
77 - (void)cancel {
78   model_->Cancel();
81 - (void)linkClicked {
82   model_->LinkClicked();
85 @end