diff -r b0dd75e285d2 -r 0f2326c2a325 ginebra2/emulator/browser.cpp --- a/ginebra2/emulator/browser.cpp Fri May 14 15:40:36 2010 +0300 +++ b/ginebra2/emulator/browser.cpp Wed Jun 23 17:59:43 2010 +0300 @@ -1,21 +1,24 @@ /* * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License as published by +* the Free Software Foundation, version 2.1 of the License. * -* Initial Contributors: -* Nokia Corporation - initial contribution. +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License for more details. * -* Contributors: +* You should have received a copy of the GNU Lesser General Public License +* along with this program. If not, +* see "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html/". * -* Description: +* Description: * */ - #include "browser.h" #ifndef NO_QSTM_GESTURE #include "WebGestureHelper.h" @@ -23,7 +26,7 @@ #include "../ChromeWidget.h" #include "HistoryFlowView.h" #include "WindowFlowView.h" -#include "WrtPageManager.h" +#include "webpagecontroller.h" #include "bedrockprovisioning.h" #include @@ -40,16 +43,24 @@ #endif #endif -GinebraBrowser::GinebraBrowser(QObject * parent) +GinebraBrowser::GinebraBrowser(QObject * parent, QString *url) : QObject(parent), m_splashScreen(NULL) { + // The initial url to go to when the browser is called from another app + if (url != 0) { + qDebug() << "GinebraBrowser::GinebraBrowser - initialurl=" << *url; +// m_initialUrl = url->mid(2); + m_initialUrl = *url; + } QString startUpChrome(BEDROCK_PROVISIONING::BedrockProvisioning::createBedrockProvisioning()->valueAsString("StartUpChrome")); - m_install = BEDROCK_PROVISIONING::BedrockProvisioning::createBedrockProvisioning()->valueAsString("ChromeBaseDirectory2") + m_install = BEDROCK_PROVISIONING::BedrockProvisioning::createBedrockProvisioning()->valueAsString("ChromeBaseDirectory") + startUpChrome.section('/', 0, -2) + "/"; m_chromeUrl = startUpChrome.section('/', -1); m_contentUrl = BEDROCK_PROVISIONING::BedrockProvisioning::createBedrockProvisioning()->valueAsString("StartPage"); + setApplicationNameVersion(); + //qDebug() << "GinebraBrowser::GinebraBrowser: " << m_install << " " << m_chromeUrl; //GVA::Settings * settings = GVA::Settings::instance(); //settings->setInstallRoot(m_install); @@ -64,6 +75,7 @@ QString iconDBPath = homeDir.absolutePath() + "/favicon"; QWebSettings::globalSettings()->setIconDatabasePath(iconDBPath);*/ + #ifdef _GVA_INSPECT_CHROME_ QWebSettings * s = m_chrome->page()->settings(); s->setAttribute(QWebSettings::DeveloperExtrasEnabled, true ); @@ -81,14 +93,14 @@ browserApp->setMainWindow(m_view); m_view->grabGesture(QStm_Gesture::assignedType()); #endif - -#ifdef Q_OS_SYMBIAN - m_view->showFullScreen(); + +#if defined(Q_OS_SYMBIAN) || defined(Q_WS_MAEMO_5) + m_view->showFullScreen(); #else m_view->setGeometry(0,0,360,640); #endif - showSplashScreen(); + showSplashScreen(); #ifndef __gva_no_chrome__ QObject::connect(m_chrome, SIGNAL(internalChromeComplete()), this, SLOT(onChromeComplete())); @@ -103,14 +115,16 @@ #endif #else onChromeComplete(); - -#endif + +#endif + // Handle openUrl signals + connect(this, SIGNAL(openUrlRequested(QString)), this, SLOT(openUrl(QString))); } -GinebraBrowser::~GinebraBrowser() +GinebraBrowser::~GinebraBrowser() { - delete m_chrome; + delete m_chrome; delete WebPageController::getSingleton(); delete m_view; destroySplashScreen(); @@ -146,7 +160,7 @@ homeDir.rmdir("favicon"); } */ -void GinebraBrowser::show() +void GinebraBrowser::show() { m_view->show(); } @@ -157,63 +171,133 @@ ControllableViewBase *windowView = WRT::WindowFlowView::createNew(m_chrome); windowView->setObjectName("WindowView"); m_chrome->addView(windowView); + + ControllableViewBase *historyView = WRT::HistoryFlowView::createNew(m_chrome); + historyView->setObjectName("HistoryView"); + m_chrome->addView(historyView); + #endif //Create a content window and add it to the chrome GVA::GWebContentView *content = new GVA::GWebContentView(m_chrome, 0, "WebView"); - //Load the initial content after the chrome loads. This makes sure that an initial bad //content page won't hang up rendering the chrome. m_chrome->addView(content); - - QString startPage = m_install + m_contentUrl; + + QString chromeBaseDir = BEDROCK_PROVISIONING::BedrockProvisioning::createBedrockProvisioning()->valueAsString("ChromeBaseDirectory"); + QString startPage = chromeBaseDir + m_contentUrl; qDebug() << "GinebraBrowser::onChromeComplete: startPage: " << startPage; bool enabled = (bool) BEDROCK_PROVISIONING::BedrockProvisioning::createBedrockProvisioning()->valueAsInt("SaveSession"); - if (enabled) + + // If the browser was launched by some other app calling QDesktopServices.openUrl, go to that url + if (!m_initialUrl.isEmpty()) { + qDebug() << "called from openurl, loading page " << m_initialUrl; + openUrl(m_initialUrl); + } + // Otherwise, load the previous page from history (if that option is enabled) + else if (enabled && m_initialUrl.isEmpty()) { + qDebug() << "loading page from history"; WebPageController::getSingleton()->loadFromHistory(); - else + } + // Otherwise, load the start page + else { + qDebug() << "loading startpage " << startPage; content->loadUrlToCurrentPage(startPage); - -#ifndef __gva_no_chrome__ - WRT::HistoryFlowView *historyView = new WRT::HistoryFlowView(WrtPageManager::getSingleton(), m_chrome); - historyView->setObjectName("HistoryView"); - m_chrome->addView(historyView); -#endif + } + m_chrome->showView("WebView"); destroySplashScreen(); } +void GinebraBrowser::queueOpenUrl(QString url) +{ + emit openUrlRequested(url); +} + +void GinebraBrowser::openUrl(QString url) +{ +#ifdef Q_OS_SYMBIAN + // Handle the url as per the old standard at + // http://wiki.forum.nokia.com/index.php/TSS000340_-_Launching_the_Web_browser_on_S60_3rd_Edition_to_open_a_specified_URL + QChar urlType = url.at(0); + // Bookmark (by uid) - not handled + if (urlType == '1') { + return; + } + // Saved deck (by uid) - not handled + else if (urlType == '2') { + return; + } + // Start page - not handled + else if (urlType == '5') { + return; + } + // Bookmark folder (by uid) - not handled + else if (urlType == '6') { + return; + } + // Url or Url + space + access point + else if (urlType == '4') { + url = url.mid(2); // Get the real url + if (url.contains(' ')) { // Chop off the access point if there is one because it's not currently handled + url = url.left(url.indexOf(' ')); + } + } + // If no number then it's just a plain url +#endif /* Q_OS_SYMBIAN */ + // Bring the browser to the front (QDesktopServices openurl is supposed to do this but doesn't) + if (m_view) { + m_view->activateWindow(); + m_view->raise(); + } + qDebug() << "GinebraBrowser::openUrl - " << url; + m_contentUrl = url; + WebPageController::getSingleton()->loadInitialUrlFromOtherApp(url); +// GVA::GWebContentView *webView = (GVA::GWebContentView *)m_chrome->getView("WebView"); +// if (webView != 0) { +// m_contentUrl = url; +// webView->loadUrlToCurrentPage(url); +// } +} + void GinebraBrowser::showSplashScreen() { QString splashImage = BEDROCK_PROVISIONING::BedrockProvisioning::createBedrockProvisioning()->valueAsString("SplashImage"); - QString baseDir = BEDROCK_PROVISIONING::BedrockProvisioning::createBedrockProvisioning()->valueAsString("ChromeBaseDirectory2"); - QString imagePath = baseDir + splashImage; - - qDebug() << "ChromeView::showSplashScreen: " << imagePath; - if(!imagePath.isNull()) { + QString baseDir = BEDROCK_PROVISIONING::BedrockProvisioning::createBedrockProvisioning()->valueAsString("ChromeBaseDirectory"); + QString imagePath = baseDir + splashImage; + + qDebug() << "ChromeView::showSplashScreen: " << imagePath; + if (!imagePath.isNull()) { m_splashScreen = new QLabel(NULL); m_splashScreen->setAlignment(Qt::AlignCenter); m_splashScreen->setStyleSheet("background-color: #FFF"); m_splashScreen->setPixmap(QPixmap(imagePath)); - if(m_splashScreen->pixmap()->isNull()) { + if (m_splashScreen->pixmap()->isNull()) { ;//qDebug() << "ChromeView::chromeLoaded: ERROR splashscreen creation failed. " << imagePath; } else { - m_splashScreen->show(); - #ifdef Q_OS_SYMBIAN - m_splashScreen->showFullScreen(); - m_view->showFullScreen(); - #else - m_splashScreen->setGeometry(0,0,360,640); - #endif + m_splashScreen->show(); + #ifdef Q_OS_SYMBIAN + m_splashScreen->showFullScreen(); + m_view->showFullScreen(); + #else + m_splashScreen->setGeometry(0,0,360,640); + #endif } } } void GinebraBrowser::destroySplashScreen() { - if(m_splashScreen) + if (m_splashScreen) { delete m_splashScreen; m_splashScreen = NULL; } } + +void GinebraBrowser::setApplicationNameVersion() +{ + QCoreApplication::setApplicationName(BEDROCK_APPLICATION_NAME); + QString browserAppVersion = BEDROCK_PROVISIONING::BedrockProvisioning::createBedrockProvisioning()->valueAsString("BedrockVersion"); + QCoreApplication::setApplicationVersion(browserAppVersion); +}