• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
7 namespace history {
8 
HistoryClientFakeBookmarks()9 HistoryClientFakeBookmarks::HistoryClientFakeBookmarks() {
10 }
11 
~HistoryClientFakeBookmarks()12 HistoryClientFakeBookmarks::~HistoryClientFakeBookmarks() {
13 }
14 
ClearAllBookmarks()15 void HistoryClientFakeBookmarks::ClearAllBookmarks() {
16   bookmarks_.clear();
17 }
18 
AddBookmark(const GURL & url)19 void HistoryClientFakeBookmarks::AddBookmark(const GURL& url) {
20   AddBookmarkWithTitle(url, base::string16());
21 }
22 
AddBookmarkWithTitle(const GURL & url,const base::string16 & title)23 void HistoryClientFakeBookmarks::AddBookmarkWithTitle(
24     const GURL& url,
25     const base::string16& title) {
26   bookmarks_.insert(std::make_pair(url, title));
27 }
28 
DelBookmark(const GURL & url)29 void HistoryClientFakeBookmarks::DelBookmark(const GURL& url) {
30   bookmarks_.erase(url);
31 }
32 
IsBookmarked(const GURL & url)33 bool HistoryClientFakeBookmarks::IsBookmarked(const GURL& url) {
34   return bookmarks_.find(url) != bookmarks_.end();
35 }
36 
GetBookmarks(std::vector<URLAndTitle> * bookmarks)37 void 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