| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 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 | 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/cocoa/cookie_details.h" | 5 #include "chrome/browser/cocoa/cookie_details.h" |
| 6 | 6 |
| 7 #include "app/l10n_util_mac.h" | 7 #include "app/l10n_util_mac.h" |
| 8 #import "base/i18n/time_formatting.h" | 8 #import "base/i18n/time_formatting.h" |
| 9 #include "base/sys_string_conversions.h" | 9 #include "base/sys_string_conversions.h" |
| 10 #include "grit/generated_resources.h" | 10 #include "grit/generated_resources.h" |
| 11 #include "chrome/browser/cookie_modal_dialog.h" | |
| 12 #include "chrome/browser/cookies_tree_model.h" | 11 #include "chrome/browser/cookies_tree_model.h" |
| 13 #include "webkit/appcache/appcache_service.h" | 12 #include "webkit/appcache/appcache_service.h" |
| 14 | 13 |
| 15 #pragma mark Cocoa Cookie Details | 14 #pragma mark Cocoa Cookie Details |
| 16 | 15 |
| 17 @implementation CocoaCookieDetails | 16 @implementation CocoaCookieDetails |
| 18 | 17 |
| 19 @synthesize canEditExpiration = canEditExpiration_; | 18 @synthesize canEditExpiration = canEditExpiration_; |
| 20 @synthesize hasExpiration = hasExpiration_; | 19 @synthesize hasExpiration = hasExpiration_; |
| 21 @synthesize type = type_; | 20 @synthesize type = type_; |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 return [[[CocoaCookieDetails alloc] | 248 return [[[CocoaCookieDetails alloc] |
| 250 initWithLocalStorage:info.local_storage_info] autorelease]; | 249 initWithLocalStorage:info.local_storage_info] autorelease]; |
| 251 } else if (nodeType == CookieTreeNode::DetailedInfo::TYPE_APPCACHE) { | 250 } else if (nodeType == CookieTreeNode::DetailedInfo::TYPE_APPCACHE) { |
| 252 return [[[CocoaCookieDetails alloc] | 251 return [[[CocoaCookieDetails alloc] |
| 253 initWithAppCacheInfo:info.appcache_info] autorelease]; | 252 initWithAppCacheInfo:info.appcache_info] autorelease]; |
| 254 } else { | 253 } else { |
| 255 return [[[CocoaCookieDetails alloc] initAsFolder] autorelease]; | 254 return [[[CocoaCookieDetails alloc] initAsFolder] autorelease]; |
| 256 } | 255 } |
| 257 } | 256 } |
| 258 | 257 |
| 259 + (CocoaCookieDetails*)createFromPromptModalDialog:(CookiePromptModalDialog*) | |
| 260 dialog { | |
| 261 CookiePromptModalDialog::DialogType type(dialog->dialog_type()); | |
| 262 CocoaCookieDetails* details = nil; | |
| 263 if (type == CookiePromptModalDialog::DIALOG_TYPE_COOKIE) { | |
| 264 net::CookieMonster::ParsedCookie pc(dialog->cookie_line()); | |
| 265 net::CookieMonster::CanonicalCookie cookie(dialog->origin(), pc); | |
| 266 const std::string& domain(pc.HasDomain() ? pc.Domain() : | |
| 267 dialog->origin().host()); | |
| 268 NSString* domainString = base::SysUTF8ToNSString(domain); | |
| 269 details = [[CocoaCookieDetails alloc] initWithCookie:&cookie | |
| 270 origin:domainString | |
| 271 canEditExpiration:YES]; | |
| 272 } else if (type == CookiePromptModalDialog::DIALOG_TYPE_LOCAL_STORAGE) { | |
| 273 details = [[CocoaCookieDetails alloc] | |
| 274 initWithLocalStorage:dialog->origin().host() | |
| 275 key:dialog->local_storage_key() | |
| 276 value:dialog->local_storage_value()]; | |
| 277 } else if (type == CookiePromptModalDialog::DIALOG_TYPE_DATABASE) { | |
| 278 details = [[CocoaCookieDetails alloc] | |
| 279 initWithDatabase:dialog->origin().host() | |
| 280 databaseName:dialog->database_name() | |
| 281 databaseDescription:dialog->display_name() | |
| 282 fileSize:dialog->estimated_size()]; | |
| 283 } else if (type == CookiePromptModalDialog::DIALOG_TYPE_APPCACHE) { | |
| 284 details = [[CocoaCookieDetails alloc] | |
| 285 initWithAppCacheManifestURL:dialog->appcache_manifest_url().spec()]; | |
| 286 } else { | |
| 287 NOTIMPLEMENTED(); | |
| 288 } | |
| 289 return [details autorelease]; | |
| 290 } | |
| 291 | |
| 292 @end | 258 @end |
| 293 | 259 |
| 294 #pragma mark Content Object Adapter | 260 #pragma mark Content Object Adapter |
| 295 | 261 |
| 296 @implementation CookiePromptContentDetailsAdapter | 262 @implementation CookiePromptContentDetailsAdapter |
| 297 | 263 |
| 298 - (id)initWithDetails:(CocoaCookieDetails*)details { | 264 - (id)initWithDetails:(CocoaCookieDetails*)details { |
| 299 if ((self = [super init])) { | 265 if ((self = [super init])) { |
| 300 details_.reset([details retain]); | 266 details_.reset([details retain]); |
| 301 } | 267 } |
| 302 return self; | 268 return self; |
| 303 } | 269 } |
| 304 | 270 |
| 305 - (CocoaCookieDetails*)details { | 271 - (CocoaCookieDetails*)details { |
| 306 return details_.get(); | 272 return details_.get(); |
| 307 } | 273 } |
| 308 | 274 |
| 309 @end | 275 @end |
| OLD | NEW |