Ticket #12850: load_url_in_new_tab.patch

File load_url_in_new_tab.patch, 3.0 KB (added by Paradoxon, 3 years ago)

Loads URLS and refs wich are handed over to webpositive in a new tab so that the previous history is still alive ;-)

  • src/apps/webpositive/BrowserApp.cpp

    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  
    6464const char* kApplicationSignature = "application/x-vnd.Haiku-WebPositive";
    6565const char* kApplicationName = B_TRANSLATE_SYSTEM_NAME("WebPositive");
    6666static const uint32 PRELOAD_BROWSING_HISTORY = 'plbh';
     67static const uint32 LOAD_PASSED_URL = 'lurl';
    6768
    6869#define ENABLE_NATIVE_COOKIES 1
    6970
    BrowserApp::ReadyToRun()  
    225226
    226227    int32 pagesCreated = 0;
    227228    bool fullscreen = false;
    228     if (fLaunchRefsMessage) {
    229         _RefsReceived(fLaunchRefsMessage, &pagesCreated, &fullscreen);
    230         delete fLaunchRefsMessage;
    231         fLaunchRefsMessage = NULL;
    232     }
    233229
    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);
    247245                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                 }
    255246            }
    256247        }
    257248    }
    258249
    259     // If previous session did not contain any window, create a new empty one.
    260250    if (pagesCreated == 0)
    261251        _CreateNewWindow("", fullscreen);
    262252
    263253    PostMessage(PRELOAD_BROWSING_HISTORY);
     254    PostMessage(LOAD_PASSED_URL);
    264255}
    265256
    266257
    BrowserApp::MessageReceived(BMessage* message)  
    323314    case ADD_CONSOLE_MESSAGE:
    324315        fConsoleWindow->PostMessage(message);
    325316        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;
    327326    default:
    328327        BApplication::MessageReceived(message);
    329328        break;