OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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/ui/omnibox/omnibox_edit_model.h" | 5 #include "chrome/browser/ui/omnibox/omnibox_edit_model.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
10 #include "base/format_macros.h" | 10 #include "base/format_macros.h" |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 is_temporary_text_set_by_instant_(false), | 130 is_temporary_text_set_by_instant_(false), |
131 selected_instant_autocomplete_match_index_(OmniboxPopupModel::kNoMatch), | 131 selected_instant_autocomplete_match_index_(OmniboxPopupModel::kNoMatch), |
132 is_instant_temporary_text_a_search_query_(false), | 132 is_instant_temporary_text_a_search_query_(false), |
133 paste_state_(NONE), | 133 paste_state_(NONE), |
134 control_key_state_(UP), | 134 control_key_state_(UP), |
135 is_keyword_hint_(false), | 135 is_keyword_hint_(false), |
136 profile_(profile), | 136 profile_(profile), |
137 in_revert_(false), | 137 in_revert_(false), |
138 in_escape_handler_(false), | 138 in_escape_handler_(false), |
139 allow_exact_keyword_match_(false) { | 139 allow_exact_keyword_match_(false) { |
140 omnibox_controller_.reset(new OmniboxController(this, profile)); | 140 omnibox_controller_.reset(new OmniboxController(this, profile, |
| 141 controller->GetInstant())); |
141 delegate_.reset(new OmniboxCurrentPageDelegateImpl(controller, profile)); | 142 delegate_.reset(new OmniboxCurrentPageDelegateImpl(controller, profile)); |
142 } | 143 } |
143 | 144 |
144 OmniboxEditModel::~OmniboxEditModel() { | 145 OmniboxEditModel::~OmniboxEditModel() { |
145 } | 146 } |
146 | 147 |
147 const OmniboxEditModel::State OmniboxEditModel::GetStateForTabSwitch() { | 148 const OmniboxEditModel::State OmniboxEditModel::GetStateForTabSwitch() { |
148 // Like typing, switching tabs "accepts" the temporary text as the user | 149 // Like typing, switching tabs "accepts" the temporary text as the user |
149 // text, because it makes little sense to have temporary text when the | 150 // text, because it makes little sense to have temporary text when the |
150 // popup is closed. | 151 // popup is closed. |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 void OmniboxEditModel::SetUserText(const string16& text) { | 221 void OmniboxEditModel::SetUserText(const string16& text) { |
221 SetInputInProgress(true); | 222 SetInputInProgress(true); |
222 InternalSetUserText(text); | 223 InternalSetUserText(text); |
223 paste_state_ = NONE; | 224 paste_state_ = NONE; |
224 has_temporary_text_ = false; | 225 has_temporary_text_ = false; |
225 is_temporary_text_set_by_instant_ = false; | 226 is_temporary_text_set_by_instant_ = false; |
226 selected_instant_autocomplete_match_index_ = OmniboxPopupModel::kNoMatch; | 227 selected_instant_autocomplete_match_index_ = OmniboxPopupModel::kNoMatch; |
227 is_instant_temporary_text_a_search_query_ = false; | 228 is_instant_temporary_text_a_search_query_ = false; |
228 } | 229 } |
229 | 230 |
230 void OmniboxEditModel::FinalizeInstantQuery(const string16& input_text, | 231 void OmniboxEditModel::FinalizeInstantQuery( |
231 const InstantSuggestion& suggestion, | 232 const string16& input_text, |
232 bool skip_inline_autocomplete) { | 233 const InstantSuggestion& suggestion) { |
233 if (skip_inline_autocomplete) { | 234 if (popup_model()->IsOpen()) { |
234 const string16 final_text = input_text + suggestion.text; | |
235 view_->OnBeforePossibleChange(); | |
236 view_->SetWindowTextAndCaretPos(final_text, final_text.length(), false, | |
237 false); | |
238 view_->OnAfterPossibleChange(); | |
239 } else if (popup_model()->IsOpen()) { | |
240 SearchProvider* search_provider = | 235 SearchProvider* search_provider = |
241 autocomplete_controller()->search_provider(); | 236 autocomplete_controller()->search_provider(); |
242 // There may be no providers during testing; guard against that. | 237 // There may be no providers during testing; guard against that. |
243 if (search_provider) | 238 if (search_provider) |
244 search_provider->FinalizeInstantQuery(input_text, suggestion); | 239 search_provider->FinalizeInstantQuery(input_text, suggestion); |
245 } | 240 } |
246 } | 241 } |
247 | 242 |
248 void OmniboxEditModel::SetInstantSuggestion( | 243 void OmniboxEditModel::SetInstantSuggestion( |
249 const InstantSuggestion& suggestion) { | 244 const InstantSuggestion& suggestion) { |
250 switch (suggestion.behavior) { | 245 switch (suggestion.behavior) { |
251 case INSTANT_COMPLETE_NOW: | 246 case INSTANT_COMPLETE_NOW: |
252 view_->SetInstantSuggestion(string16()); | 247 view_->SetInstantSuggestion(string16()); |
253 if (!suggestion.text.empty()) | 248 if (!suggestion.text.empty()) |
254 FinalizeInstantQuery(view_->GetText(), suggestion, false); | 249 FinalizeInstantQuery(view_->GetText(), suggestion); |
255 break; | 250 break; |
256 | 251 |
257 case INSTANT_COMPLETE_NEVER: { | 252 case INSTANT_COMPLETE_NEVER: { |
258 DCHECK_EQ(INSTANT_SUGGESTION_SEARCH, suggestion.type); | 253 DCHECK_EQ(INSTANT_SUGGESTION_SEARCH, suggestion.type); |
259 view_->SetInstantSuggestion(suggestion.text); | 254 view_->SetInstantSuggestion(suggestion.text); |
260 autocomplete_controller()->search_provider()->ClearInstantSuggestion(); | 255 SearchProvider* search_provider = |
| 256 autocomplete_controller()->search_provider(); |
| 257 if (search_provider) |
| 258 search_provider->ClearInstantSuggestion(); |
261 break; | 259 break; |
262 } | 260 } |
263 | 261 |
264 case INSTANT_COMPLETE_REPLACE: { | 262 case INSTANT_COMPLETE_REPLACE: { |
265 const bool save_original_selection = !has_temporary_text_; | 263 const bool save_original_selection = !has_temporary_text_; |
266 view_->SetInstantSuggestion(string16()); | 264 view_->SetInstantSuggestion(string16()); |
267 has_temporary_text_ = true; | 265 has_temporary_text_ = true; |
268 is_temporary_text_set_by_instant_ = true; | 266 is_temporary_text_set_by_instant_ = true; |
269 selected_instant_autocomplete_match_index_ = | 267 selected_instant_autocomplete_match_index_ = |
270 suggestion.autocomplete_match_index; | 268 suggestion.autocomplete_match_index; |
271 is_instant_temporary_text_a_search_query_ = | 269 is_instant_temporary_text_a_search_query_ = |
272 suggestion.type == INSTANT_SUGGESTION_SEARCH; | 270 suggestion.type == INSTANT_SUGGESTION_SEARCH; |
273 // Instant suggestions are never a keyword. | 271 // Instant suggestions are never a keyword. |
274 keyword_ = string16(); | 272 keyword_ = string16(); |
275 is_keyword_hint_ = false; | 273 is_keyword_hint_ = false; |
276 view_->OnTemporaryTextMaybeChanged(suggestion.text, | 274 view_->OnTemporaryTextMaybeChanged(suggestion.text, |
277 save_original_selection, true); | 275 save_original_selection, true); |
278 break; | 276 break; |
279 } | 277 } |
280 } | 278 } |
281 } | 279 } |
282 | 280 |
283 bool OmniboxEditModel::CommitSuggestedText(bool skip_inline_autocomplete) { | 281 bool OmniboxEditModel::CommitSuggestedText() { |
284 if (!controller_->GetInstant()) | 282 if (!controller_->GetInstant()) |
285 return false; | 283 return false; |
286 | 284 |
287 const string16 suggestion = view_->GetInstantSuggestion(); | 285 const string16 suggestion = view_->GetInstantSuggestion(); |
288 if (suggestion.empty()) | 286 if (suggestion.empty()) |
289 return false; | 287 return false; |
290 | 288 |
291 // Assume that the gray text we are committing is a search suggestion. | 289 // Assume that the gray text we are committing is a search suggestion. |
292 FinalizeInstantQuery(view_->GetText(), | 290 const string16 final_text = view_->GetText() + suggestion; |
293 InstantSuggestion(suggestion, | 291 view_->OnBeforePossibleChange(); |
294 INSTANT_COMPLETE_NOW, | 292 view_->SetWindowTextAndCaretPos(final_text, final_text.length(), false, |
295 INSTANT_SUGGESTION_SEARCH, | 293 false); |
296 string16(), | 294 view_->OnAfterPossibleChange(); |
297 OmniboxPopupModel::kNoMatch), | |
298 skip_inline_autocomplete); | |
299 return true; | 295 return true; |
300 } | 296 } |
301 | 297 |
302 void OmniboxEditModel::OnChanged() { | 298 void OmniboxEditModel::OnChanged() { |
303 // Don't call CurrentMatch() when there's no editing, as in this case we'll | 299 // Don't call CurrentMatch() when there's no editing, as in this case we'll |
304 // never actually use it. This avoids running the autocomplete providers (and | 300 // never actually use it. This avoids running the autocomplete providers (and |
305 // any systems they then spin up) during startup. | 301 // any systems they then spin up) during startup. |
306 const AutocompleteMatch& current_match = user_input_in_progress_ ? | 302 const AutocompleteMatch& current_match = user_input_in_progress_ ? |
307 CurrentMatch() : AutocompleteMatch(); | 303 CurrentMatch() : AutocompleteMatch(); |
308 | 304 |
(...skipping 11 matching lines...) Expand all Loading... |
320 // before it's needed. Note: This event is triggered as part of startup when | 316 // before it's needed. Note: This event is triggered as part of startup when |
321 // the initial tab transitions to the start page. | 317 // the initial tab transitions to the start page. |
322 recommended_action = | 318 recommended_action = |
323 action_predictor->RecommendAction(user_text_, current_match); | 319 action_predictor->RecommendAction(user_text_, current_match); |
324 } | 320 } |
325 | 321 |
326 UMA_HISTOGRAM_ENUMERATION("AutocompleteActionPredictor.Action", | 322 UMA_HISTOGRAM_ENUMERATION("AutocompleteActionPredictor.Action", |
327 recommended_action, | 323 recommended_action, |
328 AutocompleteActionPredictor::LAST_PREDICT_ACTION); | 324 AutocompleteActionPredictor::LAST_PREDICT_ACTION); |
329 | 325 |
330 if (!DoInstant(current_match)) { | 326 // Do not perform instant if we're currently reverting or the change is the |
| 327 // result of an INSTANT_COMPLETE_REPLACE instant suggestion. |
| 328 bool performed_instant = false; |
| 329 if (!in_revert_ && |
| 330 (!has_temporary_text_ || !is_temporary_text_set_by_instant_)) { |
| 331 size_t start, end; |
| 332 view_->GetSelectionBounds(&start, &end); |
| 333 string16 user_text = has_temporary_text_ ? current_match.fill_into_edit : |
| 334 DisplayTextFromUserText(user_text_); |
| 335 performed_instant = omnibox_controller_->DoInstant( |
| 336 current_match, user_text, view_->GetText(), start, end, |
| 337 user_input_in_progress_, in_escape_handler_, |
| 338 view_->DeleteAtEndPressed() || just_deleted_text_, |
| 339 KeywordIsSelected()); |
| 340 } |
| 341 |
| 342 if (!performed_instant) { |
331 // Hide any suggestions we might be showing. | 343 // Hide any suggestions we might be showing. |
332 view_->SetInstantSuggestion(string16()); | 344 view_->SetInstantSuggestion(string16()); |
333 | 345 |
334 // No need to wait any longer for Instant. | 346 // No need to wait any longer for Instant. |
335 FinalizeInstantQuery(string16(), InstantSuggestion(), false); | 347 FinalizeInstantQuery(string16(), InstantSuggestion()); |
336 } | 348 } |
337 | 349 |
338 switch (recommended_action) { | 350 switch (recommended_action) { |
339 case AutocompleteActionPredictor::ACTION_PRERENDER: | 351 case AutocompleteActionPredictor::ACTION_PRERENDER: |
340 // It's possible that there is no current page, for instance if the tab | 352 // It's possible that there is no current page, for instance if the tab |
341 // has been closed or on return from a sleep state. | 353 // has been closed or on return from a sleep state. |
342 // (http://crbug.com/105689) | 354 // (http://crbug.com/105689) |
343 if (!delegate_->CurrentPageExists()) | 355 if (!delegate_->CurrentPageExists()) |
344 break; | 356 break; |
345 // Ask for prerendering if the destination URL is different than the | 357 // Ask for prerendering if the destination URL is different than the |
(...skipping 17 matching lines...) Expand all Loading... |
363 AutocompleteMatch match; | 375 AutocompleteMatch match; |
364 GetInfoForCurrentText(&match, NULL); | 376 GetInfoForCurrentText(&match, NULL); |
365 *url = match.destination_url; | 377 *url = match.destination_url; |
366 if (*url == URLFixerUpper::FixupURL(UTF16ToUTF8(permanent_text_), | 378 if (*url == URLFixerUpper::FixupURL(UTF16ToUTF8(permanent_text_), |
367 std::string())) { | 379 std::string())) { |
368 *title = controller_->GetTitle(); | 380 *title = controller_->GetTitle(); |
369 *favicon = controller_->GetFavicon(); | 381 *favicon = controller_->GetFavicon(); |
370 } | 382 } |
371 } | 383 } |
372 | 384 |
373 bool OmniboxEditModel::UseVerbatimInstant() { | |
374 #if defined(OS_MACOSX) | |
375 // TODO(suzhe): Fix Mac port to display Instant suggest in a separated NSView, | |
376 // so that we can display Instant suggest along with composition text. | |
377 const AutocompleteInput& input = autocomplete_controller()->input(); | |
378 if (input.prevent_inline_autocomplete()) | |
379 return true; | |
380 #endif | |
381 | |
382 // The value of input.prevent_inline_autocomplete() is determined by the | |
383 // following conditions: | |
384 // 1. If the caret is at the end of the text. | |
385 // 2. If it's in IME composition mode. | |
386 // We send the caret position to Instant (so it can determine #1 itself), and | |
387 // we use a separated widget for displaying the Instant suggest (so it doesn't | |
388 // interfere with #2). So, we don't need to care about the value of | |
389 // input.prevent_inline_autocomplete() here. | |
390 return view_->DeleteAtEndPressed() || popup_model()->selected_line() != 0 || | |
391 just_deleted_text_; | |
392 } | |
393 | |
394 bool OmniboxEditModel::CurrentTextIsURL() const { | 385 bool OmniboxEditModel::CurrentTextIsURL() const { |
395 if (view_->toolbar_model()->GetSearchTermsType() != | 386 if (view_->toolbar_model()->GetSearchTermsType() != |
396 ToolbarModel::NO_SEARCH_TERMS) | 387 ToolbarModel::NO_SEARCH_TERMS) |
397 return false; | 388 return false; |
398 | 389 |
399 // If current text is not composed of replaced search terms and | 390 // If current text is not composed of replaced search terms and |
400 // !user_input_in_progress_, then permanent text is showing and should be a | 391 // !user_input_in_progress_, then permanent text is showing and should be a |
401 // URL, so no further checking is needed. By avoiding checking in this case, | 392 // URL, so no further checking is needed. By avoiding checking in this case, |
402 // we avoid calling into the autocomplete providers, and thus initializing the | 393 // we avoid calling into the autocomplete providers, and thus initializing the |
403 // history system, as long as possible, which speeds startup. | 394 // history system, as long as possible, which speeds startup. |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
495 false, true); | 486 false, true); |
496 AutocompleteActionPredictor* action_predictor = | 487 AutocompleteActionPredictor* action_predictor = |
497 AutocompleteActionPredictorFactory::GetForProfile(profile_); | 488 AutocompleteActionPredictorFactory::GetForProfile(profile_); |
498 if (action_predictor) | 489 if (action_predictor) |
499 action_predictor->ClearTransitionalMatches(); | 490 action_predictor->ClearTransitionalMatches(); |
500 } | 491 } |
501 | 492 |
502 void OmniboxEditModel::StartAutocomplete( | 493 void OmniboxEditModel::StartAutocomplete( |
503 bool has_selected_text, | 494 bool has_selected_text, |
504 bool prevent_inline_autocomplete) const { | 495 bool prevent_inline_autocomplete) const { |
505 omnibox_controller_->ClearPopupKeywordMode(); | |
506 | |
507 bool keyword_is_selected = KeywordIsSelected(); | |
508 popup_model()->SetHoveredLine(OmniboxPopupModel::kNoMatch); | |
509 | |
510 size_t cursor_position; | 496 size_t cursor_position; |
511 if (inline_autocomplete_text_.empty()) { | 497 if (inline_autocomplete_text_.empty()) { |
512 // Cursor position is equivalent to the current selection's end. | 498 // Cursor position is equivalent to the current selection's end. |
513 size_t start; | 499 size_t start; |
514 view_->GetSelectionBounds(&start, &cursor_position); | 500 view_->GetSelectionBounds(&start, &cursor_position); |
515 // Adjust cursor position taking into account possible keyword in the user | 501 // Adjust cursor position taking into account possible keyword in the user |
516 // text. We rely on DisplayTextFromUserText() method which is consistent | 502 // text. We rely on DisplayTextFromUserText() method which is consistent |
517 // with keyword extraction done in KeywordProvider/SearchProvider. | 503 // with keyword extraction done in KeywordProvider/SearchProvider. |
518 const size_t cursor_offset = | 504 const size_t cursor_offset = |
519 user_text_.length() - DisplayTextFromUserText(user_text_).length(); | 505 user_text_.length() - DisplayTextFromUserText(user_text_).length(); |
520 cursor_position += cursor_offset; | 506 cursor_position += cursor_offset; |
521 } else { | 507 } else { |
522 // There are some cases where StartAutocomplete() may be called | 508 // There are some cases where StartAutocomplete() may be called |
523 // with non-empty |inline_autocomplete_text_|. In such cases, we cannot | 509 // with non-empty |inline_autocomplete_text_|. In such cases, we cannot |
524 // use the current selection, because it could result with the cursor | 510 // use the current selection, because it could result with the cursor |
525 // position past the last character from the user text. Instead, | 511 // position past the last character from the user text. Instead, |
526 // we assume that the cursor is simply at the end of input. | 512 // we assume that the cursor is simply at the end of input. |
527 // One example is when user presses Ctrl key while having a highlighted | 513 // One example is when user presses Ctrl key while having a highlighted |
528 // inline autocomplete text. | 514 // inline autocomplete text. |
529 // TODO: Rethink how we are going to handle this case to avoid | 515 // TODO: Rethink how we are going to handle this case to avoid |
530 // inconsistent behavior when user presses Ctrl key. | 516 // inconsistent behavior when user presses Ctrl key. |
531 // See http://crbug.com/165961 and http://crbug.com/165968 for more details. | 517 // See http://crbug.com/165961 and http://crbug.com/165968 for more details. |
532 cursor_position = user_text_.length(); | 518 cursor_position = user_text_.length(); |
533 } | 519 } |
534 | 520 |
535 InstantController* instant = controller_->GetInstant(); | 521 bool keyword_is_selected = KeywordIsSelected(); |
536 if (instant) { | 522 omnibox_controller_->StartAutocomplete( |
537 instant->OnAutocompleteStart(); | 523 user_text_, |
538 // If the embedded page for InstantExtended is fetching its own suggestions, | 524 cursor_position, |
539 // suppress search suggestions from SearchProvider. We still need | |
540 // SearchProvider to run for FinalizeInstantQuery. | |
541 // TODO(dcblack): Once we are done refactoring the omnibox so we don't need | |
542 // to use FinalizeInstantQuery anymore, we can take out this check and | |
543 // remove this provider from kInstantExtendedOmniboxProviders. | |
544 if (instant->WillFetchCompletions()) | |
545 autocomplete_controller()->search_provider()->SuppressSearchSuggestions(); | |
546 } | |
547 | |
548 // We don't explicitly clear OmniboxPopupModel::manually_selected_match, as | |
549 // Start ends up invoking OmniboxPopupModel::OnResultChanged which clears it. | |
550 autocomplete_controller()->Start(AutocompleteInput( | |
551 user_text_, cursor_position, string16(), GURL(), | |
552 prevent_inline_autocomplete || just_deleted_text_ || | 525 prevent_inline_autocomplete || just_deleted_text_ || |
553 (has_selected_text && inline_autocomplete_text_.empty()) || | 526 (has_selected_text && inline_autocomplete_text_.empty()) || |
554 (paste_state_ != NONE), keyword_is_selected, | 527 (paste_state_ != NONE), |
555 keyword_is_selected || allow_exact_keyword_match_, | 528 keyword_is_selected, |
556 AutocompleteInput::ALL_MATCHES)); | 529 keyword_is_selected || allow_exact_keyword_match_); |
557 } | 530 } |
558 | 531 |
559 void OmniboxEditModel::StopAutocomplete() { | 532 void OmniboxEditModel::StopAutocomplete() { |
560 autocomplete_controller()->Stop(true); | 533 autocomplete_controller()->Stop(true); |
561 } | 534 } |
562 | 535 |
563 bool OmniboxEditModel::CanPasteAndGo(const string16& text) const { | 536 bool OmniboxEditModel::CanPasteAndGo(const string16& text) const { |
564 if (!view_->command_updater()->IsCommandEnabled(IDC_OPEN_CURRENT_URL)) | 537 if (!view_->command_updater()->IsCommandEnabled(IDC_OPEN_CURRENT_URL)) |
565 return false; | 538 return false; |
566 | 539 |
(...skipping 798 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1365 // Then check if the text before the inserted space matches a keyword. | 1338 // Then check if the text before the inserted space matches a keyword. |
1366 string16 keyword; | 1339 string16 keyword; |
1367 TrimWhitespace(new_text.substr(0, space_position), TRIM_LEADING, &keyword); | 1340 TrimWhitespace(new_text.substr(0, space_position), TRIM_LEADING, &keyword); |
1368 // TODO(sreeram): Once the Instant extended API supports keywords properly, | 1341 // TODO(sreeram): Once the Instant extended API supports keywords properly, |
1369 // keyword_provider() should never be NULL. Remove that clause. | 1342 // keyword_provider() should never be NULL. Remove that clause. |
1370 return !keyword.empty() && autocomplete_controller()->keyword_provider() && | 1343 return !keyword.empty() && autocomplete_controller()->keyword_provider() && |
1371 !autocomplete_controller()->keyword_provider()-> | 1344 !autocomplete_controller()->keyword_provider()-> |
1372 GetKeywordForText(keyword).empty(); | 1345 GetKeywordForText(keyword).empty(); |
1373 } | 1346 } |
1374 | 1347 |
1375 bool OmniboxEditModel::DoInstant(const AutocompleteMatch& match) { | |
1376 InstantController* instant = controller_->GetInstant(); | |
1377 if (!instant || in_revert_) | |
1378 return false; | |
1379 | |
1380 // Don't call Update() if the change is the result of an | |
1381 // INSTANT_COMPLETE_REPLACE instant suggestion. | |
1382 if (is_temporary_text_set_by_instant_) | |
1383 return false; | |
1384 | |
1385 // The two pieces of text we want to send Instant, viz., what the user has | |
1386 // typed, and the full omnibox text including any inline autocompletion. | |
1387 string16 user_text = has_temporary_text_ ? | |
1388 match.fill_into_edit : DisplayTextFromUserText(user_text_); | |
1389 string16 full_text = view_->GetText(); | |
1390 | |
1391 // Remove "?" if we're in forced query mode. | |
1392 AutocompleteInput::RemoveForcedQueryStringIfNecessary( | |
1393 autocomplete_controller()->input().type(), &user_text); | |
1394 AutocompleteInput::RemoveForcedQueryStringIfNecessary( | |
1395 autocomplete_controller()->input().type(), &full_text); | |
1396 | |
1397 size_t start, end; | |
1398 view_->GetSelectionBounds(&start, &end); | |
1399 | |
1400 return instant->Update(match, user_text, full_text, start, end, | |
1401 UseVerbatimInstant(), user_input_in_progress_, popup_model()->IsOpen(), | |
1402 in_escape_handler_, KeywordIsSelected()); | |
1403 } | |
1404 | |
1405 // static | 1348 // static |
1406 bool OmniboxEditModel::IsSpaceCharForAcceptingKeyword(wchar_t c) { | 1349 bool OmniboxEditModel::IsSpaceCharForAcceptingKeyword(wchar_t c) { |
1407 switch (c) { | 1350 switch (c) { |
1408 case 0x0020: // Space | 1351 case 0x0020: // Space |
1409 case 0x3000: // Ideographic Space | 1352 case 0x3000: // Ideographic Space |
1410 return true; | 1353 return true; |
1411 default: | 1354 default: |
1412 return false; | 1355 return false; |
1413 } | 1356 } |
1414 } | 1357 } |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1446 instant->OmniboxFocusChanged(state, reason, NULL); | 1389 instant->OmniboxFocusChanged(state, reason, NULL); |
1447 | 1390 |
1448 // Update state and notify view if the omnibox has focus and the caret | 1391 // Update state and notify view if the omnibox has focus and the caret |
1449 // visibility changed. | 1392 // visibility changed. |
1450 const bool was_caret_visible = is_caret_visible(); | 1393 const bool was_caret_visible = is_caret_visible(); |
1451 focus_state_ = state; | 1394 focus_state_ = state; |
1452 if (focus_state_ != OMNIBOX_FOCUS_NONE && | 1395 if (focus_state_ != OMNIBOX_FOCUS_NONE && |
1453 is_caret_visible() != was_caret_visible) | 1396 is_caret_visible() != was_caret_visible) |
1454 view_->ApplyCaretVisibility(); | 1397 view_->ApplyCaretVisibility(); |
1455 } | 1398 } |
OLD | NEW |