Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/autocomplete/autocomplete_popup_model.h" | 5 #include "chrome/browser/autocomplete/autocomplete_popup_model.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "unicode/ubidi.h" | 9 #include "unicode/ubidi.h" |
| 10 | 10 |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 135 if (match.template_url) { | 135 if (match.template_url) { |
| 136 TemplateURLService* url_service = | 136 TemplateURLService* url_service = |
| 137 TemplateURLServiceFactory::GetForProfile(edit_model_->profile()); | 137 TemplateURLServiceFactory::GetForProfile(edit_model_->profile()); |
| 138 if (!url_service) | 138 if (!url_service) |
| 139 return false; | 139 return false; |
| 140 | 140 |
| 141 // Only show the keyword for the default provider if the user typed in | 141 // Only show the keyword for the default provider if the user typed in |
| 142 // the keyword and it isn't SEARCH_WHAT_YOU_TYPED. | 142 // the keyword and it isn't SEARCH_WHAT_YOU_TYPED. |
| 143 const TemplateURL* default_url = url_service->GetDefaultSearchProvider(); | 143 const TemplateURL* default_url = url_service->GetDefaultSearchProvider(); |
| 144 if (default_url && (default_url->id() == match.template_url->id())) { | 144 if (default_url && (default_url->id() == match.template_url->id())) { |
| 145 if (StartsWith(autocomplete_controller()->input().text(), | 145 const string16& input_text = autocomplete_controller()->input().text(); |
|
sky
2011/09/08 14:21:50
This shouldn't be necessary. According to the bug
| |
| 146 default_url->keyword(), false) && | 146 const string16& default_url_keyword = default_url->keyword(); |
| 147 if (StartsWith(input_text, default_url_keyword, false) && | |
| 148 AutocompleteEditModel::IsSpaceCharForAcceptingKeyword( | |
| 149 input_text[default_url_keyword.length()]) && | |
| 147 (match.type != AutocompleteMatch::SEARCH_WHAT_YOU_TYPED)) { | 150 (match.type != AutocompleteMatch::SEARCH_WHAT_YOU_TYPED)) { |
| 148 keyword->assign(match.template_url->keyword()); | 151 keyword->assign(match.template_url->keyword()); |
| 149 return false; | 152 return false; |
| 150 } | 153 } |
| 151 } else if (TemplateURL::SupportsReplacement(match.template_url)) { | 154 } else if (TemplateURL::SupportsReplacement(match.template_url)) { |
| 152 // The current match is a keyword, return that as the selected keyword. | 155 // The current match is a keyword, return that as the selected keyword. |
| 153 keyword->assign(match.template_url->keyword()); | 156 keyword->assign(match.template_url->keyword()); |
| 154 return false; | 157 return false; |
| 155 } | 158 } |
| 156 } | 159 } |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 259 CHECK((selected_line_ != kNoMatch) || result.empty()); | 262 CHECK((selected_line_ != kNoMatch) || result.empty()); |
| 260 manually_selected_match_.Clear(); | 263 manually_selected_match_.Clear(); |
| 261 // If we're going to trim the window size to no longer include the hovered | 264 // If we're going to trim the window size to no longer include the hovered |
| 262 // line, turn hover off. Practically, this shouldn't happen, but it | 265 // line, turn hover off. Practically, this shouldn't happen, but it |
| 263 // doesn't hurt to be defensive. | 266 // doesn't hurt to be defensive. |
| 264 if ((hovered_line_ != kNoMatch) && (result.size() <= hovered_line_)) | 267 if ((hovered_line_ != kNoMatch) && (result.size() <= hovered_line_)) |
| 265 SetHoveredLine(kNoMatch); | 268 SetHoveredLine(kNoMatch); |
| 266 | 269 |
| 267 view_->UpdatePopupAppearance(); | 270 view_->UpdatePopupAppearance(); |
| 268 } | 271 } |
| OLD | NEW |