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.
5 #ifndef IOS_CHROME_BROWSER_SEARCH_SEARCH_UTIL_H_
6 #define IOS_CHROME_BROWSER_SEARCH_SEARCH_UTIL_H_
8 #include "base/strings/string16.h"
13 class ChromeBrowserState
;
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
,
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
,
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.
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
);
42 #endif // IOS_CHROME_BROWSER_SEARCH_SEARCH_UTIL_H_