| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this |
| 2 // source code is governed by a BSD-style license that can be found in the | 2 // source code is governed by a BSD-style license that can be found in the |
| 3 // LICENSE file. | 3 // LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_VIEWS_BLOCKED_POPUP_CONTAINER_CONTROLLER_H_ | 5 #ifndef CHROME_BROWSER_VIEWS_BLOCKED_POPUP_CONTAINER_CONTROLLER_H_ |
| 6 #define CHROME_BROWSER_VIEWS_BLOCKED_POPUP_CONTAINER_CONTROLLER_H_ | 6 #define CHROME_BROWSER_VIEWS_BLOCKED_POPUP_CONTAINER_CONTROLLER_H_ |
| 7 | 7 |
| 8 #import <Cocoa/Cocoa.h> | 8 #import <Cocoa/Cocoa.h> |
| 9 | 9 |
| 10 #include "base/scoped_nsobject.h" | 10 #include "base/scoped_nsobject.h" |
| 11 #include "base/scoped_ptr.h" | 11 #include "base/scoped_ptr.h" |
| 12 #include "chrome/browser/blocked_popup_container.h" | 12 #include "chrome/browser/blocked_popup_container.h" |
| 13 | 13 |
| 14 // Controller for the blocked popup view. Communicates with the cross-platform | 14 // Controller for the blocked popup view. Communicates with the cross-platform |
| 15 // code via a C++ bridge class, below. The BlockedPopupContainer class doesn't | 15 // code via a C++ bridge class, below. The BlockedPopupContainer class doesn't |
| 16 // really "own" the bridge, it just keeps a pointer to it and calls Destroy() on | 16 // really "own" the bridge, it just keeps a pointer to it and calls Destroy() on |
| 17 // it when it's supposed to go away. As a result, this class needs to own itself | 17 // it when it's supposed to go away. As a result, this class needs to own itself |
| 18 // (always keep an extra retain), and will autorelease itself (and the bridge | 18 // (always keep an extra retain), and will autorelease itself (and the bridge |
| 19 // which it owns) when the bridge gets a Destroy() message. | 19 // which it owns) when the bridge gets a Destroy() message. |
| 20 // TODO(pinkerton): Reverse the ownership if it makes more sense. I'm leaving | 20 // TODO(pinkerton): Reverse the ownership if it makes more sense. I'm leaving |
| 21 // it this way because I assume we eventually want this to be a | 21 // it this way because I assume we eventually want this to be a |
| 22 // NSViewController, and we usually have the Obj-C controller owning the | 22 // NSViewController, and we usually have the Obj-C controller owning the |
| 23 // bridge (rather than the other way around). | 23 // bridge (rather than the other way around). |
| 24 @interface BlockedPopupContainerController : NSObject { | 24 @interface BlockedPopupContainerController : NSObject { |
| 25 @private | 25 @private |
| 26 scoped_ptr<BlockedPopupContainerView> bridge_; | 26 scoped_ptr<BlockedPopupContainerView> bridge_; |
| 27 BlockedPopupContainer* container_; // Weak. "owns" me. | 27 BlockedPopupContainer* container_; // Weak. "owns" me. |
| 28 scoped_nsobject<NSView> view_; | 28 scoped_nsobject<NSView> view_; |
| 29 IBOutlet NSTextField* label_; | 29 IBOutlet NSPopUpButton* popupButton_; |
| 30 } | 30 } |
| 31 | 31 |
| 32 // Initialize with the given popup container. Creates the C++ bridge object | 32 // Initialize with the given popup container. Creates the C++ bridge object |
| 33 // used to represet the "view". | 33 // used to represet the "view". |
| 34 - (id)initWithContainer:(BlockedPopupContainer*)container; | 34 - (id)initWithContainer:(BlockedPopupContainer*)container; |
| 35 | 35 |
| 36 // Returns the C++ brige object. | 36 // Returns the C++ brige object. |
| 37 - (BlockedPopupContainerView*)bridge; | 37 - (BlockedPopupContainerView*)bridge; |
| 38 | 38 |
| 39 // Called by the bridge to perform certain actions from the back-end code. | 39 // Called by the bridge to perform certain actions from the back-end code. |
| 40 - (void)show; | 40 - (void)show; |
| 41 - (void)hide; | 41 - (void)hide; |
| 42 - (void)update; | 42 - (void)update; |
| 43 | 43 |
| 44 @end | 44 @end |
| 45 | 45 |
| 46 @interface BlockedPopupContainerController(ForTesting) | 46 @interface BlockedPopupContainerController(ForTesting) |
| 47 - (NSView*)view; | 47 - (NSView*)view; |
| 48 - (NSView*)label; | 48 - (NSPopUpButton*)popupButton; |
| 49 - (IBAction)closePopup:(id)sender; | 49 - (IBAction)closePopup:(id)sender; |
| 50 - (NSMenu*)buildMenu; |
| 51 - (void)setContainer:(BlockedPopupContainer*)container; |
| 50 @end | 52 @end |
| 51 | 53 |
| 52 #endif // CHROME_BROWSER_VIEWS_BLOCKED_POPUP_CONTAINER_CONTROLLER_H_ | 54 #endif // CHROME_BROWSER_VIEWS_BLOCKED_POPUP_CONTAINER_CONTROLLER_H_ |
| OLD | NEW |