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.

git-svn-id: http://svn.haiku-os.org/webpositive/webkit/trunk@557 94f232f2-1747-11df-bad5-a5bfde151594
This commit is contained in:
leavengood 2010-12-28 03:02:37 +00:00 committed by Alexandre Deckner
parent 530dea0f16
commit 1526be737a
2 changed files with 15 additions and 1 deletions

View File

@ -618,7 +618,10 @@ BrowserWindow::MessageReceived(BMessage* message)
if (message->FindString("url", &url) != B_OK) if (message->FindString("url", &url) != B_OK)
url = fURLInputGroup->Text(); url = fURLInputGroup->Text();
_SetPageIcon(CurrentWebView(), NULL); _SetPageIcon(CurrentWebView(), NULL);
CurrentWebView()->LoadURL(url.String()); BString newUrl = _SmartURLHandler(url);
if (newUrl != url)
fURLInputGroup->TextView()->SetText(newUrl);
CurrentWebView()->LoadURL(newUrl.String());
break; break;
} }
case GO_BACK: case GO_BACK:
@ -2090,6 +2093,16 @@ BrowserWindow::_NewTabURL(bool isNewWindow) const
} }
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 void
BrowserWindow::_HandlePageSourceResult(const BMessage* message) BrowserWindow::_HandlePageSourceResult(const BMessage* message)
{ {

View File

@ -191,6 +191,7 @@ private:
void _InvokeButtonVisibly(BButton* button); void _InvokeButtonVisibly(BButton* button);
BString _NewTabURL(bool isNewWindow) const; BString _NewTabURL(bool isNewWindow) const;
BString _SmartURLHandler(const BString& url) const;
void _HandlePageSourceResult( void _HandlePageSourceResult(
const BMessage* message); const BMessage* message);