OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/views/omnibox/omnibox_view_views.h" | 5 #include "chrome/browser/ui/views/omnibox/omnibox_view_views.h" |
6 | 6 |
7 #include "base/property_bag.h" | 7 #include "base/property_bag.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
(...skipping 576 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
587 // When the user has deleted text, we don't allow inline autocomplete. Make | 587 // When the user has deleted text, we don't allow inline autocomplete. Make |
588 // sure to not flag cases like selecting part of the text and then pasting | 588 // sure to not flag cases like selecting part of the text and then pasting |
589 // (or typing) the prefix of that selection. (We detect these by making | 589 // (or typing) the prefix of that selection. (We detect these by making |
590 // sure the caret, which should be after any insertion, hasn't moved | 590 // sure the caret, which should be after any insertion, hasn't moved |
591 // forward of the old selection start.) | 591 // forward of the old selection start.) |
592 const bool just_deleted_text = | 592 const bool just_deleted_text = |
593 (text_before_change_.length() > new_text.length()) && | 593 (text_before_change_.length() > new_text.length()) && |
594 (new_sel.start() <= sel_before_change_.GetMin()); | 594 (new_sel.start() <= sel_before_change_.GetMin()); |
595 | 595 |
596 const bool something_changed = model_->OnAfterPossibleChange( | 596 const bool something_changed = model_->OnAfterPossibleChange( |
597 new_text, new_sel.start(), new_sel.end(), selection_differs, | 597 text_before_change_, new_text, new_sel.start(), new_sel.end(), |
598 text_changed, just_deleted_text, !textfield_->IsIMEComposing()); | 598 selection_differs, text_changed, just_deleted_text, |
| 599 !textfield_->IsIMEComposing()); |
599 | 600 |
600 // If only selection was changed, we don't need to call |model_|'s | 601 // If only selection was changed, we don't need to call |model_|'s |
601 // OnChanged() method, which is called in TextChanged(). | 602 // OnChanged() method, which is called in TextChanged(). |
602 // But we still need to call EmphasizeURLComponents() to make sure the text | 603 // But we still need to call EmphasizeURLComponents() to make sure the text |
603 // attributes are updated correctly. | 604 // attributes are updated correctly. |
604 if (something_changed && text_changed) | 605 if (something_changed && text_changed) |
605 TextChanged(); | 606 TextChanged(); |
606 else if (selection_differs) | 607 else if (selection_differs) |
607 EmphasizeURLComponents(); | 608 EmphasizeURLComponents(); |
608 else if (delete_at_end_pressed_) | 609 else if (delete_at_end_pressed_) |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
844 OmniboxViewViews* omnibox_view = new OmniboxViewViews(controller, | 845 OmniboxViewViews* omnibox_view = new OmniboxViewViews(controller, |
845 toolbar_model, | 846 toolbar_model, |
846 profile, | 847 profile, |
847 command_updater, | 848 command_updater, |
848 popup_window_mode, | 849 popup_window_mode, |
849 location_bar); | 850 location_bar); |
850 omnibox_view->Init(); | 851 omnibox_view->Init(); |
851 return omnibox_view; | 852 return omnibox_view; |
852 } | 853 } |
853 #endif | 854 #endif |
OLD | NEW |