| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 CHROME_BROWSER_BOOKMARKS_BOOKMARK_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_BOOKMARKS_BOOKMARK_SERVICE_H_ |
| 6 #define CHROME_BROWSER_BOOKMARKS_BOOKMARK_SERVICE_H_ | 6 #define CHROME_BROWSER_BOOKMARKS_BOOKMARK_SERVICE_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/strings/string16.h" | 10 #include "base/strings/string16.h" |
| 11 #include "url/gurl.h" | 11 #include "url/gurl.h" |
| 12 | 12 |
| 13 namespace content { | 13 namespace content { |
| 14 class BrowserContext; | 14 class BrowserContext; |
| 15 } | 15 } |
| 16 | 16 |
| 17 // BookmarkService provides a thread safe view of bookmarks. It is used by | 17 // BookmarkService provides a thread safe view of bookmarks. It is used by |
| 18 // HistoryBackend when it needs to determine the set of bookmarked URLs | 18 // HistoryBackend when it needs to determine the set of bookmarked URLs |
| 19 // or if a URL is bookmarked. | 19 // or if a URL is bookmarked. |
| 20 // | 20 // |
| 21 // BookmarkService is owned by Profile and deleted when the Profile is deleted. | 21 // BookmarkService is owned by Profile and deleted when the Profile is deleted. |
| 22 class BookmarkService { | 22 class BookmarkService { |
| 23 public: | 23 public: |
| 24 struct URLAndTitle { | 24 struct URLAndTitle { |
| 25 GURL url; | 25 GURL url; |
| 26 string16 title; | 26 base::string16 title; |
| 27 }; | 27 }; |
| 28 | 28 |
| 29 static BookmarkService* FromBrowserContext( | 29 static BookmarkService* FromBrowserContext( |
| 30 content::BrowserContext* browser_context); | 30 content::BrowserContext* browser_context); |
| 31 | 31 |
| 32 // Returns true if the specified URL is bookmarked. | 32 // Returns true if the specified URL is bookmarked. |
| 33 // | 33 // |
| 34 // If not on the main thread you *must* invoke BlockTillLoaded first. | 34 // If not on the main thread you *must* invoke BlockTillLoaded first. |
| 35 virtual bool IsBookmarked(const GURL& url) = 0; | 35 virtual bool IsBookmarked(const GURL& url) = 0; |
| 36 | 36 |
| 37 // Returns, by reference in |bookmarks|, the set of bookmarked urls and their | 37 // Returns, by reference in |bookmarks|, the set of bookmarked urls and their |
| 38 // titles. This returns the unique set of URLs. For example, if two bookmarks | 38 // titles. This returns the unique set of URLs. For example, if two bookmarks |
| 39 // reference the same URL only one entry is added not matter the titles are | 39 // reference the same URL only one entry is added not matter the titles are |
| 40 // same or not. | 40 // same or not. |
| 41 // | 41 // |
| 42 // If not on the main thread you *must* invoke BlockTillLoaded first. | 42 // If not on the main thread you *must* invoke BlockTillLoaded first. |
| 43 virtual void GetBookmarks(std::vector<URLAndTitle>* bookmarks) = 0; | 43 virtual void GetBookmarks(std::vector<URLAndTitle>* bookmarks) = 0; |
| 44 | 44 |
| 45 // Blocks until loaded. This is intended for usage on a thread other than | 45 // Blocks until loaded. This is intended for usage on a thread other than |
| 46 // the main thread. | 46 // the main thread. |
| 47 virtual void BlockTillLoaded() = 0; | 47 virtual void BlockTillLoaded() = 0; |
| 48 | 48 |
| 49 protected: | 49 protected: |
| 50 virtual ~BookmarkService() {} | 50 virtual ~BookmarkService() {} |
| 51 }; | 51 }; |
| 52 | 52 |
| 53 #endif // CHROME_BROWSER_BOOKMARKS_BOOKMARK_SERVICE_H_ | 53 #endif // CHROME_BROWSER_BOOKMARKS_BOOKMARK_SERVICE_H_ |
| OLD | NEW |