Upstreaming browser/ui/uikit_ui_util from iOS.
[chromium-blink-merge.git] / ios / chrome / browser / search / search_util.h
blob6cb0b009163dd0942e92a567c28cce9c78faae7c
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"
10 class GURL;
12 namespace ios {
13 class ChromeBrowserState;
16 namespace web {
17 class WebState;
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);
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);
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_