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

Side by Side Diff: components/bookmarks/browser/bookmark_node_data.h

Issue 870293002: bookmarks: BookmarkNodeData's size() cleanups. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: size() Created 5 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 #ifndef COMPONENTS_BOOKMARKS_BROWSER_BOOKMARK_NODE_DATA_H_ 5 #ifndef COMPONENTS_BOOKMARKS_BROWSER_BOOKMARK_NODE_DATA_H_
6 #define COMPONENTS_BOOKMARKS_BROWSER_BOOKMARK_NODE_DATA_H_ 6 #define COMPONENTS_BOOKMARKS_BROWSER_BOOKMARK_NODE_DATA_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 const base::FilePath& profile_path) const; 142 const base::FilePath& profile_path) const;
143 143
144 // Convenience for getting the first node. Returns NULL if the data doesn't 144 // Convenience for getting the first node. Returns NULL if the data doesn't
145 // match any nodes or there is more than one node. 145 // match any nodes or there is more than one node.
146 const BookmarkNode* GetFirstNode(BookmarkModel* model, 146 const BookmarkNode* GetFirstNode(BookmarkModel* model,
147 const base::FilePath& profile_path) const; 147 const base::FilePath& profile_path) const;
148 148
149 // Do we contain valid data? 149 // Do we contain valid data?
150 bool is_valid() const { return !elements.empty(); } 150 bool is_valid() const { return !elements.empty(); }
151 151
152 // Returns true if there is a single url.
153 bool has_single_url() const { return is_valid() && elements[0].is_url; }
sky 2015/01/28 21:11:58 Is there a reason to move this?
tfarina 2015/01/29 00:10:13 Done.
154
155 // Number of elements. 152 // Number of elements.
156 size_t size() const { return elements.size(); } 153 size_t size() const { return elements.size(); }
157 154
155 // Returns true if there is a single url.
156 bool has_single_url() const {
157 return size() == 1 && elements[0].is_url;
158 }
159
158 // Clears the data. 160 // Clears the data.
159 void Clear(); 161 void Clear();
160 162
161 // Sets |profile_path_|. This is useful for the constructors/readers that 163 // Sets |profile_path_|. This is useful for the constructors/readers that
162 // don't set it. This should only be called if the profile path is not 164 // don't set it. This should only be called if the profile path is not
163 // already set. 165 // already set.
164 void SetOriginatingProfilePath(const base::FilePath& profile_path); 166 void SetOriginatingProfilePath(const base::FilePath& profile_path);
165 167
166 // Returns true if this data is from the specified profile path. 168 // Returns true if this data is from the specified profile path.
167 bool IsFromProfilePath(const base::FilePath& profile_path) const; 169 bool IsFromProfilePath(const base::FilePath& profile_path) const;
168 170
169 // The actual elements written to the clipboard. 171 // The actual elements written to the clipboard.
170 std::vector<Element> elements; 172 std::vector<Element> elements;
171 173
172 private: 174 private:
173 // Path of the profile we originated from. 175 // Path of the profile we originated from.
174 base::FilePath profile_path_; 176 base::FilePath profile_path_;
175 }; 177 };
176 178
177 } // namespace bookmarks 179 } // namespace bookmarks
178 180
179 #endif // COMPONENTS_BOOKMARKS_BROWSER_BOOKMARK_NODE_DATA_H_ 181 #endif // COMPONENTS_BOOKMARKS_BROWSER_BOOKMARK_NODE_DATA_H_
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/bookmarks/bookmark_menu_delegate.cc ('k') | components/bookmarks/browser/bookmark_node_data.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698