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:
committed by
Adrien Destugues
parent
e13de87284
commit
d21e9097b6
@@ -2259,6 +2259,9 @@ BrowserWindow::_NewTabURL(bool isNewWindow) const
|
|||||||
BString
|
BString
|
||||||
BrowserWindow::_EncodeURIComponent(const BString& search)
|
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 = " $&`:<>[]{}\"+#%@/;=?\\^|~\',";
|
const BString escCharList = " $&`:<>[]{}\"+#%@/;=?\\^|~\',";
|
||||||
BString result = search;
|
BString result = search;
|
||||||
char hexcode[4];
|
char hexcode[4];
|
||||||
@@ -2287,15 +2290,10 @@ BrowserWindow::_VisitURL(const BString& url)
|
|||||||
void
|
void
|
||||||
BrowserWindow::_VisitSearchEngine(const BString& search)
|
BrowserWindow::_VisitSearchEngine(const BString& search)
|
||||||
{
|
{
|
||||||
// TODO: Google Code-In Task to make default search
|
BString engine = "";
|
||||||
// engine modifiable from Settings? :)
|
engine.SetToFormat(fSearchPageURL,
|
||||||
|
_EncodeURIComponent(search).String());
|
||||||
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".
|
|
||||||
|
|
||||||
_VisitURL(engine);
|
_VisitURL(engine);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2303,11 +2301,9 @@ BrowserWindow::_VisitSearchEngine(const BString& search)
|
|||||||
inline bool
|
inline bool
|
||||||
BrowserWindow::_IsValidDomainChar(char ch)
|
BrowserWindow::_IsValidDomainChar(char ch)
|
||||||
{
|
{
|
||||||
// TODO: Currenlty, only a whitespace character
|
// TODO: Currenlty, only a whitespace character breaks a domain name. It
|
||||||
// breaks a domain name. It might be
|
// might be a good idea (or a bad one) to make character filtering based on
|
||||||
// a good idea (or a bad one) to make
|
// the IDNA 2008 standard.
|
||||||
// character filtering based on the
|
|
||||||
// IDNA 2008 standard.
|
|
||||||
|
|
||||||
return ch != ' ';
|
return ch != ' ';
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ const char* kSettingsKeySearchPageURL = "search page url";
|
|||||||
const char* kDefaultDownloadPath = "/boot/home/Desktop/";
|
const char* kDefaultDownloadPath = "/boot/home/Desktop/";
|
||||||
const char* kDefaultStartPageURL
|
const char* kDefaultStartPageURL
|
||||||
= "file:///boot/home/config/settings/WebPositive/LoaderPages/Welcome";
|
= "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* kSettingsKeyUseProxy = "use http proxy";
|
||||||
const char* kSettingsKeyProxyAddress = "http proxy address";
|
const char* kSettingsKeyProxyAddress = "http proxy address";
|
||||||
|
|||||||
@@ -245,8 +245,14 @@ SettingsWindow::_CreateGeneralPage(float spacing)
|
|||||||
new BMessage(MSG_SEARCH_PAGE_CHANGED));
|
new BMessage(MSG_SEARCH_PAGE_CHANGED));
|
||||||
fSearchPageControl->SetModificationMessage(
|
fSearchPageControl->SetModificationMessage(
|
||||||
new BMessage(MSG_SEARCH_PAGE_CHANGED));
|
new BMessage(MSG_SEARCH_PAGE_CHANGED));
|
||||||
fSearchPageControl->SetText(
|
BString searchURL = fSettings->GetValue(kSettingsKeySearchPageURL,
|
||||||
fSettings->GetValue(kSettingsKeySearchPageURL, kDefaultSearchPageURL));
|
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",
|
fDownloadFolderControl = new BTextControl("download folder",
|
||||||
B_TRANSLATE("Download folder:"), "",
|
B_TRANSLATE("Download folder:"), "",
|
||||||
|
|||||||
Reference in New Issue
Block a user