Using UrlHistoryList do display history list (on urientry edition).
[profile/tv/apps/web/browser.git] / services / QuickAccess / UrlHistoryList / UrlMatchesStyler.h
1 /*
2  * Copyright (c) 2015 Samsung Electronics Co., Ltd.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17 #ifndef URLMATCHESSTYLER_H_
18 #define URLMATCHESSTYLER_H_
19
20 #include <string>
21 #include <vector>
22 #include <boost/algorithm/string.hpp>
23 #include <boost/regex.hpp>
24 #include "BrowserLogger.h"
25
26 using namespace std;
27
28 namespace tizen_browser {
29 namespace base_ui {
30
31 class UrlMatchesStyler {
32 public:
33         UrlMatchesStyler();
34         virtual ~UrlMatchesStyler();
35
36         /**
37          * @brief  Get string containing EFL tags, which are highlighting given keywords.
38          * @param styledUrl url which will be styled
39          * @param highlightingKeyword keywords (entered url) indicating which
40          * fragments should be highlighted
41          * @return styledUrl enriched with EFL tags
42          */
43         string getUrlHighlightedMatches(const string& styledUrl,
44                         const string& highlightingKeywords) const;
45
46 private:
47         typedef vector<pair<int, int>> int_pairs;
48         const string FONT_COLOR_HIGHLIGHT = "#4088D3";
49         const string FONT_COLOR_NORMAL = "#888888";
50         const string FONT_SIZE = "35";
51         const string TAG_WHOLE_URL;
52         const string TAG_WHOLE_URL_CLOSE;
53         const string TAG_HIGHLIGHT, TAG_HIGHLIGHT_CLOSE;
54         const string TAG_COLOR, TAG_COLOR_CLOSE;
55         const string TAG_COMPLETE, TAG_COMPLETE_CLOSE;
56         const int TAGS_COMPLETE_LEN;
57
58         /**
59          * @brief adds '/' to a tag (<a> -> </a>)
60          * @param tag tag to be closed
61          * @return closed tag
62          */
63         string closeTag(const string& tag) const;
64     /**
65      * @brief splits given string by removing spaces
66      * @param keywordsString string to split
67      * @param resultKeywords vector to which result strings are stored
68      */
69         void splitKeywordsString(const string& keywordsString,
70                         vector<string>& resultKeywords) const;
71         /**
72          * @brief Fills vector with ranges describing beginnings end ends of occurrences of one string in another.
73          * @param checkedString the subject of search
74          * @param searchedMatch match to be searched for
75          * @param resultRanges vector filled with found ranges
76          */
77         void fillOccuranceRanges(const string& checkedString,
78                         const string& searchedMatch, int_pairs& resultRanges) const;
79         /**
80          * @brief Searches the string for positions of occurrences of another string.
81          * @param checkedString the subject of search
82          * @param searchedMatch string to be searched for
83          * @param resultPositions vector filled with result positions
84          */
85         void getMatchesPositions(const string& checkedString,
86                         const string& searchedMatch, vector<int>& resultPositions) const;
87         /**
88          * @brief merges ranges
89          * @param ranges vector of ranges to merge
90          * @param result vector filled with merged ranges
91          */
92         void mergeRanges(int_pairs& ranges, int_pairs& result) const;
93         /**
94          * @brief get string enriched with opening and closing tags on given positions
95          * @param strToHighlight string to be enriched with tags
96          * @param ranges positions of opening and closing tags
97          * @param tag opening tag (for every pair.first)
98          * @param tagClose closing tag (for every pair.second)
99          * @return string with tags
100          */
101         string getTaggedString(const string& strToHighlight,
102                         const int_pairs& ranges) const;
103
104 };
105
106 } /* namespace base_ui */
107 } /* namespace tizen_browser */
108
109 #endif /* URLMATCHESSTYLER_H_ */