Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1414)

Unified Diff: chrome/browser/ui/views/omnibox/omnibox_view_win.cc

Issue 18543012: Don't mess with omnibox selection on update when the omnibox doesn't have focus. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/views/omnibox/omnibox_view_win.cc
===================================================================
--- chrome/browser/ui/views/omnibox/omnibox_view_win.cc (revision 209724)
+++ chrome/browser/ui/views/omnibox/omnibox_view_win.cc (working copy)
@@ -646,14 +646,22 @@
// as they'd intended.
CHARRANGE sel;
GetSelection(sel);
- const bool was_reversed = (sel.cpMin > sel.cpMax);
- const bool was_select_all = (sel.cpMin != sel.cpMax) &&
- IsSelectAllForRange(sel);
+ const bool was_select_all = IsSelectAllForRange(sel);
RevertAll();
- if (was_select_all)
- SelectAll(was_reversed);
+ // When the old text was empty, we don't bother selecting the new text.
+ // You might think we could reach here if the user has deleted the previous
+ // URL, but in that case the model will see that user input is in progress
+ // and return false from UpdatePermanentText() (so we won't reach here),
+ // unless we don't have focus, in which case we don't care anyway because
+ // re-focusing the omnibox will modify the selection regardless. The only
+ // time we actually reach here with empty text is when the user was on the
+ // NTP and clicked something on the page to navigate, in which case the
+ // omnibox shouldn't have focus anyway, and selecting all will at best do
+ // nothing and at worst cause problems like reversing the URL.
+ if (was_select_all && (sel.cpMin != sel.cpMax))
+ SelectAll(sel.cpMin > sel.cpMax);
} else if (changed_security_level) {
// Only the security style changed, nothing else. Redraw our text using it.
EmphasizeURLComponents();

Powered by Google App Engine
This is Rietveld 408576698