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 #ifndef COMPONENTS_HISTORY_CORE_BROWSER_HISTORY_CLIENT_H_ 6 #define COMPONENTS_HISTORY_CORE_BROWSER_HISTORY_CLIENT_H_ 7 8 #include <vector> 9 10 #include "base/macros.h" 11 #include "base/strings/string16.h" 12 #include "components/keyed_service/core/keyed_service.h" 13 #include "sql/init_status.h" 14 #include "url/gurl.h" 15 16 namespace history { 17 18 struct URLAndTitle { 19 GURL url; 20 base::string16 title; 21 }; 22 23 // This class abstracts operations that depend on the embedder's environment, 24 // e.g. Chrome. 25 class HistoryClient : public KeyedService { 26 public: 27 HistoryClient(); 28 29 // Waits until the bookmarks have been loaded. 30 // 31 // Must not be called from the main thread. 32 virtual void BlockUntilBookmarksLoaded(); 33 34 // Returns true if the specified URL is bookmarked. 35 // 36 // If not on the main thread, then BlockUntilBookmarksLoaded must be called. 37 virtual bool IsBookmarked(const GURL& url); 38 39 // Returns, by reference in |bookmarks|, the set of bookmarked urls and their 40 // titles. This returns the unique set of URLs. For example, if two bookmarks 41 // reference the same URL only one entry is added even if the title are not 42 // the same. 43 // 44 // If not on the main thread, then BlockUntilBookmarksLoaded must be called. 45 virtual void GetBookmarks(std::vector<URLAndTitle>* bookmarks); 46 47 // Notifies the embedder that there was a problem reading the database. 48 // 49 // Must be called from the main thread. 50 virtual void NotifyProfileError(sql::InitStatus init_status); 51 52 // Returns whether database errors should be reported to the crash server. 53 virtual bool ShouldReportDatabaseError(); 54 55 protected: 56 DISALLOW_COPY_AND_ASSIGN(HistoryClient); 57 }; 58 59 } // namespace history 60 61 #endif // COMPONENTS_HISTORY_CORE_BROWSER_HISTORY_CLIENT_H_ 62