| OLD | NEW |
| 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 #ifndef CHROME_BROWSER_UI_COCOA_INFOBARS_INFOBAR_H_ | 5 #ifndef CHROME_BROWSER_UI_COCOA_INFOBARS_INFOBAR_H_ |
| 6 #define CHROME_BROWSER_UI_COCOA_INFOBARS_INFOBAR_H_ | 6 #define CHROME_BROWSER_UI_COCOA_INFOBARS_INFOBAR_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "base/logging.h" // for DCHECK | 9 #include "base/logging.h" // for DCHECK |
| 10 | 10 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 // calling CreateInfoBar(), as the returned InfoBar* object is not | 22 // calling CreateInfoBar(), as the returned InfoBar* object is not |
| 23 // pointed to by anyone. Expected usage: | 23 // pointed to by anyone. Expected usage: |
| 24 // | 24 // |
| 25 // scoped_ptr<InfoBar> infobar(delegate->CreateInfoBar()); | 25 // scoped_ptr<InfoBar> infobar(delegate->CreateInfoBar()); |
| 26 // InfoBarController* controller = infobar->controller(); | 26 // InfoBarController* controller = infobar->controller(); |
| 27 // // Do something with the controller, and save a pointer so it can be | 27 // // Do something with the controller, and save a pointer so it can be |
| 28 // // deleted later. |infobar| will be deleted automatically. | 28 // // deleted later. |infobar| will be deleted automatically. |
| 29 | 29 |
| 30 class InfoBar { | 30 class InfoBar { |
| 31 public: | 31 public: |
| 32 InfoBar(InfoBarController* controller) { | 32 InfoBar(InfoBarController* controller, InfoBarDelegate* delegate) |
| 33 : controller_(controller), delegate_(delegate) { |
| 33 DCHECK(controller); | 34 DCHECK(controller); |
| 34 controller_ = controller; | 35 DCHECK(delegate); |
| 35 } | 36 } |
| 36 | 37 |
| 37 InfoBarController* controller() { | 38 InfoBarController* controller() { |
| 38 return controller_; | 39 return controller_; |
| 39 } | 40 } |
| 40 | 41 |
| 42 InfoBarDelegate* delegate() { |
| 43 return delegate_; |
| 44 } |
| 45 |
| 41 private: | 46 private: |
| 42 // Pointer to the infobar controller. Is never null. | 47 // Pointer to the infobar controller. Is never null. |
| 43 InfoBarController* controller_; // weak | 48 InfoBarController* controller_; // weak |
| 49 InfoBarDelegate* delegate_; |
| 44 | 50 |
| 45 DISALLOW_COPY_AND_ASSIGN(InfoBar); | 51 DISALLOW_COPY_AND_ASSIGN(InfoBar); |
| 46 }; | 52 }; |
| 47 | 53 |
| 48 #endif // CHROME_BROWSER_UI_COCOA_INFOBARS_INFOBAR_H_ | 54 #endif // CHROME_BROWSER_UI_COCOA_INFOBARS_INFOBAR_H_ |
| OLD | NEW |