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 "components/omnibox/browser/omnibox_edit_model.h" | 5 #include "components/omnibox/browser/omnibox_edit_model.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
363 } | 363 } |
364 | 364 |
365 void OmniboxEditModel::Revert() { | 365 void OmniboxEditModel::Revert() { |
366 SetInputInProgress(false); | 366 SetInputInProgress(false); |
367 input_.Clear(); | 367 input_.Clear(); |
368 paste_state_ = NONE; | 368 paste_state_ = NONE; |
369 InternalSetUserText(base::string16()); | 369 InternalSetUserText(base::string16()); |
370 keyword_.clear(); | 370 keyword_.clear(); |
371 is_keyword_hint_ = false; | 371 is_keyword_hint_ = false; |
372 has_temporary_text_ = false; | 372 has_temporary_text_ = false; |
373 view_->SetWindowTextAndCaretPos(permanent_text_, | 373 size_t start, end; |
374 has_focus() ? permanent_text_.length() : 0, | 374 view_->GetSelectionBounds(&start, &end); |
375 false, true); | 375 view_->SetWindowTextAndCaretPos(permanent_text_, 0, false, false); |
| 376 view_->SetWindowTextAndCaretPos( |
| 377 permanent_text_, std::min(permanent_text_.length(), start), false, true); |
376 client_->OnRevert(); | 378 client_->OnRevert(); |
377 } | 379 } |
378 | 380 |
379 void OmniboxEditModel::StartAutocomplete(bool has_selected_text, | 381 void OmniboxEditModel::StartAutocomplete(bool has_selected_text, |
380 bool prevent_inline_autocomplete) { | 382 bool prevent_inline_autocomplete) { |
381 const base::string16 input_text = MaybePrependKeyword(user_text_); | 383 const base::string16 input_text = MaybePrependKeyword(user_text_); |
382 | 384 |
383 size_t start, cursor_position; | 385 size_t start, cursor_position; |
384 view_->GetSelectionBounds(&start, &cursor_position); | 386 view_->GetSelectionBounds(&start, &cursor_position); |
385 | 387 |
(...skipping 1000 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1386 // Update state and notify view if the omnibox has focus and the caret | 1388 // Update state and notify view if the omnibox has focus and the caret |
1387 // visibility changed. | 1389 // visibility changed. |
1388 const bool was_caret_visible = is_caret_visible(); | 1390 const bool was_caret_visible = is_caret_visible(); |
1389 focus_state_ = state; | 1391 focus_state_ = state; |
1390 if (focus_state_ != OMNIBOX_FOCUS_NONE && | 1392 if (focus_state_ != OMNIBOX_FOCUS_NONE && |
1391 is_caret_visible() != was_caret_visible) | 1393 is_caret_visible() != was_caret_visible) |
1392 view_->ApplyCaretVisibility(); | 1394 view_->ApplyCaretVisibility(); |
1393 | 1395 |
1394 client_->OnFocusChanged(focus_state_, reason); | 1396 client_->OnFocusChanged(focus_state_, reason); |
1395 } | 1397 } |
OLD | NEW |