| 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/views/omnibox/omnibox_view_win.h" | 5 #include "chrome/browser/ui/views/omnibox/omnibox_view_win.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <locale> | 8 #include <locale> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 588 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 599 if (state) { | 599 if (state) { |
| 600 SetSelectionRange(state->view_state.selection); | 600 SetSelectionRange(state->view_state.selection); |
| 601 saved_selection_for_focus_change_ = | 601 saved_selection_for_focus_change_ = |
| 602 state->view_state.saved_selection_for_focus_change; | 602 state->view_state.saved_selection_for_focus_change; |
| 603 } | 603 } |
| 604 } | 604 } |
| 605 | 605 |
| 606 void OmniboxViewWin::Update() { | 606 void OmniboxViewWin::Update() { |
| 607 const ToolbarModel::SecurityLevel old_security_level = security_level_; | 607 const ToolbarModel::SecurityLevel old_security_level = security_level_; |
| 608 security_level_ = controller()->GetToolbarModel()->GetSecurityLevel(false); | 608 security_level_ = controller()->GetToolbarModel()->GetSecurityLevel(false); |
| 609 if (model()->UpdatePermanentText( | 609 if (model()->UpdatePermanentText()) { |
| 610 controller()->GetToolbarModel()->GetText(true))) { | |
| 611 ScopedFreeze freeze(this, GetTextObjectModel()); | 610 ScopedFreeze freeze(this, GetTextObjectModel()); |
| 612 | 611 |
| 613 // Tweak: if the user had all the text selected, select all the new text. | 612 // Tweak: if the user had all the text selected, select all the new text. |
| 614 // This makes one particular case better: the user clicks in the box to | 613 // This makes one particular case better: the user clicks in the box to |
| 615 // change it right before the permanent URL is changed. Since the new URL | 614 // change it right before the permanent URL is changed. Since the new URL |
| 616 // is still fully selected, the user's typing will replace the edit contents | 615 // is still fully selected, the user's typing will replace the edit contents |
| 617 // as they'd intended. | 616 // as they'd intended. |
| 618 CHARRANGE sel; | 617 CHARRANGE sel; |
| 619 GetSelection(sel); | 618 GetSelection(sel); |
| 620 const bool was_select_all = IsSelectAllForRange(sel); | 619 const bool was_select_all = IsSelectAllForRange(sel); |
| (...skipping 2183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2804 } | 2803 } |
| 2805 | 2804 |
| 2806 int OmniboxViewWin::WidthNeededToDisplay(const string16& text) const { | 2805 int OmniboxViewWin::WidthNeededToDisplay(const string16& text) const { |
| 2807 // Use font_list_.GetPrimaryFont().GetStringWidth() instead of | 2806 // Use font_list_.GetPrimaryFont().GetStringWidth() instead of |
| 2808 // PosFromChar(GetTextLength()) because PosFromChar() is apparently buggy. | 2807 // PosFromChar(GetTextLength()) because PosFromChar() is apparently buggy. |
| 2809 // In both LTR UI and RTL UI with left-to-right layout, PosFromChar(i) might | 2808 // In both LTR UI and RTL UI with left-to-right layout, PosFromChar(i) might |
| 2810 // return 0 when i is greater than 1. | 2809 // return 0 when i is greater than 1. |
| 2811 return font_list_.GetPrimaryFont().GetStringWidth(text) + | 2810 return font_list_.GetPrimaryFont().GetStringWidth(text) + |
| 2812 GetHorizontalMargin(); | 2811 GetHorizontalMargin(); |
| 2813 } | 2812 } |
| OLD | NEW |