| OLD | NEW |
| 1 // Copyright (c) 2009 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 <Cocoa/Cocoa.h> | 5 #import <Cocoa/Cocoa.h> |
| 6 | 6 |
| 7 #include "base/scoped_nsobject.h" | 7 #include "base/scoped_nsobject.h" |
| 8 #include "chrome/browser/cookies_tree_model.h" | 8 #include "chrome/browser/cookies_tree_model.h" |
| 9 | 9 |
| 10 // This enum specifies the type of display node a CocoaCookieTreeNode is. If |
| 11 // this system is rewritten to not use bindings, this class should be |
| 12 // subclassed and specialized, rather than using an enum to determine type. |
| 13 enum CocoaCookieTreeNodeType { |
| 14 // Represents grouping data for the actual data. |
| 15 kCocoaCookieTreeNodeTypeFolder = 0, |
| 16 |
| 17 // A cookie node. |
| 18 kCocoaCookieTreeNodeTypeCookie = 1, |
| 19 |
| 20 // A local storage node. |
| 21 kCocoaCookieTreeNodeTypeLocalStorage = 2 |
| 22 }; |
| 23 |
| 10 // This class is used by CookiesWindowController and represents a node in the | 24 // This class is used by CookiesWindowController and represents a node in the |
| 11 // cookie tree view. | 25 // cookie tree view. |
| 12 @interface CocoaCookieTreeNode : NSObject { | 26 @interface CocoaCookieTreeNode : NSObject { |
| 13 scoped_nsobject<NSString> title_; | 27 scoped_nsobject<NSString> title_; |
| 14 scoped_nsobject<NSMutableArray> children_; | 28 scoped_nsobject<NSMutableArray> children_; |
| 15 // We lazily create children, so we need to know if we are a leaf. | 29 |
| 16 BOOL isLeaf_; | 30 CocoaCookieTreeNodeType nodeType_; |
| 17 | 31 |
| 18 // The platform-independent model node. | 32 // The platform-independent model node. |
| 19 CookieTreeNode* treeNode_; // weak | 33 CookieTreeNode* treeNode_; // weak |
| 20 | 34 |
| 21 // These members are only set for true cookie nodes. | 35 // These members are only set for kCocoaCookieTreeNodeTypeCookie nodes. |
| 22 BOOL isCookie_; | |
| 23 scoped_nsobject<NSString> name_; | 36 scoped_nsobject<NSString> name_; |
| 24 scoped_nsobject<NSString> content_; | 37 scoped_nsobject<NSString> content_; |
| 25 scoped_nsobject<NSString> domain_; | |
| 26 scoped_nsobject<NSString> path_; | 38 scoped_nsobject<NSString> path_; |
| 27 scoped_nsobject<NSString> sendFor_; | 39 scoped_nsobject<NSString> sendFor_; |
| 28 // Stringifed dates. | 40 // Stringifed dates. |
| 29 scoped_nsobject<NSString> created_; | 41 scoped_nsobject<NSString> created_; |
| 30 scoped_nsobject<NSString> expires_; | 42 scoped_nsobject<NSString> expires_; |
| 43 |
| 44 // These members are only set for kCocoaCookieTreeNodeTypeLocalStorage nodes. |
| 45 scoped_nsobject<NSString> fileSize_; |
| 46 scoped_nsobject<NSString> lastModified_; |
| 47 |
| 48 // These members are set for both of the two specialized node types. |
| 49 scoped_nsobject<NSString> domain_; |
| 31 } | 50 } |
| 32 | 51 |
| 33 // Designated initializer. | 52 // Designated initializer. |
| 34 - (id)initWithNode:(CookieTreeNode*)node; | 53 - (id)initWithNode:(CookieTreeNode*)node; |
| 35 | 54 |
| 36 // Re-sets all the members of the node based on |treeNode_|. | 55 // Re-sets all the members of the node based on |treeNode_|. |
| 37 - (void)rebuild; | 56 - (void)rebuild; |
| 38 | 57 |
| 39 - (BOOL)isLeaf; | 58 // Common getters.. |
| 40 | |
| 41 // Getters. | |
| 42 - (NSString*)title; | 59 - (NSString*)title; |
| 60 - (CocoaCookieTreeNodeType)nodeType; |
| 61 - (TreeModelNode*)treeNode; |
| 43 | 62 |
| 44 // |-mutableChildren| exists so that the CookiesTreeModelObserverBridge can | 63 // |-mutableChildren| exists so that the CookiesTreeModelObserverBridge can |
| 45 // operate on the children. Note that this lazily creates children. | 64 // operate on the children. Note that this lazily creates children. |
| 46 - (NSMutableArray*)mutableChildren; | 65 - (NSMutableArray*)mutableChildren; |
| 47 - (NSArray*)children; | 66 - (NSArray*)children; |
| 67 - (BOOL)isLeaf; |
| 48 | 68 |
| 49 - (TreeModelNode*)treeNode; | 69 // Used only by kCocoaCookieTreeNodeTypeCookie. Nil for other types. |
| 50 | |
| 51 // Used only by cookies. Nil for non-cookie nodes. | |
| 52 - (BOOL)isCookie; | |
| 53 - (NSString*)name; | 70 - (NSString*)name; |
| 54 - (NSString*)content; | 71 - (NSString*)content; |
| 55 - (NSString*)domain; | 72 - (NSString*)domain; |
| 56 - (NSString*)path; | 73 - (NSString*)path; |
| 57 - (NSString*)sendFor; | 74 - (NSString*)sendFor; |
| 58 - (NSString*)created; | 75 - (NSString*)created; |
| 59 - (NSString*)expires; | 76 - (NSString*)expires; |
| 60 | 77 |
| 78 // Used by kCocoaCookieTreeNodeTypeLocalStorage nodes. Nil for other types. |
| 79 - (NSString*)fileSize; |
| 80 - (NSString*)lastModified; |
| 81 |
| 61 @end | 82 @end |
| OLD | NEW |