diff options
author | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-23 01:48:58 +0000 |
---|---|---|
committer | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-23 01:48:58 +0000 |
commit | a26dc3692818f34a1bb5341931ac2cd26819bb09 (patch) | |
tree | c77abccac30298c0d1b55991321466610fb9e15c /chrome/browser/autocomplete | |
parent | ce53c9e6d9b9211f853e0d6f426a12b0bab6a875 (diff) | |
download | chromium_src-a26dc3692818f34a1bb5341931ac2cd26819bb09.zip chromium_src-a26dc3692818f34a1bb5341931ac2cd26819bb09.tar.gz chromium_src-a26dc3692818f34a1bb5341931ac2cd26819bb09.tar.bz2 |
Don't select all when autofocusing the location bar on New Tab creation. Users could already be typing in the omnibox before the load commits (e.g. due to a slow renderer process startup) and this typing would then be selected and overwritten.
BUG=41466
TEST=On a very slow machine, typing before a new tab finishes loading should not be selected or cleared once the tab finishes loading.
Review URL: http://codereview.chromium.org/1738004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@45406 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/autocomplete')
3 files changed, 9 insertions, 7 deletions
diff --git a/chrome/browser/autocomplete/autocomplete_browsertest.cc b/chrome/browser/autocomplete/autocomplete_browsertest.cc index f54e535..ba77285 100644 --- a/chrome/browser/autocomplete/autocomplete_browsertest.cc +++ b/chrome/browser/autocomplete/autocomplete_browsertest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -62,7 +62,7 @@ IN_PROC_BROWSER_TEST_F(AutocompleteBrowserTest, Basic) { // TODO(phajdan.jr): check state of IsSelectAll when it's consistent across // platforms. - location_bar->FocusLocation(); + location_bar->FocusLocation(true); EXPECT_EQ(std::wstring(), location_bar->GetInputString()); EXPECT_EQ(UTF8ToWide(chrome::kAboutBlankURL), diff --git a/chrome/browser/autocomplete/autocomplete_edit_view_mac.h b/chrome/browser/autocomplete/autocomplete_edit_view_mac.h index 11bb62f..4cf7aee 100644 --- a/chrome/browser/autocomplete/autocomplete_edit_view_mac.h +++ b/chrome/browser/autocomplete/autocomplete_edit_view_mac.h @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -91,8 +91,8 @@ class AutocompleteEditViewMac : public AutocompleteEditView, virtual void OnDidEndEditing(); virtual bool OnDoCommandBySelector(SEL cmd); - // Helper for LocationBarViewMac. Selects all in |field_|. - void FocusLocation(); + // Helper for LocationBarViewMac. Optionally selects all in |field_|. + void FocusLocation(bool select_all); // Helper to get appropriate contents from |clipboard|. Returns // empty string if no appropriate data is found on |clipboard|. diff --git a/chrome/browser/autocomplete/autocomplete_edit_view_mac.mm b/chrome/browser/autocomplete/autocomplete_edit_view_mac.mm index 81a3daf..e337744 100644 --- a/chrome/browser/autocomplete/autocomplete_edit_view_mac.mm +++ b/chrome/browser/autocomplete/autocomplete_edit_view_mac.mm @@ -316,7 +316,7 @@ void AutocompleteEditViewMac::SetWindowTextAndCaretPos(const std::wstring& text, void AutocompleteEditViewMac::SetForcedQuery() { // We need to do this first, else |SetSelectedRange()| won't work. - FocusLocation(); + FocusLocation(true); const std::wstring current_text(GetText()); if (current_text.empty() || (current_text[0] != '?')) { @@ -825,7 +825,9 @@ void AutocompleteEditViewMac::OnControlKeyChanged(bool pressed) { model_->OnControlKeyChanged(pressed); } -void AutocompleteEditViewMac::FocusLocation() { +void AutocompleteEditViewMac::FocusLocation(bool select_all) { + // TODO(pkasting): Figure out Mac's weird focus-handling and do the right + // thing here :( if ([field_ isEditable]) { [[field_ window] makeFirstResponder:field_]; DCHECK_EQ([field_ currentEditor], [[field_ window] firstResponder]); |