diff --git a/src/apps/webpositive/BrowserWindow.cpp b/src/apps/webpositive/BrowserWindow.cpp index 7d7d56a0b8..e2db73b96d 100644 --- a/src/apps/webpositive/BrowserWindow.cpp +++ b/src/apps/webpositive/BrowserWindow.cpp @@ -618,7 +618,10 @@ BrowserWindow::MessageReceived(BMessage* message) 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 @@ 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 BrowserWindow::_HandlePageSourceResult(const BMessage* message) { diff --git a/src/apps/webpositive/BrowserWindow.h b/src/apps/webpositive/BrowserWindow.h index e9f5fe3a6f..fcae9d5f7b 100644 --- a/src/apps/webpositive/BrowserWindow.h +++ b/src/apps/webpositive/BrowserWindow.h @@ -191,6 +191,7 @@ private: void _InvokeButtonVisibly(BButton* button); BString _NewTabURL(bool isNewWindow) const; + BString _SmartURLHandler(const BString& url) const; void _HandlePageSourceResult( const BMessage* message);