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 483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
494 } | 494 } |
495 | 495 |
496 if (user_input_in_progress_ == in_progress) | 496 if (user_input_in_progress_ == in_progress) |
497 return; | 497 return; |
498 | 498 |
499 user_input_in_progress_ = in_progress; | 499 user_input_in_progress_ = in_progress; |
500 if (user_input_in_progress_) { | 500 if (user_input_in_progress_) { |
501 time_user_first_modified_omnibox_ = base::TimeTicks::Now(); | 501 time_user_first_modified_omnibox_ = base::TimeTicks::Now(); |
502 content::RecordAction(base::UserMetricsAction("OmniboxInputInProgress")); | 502 content::RecordAction(base::UserMetricsAction("OmniboxInputInProgress")); |
503 autocomplete_controller()->ResetSession(); | 503 autocomplete_controller()->ResetSession(); |
504 // Once the user starts editing, re-enable URL replacement, so that it will | |
505 // kick in if applicable once the edit is committed or reverted. (While the | |
506 // edit is in progress, this won't have a visible effect.) | |
507 controller_->GetToolbarModel()->set_url_replacement_enabled(true); | |
Justin Donnelly
2014/03/27 13:47:36
I'm not sure what this was trying to accomplish.
| |
508 } | 504 } |
509 | 505 |
510 // The following code handles three cases: | 506 // The following code handles two cases: |
511 // * For HIDE_ON_USER_INPUT, it hides the chip when user input begins. | 507 // * For HIDE_ON_USER_INPUT, it hides the chip when user input begins. |
512 // * For HIDE_ON_MOUSE_RELEASE, which only hides the chip on mouse release if | 508 // * For HIDE_ON_MOUSE_RELEASE, which only hides the chip on mouse release if |
513 // the omnibox is empty, it handles the "omnibox was not empty" case by | 509 // the omnibox is empty, it handles the "omnibox was not empty" case by |
514 // acting like HIDE_ON_USER_INPUT. (If the omnibox was empty, it | 510 // acting like HIDE_ON_USER_INPUT. |
515 // effectively no-ops.) | 511 if (chrome::ShouldDisplayOriginChipV2() && in_progress) |
516 // * For both hide behaviors, it allows the chip to be reshown once input | 512 controller()->GetToolbarModel()->set_origin_chip_enabled(false); |
517 // ends. (The chip won't actually be re-shown until there's no pending | |
518 // typed navigation; see OriginChipView::ShouldShow() and | |
519 // OriginChipDecoration::ShouldShow().) | |
520 if (chrome::ShouldDisplayOriginChipV2()) | |
521 controller()->GetToolbarModel()->set_origin_chip_enabled(!in_progress); | |
Justin Donnelly
2014/03/27 13:47:36
I don't think there was ever any good reason why I
| |
522 | 513 |
523 controller_->GetToolbarModel()->set_input_in_progress(in_progress); | 514 controller_->GetToolbarModel()->set_input_in_progress(in_progress); |
524 controller_->Update(NULL); | 515 controller_->Update(NULL); |
525 | 516 |
526 if (user_input_in_progress_ || !in_revert_) | 517 if (user_input_in_progress_ || !in_revert_) |
527 delegate_->OnInputStateChanged(); | 518 delegate_->OnInputStateChanged(); |
528 } | 519 } |
529 | 520 |
530 void OmniboxEditModel::Revert() { | 521 void OmniboxEditModel::Revert() { |
531 SetInputInProgress(false); | 522 SetInputInProgress(false); |
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
979 (match.provider->type() == AutocompleteProvider::TYPE_ZERO_SUGGEST); | 970 (match.provider->type() == AutocompleteProvider::TYPE_ZERO_SUGGEST); |
980 if (!has_zero_suggest_match && !user_input_in_progress_ && | 971 if (!has_zero_suggest_match && !user_input_in_progress_ && |
981 view_->IsSelectAll()) | 972 view_->IsSelectAll()) |
982 return false; | 973 return false; |
983 | 974 |
984 if (!user_text_.empty()) { | 975 if (!user_text_.empty()) { |
985 UMA_HISTOGRAM_ENUMERATION(kOmniboxUserTextClearedHistogram, | 976 UMA_HISTOGRAM_ENUMERATION(kOmniboxUserTextClearedHistogram, |
986 OMNIBOX_USER_TEXT_CLEARED_WITH_ESCAPE, | 977 OMNIBOX_USER_TEXT_CLEARED_WITH_ESCAPE, |
987 OMNIBOX_USER_TEXT_CLEARED_NUM_OF_ITEMS); | 978 OMNIBOX_USER_TEXT_CLEARED_NUM_OF_ITEMS); |
988 } | 979 } |
989 view_->RevertAll(); | 980 view_->RevertWithoutResettingSearchTermReplacement(); |
Justin Donnelly
2014/03/27 13:47:36
As with my first note above, resetting search term
| |
990 view_->SelectAll(true); | 981 view_->SelectAll(true); |
991 return true; | 982 return true; |
992 } | 983 } |
993 | 984 |
994 void OmniboxEditModel::OnControlKeyChanged(bool pressed) { | 985 void OmniboxEditModel::OnControlKeyChanged(bool pressed) { |
995 if (pressed == (control_key_state_ == UP)) | 986 if (pressed == (control_key_state_ == UP)) |
996 control_key_state_ = pressed ? DOWN_WITHOUT_CHANGE : UP; | 987 control_key_state_ = pressed ? DOWN_WITHOUT_CHANGE : UP; |
997 } | 988 } |
998 | 989 |
999 void OmniboxEditModel::OnPaste() { | 990 void OmniboxEditModel::OnPaste() { |
(...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1436 // Update state and notify view if the omnibox has focus and the caret | 1427 // Update state and notify view if the omnibox has focus and the caret |
1437 // visibility changed. | 1428 // visibility changed. |
1438 const bool was_caret_visible = is_caret_visible(); | 1429 const bool was_caret_visible = is_caret_visible(); |
1439 focus_state_ = state; | 1430 focus_state_ = state; |
1440 if (focus_state_ != OMNIBOX_FOCUS_NONE && | 1431 if (focus_state_ != OMNIBOX_FOCUS_NONE && |
1441 is_caret_visible() != was_caret_visible) | 1432 is_caret_visible() != was_caret_visible) |
1442 view_->ApplyCaretVisibility(); | 1433 view_->ApplyCaretVisibility(); |
1443 | 1434 |
1444 delegate_->OnFocusChanged(focus_state_, reason); | 1435 delegate_->OnFocusChanged(focus_state_, reason); |
1445 } | 1436 } |
OLD | NEW |