Author: leavengood Date: Tue Dec 28 04:02:37 2010 New Revision: 557 URL: http://webpositive.haiku-os.org/changeset/557 Log: Add a stupidly simple "search Google from the URL bar" feature, a la Chrome. It still needs a lot but this doesn't seem to break anything and it already is making my browsing more productive. The hard-coding of Google will be fixed when some proper search engine provider handling is added. Modified: webkit/trunk/WebKit/haiku/WebPositive/BrowserWindow.cpp webkit/trunk/WebKit/haiku/WebPositive/BrowserWindow.h Modified: webkit/trunk/WebKit/haiku/WebPositive/BrowserWindow.cpp ============================================================================== --- webkit/trunk/WebKit/haiku/WebPositive/BrowserWindow.cpp Tue Dec 28 00:05:48 2010 (r556) +++ webkit/trunk/WebKit/haiku/WebPositive/BrowserWindow.cpp Tue Dec 28 04:02:37 2010 (r557) @@ -618,7 +618,10 @@ if (message->FindString("url", &url) != B_OK) url = fURLInputGroup->Text(); _SetPageIcon(CurrentWebView(), NULL); - CurrentWebView()->LoadURL(url.String()); + BString newUrl = _SmartURLHandler(url); + if (newUrl != url) + fURLInputGroup->TextView()->SetText(newUrl); + CurrentWebView()->LoadURL(newUrl.String()); break; } case GO_BACK: @@ -2090,6 +2093,16 @@ } +BString +BrowserWindow::_SmartURLHandler(const BString& url) const +{ + BString result = url; + if (url.FindFirst(".") == B_ERROR || url.FindFirst(" ") != B_ERROR) + result.Prepend("http://www.google.com/#q=";); + return result; +} + + void BrowserWindow::_HandlePageSourceResult(const BMessage* message) { Modified: webkit/trunk/WebKit/haiku/WebPositive/BrowserWindow.h ============================================================================== --- webkit/trunk/WebKit/haiku/WebPositive/BrowserWindow.h Tue Dec 28 00:05:48 2010 (r556) +++ webkit/trunk/WebKit/haiku/WebPositive/BrowserWindow.h Tue Dec 28 04:02:37 2010 (r557) @@ -191,6 +191,7 @@ void _InvokeButtonVisibly(BButton* button); BString _NewTabURL(bool isNewWindow) const; + BString _SmartURLHandler(const BString& url) const; void _HandlePageSourceResult( const BMessage* message);