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

Side by Side Diff: ios/chrome/browser/ui/bookmarks/bookmark_position_cache.mm

Issue 2662473003: Removing "All Bookmarks" (Closed)
Patch Set: feedback Created 3 years, 10 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "ios/chrome/browser/ui/bookmarks/bookmark_position_cache.h" 5 #import "ios/chrome/browser/ui/bookmarks/bookmark_position_cache.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/mac/objc_property_releaser.h" 10 #include "base/mac/objc_property_releaser.h"
(...skipping 25 matching lines...) Expand all
36 36
37 @end 37 @end
38 38
39 @implementation BookmarkPositionCache 39 @implementation BookmarkPositionCache
40 @synthesize folderId = _folderId; 40 @synthesize folderId = _folderId;
41 @synthesize position = _position; 41 @synthesize position = _position;
42 @synthesize type = _type; 42 @synthesize type = _type;
43 43
44 #pragma mark - Public Constructors 44 #pragma mark - Public Constructors
45 45
46 + (BookmarkPositionCache*)cacheForMenuItemAllWithPosition:(CGFloat)position {
47 return [[[BookmarkPositionCache alloc]
48 initWithFolderId:0
49 position:position
50 type:bookmarks::MenuItemAll] autorelease];
51 }
52
53 + (BookmarkPositionCache*)cacheForMenuItemFolderWithPosition:(CGFloat)position 46 + (BookmarkPositionCache*)cacheForMenuItemFolderWithPosition:(CGFloat)position
54 folderId:(int64_t)folderId { 47 folderId:(int64_t)folderId {
55 return [[[BookmarkPositionCache alloc] 48 return [[[BookmarkPositionCache alloc]
56 initWithFolderId:folderId 49 initWithFolderId:folderId
57 position:position 50 position:position
58 type:bookmarks::MenuItemFolder] autorelease]; 51 type:bookmarks::MenuItemFolder] autorelease];
59 } 52 }
60 53
61 #pragma mark - Designated Initializer 54 #pragma mark - Designated Initializer
62 55
(...skipping 21 matching lines...) Expand all
84 return YES; 77 return YES;
85 if (![object isKindOfClass:[BookmarkPositionCache class]]) 78 if (![object isKindOfClass:[BookmarkPositionCache class]])
86 return NO; 79 return NO;
87 BookmarkPositionCache* other = static_cast<BookmarkPositionCache*>(object); 80 BookmarkPositionCache* other = static_cast<BookmarkPositionCache*>(object);
88 if (self.type != other.type) 81 if (self.type != other.type)
89 return NO; 82 return NO;
90 if (fabs(self.position - other.position) > 0.01) 83 if (fabs(self.position - other.position) > 0.01)
91 return NO; 84 return NO;
92 switch (self.type) { 85 switch (self.type) {
93 case bookmarks::MenuItemDivider: 86 case bookmarks::MenuItemDivider:
94 case bookmarks::MenuItemAll:
95 case bookmarks::MenuItemSectionHeader: 87 case bookmarks::MenuItemSectionHeader:
96 return YES; 88 return YES;
97 case bookmarks::MenuItemFolder: 89 case bookmarks::MenuItemFolder:
98 return self.folderId == other.folderId; 90 return self.folderId == other.folderId;
99 } 91 }
100 } 92 }
101 93
102 - (NSUInteger)hash { 94 - (NSUInteger)hash {
103 return static_cast<NSUInteger>(self.type) ^ 95 return static_cast<NSUInteger>(self.type) ^
104 static_cast<NSUInteger>(self.folderId); 96 static_cast<NSUInteger>(self.folderId);
(...skipping 27 matching lines...) Expand all
132 } 124 }
133 125
134 - (void)encodeWithCoder:(NSCoder*)coder { 126 - (void)encodeWithCoder:(NSCoder*)coder {
135 [coder encodeInt:kVersion forKey:kVersionKey]; 127 [coder encodeInt:kVersion forKey:kVersionKey];
136 [coder encodeInt:static_cast<int>(self.type) forKey:kTypeKey]; 128 [coder encodeInt:static_cast<int>(self.type) forKey:kTypeKey];
137 [coder encodeFloat:self.position forKey:kPositionKey]; 129 [coder encodeFloat:self.position forKey:kPositionKey];
138 [coder encodeInt64:self.folderId forKey:kFolderKey]; 130 [coder encodeInt64:self.folderId forKey:kFolderKey];
139 } 131 }
140 132
141 @end 133 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698