OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/ui/cocoa/content_settings/cookie_details.h" | 5 #include "chrome/browser/ui/cocoa/content_settings/cookie_details.h" |
6 | 6 |
7 #import "base/i18n/time_formatting.h" | 7 #import "base/i18n/time_formatting.h" |
8 #include "base/sys_string_conversions.h" | 8 #include "base/sys_string_conversions.h" |
9 #include "grit/generated_resources.h" | 9 #include "grit/generated_resources.h" |
10 #include "chrome/browser/cookies_tree_model.h" | 10 #include "chrome/browser/cookies_tree_model.h" |
11 #include "ui/base/l10n/l10n_util_mac.h" | 11 #include "ui/base/l10n/l10n_util_mac.h" |
| 12 #include "ui/base/text/bytes_formatting.h" |
12 #include "webkit/appcache/appcache_service.h" | 13 #include "webkit/appcache/appcache_service.h" |
13 | 14 |
14 #pragma mark Cocoa Cookie Details | 15 #pragma mark Cocoa Cookie Details |
15 | 16 |
16 @implementation CocoaCookieDetails | 17 @implementation CocoaCookieDetails |
17 | 18 |
18 @synthesize canEditExpiration = canEditExpiration_; | 19 @synthesize canEditExpiration = canEditExpiration_; |
19 @synthesize hasExpiration = hasExpiration_; | 20 @synthesize hasExpiration = hasExpiration_; |
20 @synthesize type = type_; | 21 @synthesize type = type_; |
21 | 22 |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 return self; | 150 return self; |
150 } | 151 } |
151 | 152 |
152 - (id)initWithDatabase:(const BrowsingDataDatabaseHelper::DatabaseInfo*) | 153 - (id)initWithDatabase:(const BrowsingDataDatabaseHelper::DatabaseInfo*) |
153 databaseInfo { | 154 databaseInfo { |
154 if ((self = [super init])) { | 155 if ((self = [super init])) { |
155 type_ = kCocoaCookieDetailsTypeTreeDatabase; | 156 type_ = kCocoaCookieDetailsTypeTreeDatabase; |
156 canEditExpiration_ = NO; | 157 canEditExpiration_ = NO; |
157 databaseDescription_.reset([base::SysUTF8ToNSString( | 158 databaseDescription_.reset([base::SysUTF8ToNSString( |
158 databaseInfo->description) retain]); | 159 databaseInfo->description) retain]); |
159 fileSize_.reset([base::SysUTF16ToNSString(FormatBytes(databaseInfo->size, | 160 fileSize_.reset([base::SysUTF16ToNSString( |
160 GetByteDisplayUnits(databaseInfo->size), true)) retain]); | 161 ui::FormatBytes(databaseInfo->size)) retain]); |
161 lastModified_.reset([base::SysUTF16ToNSString( | 162 lastModified_.reset([base::SysUTF16ToNSString( |
162 base::TimeFormatFriendlyDateAndTime( | 163 base::TimeFormatFriendlyDateAndTime( |
163 databaseInfo->last_modified)) retain]); | 164 databaseInfo->last_modified)) retain]); |
164 } | 165 } |
165 return self; | 166 return self; |
166 } | 167 } |
167 | 168 |
168 - (id)initWithLocalStorage:( | 169 - (id)initWithLocalStorage:( |
169 const BrowsingDataLocalStorageHelper::LocalStorageInfo*)storageInfo { | 170 const BrowsingDataLocalStorageHelper::LocalStorageInfo*)storageInfo { |
170 if ((self = [super init])) { | 171 if ((self = [super init])) { |
171 type_ = kCocoaCookieDetailsTypeTreeLocalStorage; | 172 type_ = kCocoaCookieDetailsTypeTreeLocalStorage; |
172 canEditExpiration_ = NO; | 173 canEditExpiration_ = NO; |
173 domain_.reset([base::SysUTF8ToNSString(storageInfo->origin) retain]); | 174 domain_.reset([base::SysUTF8ToNSString(storageInfo->origin) retain]); |
174 fileSize_.reset([base::SysUTF16ToNSString(FormatBytes(storageInfo->size, | 175 fileSize_.reset( |
175 GetByteDisplayUnits(storageInfo->size), true)) retain]); | 176 [base::SysUTF16ToNSString(ui::FormatBytes(storageInfo->size)) retain]); |
176 lastModified_.reset([base::SysUTF16ToNSString( | 177 lastModified_.reset([base::SysUTF16ToNSString( |
177 base::TimeFormatFriendlyDateAndTime( | 178 base::TimeFormatFriendlyDateAndTime( |
178 storageInfo->last_modified)) retain]); | 179 storageInfo->last_modified)) retain]); |
179 } | 180 } |
180 return self; | 181 return self; |
181 } | 182 } |
182 | 183 |
183 - (id)initWithAppCacheInfo:(const appcache::AppCacheInfo*)appcacheInfo { | 184 - (id)initWithAppCacheInfo:(const appcache::AppCacheInfo*)appcacheInfo { |
184 if ((self = [super init])) { | 185 if ((self = [super init])) { |
185 type_ = kCocoaCookieDetailsTypeTreeAppCache; | 186 type_ = kCocoaCookieDetailsTypeTreeAppCache; |
186 canEditExpiration_ = NO; | 187 canEditExpiration_ = NO; |
187 manifestURL_.reset([base::SysUTF8ToNSString( | 188 manifestURL_.reset([base::SysUTF8ToNSString( |
188 appcacheInfo->manifest_url.spec()) retain]); | 189 appcacheInfo->manifest_url.spec()) retain]); |
189 fileSize_.reset([base::SysUTF16ToNSString(FormatBytes(appcacheInfo->size, | 190 fileSize_.reset([base::SysUTF16ToNSString( |
190 GetByteDisplayUnits(appcacheInfo->size), true)) retain]); | 191 ui::FormatBytes(appcacheInfo->size)) retain]); |
191 created_.reset([base::SysUTF16ToNSString( | 192 created_.reset([base::SysUTF16ToNSString( |
192 base::TimeFormatFriendlyDateAndTime( | 193 base::TimeFormatFriendlyDateAndTime( |
193 appcacheInfo->creation_time)) retain]); | 194 appcacheInfo->creation_time)) retain]); |
194 lastAccessed_.reset([base::SysUTF16ToNSString( | 195 lastAccessed_.reset([base::SysUTF16ToNSString( |
195 base::TimeFormatFriendlyDateAndTime( | 196 base::TimeFormatFriendlyDateAndTime( |
196 appcacheInfo->last_access_time)) retain]); | 197 appcacheInfo->last_access_time)) retain]); |
197 } | 198 } |
198 return self; | 199 return self; |
199 } | 200 } |
200 | 201 |
201 - (id)initWithDatabase:(const std::string&)domain | 202 - (id)initWithDatabase:(const std::string&)domain |
202 databaseName:(const string16&)databaseName | 203 databaseName:(const string16&)databaseName |
203 databaseDescription:(const string16&)databaseDescription | 204 databaseDescription:(const string16&)databaseDescription |
204 fileSize:(unsigned long)fileSize { | 205 fileSize:(unsigned long)fileSize { |
205 if ((self = [super init])) { | 206 if ((self = [super init])) { |
206 type_ = kCocoaCookieDetailsTypePromptDatabase; | 207 type_ = kCocoaCookieDetailsTypePromptDatabase; |
207 canEditExpiration_ = NO; | 208 canEditExpiration_ = NO; |
208 name_.reset([base::SysUTF16ToNSString(databaseName) retain]); | 209 name_.reset([base::SysUTF16ToNSString(databaseName) retain]); |
209 domain_.reset([base::SysUTF8ToNSString(domain) retain]); | 210 domain_.reset([base::SysUTF8ToNSString(domain) retain]); |
210 databaseDescription_.reset( | 211 databaseDescription_.reset( |
211 [base::SysUTF16ToNSString(databaseDescription) retain]); | 212 [base::SysUTF16ToNSString(databaseDescription) retain]); |
212 fileSize_.reset([base::SysUTF16ToNSString(FormatBytes(fileSize, | 213 fileSize_.reset( |
213 GetByteDisplayUnits(fileSize), true)) retain]); | 214 [base::SysUTF16ToNSString(ui::FormatBytes(fileSize)) retain]); |
214 } | 215 } |
215 return self; | 216 return self; |
216 } | 217 } |
217 | 218 |
218 - (id)initWithLocalStorage:(const std::string&)domain | 219 - (id)initWithLocalStorage:(const std::string&)domain |
219 key:(const string16&)key | 220 key:(const string16&)key |
220 value:(const string16&)value { | 221 value:(const string16&)value { |
221 if ((self = [super init])) { | 222 if ((self = [super init])) { |
222 type_ = kCocoaCookieDetailsTypePromptLocalStorage; | 223 type_ = kCocoaCookieDetailsTypePromptLocalStorage; |
223 canEditExpiration_ = NO; | 224 canEditExpiration_ = NO; |
(...skipping 12 matching lines...) Expand all Loading... |
236 } | 237 } |
237 return self; | 238 return self; |
238 } | 239 } |
239 | 240 |
240 - (id)initWithIndexedDBInfo: | 241 - (id)initWithIndexedDBInfo: |
241 (const BrowsingDataIndexedDBHelper::IndexedDBInfo*)indexedDBInfo { | 242 (const BrowsingDataIndexedDBHelper::IndexedDBInfo*)indexedDBInfo { |
242 if ((self = [super init])) { | 243 if ((self = [super init])) { |
243 type_ = kCocoaCookieDetailsTypeTreeIndexedDB; | 244 type_ = kCocoaCookieDetailsTypeTreeIndexedDB; |
244 canEditExpiration_ = NO; | 245 canEditExpiration_ = NO; |
245 domain_.reset([base::SysUTF8ToNSString(indexedDBInfo->origin) retain]); | 246 domain_.reset([base::SysUTF8ToNSString(indexedDBInfo->origin) retain]); |
246 fileSize_.reset([base::SysUTF16ToNSString(FormatBytes(indexedDBInfo->size, | 247 fileSize_.reset([base::SysUTF16ToNSString( |
247 GetByteDisplayUnits(indexedDBInfo->size), true)) retain]); | 248 ui::FormatBytes(indexedDBInfo->size)) retain]); |
248 lastModified_.reset([base::SysUTF16ToNSString( | 249 lastModified_.reset([base::SysUTF16ToNSString( |
249 base::TimeFormatFriendlyDateAndTime( | 250 base::TimeFormatFriendlyDateAndTime( |
250 indexedDBInfo->last_modified)) retain]); | 251 indexedDBInfo->last_modified)) retain]); |
251 } | 252 } |
252 return self; | 253 return self; |
253 } | 254 } |
254 | 255 |
255 + (CocoaCookieDetails*)createFromCookieTreeNode:(CookieTreeNode*)treeNode { | 256 + (CocoaCookieDetails*)createFromCookieTreeNode:(CookieTreeNode*)treeNode { |
256 CookieTreeNode::DetailedInfo info = treeNode->GetDetailedInfo(); | 257 CookieTreeNode::DetailedInfo info = treeNode->GetDetailedInfo(); |
257 CookieTreeNode::DetailedInfo::NodeType nodeType = info.node_type; | 258 CookieTreeNode::DetailedInfo::NodeType nodeType = info.node_type; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
290 details_.reset([details retain]); | 291 details_.reset([details retain]); |
291 } | 292 } |
292 return self; | 293 return self; |
293 } | 294 } |
294 | 295 |
295 - (CocoaCookieDetails*)details { | 296 - (CocoaCookieDetails*)details { |
296 return details_.get(); | 297 return details_.get(); |
297 } | 298 } |
298 | 299 |
299 @end | 300 @end |
OLD | NEW |