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

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

Issue 2666833003: Revert of Removing "All Bookmarks" (Closed)
Patch Set: 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
46 + (BookmarkPositionCache*)cacheForMenuItemFolderWithPosition:(CGFloat)position 53 + (BookmarkPositionCache*)cacheForMenuItemFolderWithPosition:(CGFloat)position
47 folderId:(int64_t)folderId { 54 folderId:(int64_t)folderId {
48 return [[[BookmarkPositionCache alloc] 55 return [[[BookmarkPositionCache alloc]
49 initWithFolderId:folderId 56 initWithFolderId:folderId
50 position:position 57 position:position
51 type:bookmarks::MenuItemFolder] autorelease]; 58 type:bookmarks::MenuItemFolder] autorelease];
52 } 59 }
53 60
54 #pragma mark - Designated Initializer 61 #pragma mark - Designated Initializer
55 62
(...skipping 21 matching lines...) Expand all
77 return YES; 84 return YES;
78 if (![object isKindOfClass:[BookmarkPositionCache class]]) 85 if (![object isKindOfClass:[BookmarkPositionCache class]])
79 return NO; 86 return NO;
80 BookmarkPositionCache* other = static_cast<BookmarkPositionCache*>(object); 87 BookmarkPositionCache* other = static_cast<BookmarkPositionCache*>(object);
81 if (self.type != other.type) 88 if (self.type != other.type)
82 return NO; 89 return NO;
83 if (fabs(self.position - other.position) > 0.01) 90 if (fabs(self.position - other.position) > 0.01)
84 return NO; 91 return NO;
85 switch (self.type) { 92 switch (self.type) {
86 case bookmarks::MenuItemDivider: 93 case bookmarks::MenuItemDivider:
94 case bookmarks::MenuItemAll:
87 case bookmarks::MenuItemSectionHeader: 95 case bookmarks::MenuItemSectionHeader:
88 return YES; 96 return YES;
89 case bookmarks::MenuItemFolder: 97 case bookmarks::MenuItemFolder:
90 return self.folderId == other.folderId; 98 return self.folderId == other.folderId;
91 } 99 }
92 } 100 }
93 101
94 - (NSUInteger)hash { 102 - (NSUInteger)hash {
95 return static_cast<NSUInteger>(self.type) ^ 103 return static_cast<NSUInteger>(self.type) ^
96 static_cast<NSUInteger>(self.folderId); 104 static_cast<NSUInteger>(self.folderId);
(...skipping 27 matching lines...) Expand all
124 } 132 }
125 133
126 - (void)encodeWithCoder:(NSCoder*)coder { 134 - (void)encodeWithCoder:(NSCoder*)coder {
127 [coder encodeInt:kVersion forKey:kVersionKey]; 135 [coder encodeInt:kVersion forKey:kVersionKey];
128 [coder encodeInt:static_cast<int>(self.type) forKey:kTypeKey]; 136 [coder encodeInt:static_cast<int>(self.type) forKey:kTypeKey];
129 [coder encodeFloat:self.position forKey:kPositionKey]; 137 [coder encodeFloat:self.position forKey:kPositionKey];
130 [coder encodeInt64:self.folderId forKey:kFolderKey]; 138 [coder encodeInt64:self.folderId forKey:kFolderKey];
131 } 139 }
132 140
133 @end 141 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698