Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1119)

Unified Diff: chrome/browser/cocoa/cookie_tree_node.mm

Issue 523025: [Mac] Implement the cookie manager (Closed)
Patch Set: Address all comments Created 10 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/cocoa/cookie_tree_node.h ('k') | chrome/browser/cocoa/cookies_window_controller.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/cocoa/cookie_tree_node.mm
diff --git a/chrome/browser/cocoa/cookie_tree_node.mm b/chrome/browser/cocoa/cookie_tree_node.mm
new file mode 100644
index 0000000000000000000000000000000000000000..1b1aafea1cda2571ec8326b6cb0341a1c8868dfa
--- /dev/null
+++ b/chrome/browser/cocoa/cookie_tree_node.mm
@@ -0,0 +1,119 @@
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#import "chrome/browser/cocoa/cookie_tree_node.h"
+
+#include "app/l10n_util_mac.h"
+#import "base/i18n/time_formatting.h"
+#include "base/sys_string_conversions.h"
+#include "grit/generated_resources.h"
+
+@implementation CocoaCookieTreeNode
+
+- (id)initWithNode:(CookieTreeNode*)node {
+ if ((self = [super init])) {
+ DCHECK(node);
+ treeNode_ = node;
+
+ const int childCount = node->GetChildCount();
+ children_.reset([[NSMutableArray alloc] initWithCapacity:childCount]);
+ for (int i = 0; i < childCount; ++i) {
+ CookieTreeNode* child = node->GetChild(i);
+ scoped_nsobject<CocoaCookieTreeNode> childNode(
+ [[CocoaCookieTreeNode alloc] initWithNode:child]);
+ [children_ addObject:childNode.get()];
+ }
+
+ [self rebuild];
+ }
+ return self;
+}
+
+- (void)rebuild {
+ title_.reset([base::SysWideToNSString(treeNode_->GetTitle()) retain]);
+ isCookie_ = NO;
+
+ CookieTreeNode::DetailedInfo info = treeNode_->GetDetailedInfo();
+ if (info.node_type == CookieTreeNode::DetailedInfo::TYPE_COOKIE) {
+ isCookie_ = YES;
+ net::CookieMonster::CanonicalCookie cookie = info.cookie->second;
+
+ name_.reset([base::SysUTF8ToNSString(cookie.Name()) retain]);
+ title_.reset([base::SysUTF8ToNSString(cookie.Name()) retain]);
+ content_.reset([base::SysUTF8ToNSString(cookie.Value()) retain]);
+ path_.reset([base::SysUTF8ToNSString(cookie.Path()) retain]);
+ domain_.reset([base::SysWideToNSString(info.origin) retain]);
+
+ if (cookie.DoesExpire()) {
+ expires_.reset([base::SysWideToNSString(
+ base::TimeFormatFriendlyDateAndTime(cookie.ExpiryDate())) retain]);
+ } else {
+ expires_.reset([l10n_util::GetNSStringWithFixup(
+ IDS_COOKIES_COOKIE_EXPIRES_SESSION) retain]);
+ }
+
+ created_.reset([base::SysWideToNSString(
+ base::TimeFormatFriendlyDateAndTime(cookie.CreationDate())) retain]);
+
+ if (cookie.IsSecure()) {
+ sendFor_.reset([l10n_util::GetNSStringWithFixup(
+ IDS_COOKIES_COOKIE_SENDFOR_SECURE) retain]);
+ } else {
+ sendFor_.reset([l10n_util::GetNSStringWithFixup(
+ IDS_COOKIES_COOKIE_SENDFOR_ANY) retain]);
+ }
+ }
+}
+
+- (BOOL)isLeaf {
+ return (treeNode_->GetChildCount() == 0);
+}
+
+- (NSString*)title {
+ return title_.get();
+}
+
+- (NSMutableArray*)children {
+ return children_.get();
+}
+
+- (TreeModelNode*)treeNode {
+ return treeNode_;
+}
+
+#pragma mark Cookie Accessors
+
+- (BOOL)isCookie {
+ return isCookie_;
+}
+
+- (NSString*)name {
+ return name_.get();
+}
+
+- (NSString*)content {
+ return content_.get();
+}
+
+- (NSString*)domain {
+ return domain_.get();
+}
+
+- (NSString*)path {
+ return path_.get();
+}
+
+- (NSString*)sendFor {
+ return sendFor_.get();
+}
+
+- (NSString*)created {
+ return created_.get();
+}
+
+- (NSString*)expires {
+ return expires_.get();
+}
+
+@end
« no previous file with comments | « chrome/browser/cocoa/cookie_tree_node.h ('k') | chrome/browser/cocoa/cookies_window_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698