summaryrefslogtreecommitdiffstats
path: root/components/bookmarks
diff options
context:
space:
mode:
authorsdefresne <sdefresne@chromium.org>2015-07-29 10:14:00 -0700
committerCommit bot <commit-bot@chromium.org>2015-07-29 17:14:35 +0000
commita445ff6f64cce280bc4c4c36041b22fa0e42e64a (patch)
tree2b25c20b991b836ad51a335d940307e896132c3c /components/bookmarks
parent7144e049e91fd5790996445374dd5234eae71d1e (diff)
downloadchromium_src-a445ff6f64cce280bc4c4c36041b22fa0e42e64a.zip
chromium_src-a445ff6f64cce280bc4c4c36041b22fa0e42e64a.tar.gz
chromium_src-a445ff6f64cce280bc4c4c36041b22fa0e42e64a.tar.bz2
Add utilities to remove duplication in BookmarkClient implementations.
Add utility free functions to //components/bookmarks/managed and //components/favicon/core to share common code between both BookmarkClient implementations (desktop and iOS). BUG=514208 Review URL: https://codereview.chromium.org/1262123002 Cr-Commit-Position: refs/heads/master@{#340912}
Diffstat (limited to 'components/bookmarks')
-rw-r--r--components/bookmarks/managed/BUILD.gn2
-rw-r--r--components/bookmarks/managed/managed_bookmark_util.cc33
-rw-r--r--components/bookmarks/managed/managed_bookmark_util.h23
3 files changed, 58 insertions, 0 deletions
diff --git a/components/bookmarks/managed/BUILD.gn b/components/bookmarks/managed/BUILD.gn
index 441ee67..ed8d2a6 100644
--- a/components/bookmarks/managed/BUILD.gn
+++ b/components/bookmarks/managed/BUILD.gn
@@ -6,6 +6,8 @@ source_set("managed") {
sources = [
"managed_bookmark_service.cc",
"managed_bookmark_service.h",
+ "managed_bookmark_util.cc",
+ "managed_bookmark_util.h",
"managed_bookmarks_tracker.cc",
"managed_bookmarks_tracker.h",
]
diff --git a/components/bookmarks/managed/managed_bookmark_util.cc b/components/bookmarks/managed/managed_bookmark_util.cc
new file mode 100644
index 0000000..d19d941
--- /dev/null
+++ b/components/bookmarks/managed/managed_bookmark_util.cc
@@ -0,0 +1,33 @@
+// Copyright 2015 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.
+
+#include "components/bookmarks/managed/managed_bookmark_util.h"
+
+#include "components/bookmarks/browser/bookmark_node.h"
+#include "components/bookmarks/managed/managed_bookmark_service.h"
+
+namespace bookmarks {
+
+bool IsPermanentNode(const BookmarkPermanentNode* node,
+ ManagedBookmarkService* managed_bookmark_service) {
+ BookmarkNode::Type type = node->type();
+ if (type == BookmarkNode::BOOKMARK_BAR ||
+ type == BookmarkNode::OTHER_NODE ||
+ type == BookmarkNode::MOBILE) {
+ return true;
+ }
+
+ return IsManagedNode(node, managed_bookmark_service);
+}
+
+bool IsManagedNode(const BookmarkPermanentNode* node,
+ ManagedBookmarkService* managed_bookmark_service) {
+ if (!managed_bookmark_service)
+ return false;
+
+ return node == managed_bookmark_service->managed_node() ||
+ node == managed_bookmark_service->supervised_node();
+}
+
+} // namespace bookmarks
diff --git a/components/bookmarks/managed/managed_bookmark_util.h b/components/bookmarks/managed/managed_bookmark_util.h
new file mode 100644
index 0000000..9b3ec181
--- /dev/null
+++ b/components/bookmarks/managed/managed_bookmark_util.h
@@ -0,0 +1,23 @@
+// Copyright 2015 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.
+
+#ifndef COMPONENTS_BOOKMARKS_MANAGED_MANAGED_BOOKMARK_UTIL_H_
+#define COMPONENTS_BOOKMARKS_MANAGED_MANAGED_BOOKMARK_UTIL_H_
+
+namespace bookmarks {
+
+class BookmarkPermanentNode;
+class ManagedBookmarkService;
+
+// Returns whether |node| is a permanent node.
+bool IsPermanentNode(const BookmarkPermanentNode* node,
+ ManagedBookmarkService* managed_bookmark_service);
+
+// Returns whether |node| is a managed node.
+bool IsManagedNode(const BookmarkPermanentNode* node,
+ ManagedBookmarkService* managed_bookmark_service);
+
+} // namespace bookmarks
+
+#endif // COMPONENTS_BOOKMARKS_MANAGED_MANAGED_BOOKMARK_UTIL_H_