summaryrefslogtreecommitdiffstats
path: root/chrome/browser/autocomplete/autocomplete_edit_view_mac.mm
diff options
context:
space:
mode:
authorviettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-12-07 18:54:33 +0000
committerviettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-12-07 18:54:33 +0000
commitcddc5241ab3085c5eb82fa65ccb1bb38d962fe46 (patch)
treec27f4742a5427229d4417df9ac6c2f6398caa69b /chrome/browser/autocomplete/autocomplete_edit_view_mac.mm
parent83cb9e0a28d12f4c68e75dca6df33678f754e302 (diff)
downloadchromium_src-cddc5241ab3085c5eb82fa65ccb1bb38d962fe46.zip
chromium_src-cddc5241ab3085c5eb82fa65ccb1bb38d962fe46.tar.gz
chromium_src-cddc5241ab3085c5eb82fa65ccb1bb38d962fe46.tar.bz2
Mac: implement "Search the Web..." (Opt-Cmd-F).
This focuses the Omnibox with '?' in the contents with the text insertion point immediately after (and no selection), unless the Omnibox already has something beginning with '?' in which case it selects the text after the '?'. This is what Ctrl-K does on other platforms. On the Mac, we get a menu item (under Edit -> Find), and the Mac-standard shortcut of Opt-Cmd-F (users can set Cmd-K as a short cut in System Preferences if they really want). Changes to MainMenu.xib: added ^IDS_EDIT_SEARCH_WEB_MAC menu item ("Search the Web...", tag 39002, Opt-Cmd-F as keyboard shortcut, sending -commandDispatch: to first responder) as first item in Find submenu, followed by a separator. BUG=29501 TEST=Check that this feature has the behaviour described above (using both the menu item and using Opt-Cmd-F), with (1) nothing in the Omnibox to begin with, (2) a random URL in the Omnibox, and (3) "?<some search term(s)>". Check that the Omnibox is properly focused (so set focus to various places, and make sure that the Omnibox gets focused). Review URL: http://codereview.chromium.org/460111 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@33971 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/autocomplete/autocomplete_edit_view_mac.mm')
-rw-r--r--chrome/browser/autocomplete/autocomplete_edit_view_mac.mm13
1 files changed, 13 insertions, 0 deletions
diff --git a/chrome/browser/autocomplete/autocomplete_edit_view_mac.mm b/chrome/browser/autocomplete/autocomplete_edit_view_mac.mm
index 8f3c58a..9fab62f 100644
--- a/chrome/browser/autocomplete/autocomplete_edit_view_mac.mm
+++ b/chrome/browser/autocomplete/autocomplete_edit_view_mac.mm
@@ -301,6 +301,19 @@ void AutocompleteEditViewMac::SetWindowTextAndCaretPos(const std::wstring& text,
SetTextAndSelectedRange(text, NSMakeRange(caret_pos, caret_pos));
}
+void AutocompleteEditViewMac::SetForcedQuery() {
+ // We need to do this first, else |SetSelectedRange()| won't work.
+ FocusLocation();
+
+ const std::wstring current_text(GetText());
+ if (current_text.empty() || (current_text[0] != '?')) {
+ SetUserText(L"?");
+ } else {
+ NSRange range = NSMakeRange(1, current_text.size() - 1);
+ [[field_ currentEditor] setSelectedRange:range];
+ }
+}
+
bool AutocompleteEditViewMac::IsSelectAll() {
if (![field_ currentEditor])
return true;