Use configured search string for searching
- The search query position is signified by %s in the search string, - Automatically migrate the old default search string to the new one. Patch from #9926 with some rework from me.
This commit is contained in:
parent
e13de87284
commit
d21e9097b6
@ -2259,6 +2259,9 @@ BrowserWindow::_NewTabURL(bool isNewWindow) const
|
||||
BString
|
||||
BrowserWindow::_EncodeURIComponent(const BString& search)
|
||||
{
|
||||
// We have to take care of some of the escaping before we hand over the
|
||||
// search string to WebKit, if we want queries like "4+3" to not be
|
||||
// searched as "4 3".
|
||||
const BString escCharList = " $&`:<>[]{}\"+#%@/;=?\\^|~\',";
|
||||
BString result = search;
|
||||
char hexcode[4];
|
||||
@ -2287,15 +2290,10 @@ BrowserWindow::_VisitURL(const BString& url)
|
||||
void
|
||||
BrowserWindow::_VisitSearchEngine(const BString& search)
|
||||
{
|
||||
// TODO: Google Code-In Task to make default search
|
||||
// engine modifiable from Settings? :)
|
||||
|
||||
BString engine = "http://www.google.com/search?q=";
|
||||
engine += _EncodeURIComponent(search);
|
||||
// We have to take care of some of the escaping before
|
||||
// we hand over the string to WebKit, if we want queries
|
||||
// like "4+3" to not be searched as "4 3".
|
||||
|
||||
BString engine = "";
|
||||
engine.SetToFormat(fSearchPageURL,
|
||||
_EncodeURIComponent(search).String());
|
||||
|
||||
_VisitURL(engine);
|
||||
}
|
||||
|
||||
@ -2303,11 +2301,9 @@ BrowserWindow::_VisitSearchEngine(const BString& search)
|
||||
inline bool
|
||||
BrowserWindow::_IsValidDomainChar(char ch)
|
||||
{
|
||||
// TODO: Currenlty, only a whitespace character
|
||||
// breaks a domain name. It might be
|
||||
// a good idea (or a bad one) to make
|
||||
// character filtering based on the
|
||||
// IDNA 2008 standard.
|
||||
// TODO: Currenlty, only a whitespace character breaks a domain name. It
|
||||
// might be a good idea (or a bad one) to make character filtering based on
|
||||
// the IDNA 2008 standard.
|
||||
|
||||
return ch != ' ';
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ const char* kSettingsKeySearchPageURL = "search page url";
|
||||
const char* kDefaultDownloadPath = "/boot/home/Desktop/";
|
||||
const char* kDefaultStartPageURL
|
||||
= "file:///boot/home/config/settings/WebPositive/LoaderPages/Welcome";
|
||||
const char* kDefaultSearchPageURL = "http://www.google.com";
|
||||
const char* kDefaultSearchPageURL = "http://www.google.com/search?q=%s";
|
||||
|
||||
const char* kSettingsKeyUseProxy = "use http proxy";
|
||||
const char* kSettingsKeyProxyAddress = "http proxy address";
|
||||
|
@ -245,8 +245,14 @@ SettingsWindow::_CreateGeneralPage(float spacing)
|
||||
new BMessage(MSG_SEARCH_PAGE_CHANGED));
|
||||
fSearchPageControl->SetModificationMessage(
|
||||
new BMessage(MSG_SEARCH_PAGE_CHANGED));
|
||||
fSearchPageControl->SetText(
|
||||
fSettings->GetValue(kSettingsKeySearchPageURL, kDefaultSearchPageURL));
|
||||
BString searchURL = fSettings->GetValue(kSettingsKeySearchPageURL,
|
||||
kDefaultSearchPageURL);
|
||||
if (searchURL == "http://www.google.com") {
|
||||
// Migrate old settings files.
|
||||
searchURL = kDefaultSearchPageURL;
|
||||
fSettings->SetValue(kSettingsKeySearchPageURL, kDefaultSearchPageURL);
|
||||
}
|
||||
fSearchPageControl->SetText(searchURL);
|
||||
|
||||
fDownloadFolderControl = new BTextControl("download folder",
|
||||
B_TRANSLATE("Download folder:"), "",
|
||||
|
Loading…
Reference in New Issue
Block a user