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

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

Issue 6339002: [Mac] Consolidate all files relating to preferences in a subdir of c/b/ui/coc... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 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 | Annotate | Revision Log
OLDNEW
(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 #import "chrome/browser/ui/cocoa/cookie_tree_node.h"
12 #include "net/base/cookie_monster.h"
13
14 @class CookiesWindowController;
15 @class CookieDetailsViewController;
16 class Profile;
17
18 namespace {
19 class CookiesWindowControllerTest;
20 }
21
22 namespace ui {
23 class TreeModel;
24 class TreeModelNode;
25 }
26
27 // Thin bridge to the window controller that performs model update actions
28 // directly on the treeController_.
29 class CookiesTreeModelObserverBridge : public CookiesTreeModel::Observer {
30 public:
31 explicit CookiesTreeModelObserverBridge(CookiesWindowController* controller);
32
33 // Begin TreeModelObserver implementation.
34 virtual void TreeNodesAdded(ui::TreeModel* model,
35 ui::TreeModelNode* parent,
36 int start,
37 int count);
38 virtual void TreeNodesRemoved(ui::TreeModel* model,
39 ui::TreeModelNode* parent,
40 int start,
41 int count);
42 virtual void TreeNodeChanged(ui::TreeModel* model, ui::TreeModelNode* node);
43 // End TreeModelObserver implementation.
44
45 virtual void TreeModelBeginBatch(CookiesTreeModel* model);
46 virtual void TreeModelEndBatch(CookiesTreeModel* model);
47
48 // Invalidates the Cocoa model. This is used to tear down the Cocoa model
49 // when we're about to entirely rebuild it.
50 void InvalidateCocoaModel();
51
52 private:
53 friend class ::CookiesWindowControllerTest;
54
55 // Creates a CocoaCookieTreeNode from a platform-independent one.
56 // Return value is autoreleased. This creates child nodes recusively.
57 CocoaCookieTreeNode* CocoaNodeFromTreeNode(ui::TreeModelNode* node);
58
59 // Finds the Cocoa model node based on a platform-independent one. This is
60 // done by comparing the treeNode pointers. |start| is the node to start
61 // searching at. If |start| is nil, the root is used.
62 CocoaCookieTreeNode* FindCocoaNode(ui::TreeModelNode* node,
63 CocoaCookieTreeNode* start);
64
65 // Returns whether or not the Cocoa tree model is built.
66 bool HasCocoaModel();
67
68 CookiesWindowController* window_controller_; // weak, owns us.
69
70 // If this is true, then the Model has informed us that it is batching
71 // updates. Rather than updating the Cocoa side of the model, we ignore those
72 // small changes and rebuild once at the end.
73 bool batch_update_;
74 };
75
76 // Controller for the cookies manager. This class stores an internal copy of
77 // the CookiesTreeModel but with Cocoa-converted values (NSStrings and NSImages
78 // instead of std::strings and SkBitmaps). Doing this allows us to use bindings
79 // for the interface. Changes are pushed to this internal model via a very thin
80 // bridge (see above).
81 @interface CookiesWindowController : NSWindowController
82 <NSOutlineViewDelegate,
83 NSWindowDelegate> {
84 @private
85 // Platform-independent model and C++/Obj-C bridge components.
86 scoped_ptr<CookiesTreeModel> treeModel_;
87 scoped_ptr<CookiesTreeModelObserverBridge> modelObserver_;
88
89 // Cached array of icons.
90 scoped_nsobject<NSMutableArray> icons_;
91
92 // Our Cocoa copy of the model.
93 scoped_nsobject<CocoaCookieTreeNode> cocoaTreeModel_;
94
95 // A flag indicating whether or not the "Remove" button should be enabled.
96 BOOL removeButtonEnabled_;
97
98 IBOutlet NSTreeController* treeController_;
99 IBOutlet NSOutlineView* outlineView_;
100 IBOutlet NSSearchField* searchField_;
101 IBOutlet NSView* cookieDetailsViewPlaceholder_;
102 IBOutlet NSButton* removeButton_;
103
104 scoped_nsobject<CookieDetailsViewController> detailsViewController_;
105 Profile* profile_; // weak
106 BrowsingDataDatabaseHelper* databaseHelper_; // weak
107 BrowsingDataLocalStorageHelper* storageHelper_; // weak
108 BrowsingDataAppCacheHelper* appcacheHelper_; // weak
109 BrowsingDataIndexedDBHelper* indexedDBHelper_; // weak
110 }
111 @property (assign, nonatomic) BOOL removeButtonEnabled;
112 @property (readonly, nonatomic) NSTreeController* treeController;
113
114 // Designated initializer. Profile cannot be NULL.
115 - (id)initWithProfile:(Profile*)profile
116 databaseHelper:(BrowsingDataDatabaseHelper*)databaseHelper
117 storageHelper:(BrowsingDataLocalStorageHelper*)storageHelper
118 appcacheHelper:(BrowsingDataAppCacheHelper*)appcacheHelper
119 indexedDBHelper:(BrowsingDataIndexedDBHelper*)indexedDBHelper;
120
121 // Shows the cookies window as a modal sheet attached to |window|.
122 - (void)attachSheetTo:(NSWindow*)window;
123
124 // Updates the filter from the search field.
125 - (IBAction)updateFilter:(id)sender;
126
127 // Delete cookie actions.
128 - (IBAction)deleteCookie:(id)sender;
129 - (IBAction)deleteAllCookies:(id)sender;
130
131 // Closes the sheet and ends the modal loop. This will also cleanup the memory.
132 - (IBAction)closeSheet:(id)sender;
133
134 // Returns the cocoaTreeModel_.
135 - (CocoaCookieTreeNode*)cocoaTreeModel;
136 - (void)setCocoaTreeModel:(CocoaCookieTreeNode*)model;
137
138 // Returns the treeModel_.
139 - (CookiesTreeModel*)treeModel;
140
141 @end
142
143 @interface CookiesWindowController (UnitTesting)
144 - (void)deleteNodeAtIndexPath:(NSIndexPath*)path;
145 - (void)clearBrowsingDataNotification:(NSNotification*)notif;
146 - (CookiesTreeModelObserverBridge*)modelObserver;
147 - (NSArray*)icons;
148 - (void)loadTreeModelFromProfile;
149 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698