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