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
3// found in the LICENSE file.
4
5#include "components/history/core/test/history_client_fake_bookmarks.h"
6
7namespace history {
8
9HistoryClientFakeBookmarks::HistoryClientFakeBookmarks() {
10}
11
12HistoryClientFakeBookmarks::~HistoryClientFakeBookmarks() {
13}
14
15void HistoryClientFakeBookmarks::ClearAllBookmarks() {
16  bookmarks_.clear();
17}
18
19void HistoryClientFakeBookmarks::AddBookmark(const GURL& url) {
20  AddBookmarkWithTitle(url, base::string16());
21}
22
23void HistoryClientFakeBookmarks::AddBookmarkWithTitle(
24    const GURL& url,
25    const base::string16& title) {
26  bookmarks_.insert(std::make_pair(url, title));
27}
28
29void HistoryClientFakeBookmarks::DelBookmark(const GURL& url) {
30  bookmarks_.erase(url);
31}
32
33bool HistoryClientFakeBookmarks::IsBookmarked(const GURL& url) {
34  return bookmarks_.find(url) != bookmarks_.end();
35}
36
37void HistoryClientFakeBookmarks::GetBookmarks(
38    std::vector<URLAndTitle>* bookmarks) {
39  bookmarks->reserve(bookmarks->size() + bookmarks_.size());
40  typedef std::map<GURL, base::string16>::const_iterator iterator;
41  for (iterator i = bookmarks_.begin(); i != bookmarks_.end(); ++i) {
42    URLAndTitle urlAndTitle = {i->first, i->second};
43    bookmarks->push_back(urlAndTitle);
44  }
45}
46
47}  // namespace history
48