| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_UI_COCOA_INFOBARS_INFOBAR_H_ | |
| 6 #define CHROME_BROWSER_UI_COCOA_INFOBARS_INFOBAR_H_ | |
| 7 | |
| 8 #include "base/logging.h" // for DCHECK | |
| 9 | |
| 10 #if defined(__OBJC__) | |
| 11 @class InfoBarController; | |
| 12 #else | |
| 13 class InfoBarController; | |
| 14 #endif | |
| 15 | |
| 16 // A C++ wrapper around an Objective-C InfoBarController. This class | |
| 17 // exists solely to be the return value for InfoBarDelegate::CreateInfoBar(), | |
| 18 // as defined in chrome/browser/infobars/confirm_infobar_delegate.h. This | |
| 19 // class would be analogous to the various bridge classes we already | |
| 20 // have, but since there is no pre-defined InfoBar interface, it is | |
| 21 // easier to simply throw away this object and deal with the | |
| 22 // controller directly rather than pass messages through a bridge. | |
| 23 // | |
| 24 // Callers should delete the returned InfoBar immediately after | |
| 25 // calling CreateInfoBar(), as the returned InfoBar* object is not | |
| 26 // pointed to by anyone. Expected usage: | |
| 27 // | |
| 28 // scoped_ptr<InfoBar> infobar(delegate->CreateInfoBar()); | |
| 29 // InfoBarController* controller = infobar->controller(); | |
| 30 // // Do something with the controller, and save a pointer so it can be | |
| 31 // // deleted later. |infobar| will be deleted automatically. | |
| 32 | |
| 33 class InfoBar { | |
| 34 public: | |
| 35 InfoBar(InfoBarController* controller, InfoBarDelegate* delegate) | |
| 36 : controller_(controller), delegate_(delegate) { | |
| 37 DCHECK(controller); | |
| 38 DCHECK(delegate); | |
| 39 } | |
| 40 | |
| 41 InfoBarController* controller() { | |
| 42 return controller_; | |
| 43 } | |
| 44 | |
| 45 InfoBarDelegate* delegate() { | |
| 46 return delegate_; | |
| 47 } | |
| 48 | |
| 49 private: | |
| 50 // Pointer to the infobar controller. Is never null. | |
| 51 InfoBarController* controller_; // weak | |
| 52 InfoBarDelegate* delegate_; | |
| 53 | |
| 54 DISALLOW_COPY_AND_ASSIGN(InfoBar); | |
| 55 }; | |
| 56 | |
| 57 #endif // CHROME_BROWSER_UI_COCOA_INFOBARS_INFOBAR_H_ | |
| OLD | NEW |