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/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" |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 } | 110 } |
111 | 111 |
112 - (id)initAsFolder { | 112 - (id)initAsFolder { |
113 if ((self = [super init])) { | 113 if ((self = [super init])) { |
114 type_ = kCocoaCookieDetailsTypeFolder; | 114 type_ = kCocoaCookieDetailsTypeFolder; |
115 } | 115 } |
116 return self; | 116 return self; |
117 } | 117 } |
118 | 118 |
119 - (id)initWithCookie:(const net::CookieMonster::CanonicalCookie*)cookie | 119 - (id)initWithCookie:(const net::CookieMonster::CanonicalCookie*)cookie |
120 origin:(NSString*)origin | |
121 canEditExpiration:(BOOL)canEditExpiration { | 120 canEditExpiration:(BOOL)canEditExpiration { |
122 if ((self = [super init])) { | 121 if ((self = [super init])) { |
123 type_ = kCocoaCookieDetailsTypeCookie; | 122 type_ = kCocoaCookieDetailsTypeCookie; |
124 hasExpiration_ = cookie->IsPersistent(); | 123 hasExpiration_ = cookie->IsPersistent(); |
125 canEditExpiration_ = canEditExpiration && hasExpiration_; | 124 canEditExpiration_ = canEditExpiration && hasExpiration_; |
126 name_.reset([base::SysUTF8ToNSString(cookie->Name()) retain]); | 125 name_.reset([base::SysUTF8ToNSString(cookie->Name()) retain]); |
127 content_.reset([base::SysUTF8ToNSString(cookie->Value()) retain]); | 126 content_.reset([base::SysUTF8ToNSString(cookie->Value()) retain]); |
128 path_.reset([base::SysUTF8ToNSString(cookie->Path()) retain]); | 127 path_.reset([base::SysUTF8ToNSString(cookie->Path()) retain]); |
129 domain_.reset([origin retain]); | 128 domain_.reset([base::SysUTF8ToNSString(cookie->Domain()) retain]); |
130 | 129 |
131 if (cookie->IsPersistent()) { | 130 if (cookie->IsPersistent()) { |
132 expires_.reset([base::SysUTF16ToNSString( | 131 expires_.reset([base::SysUTF16ToNSString( |
133 base::TimeFormatFriendlyDateAndTime(cookie->ExpiryDate())) retain]); | 132 base::TimeFormatFriendlyDateAndTime(cookie->ExpiryDate())) retain]); |
134 } else { | 133 } else { |
135 expires_.reset([l10n_util::GetNSStringWithFixup( | 134 expires_.reset([l10n_util::GetNSStringWithFixup( |
136 IDS_COOKIES_COOKIE_EXPIRES_SESSION) retain]); | 135 IDS_COOKIES_COOKIE_EXPIRES_SESSION) retain]); |
137 } | 136 } |
138 | 137 |
139 created_.reset([base::SysUTF16ToNSString( | 138 created_.reset([base::SysUTF16ToNSString( |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
251 lastModified_.reset([base::SysUTF16ToNSString( | 250 lastModified_.reset([base::SysUTF16ToNSString( |
252 base::TimeFormatFriendlyDateAndTime( | 251 base::TimeFormatFriendlyDateAndTime( |
253 indexedDBInfo->last_modified)) retain]); | 252 indexedDBInfo->last_modified)) retain]); |
254 } | 253 } |
255 return self; | 254 return self; |
256 } | 255 } |
257 | 256 |
258 + (CocoaCookieDetails*)createFromCookieTreeNode:(CookieTreeNode*)treeNode { | 257 + (CocoaCookieDetails*)createFromCookieTreeNode:(CookieTreeNode*)treeNode { |
259 CookieTreeNode::DetailedInfo info = treeNode->GetDetailedInfo(); | 258 CookieTreeNode::DetailedInfo info = treeNode->GetDetailedInfo(); |
260 CookieTreeNode::DetailedInfo::NodeType nodeType = info.node_type; | 259 CookieTreeNode::DetailedInfo::NodeType nodeType = info.node_type; |
261 NSString* origin; | |
262 switch (nodeType) { | 260 switch (nodeType) { |
263 case CookieTreeNode::DetailedInfo::TYPE_COOKIE: | 261 case CookieTreeNode::DetailedInfo::TYPE_COOKIE: |
264 origin = base::SysUTF16ToNSString(info.origin.c_str()); | |
265 return [[[CocoaCookieDetails alloc] initWithCookie:info.cookie | 262 return [[[CocoaCookieDetails alloc] initWithCookie:info.cookie |
266 origin:origin | |
267 canEditExpiration:NO] autorelease]; | 263 canEditExpiration:NO] autorelease]; |
268 case CookieTreeNode::DetailedInfo::TYPE_DATABASE: | 264 case CookieTreeNode::DetailedInfo::TYPE_DATABASE: |
269 return [[[CocoaCookieDetails alloc] | 265 return [[[CocoaCookieDetails alloc] |
270 initWithDatabase:info.database_info] autorelease]; | 266 initWithDatabase:info.database_info] autorelease]; |
271 case CookieTreeNode::DetailedInfo::TYPE_LOCAL_STORAGE: | 267 case CookieTreeNode::DetailedInfo::TYPE_LOCAL_STORAGE: |
272 return [[[CocoaCookieDetails alloc] | 268 return [[[CocoaCookieDetails alloc] |
273 initWithLocalStorage:info.local_storage_info] autorelease]; | 269 initWithLocalStorage:info.local_storage_info] autorelease]; |
274 case CookieTreeNode::DetailedInfo::TYPE_APPCACHE: | 270 case CookieTreeNode::DetailedInfo::TYPE_APPCACHE: |
275 return [[[CocoaCookieDetails alloc] | 271 return [[[CocoaCookieDetails alloc] |
276 initWithAppCacheInfo:info.appcache_info] autorelease]; | 272 initWithAppCacheInfo:info.appcache_info] autorelease]; |
(...skipping 16 matching lines...) Expand all Loading... |
293 details_.reset([details retain]); | 289 details_.reset([details retain]); |
294 } | 290 } |
295 return self; | 291 return self; |
296 } | 292 } |
297 | 293 |
298 - (CocoaCookieDetails*)details { | 294 - (CocoaCookieDetails*)details { |
299 return details_.get(); | 295 return details_.get(); |
300 } | 296 } |
301 | 297 |
302 @end | 298 @end |
OLD | NEW |