Chromium Code Reviews| 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 #import "chrome/browser/cocoa/cookie_tree_node.h" | 5 #import "chrome/browser/cocoa/cookie_tree_node.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 | 11 |
| 12 @implementation CocoaCookieTreeNode | 12 @implementation CocoaCookieTreeNode |
| 13 | 13 |
| 14 - (id)initWithNode:(CookieTreeNode*)node { | 14 - (id)initWithNode:(CookieTreeNode*)node { |
| 15 if ((self = [super init])) { | 15 if ((self = [super init])) { |
| 16 DCHECK(node); | 16 DCHECK(node); |
| 17 treeNode_ = node; | 17 treeNode_ = node; |
| 18 | 18 isLeaf_ = (node->GetChildCount() == 0); |
|
John Grabowski
2010/02/01 07:52:06
Not sure why there is a need for a local variable
| |
| 19 const int childCount = node->GetChildCount(); | |
| 20 children_.reset([[NSMutableArray alloc] initWithCapacity:childCount]); | |
| 21 for (int i = 0; i < childCount; ++i) { | |
| 22 CookieTreeNode* child = node->GetChild(i); | |
| 23 scoped_nsobject<CocoaCookieTreeNode> childNode( | |
| 24 [[CocoaCookieTreeNode alloc] initWithNode:child]); | |
| 25 [children_ addObject:childNode.get()]; | |
| 26 } | |
| 27 | 19 |
| 28 [self rebuild]; | 20 [self rebuild]; |
| 29 } | 21 } |
| 30 return self; | 22 return self; |
| 31 } | 23 } |
| 32 | 24 |
| 33 - (void)rebuild { | 25 - (void)rebuild { |
| 34 title_.reset([base::SysWideToNSString(treeNode_->GetTitle()) retain]); | 26 title_.reset([base::SysWideToNSString(treeNode_->GetTitle()) retain]); |
| 35 isCookie_ = NO; | 27 isCookie_ = NO; |
| 36 | 28 |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 60 sendFor_.reset([l10n_util::GetNSStringWithFixup( | 52 sendFor_.reset([l10n_util::GetNSStringWithFixup( |
| 61 IDS_COOKIES_COOKIE_SENDFOR_SECURE) retain]); | 53 IDS_COOKIES_COOKIE_SENDFOR_SECURE) retain]); |
| 62 } else { | 54 } else { |
| 63 sendFor_.reset([l10n_util::GetNSStringWithFixup( | 55 sendFor_.reset([l10n_util::GetNSStringWithFixup( |
| 64 IDS_COOKIES_COOKIE_SENDFOR_ANY) retain]); | 56 IDS_COOKIES_COOKIE_SENDFOR_ANY) retain]); |
| 65 } | 57 } |
| 66 } | 58 } |
| 67 } | 59 } |
| 68 | 60 |
| 69 - (BOOL)isLeaf { | 61 - (BOOL)isLeaf { |
| 70 return ([children_ count] == 0); | 62 return isLeaf_; |
| 71 } | 63 } |
| 72 | 64 |
| 73 - (NSString*)title { | 65 - (NSString*)title { |
| 74 return title_.get(); | 66 return title_.get(); |
| 75 } | 67 } |
| 76 | 68 |
| 77 - (NSMutableArray*)children { | 69 - (NSMutableArray*)children { |
| 78 return children_.get(); | 70 if (!children_.get()) { |
| 71 const int childCount = treeNode_->GetChildCount(); | |
| 72 children_.reset([[NSMutableArray alloc] initWithCapacity:childCount]); | |
| 73 for (int i = 0; i < childCount; ++i) { | |
| 74 CookieTreeNode* child = treeNode_->GetChild(i); | |
| 75 scoped_nsobject<CocoaCookieTreeNode> childNode( | |
| 76 [[CocoaCookieTreeNode alloc] initWithNode:child]); | |
| 77 [children_ addObject:childNode.get()]; | |
| 78 } | |
| 79 } | |
| 80 return children_.get(); | |
| 79 } | 81 } |
| 80 | 82 |
| 81 - (TreeModelNode*)treeNode { | 83 - (TreeModelNode*)treeNode { |
| 82 return treeNode_; | 84 return treeNode_; |
| 83 } | 85 } |
| 84 | 86 |
| 85 #pragma mark Cookie Accessors | 87 #pragma mark Cookie Accessors |
| 86 | 88 |
| 87 - (BOOL)isCookie { | 89 - (BOOL)isCookie { |
| 88 return isCookie_; | 90 return isCookie_; |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 110 | 112 |
| 111 - (NSString*)created { | 113 - (NSString*)created { |
| 112 return created_.get(); | 114 return created_.get(); |
| 113 } | 115 } |
| 114 | 116 |
| 115 - (NSString*)expires { | 117 - (NSString*)expires { |
| 116 return expires_.get(); | 118 return expires_.get(); |
| 117 } | 119 } |
| 118 | 120 |
| 119 @end | 121 @end |
| OLD | NEW |