From 00e4a54230b145db5e8bd54d68b45fe800198057 Mon Sep 17 00:00:00 2001
From: Paradoxon <two4god@gmail.com>
Date: Fri, 16 Sep 2016 22:54:44 +0200
Subject: [PATCH] load url wich are passed to the WebPositive into a new tab
---
src/apps/webpositive/BrowserApp.cpp | 53 ++++++++++++++++++-------------------
1 file changed, 26 insertions(+), 27 deletions(-)
diff --git a/src/apps/webpositive/BrowserApp.cpp b/src/apps/webpositive/BrowserApp.cpp
index 0b4df79..fdb29fc 100644
a
|
b
|
|
64 | 64 | const char* kApplicationSignature = "application/x-vnd.Haiku-WebPositive"; |
65 | 65 | const char* kApplicationName = B_TRANSLATE_SYSTEM_NAME("WebPositive"); |
66 | 66 | static const uint32 PRELOAD_BROWSING_HISTORY = 'plbh'; |
| 67 | static const uint32 LOAD_PASSED_URL = 'lurl'; |
67 | 68 | |
68 | 69 | #define ENABLE_NATIVE_COOKIES 1 |
69 | 70 | |
… |
… |
BrowserApp::ReadyToRun()
|
225 | 226 | |
226 | 227 | int32 pagesCreated = 0; |
227 | 228 | bool fullscreen = false; |
228 | | if (fLaunchRefsMessage) { |
229 | | _RefsReceived(fLaunchRefsMessage, &pagesCreated, &fullscreen); |
230 | | delete fLaunchRefsMessage; |
231 | | fLaunchRefsMessage = NULL; |
232 | | } |
233 | 229 | |
234 | | // If no refs led to a new open page, restore previous session. |
235 | | if (pagesCreated == 0) { |
236 | | BMessage archivedWindow; |
237 | | for (int i = 0; fSession->FindMessage("window", i, &archivedWindow) == B_OK; |
238 | | i++) { |
239 | | BRect frame = archivedWindow.FindRect("window frame"); |
240 | | BString url; |
241 | | archivedWindow.FindString("tab", 0, &url); |
242 | | BrowserWindow* window = new(std::nothrow) BrowserWindow(frame, |
243 | | fSettings, url, fContext); |
244 | | |
245 | | if (window != NULL) { |
246 | | window->Show(); |
| 230 | BMessage archivedWindow; |
| 231 | for (int i = 0; fSession->FindMessage("window", i, &archivedWindow) == B_OK; |
| 232 | i++) { |
| 233 | BRect frame = archivedWindow.FindRect("window frame"); |
| 234 | BString url; |
| 235 | archivedWindow.FindString("tab", 0, &url); |
| 236 | BrowserWindow* window = new(std::nothrow) BrowserWindow(frame, |
| 237 | fSettings, url, fContext); |
| 238 | if (window != NULL) { |
| 239 | window->Show(); |
| 240 | pagesCreated++; |
| 241 | for (int j = 1; archivedWindow.FindString("tab", j, &url) == B_OK; |
| 242 | j++) { |
| 243 | printf("Create %d:%d\n", i, j); |
| 244 | _CreateNewTab(window, url, false); |
247 | 245 | pagesCreated++; |
248 | | |
249 | | for (int j = 1; archivedWindow.FindString("tab", j, &url) == B_OK; |
250 | | j++) { |
251 | | printf("Create %d:%d\n", i, j); |
252 | | _CreateNewTab(window, url, false); |
253 | | pagesCreated++; |
254 | | } |
255 | 246 | } |
256 | 247 | } |
257 | 248 | } |
258 | 249 | |
259 | | // If previous session did not contain any window, create a new empty one. |
260 | 250 | if (pagesCreated == 0) |
261 | 251 | _CreateNewWindow("", fullscreen); |
262 | 252 | |
263 | 253 | PostMessage(PRELOAD_BROWSING_HISTORY); |
| 254 | PostMessage(LOAD_PASSED_URL); |
264 | 255 | } |
265 | 256 | |
266 | 257 | |
… |
… |
BrowserApp::MessageReceived(BMessage* message)
|
323 | 314 | case ADD_CONSOLE_MESSAGE: |
324 | 315 | fConsoleWindow->PostMessage(message); |
325 | 316 | break; |
326 | | |
| 317 | case LOAD_PASSED_URL: |
| 318 | if (fLaunchRefsMessage) { |
| 319 | int32 pagesCreated; |
| 320 | bool fullscreen; |
| 321 | _RefsReceived(fLaunchRefsMessage, &pagesCreated, &fullscreen); |
| 322 | delete fLaunchRefsMessage; |
| 323 | fLaunchRefsMessage = NULL; |
| 324 | } |
| 325 | break; |
327 | 326 | default: |
328 | 327 | BApplication::MessageReceived(message); |
329 | 328 | break; |