Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(422)

Side by Side Diff: chrome/browser/ui/cocoa/confirm_bubble_controller.mm

Issue 8697001: Implement confirm bubble for Mac. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 8 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
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.
4
5 #import "chrome/browser/ui/cocoa/confirm_bubble_controller.h"
6
7 #include "base/mac/mac_util.h"
8 #include "base/sys_string_conversions.h"
9 #import "chrome/browser/ui/cocoa/confirm_bubble_view.h"
10 #import "chrome/browser/ui/confirm_bubble_model.h"
11 #include "ui/gfx/image/image.h"
12 #include "ui/gfx/point.h"
13
14 @implementation ConfirmBubbleController
15
16 - (id)initWithParent:(NSView*)parent
17 origin:(CGPoint)origin
18 model:(ConfirmBubbleModel*)model {
19 if ((self = [super initWithNibName:nil bundle:nil])) {
20 parent_ = parent;
21 origin_ = origin;
22 model_ = model;
23 }
24 return self;
25 }
26
27 - (void)loadView {
28 [self setView:[[[ConfirmBubbleView alloc] initWithParent:parent_
29 controller:self] autorelease]];
30 }
31
32 - (void)windowWillClose:(NSNotification*)notification {
33 [self autorelease];
34 }
35
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_);
40 }
41
42 - (NSString*)title {
43 return base::SysUTF16ToNSString(model_->GetTitle());
44 }
45
46 - (NSString*)messageText {
47 return base::SysUTF16ToNSString(model_->GetMessageText());
48 }
49
50 - (NSString*)linkText {
51 return base::SysUTF16ToNSString(model_->GetLinkText());
52 }
53
54 - (NSString*)okButtonText {
55 return base::SysUTF16ToNSString(
56 model_->GetButtonLabel(ConfirmBubbleModel::BUTTON_OK));
57 }
58
59 - (NSString*)cancelButtonText {
60 return base::SysUTF16ToNSString(
61 model_->GetButtonLabel(ConfirmBubbleModel::BUTTON_CANCEL));
62 }
63
64 - (BOOL)hasOkButton {
65 return (model_->GetButtons() & ConfirmBubbleModel::BUTTON_OK) ? YES : NO;
66 }
67
68 - (BOOL)hasCancelButton {
69 return (model_->GetButtons() & ConfirmBubbleModel::BUTTON_CANCEL) ? YES : NO;
70 }
71
72 - (NSImage*)icon {
73 gfx::Image* image = model_->GetIcon();
74 return !image ? nil : image->ToNSImage();
75 }
76
77 // Action handlers.
78 - (void)accept {
79 model_->Accept();
80 }
81
82 - (void)cancel {
83 model_->Cancel();
84 }
85
86 - (void)linkClicked {
87 model_->LinkClicked();
88 }
89
90 @end
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/confirm_bubble_controller.h ('k') | chrome/browser/ui/cocoa/confirm_bubble_controller_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698