summaryrefslogtreecommitdiffstats
path: root/components/bookmarks
diff options
context:
space:
mode:
authortfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-07-15 18:56:52 +0000
committertfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-07-15 18:56:52 +0000
commit2cd924dfc3a1d20c67018f58d64575706f9b8fe1 (patch)
tree5c998d99dd909bec2dcc8db1e633e203920c73eb /components/bookmarks
parentb1ae21e6d1dbf9ddc3ec489ec387c5b405ca8599 (diff)
downloadchromium_src-2cd924dfc3a1d20c67018f58d64575706f9b8fe1.zip
chromium_src-2cd924dfc3a1d20c67018f58d64575706f9b8fe1.tar.gz
chromium_src-2cd924dfc3a1d20c67018f58d64575706f9b8fe1.tar.bz2
Move bookmark_utils into bookmarks namespace.
BUG=370433 TEST=None R=sky@chromium.org Review URL: https://codereview.chromium.org/386283002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@283224 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'components/bookmarks')
-rw-r--r--components/bookmarks/browser/bookmark_index.cc17
-rw-r--r--components/bookmarks/browser/bookmark_model.cc6
-rw-r--r--components/bookmarks/browser/bookmark_model_unittest.cc20
-rw-r--r--components/bookmarks/browser/bookmark_node_data.cc3
-rw-r--r--components/bookmarks/browser/bookmark_utils.cc9
-rw-r--r--components/bookmarks/browser/bookmark_utils.h12
-rw-r--r--components/bookmarks/browser/bookmark_utils_unittest.cc5
7 files changed, 34 insertions, 38 deletions
diff --git a/components/bookmarks/browser/bookmark_index.cc b/components/bookmarks/browser/bookmark_index.cc
index 282252a..e52b4ec 100644
--- a/components/bookmarks/browser/bookmark_index.cc
+++ b/components/bookmarks/browser/bookmark_index.cc
@@ -19,13 +19,11 @@
#include "components/query_parser/snippet.h"
#include "third_party/icu/source/common/unicode/normalizer2.h"
-using bookmarks::BookmarkClient;
+namespace bookmarks {
typedef BookmarkClient::NodeTypedCountPair NodeTypedCountPair;
typedef BookmarkClient::NodeTypedCountPairs NodeTypedCountPairs;
-namespace bookmarks {
-
namespace {
// Returns a normalized version of the UTF16 string |text|. If it fails to
@@ -118,8 +116,8 @@ void BookmarkIndex::Add(const BookmarkNode* node) {
for (size_t i = 0; i < terms.size(); ++i)
RegisterNode(terms[i], node);
if (index_urls_) {
- terms = ExtractQueryWords(bookmark_utils::CleanUpUrlForMatching(
- node->url(), languages_, NULL));
+ terms =
+ ExtractQueryWords(CleanUpUrlForMatching(node->url(), languages_, NULL));
for (size_t i = 0; i < terms.size(); ++i)
RegisterNode(terms[i], node);
}
@@ -134,8 +132,8 @@ void BookmarkIndex::Remove(const BookmarkNode* node) {
for (size_t i = 0; i < terms.size(); ++i)
UnregisterNode(terms[i], node);
if (index_urls_) {
- terms = ExtractQueryWords(bookmark_utils::CleanUpUrlForMatching(
- node->url(), languages_, NULL));
+ terms =
+ ExtractQueryWords(CleanUpUrlForMatching(node->url(), languages_, NULL));
for (size_t i = 0; i < terms.size(); ++i)
UnregisterNode(terms[i], node);
}
@@ -221,8 +219,9 @@ void BookmarkIndex::AddMatchToResults(
parser->ExtractQueryWords(lower_title, &title_words);
base::OffsetAdjuster::Adjustments adjustments;
if (index_urls_) {
- parser->ExtractQueryWords(bookmark_utils::CleanUpUrlForMatching(
- node->url(), languages_, &adjustments), &url_words);
+ parser->ExtractQueryWords(
+ CleanUpUrlForMatching(node->url(), languages_, &adjustments),
+ &url_words);
}
query_parser::Snippet::MatchPositions title_matches, url_matches;
for (size_t i = 0; i < query_nodes.size(); ++i) {
diff --git a/components/bookmarks/browser/bookmark_model.cc b/components/bookmarks/browser/bookmark_model.cc
index 35145c0..c0a059f 100644
--- a/components/bookmarks/browser/bookmark_model.cc
+++ b/components/bookmarks/browser/bookmark_model.cc
@@ -153,7 +153,7 @@ void BookmarkModel::Load(
const BookmarkNode* BookmarkModel::GetParentForNewNodes() {
std::vector<const BookmarkNode*> nodes =
- bookmark_utils::GetMostRecentlyModifiedUserFolders(this, 1);
+ bookmarks::GetMostRecentlyModifiedUserFolders(this, 1);
DCHECK(!nodes.empty()); // This list is always padded with default folders.
return nodes[0];
}
@@ -293,7 +293,7 @@ void BookmarkModel::Copy(const BookmarkNode* node,
std::vector<BookmarkNodeData::Element> elements(drag_data.elements);
// CloneBookmarkNode will use BookmarkModel methods to do the job, so we
// don't need to send notifications here.
- bookmark_utils::CloneBookmarkNode(this, elements, new_parent, index, true);
+ bookmarks::CloneBookmarkNode(this, elements, new_parent, index, true);
if (store_.get())
store_->ScheduleSave();
@@ -510,7 +510,7 @@ const BookmarkNode* BookmarkModel::GetMostRecentlyAddedUserNodeForURL(
const GURL& url) {
std::vector<const BookmarkNode*> nodes;
GetNodesByURL(url, &nodes);
- std::sort(nodes.begin(), nodes.end(), &bookmark_utils::MoreRecentlyAdded);
+ std::sort(nodes.begin(), nodes.end(), &bookmarks::MoreRecentlyAdded);
// Look for the first node that the user can edit.
for (size_t i = 0; i < nodes.size(); ++i) {
diff --git a/components/bookmarks/browser/bookmark_model_unittest.cc b/components/bookmarks/browser/bookmark_model_unittest.cc
index fbdb34a..fa0787aa 100644
--- a/components/bookmarks/browser/bookmark_model_unittest.cc
+++ b/components/bookmarks/browser/bookmark_model_unittest.cc
@@ -735,7 +735,7 @@ TEST_F(BookmarkModelTest, MostRecentlyModifiedFolders) {
// Make sure folder is in the most recently modified.
std::vector<const BookmarkNode*> most_recent_folders =
- bookmark_utils::GetMostRecentlyModifiedUserFolders(model_.get(), 1);
+ bookmarks::GetMostRecentlyModifiedUserFolders(model_.get(), 1);
ASSERT_EQ(1U, most_recent_folders.size());
ASSERT_EQ(folder, most_recent_folders[0]);
@@ -743,7 +743,7 @@ TEST_F(BookmarkModelTest, MostRecentlyModifiedFolders) {
// returned list.
model_->Remove(folder->parent(), 0);
most_recent_folders =
- bookmark_utils::GetMostRecentlyModifiedUserFolders(model_.get(), 1);
+ bookmarks::GetMostRecentlyModifiedUserFolders(model_.get(), 1);
ASSERT_EQ(1U, most_recent_folders.size());
ASSERT_TRUE(most_recent_folders[0] != folder);
}
@@ -776,7 +776,7 @@ TEST_F(BookmarkModelTest, MostRecentlyAddedEntries) {
// Make sure order is honored.
std::vector<const BookmarkNode*> recently_added;
- bookmark_utils::GetMostRecentlyAddedEntries(model_.get(), 2, &recently_added);
+ bookmarks::GetMostRecentlyAddedEntries(model_.get(), 2, &recently_added);
ASSERT_EQ(2U, recently_added.size());
ASSERT_TRUE(n1 == recently_added[0]);
ASSERT_TRUE(n2 == recently_added[1]);
@@ -784,7 +784,7 @@ TEST_F(BookmarkModelTest, MostRecentlyAddedEntries) {
// swap 1 and 2, then check again.
recently_added.clear();
SwapDateAdded(n1, n2);
- bookmark_utils::GetMostRecentlyAddedEntries(model_.get(), 4, &recently_added);
+ bookmarks::GetMostRecentlyAddedEntries(model_.get(), 4, &recently_added);
ASSERT_EQ(4U, recently_added.size());
ASSERT_TRUE(n2 == recently_added[0]);
ASSERT_TRUE(n1 == recently_added[1]);
@@ -1141,12 +1141,12 @@ TEST_F(BookmarkModelTest, IsBookmarked) {
EXPECT_TRUE(model_->IsBookmarked(GURL("http://youtube.com")));
EXPECT_FALSE(model_->IsBookmarked(GURL("http://reddit.com")));
- EXPECT_TRUE(bookmark_utils::IsBookmarkedByUser(model_.get(),
- GURL("http://google.com")));
- EXPECT_FALSE(bookmark_utils::IsBookmarkedByUser(model_.get(),
- GURL("http://youtube.com")));
- EXPECT_FALSE(bookmark_utils::IsBookmarkedByUser(model_.get(),
- GURL("http://reddit.com")));
+ EXPECT_TRUE(
+ bookmarks::IsBookmarkedByUser(model_.get(), GURL("http://google.com")));
+ EXPECT_FALSE(
+ bookmarks::IsBookmarkedByUser(model_.get(), GURL("http://youtube.com")));
+ EXPECT_FALSE(
+ bookmarks::IsBookmarkedByUser(model_.get(), GURL("http://reddit.com")));
}
// Verifies that GetMostRecentlyAddedUserNodeForURL skips bookmarks that
diff --git a/components/bookmarks/browser/bookmark_node_data.cc b/components/bookmarks/browser/bookmark_node_data.cc
index 0e36d0a..365c1ea 100644
--- a/components/bookmarks/browser/bookmark_node_data.cc
+++ b/components/bookmarks/browser/bookmark_node_data.cc
@@ -251,7 +251,8 @@ std::vector<const BookmarkNode*> BookmarkNodeData::GetNodes(
return nodes;
for (size_t i = 0; i < elements.size(); ++i) {
- const BookmarkNode* node = GetBookmarkNodeByID(model, elements[i].id_);
+ const BookmarkNode* node =
+ bookmarks::GetBookmarkNodeByID(model, elements[i].id_);
if (!node) {
nodes.clear();
return nodes;
diff --git a/components/bookmarks/browser/bookmark_utils.cc b/components/bookmarks/browser/bookmark_utils.cc
index 336a44d..03a56cc 100644
--- a/components/bookmarks/browser/bookmark_utils.cc
+++ b/components/bookmarks/browser/bookmark_utils.cc
@@ -25,7 +25,8 @@
#include "url/gurl.h"
using base::Time;
-using bookmarks::BookmarkClient;
+
+namespace bookmarks {
namespace {
@@ -143,8 +144,6 @@ std::string TruncateUrl(const std::string& url) {
} // namespace
-namespace bookmark_utils {
-
QueryFields::QueryFields() {}
QueryFields::~QueryFields() {}
@@ -439,9 +438,9 @@ bool IsBookmarkedByUser(BookmarkModel* model, const GURL& url) {
return false;
}
-} // namespace bookmark_utils
-
const BookmarkNode* GetBookmarkNodeByID(const BookmarkModel* model, int64 id) {
// TODO(sky): TreeNode needs a method that visits all nodes using a predicate.
return GetNodeByID(model->root_node(), id);
}
+
+} // namespace bookmarks
diff --git a/components/bookmarks/browser/bookmark_utils.h b/components/bookmarks/browser/bookmark_utils.h
index d4c846f..32dfbe8 100644
--- a/components/bookmarks/browser/bookmark_utils.h
+++ b/components/bookmarks/browser/bookmark_utils.h
@@ -16,10 +16,6 @@ class BookmarkModel;
class BookmarkNode;
class GURL;
-namespace bookmarks {
-class BookmarkClient;
-}
-
namespace user_prefs {
class PrefRegistrySyncable;
}
@@ -27,7 +23,9 @@ class PrefRegistrySyncable;
// A collection of bookmark utility functions used by various parts of the UI
// that show bookmarks (bookmark manager, bookmark bar view, ...) and other
// systems that involve indexing and searching bookmarks.
-namespace bookmark_utils {
+namespace bookmarks {
+
+class BookmarkClient;
// Fields to use when finding matching bookmarks.
struct QueryFields {
@@ -149,9 +147,9 @@ bool CanAllBeEditedByUser(bookmarks::BookmarkClient* client,
// by the user.
bool IsBookmarkedByUser(BookmarkModel* model, const GURL& url);
-} // namespace bookmark_utils
-
// Returns the node with |id|, or NULL if there is no node with |id|.
const BookmarkNode* GetBookmarkNodeByID(const BookmarkModel* model, int64 id);
+} // namespace bookmarks
+
#endif // COMPONENTS_BOOKMARKS_BROWSER_BOOKMARK_UTILS_H_
diff --git a/components/bookmarks/browser/bookmark_utils_unittest.cc b/components/bookmarks/browser/bookmark_utils_unittest.cc
index abea315..fd3d472 100644
--- a/components/bookmarks/browser/bookmark_utils_unittest.cc
+++ b/components/bookmarks/browser/bookmark_utils_unittest.cc
@@ -17,10 +17,9 @@
#include "ui/base/clipboard/scoped_clipboard_writer.h"
using base::ASCIIToUTF16;
-using bookmarks::BookmarkClient;
using std::string;
-namespace bookmark_utils {
+namespace bookmarks {
namespace {
class BookmarkUtilsTest : public testing::Test,
@@ -452,4 +451,4 @@ TEST_F(BookmarkUtilsTest, RemoveAllBookmarks) {
}
} // namespace
-} // namespace bookmark_utils
+} // namespace bookmarks