2 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #ifndef __HISTORY_SERVICE_H
18 #define __HISTORY_SERVICE_H
22 #include <boost/date_time/gregorian/gregorian.hpp>
23 #include <boost/signals2/signal.hpp>
25 #include "ServiceFactory.h"
26 #include "service_macros.h"
27 #include "BrowserImage.h"
28 #include "HistoryItem.h"
29 #include "HistoryStorage.h"
30 #include "StorageService.h"
31 #include <web/web_history.h>
32 #define DOMAIN_HISTORY_SERVICE "org.tizen.browser.historyservice"
34 namespace tizen_browser
39 class BROWSER_EXPORT HistoryService: public tizen_browser::core::AbstractService
43 virtual ~HistoryService();
44 virtual std::string getName();
47 * @throws HistoryException on error
49 void addHistoryItem(std::shared_ptr<HistoryItem> hi);
52 * If hi->getUrl() exists on a table HISTORY update visit_counter and visit_date, unless insert hi to database.
54 * @throws HistoryException on error
56 void insertOrRefresh(std::shared_ptr<HistoryItem> hi);
59 * @throws HistoryException on error
61 void clearAllHistory();
64 * @throws HistoryException on error
66 void clearURLHistory(const std::string & url);
69 * @throws HistoryException on error
71 std::shared_ptr<HistoryItem> getHistoryItem(const std::string & url);
74 * @throws HistoryException on error
76 HistoryItemVector & getHistoryItems(int historyDepthInDays = 7, int maxItems = 50);
79 * @throws HistoryException on error
81 int getHistoryItemsCount();
84 * @throws HistoryException on error
86 int getHistoryVisitCounter(const std::string & url);
88 void setStorageServiceTestMode(bool testmode = true);
90 boost::signals2::signal<void (bool)>historyEmpty;
93 std::vector<std::shared_ptr<HistoryItem>> history_list;
94 std::shared_ptr<tizen_browser::services::StorageService> m_storageManager;
97 * @throws StorageExceptionInitialization on error
99 void initDatabaseBookmark(const std::string & db_str);
101 std::shared_ptr<tizen_browser::services::StorageService> getStorageManager();