[Metrics] Make MetricsStateManager take a callback param to check if UMA is enabled.
[chromium-blink-merge.git] / chrome / browser / ui / cocoa / content_settings / collected_cookies_mac.h
blob456f5f77432d3038f68c22bab6c9791d6d728f68
1 // Copyright (c) 2012 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.
5 #import <Cocoa/Cocoa.h>
7 #include "base/mac/scoped_nsobject.h"
8 #include "base/memory/scoped_ptr.h"
9 #include "chrome/browser/browsing_data/cookies_tree_model.h"
10 #include "chrome/browser/ui/cocoa/constrained_window/constrained_window_mac.h"
11 #import "chrome/browser/ui/cocoa/content_settings/cookie_tree_node.h"
12 #import "chrome/browser/ui/cocoa/content_settings/cookies_tree_controller_bridge.h"
13 #include "content/public/browser/notification_observer.h"
14 #include "content/public/browser/notification_registrar.h"
16 @class CollectedCookiesWindowController;
17 @class CookieDetailsViewController;
18 @class VerticalGradientView;
20 namespace content {
21 class WebContents;
24 // The constrained window delegate reponsible for managing the collected
25 // cookies dialog.
26 class CollectedCookiesMac : public ConstrainedWindowMacDelegate,
27 public content::NotificationObserver {
28 public:
29 CollectedCookiesMac(content::WebContents* web_contents);
30 virtual ~CollectedCookiesMac();
32 void PerformClose();
34 // ConstrainedWindowMacDelegate implementation.
35 virtual void OnConstrainedWindowClosed(
36 ConstrainedWindowMac* window) OVERRIDE;
38 CollectedCookiesWindowController* sheet_controller() const {
39 return sheet_controller_.get();
42 private:
43 // NotificationObserver implementation.
44 virtual void Observe(int type,
45 const content::NotificationSource& source,
46 const content::NotificationDetails& details) OVERRIDE;
48 content::NotificationRegistrar registrar_;
50 scoped_ptr<ConstrainedWindowMac> window_;
52 base::scoped_nsobject<CollectedCookiesWindowController> sheet_controller_;
54 DISALLOW_COPY_AND_ASSIGN(CollectedCookiesMac);
57 // Controller for the collected cookies dialog. This class stores an internal
58 // copy of the CookiesTreeModel but with Cocoa-converted values (NSStrings and
59 // NSImages instead of std::strings and ImageSkias). Doing this allows us to use
60 // bindings for the interface. Changes are pushed to this internal model via a
61 // very thin bridge (see cookies_window_controller.h).
62 @interface CollectedCookiesWindowController : NSWindowController
63 <NSOutlineViewDelegate,
64 NSTabViewDelegate,
65 NSWindowDelegate> {
66 @private
67 // Platform-independent model.
68 scoped_ptr<CookiesTreeModel> allowedTreeModel_;
69 scoped_ptr<CookiesTreeModel> blockedTreeModel_;
71 // Cached array of icons.
72 base::scoped_nsobject<NSMutableArray> icons_;
74 // Our Cocoa copy of the model.
75 scoped_ptr<CookiesTreeControllerBridge> allowedControllerBridge_;
76 scoped_ptr<CookiesTreeControllerBridge> blockedControllerBridge_;
78 BOOL allowedCookiesButtonsEnabled_;
79 BOOL blockedCookiesButtonsEnabled_;
80 BOOL deleteCookiesButtonEnabled_; // Only in the allowed pane.
82 IBOutlet NSTreeController* allowedTreeController_;
83 IBOutlet NSTreeController* blockedTreeController_;
84 IBOutlet NSOutlineView* allowedOutlineView_;
85 IBOutlet NSOutlineView* blockedOutlineView_;
86 IBOutlet VerticalGradientView* infoBar_;
87 IBOutlet NSImageView* infoBarIcon_;
88 IBOutlet NSTextField* infoBarText_;
89 IBOutlet NSTabView* tabView_;
90 IBOutlet NSScrollView* blockedScrollView_;
91 IBOutlet NSTextField* blockedCookiesText_;
92 IBOutlet NSView* cookieDetailsViewPlaceholder_;
94 base::scoped_nsobject<NSViewAnimation> animation_;
96 base::scoped_nsobject<CookieDetailsViewController> detailsViewController_;
98 content::WebContents* webContents_; // weak
100 CollectedCookiesMac* collectedCookiesMac_; // weak
102 BOOL infoBarVisible_;
104 BOOL contentSettingsChanged_;
107 @property(readonly, nonatomic) IBOutlet NSTreeController* allowedTreeController;
108 @property(readonly, nonatomic) IBOutlet NSTreeController* blockedTreeController;
109 @property(readonly, nonatomic) IBOutlet NSOutlineView* allowedOutlineView;
110 @property(readonly, nonatomic) IBOutlet NSOutlineView* blockedOutlineView;
111 @property(readonly, nonatomic) IBOutlet VerticalGradientView* infoBar;
112 @property(readonly, nonatomic) IBOutlet NSImageView* infoBarIcon;
113 @property(readonly, nonatomic) IBOutlet NSTextField* infoBarText;
114 @property(readonly, nonatomic) IBOutlet NSTabView* tabView;
115 @property(readonly, nonatomic) IBOutlet NSScrollView* blockedScrollView;
116 @property(readonly, nonatomic) IBOutlet NSTextField* blockedCookiesText;
117 @property(readonly, nonatomic) IBOutlet NSView* cookieDetailsViewPlaceholder;
119 @property(assign, nonatomic) BOOL allowedCookiesButtonsEnabled;
120 @property(assign, nonatomic) BOOL blockedCookiesButtonsEnabled;
121 @property(assign, nonatomic) BOOL deleteCookiesButtonEnabled;
123 // Designated initializer. The WebContents cannot be NULL.
124 - (id)initWithWebContents:(content::WebContents*)webContents
125 collectedCookiesMac:(CollectedCookiesMac*)collectedCookiesMac;
127 // Closes the sheet and ends the modal loop. This will also clean up the memory.
128 - (IBAction)closeSheet:(id)sender;
130 - (IBAction)allowOrigin:(id)sender;
131 - (IBAction)allowForSessionFromOrigin:(id)sender;
132 - (IBAction)blockOrigin:(id)sender;
134 // Allows the deletion of set cookies (only visible in the Allowed pane).
135 - (IBAction)deleteSelected:(id)sender;
137 // Returns the |cocoaAllowedTreeModel_| and |cocoaBlockedTreeModel_|.
138 - (CocoaCookieTreeNode*)cocoaAllowedTreeModel;
139 - (CocoaCookieTreeNode*)cocoaBlockedTreeModel;
141 // Returns the |allowedTreeModel_| and |blockedTreeModel_|.
142 - (CookiesTreeModel*)allowedTreeModel;
143 - (CookiesTreeModel*)blockedTreeModel;
145 - (void)loadTreeModelFromWebContents;
147 // Given an array of selected NSTreeNode objects, normalizes the selection so
148 // that it does not contain any children whose parents are also in the array.
149 + (NSArray*)normalizeNodeSelection:(NSArray*)selection;
151 @end