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 #include "chrome/browser/browsing_data_database_helper.h" | |
8 #include "chrome/browser/browsing_data_indexed_db_helper.h" | |
9 #include "chrome/browser/browsing_data_local_storage_helper.h" | |
10 #include "base/scoped_nsobject.h" | |
11 #include "net/base/cookie_monster.h" | |
12 #include "webkit/appcache/appcache_service.h" | |
13 | |
14 class CookieTreeNode; | |
15 class CookiePromptModalDialog; | |
16 | |
17 // This enum specifies the type of information contained in the | |
18 // cookie details. | |
19 enum CocoaCookieDetailsType { | |
20 // Represents grouping of cookie data, used in the cookie tree. | |
21 kCocoaCookieDetailsTypeFolder = 0, | |
22 | |
23 // Detailed information about a cookie, used both in the cookie | |
24 // tree and the cookie prompt. | |
25 kCocoaCookieDetailsTypeCookie, | |
26 | |
27 // Detailed information about a web database used for | |
28 // display in the cookie tree. | |
29 kCocoaCookieDetailsTypeTreeDatabase, | |
30 | |
31 // Detailed information about local storage used for | |
32 // display in the cookie tree. | |
33 kCocoaCookieDetailsTypeTreeLocalStorage, | |
34 | |
35 // Detailed information about an appcache used for display in the | |
36 // cookie tree. | |
37 kCocoaCookieDetailsTypeTreeAppCache, | |
38 | |
39 // Detailed information about an IndexedDB used for display in the | |
40 // cookie tree. | |
41 kCocoaCookieDetailsTypeTreeIndexedDB, | |
42 | |
43 // Detailed information about a web database used for display | |
44 // in the cookie prompt dialog. | |
45 kCocoaCookieDetailsTypePromptDatabase, | |
46 | |
47 // Detailed information about local storage used for display | |
48 // in the cookie prompt dialog. | |
49 kCocoaCookieDetailsTypePromptLocalStorage, | |
50 | |
51 // Detailed information about app caches used for display | |
52 // in the cookie prompt dialog. | |
53 kCocoaCookieDetailsTypePromptAppCache | |
54 }; | |
55 | |
56 // This class contains all of the information that can be displayed in | |
57 // a cookie details view. Because the view uses bindings to display | |
58 // the cookie information, the methods that provide that information | |
59 // for display must be implemented directly on this class and not on any | |
60 // of its subclasses. | |
61 // If this system is rewritten to not use bindings, this class should be | |
62 // subclassed and specialized, rather than using an enum to determine type. | |
63 @interface CocoaCookieDetails : NSObject { | |
64 @private | |
65 CocoaCookieDetailsType type_; | |
66 | |
67 // Used for type kCocoaCookieDetailsTypeCookie to indicate whether | |
68 // it should be possible to edit the expiration. | |
69 BOOL canEditExpiration_; | |
70 | |
71 // Indicates whether a cookie has an explcit expiration. If not | |
72 // it will expire with the session. | |
73 BOOL hasExpiration_; | |
74 | |
75 // Only set for type kCocoaCookieDetailsTypeCookie. | |
76 scoped_nsobject<NSString> content_; | |
77 scoped_nsobject<NSString> path_; | |
78 scoped_nsobject<NSString> sendFor_; | |
79 // Stringifed dates. | |
80 scoped_nsobject<NSString> expires_; | |
81 | |
82 // Only set for type kCocoaCookieDetailsTypeCookie and | |
83 // kCocoaCookieDetailsTypeTreeAppCache nodes. | |
84 scoped_nsobject<NSString> created_; | |
85 | |
86 // Only set for types kCocoaCookieDetailsTypeCookie, and | |
87 // kCocoaCookieDetailsTypePromptDatabase nodes. | |
88 scoped_nsobject<NSString> name_; | |
89 | |
90 // Only set for type kCocoaCookieDetailsTypeTreeLocalStorage, | |
91 // kCocoaCookieDetailsTypeTreeDatabase, | |
92 // kCocoaCookieDetailsTypePromptDatabase, | |
93 // kCocoaCookieDetailsTypeTreeIndexedDB, and | |
94 // kCocoaCookieDetailsTypeTreeAppCache nodes. | |
95 scoped_nsobject<NSString> fileSize_; | |
96 | |
97 // Only set for types kCocoaCookieDetailsTypeTreeLocalStorage, | |
98 // kCocoaCookieDetailsTypeTreeDatabase, and | |
99 // kCocoaCookieDetailsTypeTreeIndexedDB nodes. | |
100 scoped_nsobject<NSString> lastModified_; | |
101 | |
102 // Only set for type kCocoaCookieDetailsTypeTreeAppCache nodes. | |
103 scoped_nsobject<NSString> lastAccessed_; | |
104 | |
105 // Only set for type kCocoaCookieDetailsTypeCookie, | |
106 // kCocoaCookieDetailsTypePromptDatabase, | |
107 // kCocoaCookieDetailsTypePromptLocalStorage, and | |
108 // kCocoaCookieDetailsTypeTreeIndexedDB nodes. | |
109 scoped_nsobject<NSString> domain_; | |
110 | |
111 // Only set for type kCocoaCookieTreeNodeTypeDatabaseStorage and | |
112 // kCocoaCookieDetailsTypePromptDatabase nodes. | |
113 scoped_nsobject<NSString> databaseDescription_; | |
114 | |
115 // Only set for type kCocoaCookieDetailsTypePromptLocalStorage. | |
116 scoped_nsobject<NSString> localStorageKey_; | |
117 scoped_nsobject<NSString> localStorageValue_; | |
118 | |
119 // Only set for type kCocoaCookieDetailsTypeTreeAppCache and | |
120 // kCocoaCookieDetailsTypePromptAppCache. | |
121 scoped_nsobject<NSString> manifestURL_; | |
122 } | |
123 | |
124 @property (nonatomic, readonly) BOOL canEditExpiration; | |
125 @property (nonatomic) BOOL hasExpiration; | |
126 @property (nonatomic, readonly) CocoaCookieDetailsType type; | |
127 | |
128 // The following methods are used in the bindings of subviews inside | |
129 // the cookie detail view. Note that the method that tests the | |
130 // visibility of the subview for cookie-specific information has a different | |
131 // polarity than the other visibility testing methods. This ensures that | |
132 // this subview is shown when there is no selection in the cookie tree, | |
133 // because a hidden value of |false| is generated when the key value binding | |
134 // is evaluated through a nil object. The other methods are bound using a | |
135 // |NSNegateBoolean| transformer, so that when there is a empty selection the | |
136 // hidden value is |true|. | |
137 - (BOOL)shouldHideCookieDetailsView; | |
138 - (BOOL)shouldShowLocalStorageTreeDetailsView; | |
139 - (BOOL)shouldShowLocalStoragePromptDetailsView; | |
140 - (BOOL)shouldShowDatabaseTreeDetailsView; | |
141 - (BOOL)shouldShowDatabasePromptDetailsView; | |
142 - (BOOL)shouldShowAppCachePromptDetailsView; | |
143 - (BOOL)shouldShowAppCacheTreeDetailsView; | |
144 - (BOOL)shouldShowIndexedDBTreeDetailsView; | |
145 | |
146 - (NSString*)name; | |
147 - (NSString*)content; | |
148 - (NSString*)domain; | |
149 - (NSString*)path; | |
150 - (NSString*)sendFor; | |
151 - (NSString*)created; | |
152 - (NSString*)expires; | |
153 - (NSString*)fileSize; | |
154 - (NSString*)lastModified; | |
155 - (NSString*)lastAccessed; | |
156 - (NSString*)databaseDescription; | |
157 - (NSString*)localStorageKey; | |
158 - (NSString*)localStorageValue; | |
159 - (NSString*)manifestURL; | |
160 | |
161 // Used for folders in the cookie tree. | |
162 - (id)initAsFolder; | |
163 | |
164 // Used for cookie details in both the cookie tree and the cookie prompt dialog. | |
165 - (id)initWithCookie:(const net::CookieMonster::CanonicalCookie*)treeNode | |
166 origin:(NSString*)origin | |
167 canEditExpiration:(BOOL)canEditExpiration; | |
168 | |
169 // Used for database details in the cookie tree. | |
170 - (id)initWithDatabase: | |
171 (const BrowsingDataDatabaseHelper::DatabaseInfo*)databaseInfo; | |
172 | |
173 // Used for local storage details in the cookie tree. | |
174 - (id)initWithLocalStorage: | |
175 (const BrowsingDataLocalStorageHelper::LocalStorageInfo*)localStorageInfo; | |
176 | |
177 // Used for database details in the cookie prompt dialog. | |
178 - (id)initWithDatabase:(const std::string&)domain | |
179 databaseName:(const string16&)databaseName | |
180 databaseDescription:(const string16&)databaseDescription | |
181 fileSize:(unsigned long)fileSize; | |
182 | |
183 // -initWithAppCacheInfo: creates a cookie details with the manifest URL plus | |
184 // all of this additional information that is available after an appcache is | |
185 // actually created, including it's creation date, size and last accessed time. | |
186 - (id)initWithAppCacheInfo:(const appcache::AppCacheInfo*)appcacheInfo; | |
187 | |
188 // Used for local storage details in the cookie prompt dialog. | |
189 - (id)initWithLocalStorage:(const std::string&)domain | |
190 key:(const string16&)key | |
191 value:(const string16&)value; | |
192 | |
193 // -initWithAppCacheManifestURL: is called when the cookie prompt is displayed | |
194 // for an appcache, at that time only the manifest URL of the appcache is known. | |
195 - (id)initWithAppCacheManifestURL:(const std::string&)manifestURL; | |
196 | |
197 // Used for IndexedDB details in the cookie tree. | |
198 - (id)initWithIndexedDBInfo: | |
199 (const BrowsingDataIndexedDBHelper::IndexedDBInfo*)indexedDB; | |
200 | |
201 // A factory method to create a configured instance given a node from | |
202 // the cookie tree in |treeNode|. | |
203 + (CocoaCookieDetails*)createFromCookieTreeNode:(CookieTreeNode*)treeNode; | |
204 | |
205 @end | |
206 | |
207 // The subpanes of the cookie details view expect to be able to bind to methods | |
208 // through a key path in the form |content.details.xxxx|. This class serves as | |
209 // an adapter that simply wraps a |CocoaCookieDetails| object. An instance of | |
210 // this class is set as the content object for cookie details view's object | |
211 // controller so that key paths are properly resolved through to the | |
212 // |CocoaCookieDetails| object for the cookie prompt. | |
213 @interface CookiePromptContentDetailsAdapter : NSObject { | |
214 @private | |
215 scoped_nsobject<CocoaCookieDetails> details_; | |
216 } | |
217 | |
218 - (CocoaCookieDetails*)details; | |
219 | |
220 // The adapter assumes ownership of the details object | |
221 // in its initializer. | |
222 - (id)initWithDetails:(CocoaCookieDetails*)details; | |
223 @end | |
224 | |
OLD | NEW |