summaryrefslogtreecommitdiffstats
path: root/chrome/browser/autocomplete
diff options
context:
space:
mode:
authorsuzhe@google.com <suzhe@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-02-22 06:44:58 +0000
committersuzhe@google.com <suzhe@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-02-22 06:44:58 +0000
commite72e731b7302c56d181ff8628c278ea7b31a0cc8 (patch)
treea2b39178642d4ca5c395ae474cc69b8182d3e778 /chrome/browser/autocomplete
parente20aa5b622e390c720d1a07d55136b411b8808c5 (diff)
downloadchromium_src-e72e731b7302c56d181ff8628c278ea7b31a0cc8.zip
chromium_src-e72e731b7302c56d181ff8628c278ea7b31a0cc8.tar.gz
chromium_src-e72e731b7302c56d181ff8628c278ea7b31a0cc8.tar.bz2
[Mac] Pressing ctrl key shouldn't affect inline autocomplete suggest.
This CL reverts an inappropriate change introduced by http://codereview.chromium.org/5966006. BUG=73488 TEST=Pressing ctrl key in omnibox shouldn't affect existing inline autocomplete suggest text. Review URL: http://codereview.chromium.org/6541048 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@75574 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/autocomplete')
-rw-r--r--chrome/browser/autocomplete/autocomplete_edit_view_browsertest.cc34
-rw-r--r--chrome/browser/autocomplete/autocomplete_edit_view_mac.mm12
2 files changed, 44 insertions, 2 deletions
diff --git a/chrome/browser/autocomplete/autocomplete_edit_view_browsertest.cc b/chrome/browser/autocomplete/autocomplete_edit_view_browsertest.cc
index ce91cf3..72c3f81 100644
--- a/chrome/browser/autocomplete/autocomplete_edit_view_browsertest.cc
+++ b/chrome/browser/autocomplete/autocomplete_edit_view_browsertest.cc
@@ -1021,6 +1021,30 @@ class AutocompleteEditViewTest : public InProcessBrowserTest,
// Make sure we're still in keyword mode.
ASSERT_EQ(kSearchKeyword, UTF16ToUTF8(edit_view->model()->keyword()));
}
+
+ void CtrlKeyPressedWithInlineAutocompleteTest() {
+ AutocompleteEditView* edit_view = NULL;
+ ASSERT_NO_FATAL_FAILURE(GetAutocompleteEditView(&edit_view));
+ AutocompletePopupModel* popup_model = edit_view->model()->popup_model();
+ ASSERT_TRUE(popup_model);
+
+ // Input something to trigger inline autocomplete.
+ ASSERT_NO_FATAL_FAILURE(SendKeySequence(kInlineAutocompleteTextKeys));
+ ASSERT_NO_FATAL_FAILURE(WaitForAutocompleteControllerDone());
+ ASSERT_TRUE(popup_model->IsOpen());
+
+ string16 old_text = edit_view->GetText();
+
+ // Make sure inline autocomplete is triggerred.
+ EXPECT_GT(old_text.length(), arraysize(kInlineAutocompleteText) - 1);
+
+ // Press ctrl key.
+ edit_view->model()->OnControlKeyChanged(true);
+
+ // Inline autocomplete should still be there.
+ EXPECT_EQ(old_text, edit_view->GetText());
+ }
+
};
// Test if ctrl-* accelerators are workable in omnibox.
@@ -1091,6 +1115,11 @@ IN_PROC_BROWSER_TEST_F(AutocompleteEditViewTest,
PersistKeywordModeOnTabSwitch();
}
+IN_PROC_BROWSER_TEST_F(AutocompleteEditViewTest,
+ CtrlKeyPressedWithInlineAutocompleteTest) {
+ CtrlKeyPressedWithInlineAutocompleteTest();
+}
+
#if defined(OS_LINUX)
// TODO(oshima): enable these tests for views-implmentation when
// these featuers are supported.
@@ -1288,4 +1317,9 @@ IN_PROC_BROWSER_TEST_F(AutocompleteEditViewViewsTest,
PersistKeywordModeOnTabSwitch();
}
+IN_PROC_BROWSER_TEST_F(AutocompleteEditViewViewsTest,
+ CtrlKeyPressedWithInlineAutocompleteTest) {
+ CtrlKeyPressedWithInlineAutocompleteTest();
+}
+
#endif
diff --git a/chrome/browser/autocomplete/autocomplete_edit_view_mac.mm b/chrome/browser/autocomplete/autocomplete_edit_view_mac.mm
index 5728bfd..482c676 100644
--- a/chrome/browser/autocomplete/autocomplete_edit_view_mac.mm
+++ b/chrome/browser/autocomplete/autocomplete_edit_view_mac.mm
@@ -421,8 +421,16 @@ void AutocompleteEditViewMac::UpdatePopup() {
// * The caret/selection isn't at the end of the text
// * The user has just pasted in something that replaced all the text
// * The user is trying to compose something in an IME
- model_->StartAutocomplete(GetSelectedRange().length != 0,
- IsImeComposing() || !IsCaretAtEnd());
+ bool prevent_inline_autocomplete = IsImeComposing();
+ NSTextView* editor = (NSTextView*)[field_ currentEditor];
+ if (editor) {
+ if (NSMaxRange([editor selectedRange]) <
+ [[editor textStorage] length] - suggest_text_length_)
+ prevent_inline_autocomplete = true;
+ }
+
+ model_->StartAutocomplete([editor selectedRange].length != 0,
+ prevent_inline_autocomplete);
}
void AutocompleteEditViewMac::ClosePopup() {