| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2010 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 #import <Cocoa/Cocoa.h> | |
| 6 | |
| 7 #import "base/mac/cocoa_protocols.h" | |
| 8 #include "base/scoped_nsobject.h" | |
| 9 #include "base/scoped_ptr.h" | |
| 10 #include "chrome/browser/cookies_tree_model.h" | |
| 11 #include "chrome/browser/ui/cocoa/constrained_window_mac.h" | |
| 12 #import "chrome/browser/ui/cocoa/cookie_tree_node.h" | |
| 13 #include "chrome/common/notification_registrar.h" | |
| 14 | |
| 15 @class CollectedCookiesWindowController; | |
| 16 @class VerticalGradientView; | |
| 17 class TabContents; | |
| 18 | |
| 19 // The constrained window delegate reponsible for managing the collected | |
| 20 // cookies dialog. | |
| 21 class CollectedCookiesMac : public ConstrainedWindowMacDelegateCustomSheet, | |
| 22 public NotificationObserver { | |
| 23 public: | |
| 24 CollectedCookiesMac(NSWindow* parent, TabContents* tab_contents); | |
| 25 | |
| 26 void OnSheetDidEnd(NSWindow* sheet); | |
| 27 | |
| 28 // ConstrainedWindowMacDelegateCustomSheet implementation. | |
| 29 virtual void DeleteDelegate(); | |
| 30 | |
| 31 private: | |
| 32 virtual ~CollectedCookiesMac(); | |
| 33 | |
| 34 // NotificationObserver implementation. | |
| 35 void Observe(NotificationType type, | |
| 36 const NotificationSource& source, | |
| 37 const NotificationDetails& details); | |
| 38 | |
| 39 NotificationRegistrar registrar_; | |
| 40 | |
| 41 ConstrainedWindow* window_; | |
| 42 | |
| 43 TabContents* tab_contents_; | |
| 44 | |
| 45 CollectedCookiesWindowController* sheet_controller_; | |
| 46 | |
| 47 DISALLOW_COPY_AND_ASSIGN(CollectedCookiesMac); | |
| 48 }; | |
| 49 | |
| 50 // Controller for the collected cookies dialog. This class stores an internal | |
| 51 // copy of the CookiesTreeModel but with Cocoa-converted values (NSStrings and | |
| 52 // NSImages instead of std::strings and SkBitmaps). Doing this allows us to use | |
| 53 // bindings for the interface. Changes are pushed to this internal model via a | |
| 54 // very thin bridge (see cookies_window_controller.h). | |
| 55 @interface CollectedCookiesWindowController : NSWindowController | |
| 56 <NSOutlineViewDelegate, | |
| 57 NSWindowDelegate> { | |
| 58 @private | |
| 59 // Platform-independent model. | |
| 60 scoped_ptr<CookiesTreeModel> allowedTreeModel_; | |
| 61 scoped_ptr<CookiesTreeModel> blockedTreeModel_; | |
| 62 | |
| 63 // Cached array of icons. | |
| 64 scoped_nsobject<NSMutableArray> icons_; | |
| 65 | |
| 66 // Our Cocoa copy of the model. | |
| 67 scoped_nsobject<CocoaCookieTreeNode> cocoaAllowedTreeModel_; | |
| 68 scoped_nsobject<CocoaCookieTreeNode> cocoaBlockedTreeModel_; | |
| 69 | |
| 70 BOOL allowedCookiesButtonsEnabled_; | |
| 71 BOOL blockedCookiesButtonsEnabled_; | |
| 72 | |
| 73 IBOutlet NSTreeController* allowedTreeController_; | |
| 74 IBOutlet NSTreeController* blockedTreeController_; | |
| 75 IBOutlet NSOutlineView* allowedOutlineView_; | |
| 76 IBOutlet NSOutlineView* blockedOutlineView_; | |
| 77 IBOutlet VerticalGradientView* infoBar_; | |
| 78 IBOutlet NSImageView* infoBarIcon_; | |
| 79 IBOutlet NSTextField* infoBarText_; | |
| 80 IBOutlet NSSplitView* splitView_; | |
| 81 IBOutlet NSScrollView* lowerScrollView_; | |
| 82 IBOutlet NSTextField* blockedCookiesText_; | |
| 83 | |
| 84 scoped_nsobject<NSViewAnimation> animation_; | |
| 85 | |
| 86 TabContents* tabContents_; // weak | |
| 87 | |
| 88 BOOL infoBarVisible_; | |
| 89 } | |
| 90 @property (readonly, nonatomic) NSTreeController* allowedTreeController; | |
| 91 @property (readonly, nonatomic) NSTreeController* blockedTreeController; | |
| 92 | |
| 93 @property (assign, nonatomic) BOOL allowedCookiesButtonsEnabled; | |
| 94 @property (assign, nonatomic) BOOL blockedCookiesButtonsEnabled; | |
| 95 | |
| 96 // Designated initializer. TabContents cannot be NULL. | |
| 97 - (id)initWithTabContents:(TabContents*)tabContents; | |
| 98 | |
| 99 // Closes the sheet and ends the modal loop. This will also cleanup the memory. | |
| 100 - (IBAction)closeSheet:(id)sender; | |
| 101 | |
| 102 - (IBAction)allowOrigin:(id)sender; | |
| 103 - (IBAction)allowForSessionFromOrigin:(id)sender; | |
| 104 - (IBAction)blockOrigin:(id)sender; | |
| 105 | |
| 106 // NSSplitView delegate methods: | |
| 107 - (CGFloat) splitView:(NSSplitView *)sender | |
| 108 constrainMinCoordinate:(CGFloat)proposedMin | |
| 109 ofSubviewAt:(NSInteger)offset; | |
| 110 - (BOOL)splitView:(NSSplitView *)sender canCollapseSubview:(NSView *)subview; | |
| 111 | |
| 112 // Returns the cocoaAllowedTreeModel_ and cocoaBlockedTreeModel_. | |
| 113 - (CocoaCookieTreeNode*)cocoaAllowedTreeModel; | |
| 114 - (CocoaCookieTreeNode*)cocoaBlockedTreeModel; | |
| 115 - (void)setCocoaAllowedTreeModel:(CocoaCookieTreeNode*)model; | |
| 116 - (void)setCocoaBlockedTreeModel:(CocoaCookieTreeNode*)model; | |
| 117 | |
| 118 // Returns the allowedTreeModel_ and blockedTreeModel_. | |
| 119 - (CookiesTreeModel*)allowedTreeModel; | |
| 120 - (CookiesTreeModel*)blockedTreeModel; | |
| 121 | |
| 122 - (void)loadTreeModelFromTabContents; | |
| 123 @end | |
| OLD | NEW |