OLD | NEW |
| (Empty) |
1 // Copyright 2015 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 IOS_CHROME_BROWSER_SEARCH_SEARCH_UTIL_H_ | |
6 #define IOS_CHROME_BROWSER_SEARCH_SEARCH_UTIL_H_ | |
7 | |
8 #include "base/strings/string16.h" | |
9 | |
10 class GURL; | |
11 | |
12 namespace ios { | |
13 class ChromeBrowserState; | |
14 } | |
15 | |
16 namespace web { | |
17 class WebState; | |
18 } | |
19 | |
20 // Extracts and returns search terms from |url|. Does not consider | |
21 // IsQueryExtractionEnabled() and Instant support state of the page and does | |
22 // not check for a privileged process, so most callers should use | |
23 // GetSearchTerms() below instead. | |
24 base::string16 ExtractSearchTermsFromURL(ios::ChromeBrowserState* browser_state, | |
25 const GURL& url); | |
26 | |
27 // Returns true if it is okay to extract search terms from |url|. |url| must | |
28 // have a secure scheme and must contain the search terms replacement key for | |
29 // the default search provider. | |
30 bool IsQueryExtractionAllowedForURL(ios::ChromeBrowserState* browser_state, | |
31 const GURL& url); | |
32 | |
33 // Returns search terms if this WebState is a search results page. It looks | |
34 // in the visible NavigationItem first, to see if search terms have already | |
35 // been extracted. Failing that, it tries to extract search terms from the URL. | |
36 // | |
37 // Returns a blank string if search terms were not found, or if search terms | |
38 // extraction is disabled for this WebState or BrowserState, or if |web_state| | |
39 // does not support Instant. | |
40 base::string16 GetSearchTerms(web::WebState* web_state); | |
41 | |
42 #endif // IOS_CHROME_BROWSER_SEARCH_SEARCH_UTIL_H_ | |
OLD | NEW |