Commit 13577719 authored by Justin Donnelly's avatar Justin Donnelly Committed by Commit Bot

[omnibox] Add shift-enter handling to the selected suggestion.

Shift-enter will open the currently selected match in a new window. The
primary purpose of this change is to avoid regressing the existing Cocoa
behavior when MacViews launches. However, it seems just as useful on all
desktop platforms and shift-enter isn't currently in use for anything
else.

Also, remove some dead code that was added to support tab switch back in
https://crrev.com/c/809527. We don't use this shift-enter behavior
anymore so the OnShiftKeyChanged method is no longer needed.

Bug: 863156
Change-Id: I41960db2dd3a81be0ba79db90b2e69a69cf50031
Reviewed-on: https://chromium-review.googlesource.com/1136651Reviewed-by: default avatarKevin Bailey <krb@chromium.org>
Reviewed-by: default avatarElly Fong-Jones <ellyjones@chromium.org>
Commit-Queue: Justin Donnelly <jdonnelly@chromium.org>
Cr-Commit-Position: refs/heads/master@{#575261}
parent f4731742
......@@ -803,11 +803,6 @@ bool OmniboxViewMac::OnDoCommandBySelector(SEL cmd) {
// |-noop:| is sent when the user presses Cmd+Return. Override the no-op
// behavior with the proper WindowOpenDisposition.
NSEvent* event = [NSApp currentEvent];
if (([event type] == NSKeyDown || [event type] == NSKeyUp) &&
[event keyCode] == kVK_Shift) {
OnShiftKeyChanged([event type] == NSKeyDown);
return true;
}
if (cmd == @selector(insertNewline:) ||
(cmd == @selector(noop:) &&
([event type] == NSKeyDown || [event type] == NSKeyUp) &&
......@@ -872,7 +867,6 @@ void OmniboxViewMac::OnSetFocus(bool control_down) {
}
void OmniboxViewMac::OnKillFocus() {
OnShiftKeyChanged(false);
// Tell the model to reset itself.
model()->OnWillKillFocus();
model()->OnKillFocus();
......
......@@ -1054,8 +1054,6 @@ void OmniboxViewViews::OnBlur() {
CloseOmniboxPopup();
}
OnShiftKeyChanged(false);
// Tell the model to reset itself.
model()->OnKillFocus();
......@@ -1181,8 +1179,6 @@ bool OmniboxViewViews::HandleKeyEvent(views::Textfield* textfield,
// The omnibox contents may change while the control key is pressed.
if (event.key_code() == ui::VKEY_CONTROL)
model()->OnControlKeyChanged(false);
else if (event.key_code() == ui::VKEY_SHIFT)
OnShiftKeyChanged(false);
return false;
}
......@@ -1209,6 +1205,8 @@ bool OmniboxViewViews::HandleKeyEvent(views::Textfield* textfield,
} else if (command) {
model()->AcceptInput(WindowOpenDisposition::NEW_BACKGROUND_TAB,
false);
} else if (shift) {
model()->AcceptInput(WindowOpenDisposition::NEW_WINDOW, false);
} else {
model()->AcceptInput(WindowOpenDisposition::CURRENT_TAB, false);
}
......@@ -1222,10 +1220,6 @@ bool OmniboxViewViews::HandleKeyEvent(views::Textfield* textfield,
model()->OnControlKeyChanged(true);
break;
case ui::VKEY_SHIFT:
OnShiftKeyChanged(true);
break;
case ui::VKEY_DELETE:
if (shift && model()->popup_model()->IsOpen())
model()->popup_model()->TryDeletingCurrentItem();
......
......@@ -220,7 +220,7 @@ OmniboxView::StateChanges OmniboxView::GetStateChanges(const State& before,
OmniboxView::OmniboxView(OmniboxEditController* controller,
std::unique_ptr<OmniboxClient> client)
: controller_(controller), shift_key_down_(false) {
: controller_(controller) {
// |client| can be null in tests.
if (client) {
model_.reset(new OmniboxEditModel(this, controller, std::move(client)));
......
......@@ -287,15 +287,12 @@ class OmniboxView {
const bool text_is_url,
const AutocompleteSchemeClassifier& classifier);
void OnShiftKeyChanged(bool down) { shift_key_down_ = down; }
private:
friend class OmniboxViewMacTest;
// |model_| can be NULL in tests.
std::unique_ptr<OmniboxEditModel> model_;
OmniboxEditController* controller_;
bool shift_key_down_;
DISALLOW_COPY_AND_ASSIGN(OmniboxView);
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment