[email protected] | 91cea0e | 2009-07-17 03:16:58 | [diff] [blame] | 1 | // Copyright (c) 2009 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_COCOA_INFOBAR_H_ |
| 6 | #define CHROME_BROWSER_COCOA_INFOBAR_H_ |
| 7 | |
| 8 | #include "base/logging.h" // for DCHECK |
| 9 | |
| 10 | @class InfoBarController; |
| 11 | |
| 12 | // A C++ wrapper around an Objective-C InfoBarController. This class |
| 13 | // exists solely to be the return value for InfoBarDelegate::CreateInfoBar(), |
| 14 | // as defined in chrome/browser/tab_contents/infobar_delegate.h. This |
| 15 | // class would be analogous to the various bridge classes we already |
| 16 | // have, but since there is no pre-defined InfoBar interface, it is |
| 17 | // easier to simply throw away this object and deal with the |
| 18 | // controller directly rather than pass messages through a bridge. |
| 19 | // |
| 20 | // Callers should delete the returned InfoBar immediately after |
| 21 | // calling CreateInfoBar(), as the returned InfoBar* object is not |
| 22 | // pointed to by anyone. Expected usage: |
| 23 | // |
| 24 | // scoped_ptr<InfoBar> infobar(delegate->CreateInfoBar()); |
| 25 | // InfoBarController* controller = infobar->controller(); |
| 26 | // // Do something with the controller, and save a pointer so it can be |
| 27 | // // deleted later. |infobar| will be deleted automatically. |
| 28 | |
| 29 | class InfoBar { |
| 30 | public: |
| 31 | InfoBar(InfoBarController* controller) { |
| 32 | DCHECK(controller); |
| 33 | controller_ = controller; |
| 34 | } |
| 35 | |
| 36 | InfoBarController* controller() { |
| 37 | return controller_; |
| 38 | } |
| 39 | |
| 40 | private: |
| 41 | // Pointer to the infobar controller. Is never null. |
| 42 | InfoBarController* controller_; // weak |
| 43 | |
| 44 | DISALLOW_COPY_AND_ASSIGN(InfoBar); |
| 45 | }; |
| 46 | |
| 47 | #endif // CHROME_BROWSER_COCOA_INFOBAR_H_ |