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

Side by Side Diff: chrome/browser/ui/cocoa/infobars/infobar_controller.h

Issue 7981045: Make infobars ignore button clicks when closing. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 2 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #import <Cocoa/Cocoa.h> 5 #import <Cocoa/Cocoa.h>
6 6
7 #import "base/mac/cocoa_protocols.h" 7 #import "base/mac/cocoa_protocols.h"
8 #include "base/memory/scoped_nsobject.h" 8 #include "base/memory/scoped_nsobject.h"
9 9
10 @class AnimatableView; 10 @class AnimatableView;
(...skipping 30 matching lines...) Expand all
41 // text views cannot conveniently be created in IB. The xib file contains 41 // text views cannot conveniently be created in IB. The xib file contains
42 // a text field |labelPlaceholder_| that's replaced by this text view |label_| 42 // a text field |labelPlaceholder_| that's replaced by this text view |label_|
43 // in -awakeFromNib. 43 // in -awakeFromNib.
44 scoped_nsobject<NSTextView> label_; 44 scoped_nsobject<NSTextView> label_;
45 }; 45 };
46 46
47 // Initializes a new InfoBarController. 47 // Initializes a new InfoBarController.
48 - (id)initWithDelegate:(InfoBarDelegate*)delegate 48 - (id)initWithDelegate:(InfoBarDelegate*)delegate
49 owner:(TabContentsWrapper*)owner; 49 owner:(TabContentsWrapper*)owner;
50 50
51 // Returns YES if the infobar is owned. If this is NO, it is not safe to call
52 // any delegate functions, since they might attempt to access the owner. Code
53 // should generally just do nothing at all in this case (once we're closing, all
54 // controls can safely just go dead).
55 - (BOOL)isOwned;
56
51 // Called when someone clicks on the OK or Cancel buttons. Subclasses 57 // Called when someone clicks on the OK or Cancel buttons. Subclasses
52 // must override if they do not hide the buttons. 58 // must override if they do not hide the buttons.
53 - (void)ok:(id)sender; 59 - (void)ok:(id)sender;
54 - (void)cancel:(id)sender; 60 - (void)cancel:(id)sender;
55 61
56 // Called when someone clicks on the close button. Dismisses the 62 // Called when someone clicks on the close button. Dismisses the infobar
57 // infobar without taking any action. 63 // without taking any action.
64 // NOTE: Subclasses should not call this to close the infobar as it will lead to
65 // errors in stat counting. Call -removeSelf instead.
58 - (IBAction)dismiss:(id)sender; 66 - (IBAction)dismiss:(id)sender;
59 67
68 // Asks the container controller to remove the infobar for this delegate. This
69 // call will trigger a notification that starts the infobar animating closed.
70 - (void)removeSelf;
71
60 // Returns a pointer to this controller's view, cast as an AnimatableView. 72 // Returns a pointer to this controller's view, cast as an AnimatableView.
61 - (AnimatableView*)animatableView; 73 - (AnimatableView*)animatableView;
62 74
63 // Open or animate open the infobar. 75 // Open or animate open the infobar.
64 - (void)open; 76 - (void)open;
65 - (void)animateOpen; 77 - (void)animateOpen;
66 78
67 // Close or animate close the infobar. 79 // Close or animate close the infobar.
68 - (void)close; 80 - (void)close;
69 - (void)animateClosed; 81 - (void)animateClosed;
70 82
71 // Subclasses can override this method to add additional controls to 83 // Subclasses can override this method to add additional controls to
72 // the infobar view. This method is called by awakeFromNib. The 84 // the infobar view. This method is called by awakeFromNib. The
73 // default implementation does nothing. 85 // default implementation does nothing.
74 - (void)addAdditionalControls; 86 - (void)addAdditionalControls;
75 87
76 // Subclasses must override this method to perform cleanup just before the 88 // Subclasses must override this method to perform cleanup just before the
77 // infobar closes. 89 // infobar closes.
78 - (void)infobarWillClose; 90 - (void)infobarWillClose;
79 91
80 // Removes the OK and Cancel buttons and resizes the textfield to use the 92 // Removes the OK and Cancel buttons and resizes the textfield to use the
81 // space. 93 // space.
82 - (void)removeButtons; 94 - (void)removeButtons;
83 95
84 @property(nonatomic, assign) id<InfoBarContainer> containerController; 96 @property(nonatomic, assign) id<InfoBarContainer> containerController;
85 @property(nonatomic, readonly) InfoBarDelegate* delegate; 97 @property(nonatomic, readonly) InfoBarDelegate* delegate;
86 98
87 @end 99 @end
88 100
101 @interface InfoBarController (Protected)
102 // Closes and disables the provided menu. Subclasses should call this for each
103 // popup menu in -infobarWillClose.
104 - (void)disablePopUpMenu:(NSMenu*)menu;
105 @end
106
89 ///////////////////////////////////////////////////////////////////////// 107 /////////////////////////////////////////////////////////////////////////
90 // InfoBarController subclasses, one for each InfoBarDelegate 108 // InfoBarController subclasses, one for each InfoBarDelegate
91 // subclass. Each of these subclasses overrides addAdditionalControls to 109 // subclass. Each of these subclasses overrides addAdditionalControls to
92 // configure its view as necessary. 110 // configure its view as necessary.
93 111
94 @interface LinkInfoBarController : InfoBarController 112 @interface LinkInfoBarController : InfoBarController
95 // Called when there is a click on the link in the infobar. 113 // Called when there is a click on the link in the infobar.
96 - (void)linkClicked; 114 - (void)linkClicked;
97 @end 115 @end
98 116
99 117
100 @interface ConfirmInfoBarController : InfoBarController 118 @interface ConfirmInfoBarController : InfoBarController
101 // Called when the OK and Cancel buttons are clicked. 119 // Called when the OK and Cancel buttons are clicked.
102 - (IBAction)ok:(id)sender; 120 - (IBAction)ok:(id)sender;
103 - (IBAction)cancel:(id)sender; 121 - (IBAction)cancel:(id)sender;
104 // Called when there is a click on the link in the infobar. 122 // Called when there is a click on the link in the infobar.
105 - (void)linkClicked; 123 - (void)linkClicked;
106 @end 124 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698