OLD | NEW |
(Empty) | |
| 1 // Copyright 2014 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_UI_CONTEXTUAL_SEARCH_CONTEXTUAL_SEARCH_CONTEXT_H_ |
| 6 #define IOS_CHROME_BROWSER_UI_CONTEXTUAL_SEARCH_CONTEXTUAL_SEARCH_CONTEXT_H_ |
| 7 |
| 8 #include <string> |
| 9 |
| 10 #include "base/macros.h" |
| 11 #include "url/gurl.h" |
| 12 |
| 13 // Encapsulates key parts of a Contextual Search Context, including surrounding |
| 14 // text. |
| 15 struct ContextualSearchContext { |
| 16 ContextualSearchContext(const std::string& selected_text, |
| 17 const bool use_resolved_search_term, |
| 18 const GURL& page_url, |
| 19 const std::string& encoding); |
| 20 ~ContextualSearchContext(); |
| 21 |
| 22 // Text that was tapped on. |
| 23 const std::string selected_text; |
| 24 // If the resolved term (rather than the selected text) should be used. |
| 25 const bool use_resolved_search_term; |
| 26 // URL of the page that was tapped in. |
| 27 const GURL page_url; |
| 28 // Encoding of the page. |
| 29 const std::string encoding; |
| 30 |
| 31 // Text surrounding the tapped text. |
| 32 base::string16 surrounding_text; |
| 33 // Starting offset of |selected_text| within |surrounding_text|. |
| 34 int start_offset; |
| 35 // End offset of |selected_text| within |surrounding_text|. |
| 36 int end_offset; |
| 37 |
| 38 // Returns whether the selection needs context resolution. If no, |
| 39 // |selected_text| is the correct query, both for searching and displaying and |
| 40 // |surrounding_text|, |start_offset|, |end_offset| are irrelevant. |
| 41 bool HasSurroundingText(); |
| 42 |
| 43 DISALLOW_COPY_AND_ASSIGN(ContextualSearchContext); |
| 44 }; |
| 45 |
| 46 #endif // IOS_CHROME_BROWSER_UI_CONTEXTUAL_SEARCH_CONTEXTUAL_SEARCH_CONTEXT_H_ |
OLD | NEW |