Commit 97567bc0 authored by jdonnelly's avatar jdonnelly Committed by Commit bot

Remove the use of custom logic to determine search suggestion types.

iOS has a custom method for determining which omnibox suggestion types
are search/query types (as opposed to URL types). This change removes it
in favor of the cross-platform method used on other platforms. This has
useful effects on how we display navsuggest and calculator suggestions
and eliminates the need to maintain separate logic.

See the bug for a detailed description of the motivation for this change
and an analysis of its effects.

BUG=716047

Review-Url: https://codereview.chromium.org/2852553002
Cr-Commit-Position: refs/heads/master@{#468317}
parent 3016c726
...@@ -285,7 +285,7 @@ initWithPopupView:(OmniboxPopupViewIOS*)view ...@@ -285,7 +285,7 @@ initWithPopupView:(OmniboxPopupViewIOS*)view
// suggestions. For all other search suggestions, |match.description| is the // suggestions. For all other search suggestions, |match.description| is the
// name of the currently selected search engine, which for mobile we suppress. // name of the currently selected search engine, which for mobile we suppress.
NSString* detailText = nil; NSString* detailText = nil;
if (![self isSearchMatch:match.type]) if (!AutocompleteMatch::IsSearchType(match.type))
detailText = base::SysUTF16ToNSString(match.contents); detailText = base::SysUTF16ToNSString(match.contents);
else if (match.type == AutocompleteMatchType::SEARCH_SUGGEST_ENTITY) else if (match.type == AutocompleteMatchType::SEARCH_SUGGEST_ENTITY)
detailText = base::SysUTF16ToNSString(match.description); detailText = base::SysUTF16ToNSString(match.description);
...@@ -304,7 +304,8 @@ initWithPopupView:(OmniboxPopupViewIOS*)view ...@@ -304,7 +304,8 @@ initWithPopupView:(OmniboxPopupViewIOS*)view
detailTextLabel.numberOfLines = 1; detailTextLabel.numberOfLines = 1;
} else { } else {
const ACMatchClassifications* classifications = const ACMatchClassifications* classifications =
![self isSearchMatch:match.type] ? &match.contents_class : nil; !AutocompleteMatch::IsSearchType(match.type) ? &match.contents_class
: nil;
// The suggestion detail color should match the main text color for entity // The suggestion detail color should match the main text color for entity
// suggestions. For non-search suggestions (URLs), a highlight color is used // suggestions. For non-search suggestions (URLs), a highlight color is used
// instead. // instead.
...@@ -334,12 +335,13 @@ initWithPopupView:(OmniboxPopupViewIOS*)view ...@@ -334,12 +335,13 @@ initWithPopupView:(OmniboxPopupViewIOS*)view
// The text should be search term (|match.contents|) for searches, otherwise // The text should be search term (|match.contents|) for searches, otherwise
// page title (|match.description|). // page title (|match.description|).
base::string16 textString = base::string16 textString = AutocompleteMatch::IsSearchType(match.type)
[self isSearchMatch:match.type] ? match.contents : match.description; ? match.contents
: match.description;
NSString* text = base::SysUTF16ToNSString(textString); NSString* text = base::SysUTF16ToNSString(textString);
const ACMatchClassifications* textClassifications = const ACMatchClassifications* textClassifications =
[self isSearchMatch:match.type] ? &match.contents_class AutocompleteMatch::IsSearchType(match.type) ? &match.contents_class
: &match.description_class; : &match.description_class;
// If for some reason the title is empty, copy the detailText. // If for some reason the title is empty, copy the detailText.
if ([text length] == 0 && [detailText length] != 0) { if ([text length] == 0 && [detailText length] != 0) {
...@@ -669,15 +671,6 @@ initWithPopupView:(OmniboxPopupViewIOS*)view ...@@ -669,15 +671,6 @@ initWithPopupView:(OmniboxPopupViewIOS*)view
_alignment = alignment; _alignment = alignment;
} }
- (BOOL)isSearchMatch:(const AutocompleteMatch::Type&)type {
return (type == AutocompleteMatchType::NAVSUGGEST ||
type == AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED ||
type == AutocompleteMatchType::SEARCH_HISTORY ||
type == AutocompleteMatchType::SEARCH_SUGGEST ||
type == AutocompleteMatchType::SEARCH_SUGGEST_ENTITY ||
type == AutocompleteMatchType::SEARCH_OTHER_ENGINE);
}
- (NSMutableAttributedString*) - (NSMutableAttributedString*)
attributedStringWithString:(NSString*)text attributedStringWithString:(NSString*)text
classifications:(const ACMatchClassifications*)classifications classifications:(const ACMatchClassifications*)classifications
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment