| OLD | NEW |
| 1 // Copyright 2008, Google Inc. | 1 // Copyright 2008, Google Inc. |
| 2 // All rights reserved. | 2 // All rights reserved. |
| 3 // | 3 // |
| 4 // Redistribution and use in source and binary forms, with or without | 4 // Redistribution and use in source and binary forms, with or without |
| 5 // modification, are permitted provided that the following conditions are | 5 // modification, are permitted provided that the following conditions are |
| 6 // met: | 6 // met: |
| 7 // | 7 // |
| 8 // * Redistributions of source code must retain the above copyright | 8 // * Redistributions of source code must retain the above copyright |
| 9 // notice, this list of conditions and the following disclaimer. | 9 // notice, this list of conditions and the following disclaimer. |
| 10 // * Redistributions in binary form must reproduce the above | 10 // * Redistributions in binary form must reproduce the above |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 AutocompleteInput::AutocompleteInput(const std::wstring& text, | 55 AutocompleteInput::AutocompleteInput(const std::wstring& text, |
| 56 const std::wstring& desired_tld, | 56 const std::wstring& desired_tld, |
| 57 bool prevent_inline_autocomplete) | 57 bool prevent_inline_autocomplete) |
| 58 : desired_tld_(desired_tld), | 58 : desired_tld_(desired_tld), |
| 59 prevent_inline_autocomplete_(prevent_inline_autocomplete) { | 59 prevent_inline_autocomplete_(prevent_inline_autocomplete) { |
| 60 // Trim whitespace from edges of input; don't inline autocomplete if there | 60 // Trim whitespace from edges of input; don't inline autocomplete if there |
| 61 // was trailing whitespace. | 61 // was trailing whitespace. |
| 62 if (TrimWhitespace(text, TRIM_ALL, &text_) & TRIM_TRAILING) | 62 if (TrimWhitespace(text, TRIM_ALL, &text_) & TRIM_TRAILING) |
| 63 prevent_inline_autocomplete_ = true; | 63 prevent_inline_autocomplete_ = true; |
| 64 | 64 |
| 65 url_parse::Parsed parts; | 65 type_ = Parse(text_, desired_tld, &parts_, &scheme_); |
| 66 type_ = Parse(text_, desired_tld, &parts, &scheme_); | |
| 67 | 66 |
| 68 if (type_ == INVALID) | 67 if (type_ == INVALID) |
| 69 return; | 68 return; |
| 70 | 69 |
| 71 if (type_ == FORCED_QUERY && text_[0] == L'?') | 70 if (type_ == FORCED_QUERY && text_[0] == L'?') |
| 72 text_.erase(0, 1); | 71 text_.erase(0, 1); |
| 73 } | 72 } |
| 74 | 73 |
| 75 //static | 74 //static |
| 76 AutocompleteInput::Type AutocompleteInput::Parse(const std::wstring& text, | 75 AutocompleteInput::Type AutocompleteInput::Parse(const std::wstring& text, |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 return (text_ == other.text_) && | 235 return (text_ == other.text_) && |
| 237 (type_ == other.type_) && | 236 (type_ == other.type_) && |
| 238 (desired_tld_ == other.desired_tld_) && | 237 (desired_tld_ == other.desired_tld_) && |
| 239 (scheme_ == other.scheme_) && | 238 (scheme_ == other.scheme_) && |
| 240 (prevent_inline_autocomplete_ == other.prevent_inline_autocomplete_); | 239 (prevent_inline_autocomplete_ == other.prevent_inline_autocomplete_); |
| 241 } | 240 } |
| 242 | 241 |
| 243 void AutocompleteInput::Clear() { | 242 void AutocompleteInput::Clear() { |
| 244 text_.clear(); | 243 text_.clear(); |
| 245 type_ = INVALID; | 244 type_ = INVALID; |
| 245 parts_ = url_parse::Parsed(); |
| 246 scheme_.clear(); | 246 scheme_.clear(); |
| 247 desired_tld_.clear(); | 247 desired_tld_.clear(); |
| 248 prevent_inline_autocomplete_ = false; | 248 prevent_inline_autocomplete_ = false; |
| 249 } | 249 } |
| 250 | 250 |
| 251 // AutocompleteMatch ---------------------------------------------------------- | 251 // AutocompleteMatch ---------------------------------------------------------- |
| 252 | 252 |
| 253 AutocompleteMatch::AutocompleteMatch() | 253 AutocompleteMatch::AutocompleteMatch() |
| 254 : provider(NULL), | 254 : provider(NULL), |
| 255 relevance(0), | 255 relevance(0), |
| (...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 745 ACMatchClassification(keyword_offset + input_.text().size(), | 745 ACMatchClassification(keyword_offset + input_.text().size(), |
| 746 ACMatchClassification::NONE)); | 746 ACMatchClassification::NONE)); |
| 747 } | 747 } |
| 748 match.destination_url = | 748 match.destination_url = |
| 749 UTF8ToWide(HistoryTabUI::GetHistoryURLWithSearchText( | 749 UTF8ToWide(HistoryTabUI::GetHistoryURLWithSearchText( |
| 750 input_.text()).spec()); | 750 input_.text()).spec()); |
| 751 match.transition = PageTransition::AUTO_BOOKMARK; | 751 match.transition = PageTransition::AUTO_BOOKMARK; |
| 752 match.provider = history_contents_provider_; | 752 match.provider = history_contents_provider_; |
| 753 result->AddMatch(match); | 753 result->AddMatch(match); |
| 754 } | 754 } |
| OLD | NEW |