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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/cocoa/confirm_bubble_controller.mm
===================================================================
--- chrome/browser/ui/cocoa/confirm_bubble_controller.mm (revision 0)
+++ chrome/browser/ui/cocoa/confirm_bubble_controller.mm (revision 0)
@@ -0,0 +1,90 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#import "chrome/browser/ui/cocoa/confirm_bubble_controller.h"
+
+#include "base/mac/mac_util.h"
+#include "base/sys_string_conversions.h"
+#import "chrome/browser/ui/cocoa/confirm_bubble_view.h"
+#import "chrome/browser/ui/confirm_bubble_model.h"
+#include "ui/gfx/image/image.h"
+#include "ui/gfx/point.h"
+
+@implementation ConfirmBubbleController
+
+- (id)initWithParent:(NSView*)parent
+ origin:(CGPoint)origin
+ model:(ConfirmBubbleModel*)model {
+ if ((self = [super initWithNibName:nil bundle:nil])) {
+ parent_ = parent;
+ origin_ = origin;
+ model_ = model;
+ }
+ return self;
+}
+
+- (void)loadView {
+ [self setView:[[[ConfirmBubbleView alloc] initWithParent:parent_
+ controller:self] autorelease]];
+}
+
+- (void)windowWillClose:(NSNotification*)notification {
+ [self autorelease];
+}
+
+// Accessors. This functions converts the C++ types retrieved from the
+// ConfirmBubbleModel object to Objective-C types, and return them.
+- (NSPoint)origin {
+ return NSPointFromCGPoint(origin_);
+}
+
+- (NSString*)title {
+ return base::SysUTF16ToNSString(model_->GetTitle());
+}
+
+- (NSString*)messageText {
+ return base::SysUTF16ToNSString(model_->GetMessageText());
+}
+
+- (NSString*)linkText {
+ return base::SysUTF16ToNSString(model_->GetLinkText());
+}
+
+- (NSString*)okButtonText {
+ return base::SysUTF16ToNSString(
+ model_->GetButtonLabel(ConfirmBubbleModel::BUTTON_OK));
+}
+
+- (NSString*)cancelButtonText {
+ return base::SysUTF16ToNSString(
+ model_->GetButtonLabel(ConfirmBubbleModel::BUTTON_CANCEL));
+}
+
+- (BOOL)hasOkButton {
+ return (model_->GetButtons() & ConfirmBubbleModel::BUTTON_OK) ? YES : NO;
+}
+
+- (BOOL)hasCancelButton {
+ return (model_->GetButtons() & ConfirmBubbleModel::BUTTON_CANCEL) ? YES : NO;
+}
+
+- (NSImage*)icon {
+ gfx::Image* image = model_->GetIcon();
+ return !image ? nil : image->ToNSImage();
+}
+
+// Action handlers.
+- (void)accept {
+ model_->Accept();
+}
+
+- (void)cancel {
+ model_->Cancel();
+}
+
+- (void)linkClicked {
+ model_->LinkClicked();
+}
+
+@end
Property changes on: chrome/browser/ui/cocoa/confirm_bubble_controller.mm
___________________________________________________________________
Added: svn:eol-style
+ LF
« 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