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 482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
493 // inline autocomplete text. | 493 // inline autocomplete text. |
494 // TODO: Rethink how we are going to handle this case to avoid | 494 // TODO: Rethink how we are going to handle this case to avoid |
495 // inconsistent behavior when user presses Ctrl key. | 495 // inconsistent behavior when user presses Ctrl key. |
496 // See http://crbug.com/165961 and http://crbug.com/165968 for more details. | 496 // See http://crbug.com/165961 and http://crbug.com/165968 for more details. |
497 cursor_position = user_text_.length(); | 497 cursor_position = user_text_.length(); |
498 } | 498 } |
499 | 499 |
500 // We don't explicitly clear OmniboxPopupModel::manually_selected_match, as | 500 // We don't explicitly clear OmniboxPopupModel::manually_selected_match, as |
501 // Start ends up invoking OmniboxPopupModel::OnResultChanged which clears it. | 501 // Start ends up invoking OmniboxPopupModel::OnResultChanged which clears it. |
502 autocomplete_controller_->Start(AutocompleteInput( | 502 autocomplete_controller_->Start(AutocompleteInput( |
503 user_text_, cursor_position, string16(), | 503 user_text_, cursor_position, string16(), GURL(), |
504 prevent_inline_autocomplete || just_deleted_text_ || | 504 prevent_inline_autocomplete || just_deleted_text_ || |
505 (has_selected_text && inline_autocomplete_text_.empty()) || | 505 (has_selected_text && inline_autocomplete_text_.empty()) || |
506 (paste_state_ != NONE), keyword_is_selected, | 506 (paste_state_ != NONE), keyword_is_selected, |
507 keyword_is_selected || allow_exact_keyword_match_, | 507 keyword_is_selected || allow_exact_keyword_match_, |
508 AutocompleteInput::ALL_MATCHES)); | 508 AutocompleteInput::ALL_MATCHES)); |
509 } | 509 } |
510 | 510 |
511 void OmniboxEditModel::StopAutocomplete() { | 511 void OmniboxEditModel::StopAutocomplete() { |
512 autocomplete_controller_->Stop(true); | 512 autocomplete_controller_->Stop(true); |
513 } | 513 } |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
552 // as the desired TLD. Then use this autocomplete input to generate a | 552 // as the desired TLD. Then use this autocomplete input to generate a |
553 // URL_WHAT_YOU_TYPED AutocompleteMatch. Note that using the most recent | 553 // URL_WHAT_YOU_TYPED AutocompleteMatch. Note that using the most recent |
554 // input instead of the currently visible text means we'll ignore any | 554 // input instead of the currently visible text means we'll ignore any |
555 // visible inline autocompletion: if a user types "foo" and is autocompleted | 555 // visible inline autocompletion: if a user types "foo" and is autocompleted |
556 // to "foodnetwork.com", ctrl-enter will navigate to "foo.com", not | 556 // to "foodnetwork.com", ctrl-enter will navigate to "foo.com", not |
557 // "foodnetwork.com". At the time of writing, this behavior matches | 557 // "foodnetwork.com". At the time of writing, this behavior matches |
558 // Internet Explorer, but not Firefox. | 558 // Internet Explorer, but not Firefox. |
559 const AutocompleteInput& old_input = autocomplete_controller_->input(); | 559 const AutocompleteInput& old_input = autocomplete_controller_->input(); |
560 AutocompleteInput input( | 560 AutocompleteInput input( |
561 old_input.text(), old_input.cursor_position(), ASCIIToUTF16("com"), | 561 old_input.text(), old_input.cursor_position(), ASCIIToUTF16("com"), |
562 old_input.prevent_inline_autocomplete(), | 562 GURL(), old_input.prevent_inline_autocomplete(), |
563 old_input.prefer_keyword(), | 563 old_input.prefer_keyword(), old_input.allow_exact_keyword_match(), |
564 old_input.allow_exact_keyword_match(), | |
565 old_input.matches_requested()); | 564 old_input.matches_requested()); |
566 AutocompleteMatch url_match = | 565 AutocompleteMatch url_match = |
567 HistoryURLProvider::SuggestExactInput(match.provider, input, true); | 566 HistoryURLProvider::SuggestExactInput(match.provider, input, true); |
568 | 567 |
569 if (url_match.destination_url.is_valid()) { | 568 if (url_match.destination_url.is_valid()) { |
570 // We have a valid URL, we use this newly generated AutocompleteMatch. | 569 // We have a valid URL, we use this newly generated AutocompleteMatch. |
571 match = url_match; | 570 match = url_match; |
572 alternate_nav_url = GURL(); | 571 alternate_nav_url = GURL(); |
573 } | 572 } |
574 } | 573 } |
(...skipping 804 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1379 instant->OmniboxFocusChanged(state, reason, NULL); | 1378 instant->OmniboxFocusChanged(state, reason, NULL); |
1380 | 1379 |
1381 // Update state and notify view if the omnibox has focus and the caret | 1380 // Update state and notify view if the omnibox has focus and the caret |
1382 // visibility changed. | 1381 // visibility changed. |
1383 const bool was_caret_visible = is_caret_visible(); | 1382 const bool was_caret_visible = is_caret_visible(); |
1384 focus_state_ = state; | 1383 focus_state_ = state; |
1385 if (focus_state_ != OMNIBOX_FOCUS_NONE && | 1384 if (focus_state_ != OMNIBOX_FOCUS_NONE && |
1386 is_caret_visible() != was_caret_visible) | 1385 is_caret_visible() != was_caret_visible) |
1387 view_->ApplyCaretVisibility(); | 1386 view_->ApplyCaretVisibility(); |
1388 } | 1387 } |
OLD | NEW |