Home | History | Annotate | Download | only in cocoa
      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 #ifndef CHROME_BROWSER_UI_COCOA_CONFIRM_BUBBLE_COCOA_H_
      6 #define CHROME_BROWSER_UI_COCOA_CONFIRM_BUBBLE_COCOA_H_
      7 
      8 #import <Cocoa/Cocoa.h>
      9 
     10 #include "base/mac/scoped_nsobject.h"
     11 
     12 @class ConfirmBubbleController;
     13 class ConfirmBubbleModel;
     14 
     15 // A view class that implements a bubble consisting of the following items:
     16 // * one icon ("icon")
     17 // * one title text ("title")
     18 // * one message text ("message")
     19 // * one optional link ("link")
     20 // * two optional buttons ("ok" and "cancel")
     21 //
     22 // This bubble is convenient when we wish to ask transient, non-blocking
     23 // questions. Unlike a dialog, a bubble menu disappears when we click outside of
     24 // its window to avoid blocking user operations. A bubble is laid out as
     25 // follows:
     26 //
     27 //   +------------------------+
     28 //   | icon title             |
     29 //   | message                |
     30 //   | link                   |
     31 //   |          [Cancel] [OK] |
     32 //   +------------------------+
     33 //
     34 @interface ConfirmBubbleCocoa : NSView<NSTextViewDelegate> {
     35  @private
     36   NSView* parent_;  // weak
     37   ConfirmBubbleController* controller_;  // weak
     38 
     39   // Controls used in this bubble.
     40   base::scoped_nsobject<NSImageView> icon_;
     41   base::scoped_nsobject<NSTextView> titleLabel_;
     42   base::scoped_nsobject<NSTextView> messageLabel_;
     43   base::scoped_nsobject<NSButton> okButton_;
     44   base::scoped_nsobject<NSButton> cancelButton_;
     45 }
     46 
     47 // Initializes a bubble view. Since this initializer programmatically creates a
     48 // custom NSView (i.e. without using a nib file), this function should be called
     49 // from loadView: of the controller object which owns this view.
     50 - (id)initWithParent:(NSView*)parent
     51           controller:(ConfirmBubbleController*)controller;
     52 
     53 @end
     54 
     55 // Exposed only for unit testing.
     56 @interface ConfirmBubbleCocoa (ExposedForUnitTesting)
     57 - (void)clickOk;
     58 - (void)clickCancel;
     59 - (void)clickLink;
     60 @end
     61 
     62 #endif  // CHROME_BROWSER_UI_COCOA_CONFIRM_BUBBLE_COCOA_H_
     63