Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(270)

Side by Side Diff: chrome/browser/cocoa/cookies_window_controller.h

Issue 523025: [Mac] Implement the cookie manager (Closed)
Patch Set: Address all comments Created 10 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 #import <Cocoa/Cocoa.h>
6
7 #include "app/tree_model.h"
8 #include "base/cocoa_protocols_mac.h"
9 #include "base/scoped_nsobject.h"
10 #include "base/scoped_ptr.h"
11 #import "chrome/browser/cocoa/cookie_tree_node.h"
12 #include "chrome/browser/cookies_tree_model.h"
13 #include "net/base/cookie_monster.h"
14
15 @class CookiesWindowController;
16 class CookiesWindowControllerTest;
17 class Profile;
18
19 // Thin bridge to the window controller that performs model update actions
20 // directly on the treeController_.
21 class CookiesTreeModelObserverBridge : public TreeModelObserver {
22 public:
23 explicit CookiesTreeModelObserverBridge(CookiesWindowController* controller);
24
25 // Notification that nodes were added to the specified parent.
26 virtual void TreeNodesAdded(TreeModel* model,
27 TreeModelNode* parent,
28 int start,
29 int count);
30
31 // Notification that nodes were removed from the specified parent.
32 virtual void TreeNodesRemoved(TreeModel* model,
33 TreeModelNode* parent,
34 int start,
35 int count);
36
37 // Notification the children of |parent| have been reordered. Note, only
38 // the direct children of |parent| have been reordered, not descendants.
39 virtual void TreeNodeChildrenReordered(TreeModel* model,
40 TreeModelNode* parent);
41
42 // Notification that the contents of a node has changed.
43 virtual void TreeNodeChanged(TreeModel* model, TreeModelNode* node);
44
45 private:
46 friend class CookiesWindowControllerTest;
47
48 // Creates an CocoaCookieTreeNodefrom a platform-independent one.
49 // Return value is autoreleased. This can recusively create child nodes.
50 CocoaCookieTreeNode* CocoaNodeFromTreeNode(TreeModelNode* node,
51 bool recurse);
52
53 // Finds the Cocoa model node based on a platform-independent one. This is
54 // done by comparing the treeNode pointers. |start| is the node to start
55 // searching at. If |start| is nil, the root is used.
56 CocoaCookieTreeNode* FindCocoaNode(TreeModelNode* node,
57 CocoaCookieTreeNode* start);
58
59 CookiesWindowController* window_controller_; // weak, owns us.
60 };
61
62 // Controller for the cookies manager. This class stores an internal copy of
63 // the CookiesTreeModel but with Cocoa-converted values (NSStrings and NSImages
64 // instead of std::strings and SkBitmaps). Doing this allows us to use bindings
65 // for the interface. Changes are pushed to this internal model via a very thin
66 // bridge (see above).
67 //
68 // TODO(rsesek): Localize this nib.
69 @interface CookiesWindowController : NSWindowController
70 <NSOutlineViewDelegate,
71 NSWindowDelegate> {
72 @private
73 // Platform-independent model and C++/Obj-C bridge components.
74 scoped_ptr<CookiesTreeModel> treeModel_;
75 scoped_ptr<CookiesTreeModelObserverBridge> modelObserver_;
76
77 // Cached array of icons.
78 scoped_nsobject<NSMutableArray> icons_;
79
80 // Our Cocoa copy of the model.
81 scoped_nsobject<CocoaCookieTreeNode> cocoaTreeModel_;
82
83 IBOutlet NSTreeController* treeController_;
84
85 Profile* profile_; // weak
86 }
87 @property (readonly, nonatomic) NSTreeController* treeController;
88
89 // Designated initializer. Profile cannot be NULL.
90 - (id)initWithProfile:(Profile*)profile;
91
92 // Shows the cookies window as a modal sheet attached to |window|.
93 - (void)attachSheetTo:(NSWindow*)window;
94
95 // Delete cookie actions.
96 - (IBAction)deleteCookie:(id)sender;
97 - (IBAction)deleteAllCookies:(id)sender;
98
99 // Closes the sheet and ends the modal loop. This will also cleanup the memory.
100 - (IBAction)closeSheet:(id)sender;
101
102 // Returns the cocoaTreeModel_.
103 - (CocoaCookieTreeNode*)cocoaTreeModel;
104 - (void)setCocoaTreeModel:(CocoaCookieTreeNode*)model;
105
106 // Returns the treeModel_.
107 - (CookiesTreeModel*)treeModel;
108
109 @end
110
111 @interface CookiesWindowController (UnitTesting)
112 - (CookiesTreeModelObserverBridge*)modelObserver;
113 - (NSArray*)icons;
114 @end
OLDNEW
« no previous file with comments | « chrome/browser/cocoa/cookie_tree_node.mm ('k') | chrome/browser/cocoa/cookies_window_controller.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698