* Made BWebPage download related methods and listener member static.

* Introduced BWebPage::RequestDownload() public API (expected to run
   synchronous).
 * Added necessary wiring for "Download this link" in context menus.
 * Restarting downloads works in principle, although with some quirks.
   (Sometimes it appears the "Desktop" is being downloaded...)

git-svn-id: http://svn.haiku-os.org/webpositive/webkit/trunk@310 94f232f2-1747-11df-bad5-a5bfde151594
This commit is contained in:
stippi 2010-03-14 10:27:39 +00:00 committed by Alexandre Deckner
parent dcad381777
commit 88e373028c
4 changed files with 11 additions and 16 deletions

View File

@ -124,7 +124,7 @@ BrowserApp::ReadyToRun()
BWebSettings::SetPersistentStoragePath(path.Path());
}
BString mainSettingsPath(kApplicationName);
mainSettingsPath << "/Application";
fSettings = new SettingsMessage(B_USER_SETTINGS_DIRECTORY,
@ -148,6 +148,8 @@ BrowserApp::ReadyToRun()
fDownloadWindow = new DownloadWindow(downloadWindowFrame, showDownloads);
fSettingsWindow = new SettingsWindow(settingsWindowFrame, fSettings);
BWebPage::SetDownloadListener(BMessenger(fDownloadWindow));
fInitialized = true;
if (fLaunchRefsMessage) {
@ -155,8 +157,7 @@ BrowserApp::ReadyToRun()
delete fLaunchRefsMessage;
fLaunchRefsMessage = 0;
} else {
BrowserWindow* window = new BrowserWindow(fLastWindowFrame,
BMessenger(fDownloadWindow));
BrowserWindow* window = new BrowserWindow(fLastWindowFrame);
window->Show();
}
PostMessage(PRELOAD_BROWSING_HISTORY);
@ -313,8 +314,7 @@ BrowserApp::_CreateNewWindow(const BString& url)
if (!BScreen().Frame().Contains(fLastWindowFrame))
fLastWindowFrame.OffsetTo(50, 50);
BrowserWindow* window = new BrowserWindow(fLastWindowFrame,
BMessenger(fDownloadWindow));
BrowserWindow* window = new BrowserWindow(fLastWindowFrame);
window->Show();
if (url.Length())
window->CurrentWebView()->LoadURL(url.String());

View File

@ -195,13 +195,11 @@ private:
// #pragma mark - BrowserWindow
BrowserWindow::BrowserWindow(BRect frame, const BMessenger& downloadListener,
ToolbarPolicy toolbarPolicy)
BrowserWindow::BrowserWindow(BRect frame, ToolbarPolicy toolbarPolicy)
:
BWebWindow(frame, kApplicationName,
B_DOCUMENT_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL,
B_AUTO_UPDATE_SIZE_LIMITS | B_ASYNCHRONOUS_CONTROLS),
fDownloadListener(downloadListener)
B_AUTO_UPDATE_SIZE_LIMITS | B_ASYNCHRONOUS_CONTROLS)
{
BMessage* newTabMessage = new BMessage(NEW_TAB);
newTabMessage->AddString("url", "");
@ -373,7 +371,7 @@ BrowserWindow::BrowserWindow(BRect frame, const BMessenger& downloadListener,
snprintf(numStr, sizeof(numStr), "%d", (int) i);
AddShortcut(numStr[0], B_COMMAND_KEY, selectTab);
}
be_app->PostMessage(WINDOW_OPENED);
}
@ -538,7 +536,7 @@ BrowserWindow::MessageReceived(BMessage* message)
&& fTabManager->CountTabs() > index) {
fTabManager->SelectTab(index);
}
break;
}
@ -629,7 +627,6 @@ BrowserWindow::CreateNewTab(const BString& url, bool select, BWebView* webView)
// Executed in app thread (new BWebPage needs to be created in app thread).
if (!webView)
webView = new BWebView("web view");
webView->WebPage()->SetDownloadListener(fDownloadListener);
fTabManager->AddTab(webView, "New tab");
@ -675,7 +672,7 @@ BrowserWindow::NewWindowRequested(const BString& url, bool primaryAction)
}
void
void
BrowserWindow::NewPageCreated(BWebView* view)
{
CreateNewTab(BString(), true, view);

View File

@ -66,7 +66,6 @@ enum {
class BrowserWindow : public BWebWindow {
public:
BrowserWindow(BRect frame,
const BMessenger& downloadListener,
ToolbarPolicy = HaveToolbar);
virtual ~BrowserWindow();
@ -121,7 +120,6 @@ private:
void _ShutdownTab(int32 index);
private:
BMessenger fDownloadListener;
BMenu* fGoMenu;
IconButton* fBackButton;
IconButton* fForwardButton;

View File

@ -257,7 +257,7 @@ public:
break;
}
case RESTART_DOWNLOAD:
// TODO:
BWebPage::RequestDownload(m_url);
break;
case CANCEL_DOWNLOAD: