| 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 455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 466 } else { | 466 } else { |
| 467 // There are some cases where StartAutocomplete() may be called | 467 // There are some cases where StartAutocomplete() may be called |
| 468 // with non-empty |inline_autocomplete_text_|. In such cases, we cannot | 468 // with non-empty |inline_autocomplete_text_|. In such cases, we cannot |
| 469 // use the current selection, because it could result with the cursor | 469 // use the current selection, because it could result with the cursor |
| 470 // position past the last character from the user text. Instead, | 470 // position past the last character from the user text. Instead, |
| 471 // we assume that the cursor is simply at the end of input. | 471 // we assume that the cursor is simply at the end of input. |
| 472 // One example is when user presses Ctrl key while having a highlighted | 472 // One example is when user presses Ctrl key while having a highlighted |
| 473 // inline autocomplete text. | 473 // inline autocomplete text. |
| 474 // TODO: Rethink how we are going to handle this case to avoid | 474 // TODO: Rethink how we are going to handle this case to avoid |
| 475 // inconsistent behavior when user presses Ctrl key. | 475 // inconsistent behavior when user presses Ctrl key. |
| 476 // See http://crbug.com/165961 and http://crbug.com/165968 for more details. |
| 476 cursor_position = user_text_.length(); | 477 cursor_position = user_text_.length(); |
| 477 } | 478 } |
| 478 | 479 |
| 479 // We don't explicitly clear OmniboxPopupModel::manually_selected_match, as | 480 // We don't explicitly clear OmniboxPopupModel::manually_selected_match, as |
| 480 // Start ends up invoking OmniboxPopupModel::OnResultChanged which clears it. | 481 // Start ends up invoking OmniboxPopupModel::OnResultChanged which clears it. |
| 481 autocomplete_controller_->Start(AutocompleteInput( | 482 autocomplete_controller_->Start(AutocompleteInput( |
| 482 user_text_, cursor_position, GetDesiredTLD(), | 483 user_text_, cursor_position, GetDesiredTLD(), |
| 483 prevent_inline_autocomplete || just_deleted_text_ || | 484 prevent_inline_autocomplete || just_deleted_text_ || |
| 484 (has_selected_text && inline_autocomplete_text_.empty()) || | 485 (has_selected_text && inline_autocomplete_text_.empty()) || |
| 485 (paste_state_ != NONE), keyword_is_selected, | 486 (paste_state_ != NONE), keyword_is_selected, |
| (...skipping 850 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1336 instant->OmniboxFocusChanged(state, reason, NULL); | 1337 instant->OmniboxFocusChanged(state, reason, NULL); |
| 1337 | 1338 |
| 1338 // Update state and notify view if the omnibox has focus and the caret | 1339 // Update state and notify view if the omnibox has focus and the caret |
| 1339 // visibility changed. | 1340 // visibility changed. |
| 1340 const bool was_caret_visible = is_caret_visible(); | 1341 const bool was_caret_visible = is_caret_visible(); |
| 1341 focus_state_ = state; | 1342 focus_state_ = state; |
| 1342 if (focus_state_ != OMNIBOX_FOCUS_NONE && | 1343 if (focus_state_ != OMNIBOX_FOCUS_NONE && |
| 1343 is_caret_visible() != was_caret_visible) | 1344 is_caret_visible() != was_caret_visible) |
| 1344 view_->ApplyCaretVisibility(); | 1345 view_->ApplyCaretVisibility(); |
| 1345 } | 1346 } |
| OLD | NEW |