| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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/strings/sys_string_conversions.h" | 8 #include "base/strings/sys_string_conversions.h" |
| 9 #include "chrome/browser/browsing_data/cookies_tree_model.h" | 9 #include "chrome/browser/browsing_data/cookies_tree_model.h" |
| 10 #include "chrome/grit/generated_resources.h" | 10 #include "chrome/grit/generated_resources.h" |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 } | 51 } |
| 52 | 52 |
| 53 - (BOOL)shouldShowIndexedDBTreeDetailsView { | 53 - (BOOL)shouldShowIndexedDBTreeDetailsView { |
| 54 return type_ == kCocoaCookieDetailsTypeTreeIndexedDB; | 54 return type_ == kCocoaCookieDetailsTypeTreeIndexedDB; |
| 55 } | 55 } |
| 56 | 56 |
| 57 - (BOOL)shouldShowServiceWorkerTreeDetailsView { | 57 - (BOOL)shouldShowServiceWorkerTreeDetailsView { |
| 58 return type_ == kCocoaCookieDetailsTypeTreeServiceWorker; | 58 return type_ == kCocoaCookieDetailsTypeTreeServiceWorker; |
| 59 } | 59 } |
| 60 | 60 |
| 61 - (BOOL)shouldShowCacheStorageTreeDetailsView { |
| 62 return type_ == kCocoaCookieDetailsTypeTreeCacheStorage; |
| 63 } |
| 64 |
| 61 - (NSString*)name { | 65 - (NSString*)name { |
| 62 return name_.get(); | 66 return name_.get(); |
| 63 } | 67 } |
| 64 | 68 |
| 65 - (NSString*)content { | 69 - (NSString*)content { |
| 66 return content_.get(); | 70 return content_.get(); |
| 67 } | 71 } |
| 68 | 72 |
| 69 - (NSString*)domain { | 73 - (NSString*)domain { |
| 70 return domain_.get(); | 74 return domain_.get(); |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 273 for (std::vector<GURL>::const_iterator it = | 277 for (std::vector<GURL>::const_iterator it = |
| 274 serviceWorkerInfo->scopes.begin(); | 278 serviceWorkerInfo->scopes.begin(); |
| 275 it != serviceWorkerInfo->scopes.end(); ++it) { | 279 it != serviceWorkerInfo->scopes.end(); ++it) { |
| 276 [scopes addObject:base::SysUTF8ToNSString(it->spec())]; | 280 [scopes addObject:base::SysUTF8ToNSString(it->spec())]; |
| 277 } | 281 } |
| 278 scopes_.reset([[scopes componentsJoinedByString:@","] retain]); | 282 scopes_.reset([[scopes componentsJoinedByString:@","] retain]); |
| 279 } | 283 } |
| 280 return self; | 284 return self; |
| 281 } | 285 } |
| 282 | 286 |
| 287 - (id)initWithCacheStorageUsageInfo: |
| 288 (const content::CacheStorageUsageInfo*)cacheStorageInfo { |
| 289 if ((self = [super init])) { |
| 290 type_ = kCocoaCookieDetailsTypeTreeCacheStorage; |
| 291 canEditExpiration_ = NO; |
| 292 domain_.reset( |
| 293 [base::SysUTF8ToNSString(cacheStorageInfo->origin.spec()) retain]); |
| 294 fileSize_.reset([base::SysUTF16ToNSString( |
| 295 ui::FormatBytes(cacheStorageInfo->total_size_bytes)) retain]); |
| 296 lastModified_.reset([base::SysUTF16ToNSString( |
| 297 base::TimeFormatFriendlyDateAndTime(cacheStorageInfo->last_modified_)) |
| 298 retain]); |
| 299 } |
| 300 return self; |
| 301 } |
| 302 |
| 283 + (CocoaCookieDetails*)createFromCookieTreeNode:(CookieTreeNode*)treeNode { | 303 + (CocoaCookieDetails*)createFromCookieTreeNode:(CookieTreeNode*)treeNode { |
| 284 CookieTreeNode::DetailedInfo info = treeNode->GetDetailedInfo(); | 304 CookieTreeNode::DetailedInfo info = treeNode->GetDetailedInfo(); |
| 285 CookieTreeNode::DetailedInfo::NodeType nodeType = info.node_type; | 305 CookieTreeNode::DetailedInfo::NodeType nodeType = info.node_type; |
| 286 switch (nodeType) { | 306 switch (nodeType) { |
| 287 case CookieTreeNode::DetailedInfo::TYPE_COOKIE: | 307 case CookieTreeNode::DetailedInfo::TYPE_COOKIE: |
| 288 return [[[CocoaCookieDetails alloc] initWithCookie:info.cookie | 308 return [[[CocoaCookieDetails alloc] initWithCookie:info.cookie |
| 289 canEditExpiration:NO] autorelease]; | 309 canEditExpiration:NO] autorelease]; |
| 290 case CookieTreeNode::DetailedInfo::TYPE_DATABASE: | 310 case CookieTreeNode::DetailedInfo::TYPE_DATABASE: |
| 291 return [[[CocoaCookieDetails alloc] | 311 return [[[CocoaCookieDetails alloc] |
| 292 initWithDatabase:info.database_info] autorelease]; | 312 initWithDatabase:info.database_info] autorelease]; |
| 293 case CookieTreeNode::DetailedInfo::TYPE_LOCAL_STORAGE: | 313 case CookieTreeNode::DetailedInfo::TYPE_LOCAL_STORAGE: |
| 294 return [[[CocoaCookieDetails alloc] | 314 return [[[CocoaCookieDetails alloc] |
| 295 initWithLocalStorage:info.local_storage_info] autorelease]; | 315 initWithLocalStorage:info.local_storage_info] autorelease]; |
| 296 case CookieTreeNode::DetailedInfo::TYPE_APPCACHE: | 316 case CookieTreeNode::DetailedInfo::TYPE_APPCACHE: |
| 297 return [[[CocoaCookieDetails alloc] | 317 return [[[CocoaCookieDetails alloc] |
| 298 initWithAppCacheInfo:info.appcache_info] autorelease]; | 318 initWithAppCacheInfo:info.appcache_info] autorelease]; |
| 299 case CookieTreeNode::DetailedInfo::TYPE_INDEXED_DB: | 319 case CookieTreeNode::DetailedInfo::TYPE_INDEXED_DB: |
| 300 return [[[CocoaCookieDetails alloc] | 320 return [[[CocoaCookieDetails alloc] |
| 301 initWithIndexedDBInfo:info.indexed_db_info] autorelease]; | 321 initWithIndexedDBInfo:info.indexed_db_info] autorelease]; |
| 302 case CookieTreeNode::DetailedInfo::TYPE_SERVICE_WORKER: | 322 case CookieTreeNode::DetailedInfo::TYPE_SERVICE_WORKER: |
| 303 return [[[CocoaCookieDetails alloc] | 323 return [[[CocoaCookieDetails alloc] |
| 304 initWithServiceWorkerUsageInfo:info.service_worker_info] autorelease]; | 324 initWithServiceWorkerUsageInfo:info.service_worker_info] autorelease]; |
| 325 case CookieTreeNode::DetailedInfo::TYPE_CACHE_STORAGE: |
| 326 return [[[CocoaCookieDetails alloc] |
| 327 initWithCacheStorageUsageInfo:info.cache_storage_info] autorelease]; |
| 305 default: | 328 default: |
| 306 return [[[CocoaCookieDetails alloc] initAsFolder] autorelease]; | 329 return [[[CocoaCookieDetails alloc] initAsFolder] autorelease]; |
| 307 } | 330 } |
| 308 } | 331 } |
| 309 | 332 |
| 310 @end | 333 @end |
| 311 | 334 |
| 312 #pragma mark Content Object Adapter | 335 #pragma mark Content Object Adapter |
| 313 | 336 |
| 314 @implementation CookiePromptContentDetailsAdapter | 337 @implementation CookiePromptContentDetailsAdapter |
| 315 | 338 |
| 316 - (id)initWithDetails:(CocoaCookieDetails*)details { | 339 - (id)initWithDetails:(CocoaCookieDetails*)details { |
| 317 if ((self = [super init])) { | 340 if ((self = [super init])) { |
| 318 details_.reset([details retain]); | 341 details_.reset([details retain]); |
| 319 } | 342 } |
| 320 return self; | 343 return self; |
| 321 } | 344 } |
| 322 | 345 |
| 323 - (CocoaCookieDetails*)details { | 346 - (CocoaCookieDetails*)details { |
| 324 return details_.get(); | 347 return details_.get(); |
| 325 } | 348 } |
| 326 | 349 |
| 327 @end | 350 @end |
| OLD | NEW |