1 /* |
1 /* |
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
3 * All rights reserved. |
3 * All rights reserved. |
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
4 * |
9 * Initial Contributors: |
5 * This program is free software: you can redistribute it and/or modify |
10 * Nokia Corporation - initial contribution. |
6 * it under the terms of the GNU Lesser General Public License as published by |
|
7 * the Free Software Foundation, version 2.1 of the License. |
|
8 * |
|
9 * This program is distributed in the hope that it will be useful, |
|
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 * GNU Lesser General Public License for more details. |
11 * |
13 * |
12 * Contributors: |
14 * You should have received a copy of the GNU Lesser General Public License |
|
15 * along with this program. If not, |
|
16 * see "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html/". |
13 * |
17 * |
14 * Description: |
18 * Description: |
15 * |
19 * |
16 */ |
20 */ |
17 |
21 |
18 |
|
19 #include "browserpagefactory.h" |
22 #include "browserpagefactory.h" |
20 #include "webcontentview.h" |
|
21 #include "wrtpage.h" |
|
22 #include "wrtbrowsercontainer_p.h" |
23 #include "wrtbrowsercontainer_p.h" |
23 #include "wrtbrowsercontainer.h" |
24 #include "wrtbrowsercontainer.h" |
24 #include "webpagedata.h" |
25 #include "webpagedata.h" |
25 #include "qwebhistory.h" |
|
26 #include "qwebframe.h" |
|
27 #include "SchemeHandlerBr.h" |
26 #include "SchemeHandlerBr.h" |
28 #include "webnetworkaccessmanager.h" |
27 #include "webnetworkaccessmanager.h" |
29 #ifdef QT_MOBILITY_BEARER_MANAGEMENT |
|
30 #include "WebNetworkConnectionManager.h" |
|
31 #endif // QT_MOBILITY_BEARER_MANAGEMENT |
|
32 #include "webcookiejar.h" |
28 #include "webcookiejar.h" |
33 #include "webnavigation.h" |
|
34 #include "secureuicontroller.h" |
29 #include "secureuicontroller.h" |
35 #include "LoadController.h" |
30 #include "LoadController.h" |
36 #include "WebDialogProvider.h" |
31 #include "WebDialogProvider.h" |
37 #include "bedrockprovisioning.h" |
32 #include "bedrockprovisioning.h" |
38 #include <QPainter> |
33 #include <QPainter> |
39 #include <QAuthenticator> |
34 #include <QAuthenticator> |
40 #include <QFile> |
35 #include <QFile> |
41 #include <QMessageBox> |
36 #include <QMessageBox> |
|
37 #include <QWebHistory> |
|
38 #include <QWebFrame> |
|
39 #include <QGraphicsWebView> |
|
40 |
|
41 QDataStream &operator<<(QDataStream &out, const WebPageData &myObj) |
|
42 { |
|
43 out << myObj.m_thumbnail << myObj.m_zoomFactor << myObj.m_contentsPos; |
|
44 return out; |
|
45 } |
|
46 |
|
47 QDataStream &operator>>(QDataStream &in, WebPageData &myObj) |
|
48 { |
|
49 in >> myObj.m_thumbnail >> myObj.m_zoomFactor >> myObj.m_contentsPos; |
|
50 return in; |
|
51 } |
42 |
52 |
43 namespace WRT |
53 namespace WRT |
44 { |
54 { |
45 |
55 const int historyItemsCount = 10; |
46 const int historyItemsCount = 20; |
|
47 |
56 |
48 WrtBrowserContainerPrivate::WrtBrowserContainerPrivate(QObject* parent, |
57 WrtBrowserContainerPrivate::WrtBrowserContainerPrivate(QObject* parent, |
49 WrtBrowserContainer* page/*never NULL*/) : m_schemeHandler(new SchemeHandler()) |
58 WrtBrowserContainer* page/*never NULL*/) : m_schemeHandler(new SchemeHandler()) |
50 , m_pageFactory(0) |
59 , m_pageFactory(0) |
51 , m_widget(0) |
60 , m_widget(0) |
52 { |
61 , m_fileChooser(0) |
53 assert(page); |
62 , m_needUpdateThumbnail(false) |
|
63 { |
54 m_page = page; |
64 m_page = page; |
55 |
65 |
56 m_secureController = new WRT::SecureUIController(parent); |
66 m_secureController = new WRT::SecureUIController(parent); |
57 m_loadController = new WRT::LoadController(); |
67 m_loadController = new WRT::LoadController(); |
58 |
68 |
88 else |
99 else |
89 return new WrtBrowserContainer(parent); |
100 return new WrtBrowserContainer(parent); |
90 } |
101 } |
91 |
102 |
92 /*! |
103 /*! |
93 * \class WrtBrowserContainer |
|
94 * \brief Description: This class is a handle to open page on which user can |
|
95 * load an url , view history items, load an history item into the page etc. |
|
96 * @see WrtPageManager |
|
97 */ |
|
98 |
|
99 /*! |
|
100 * WrtBrowserContainer Constructor |
104 * WrtBrowserContainer Constructor |
101 * @param parent : Widget parent |
105 * @param parent : Widget parent |
102 */ |
106 */ |
103 WrtBrowserContainer::WrtBrowserContainer(QObject* parent) : |
107 WrtBrowserContainer::WrtBrowserContainer(QObject* parent) : |
104 WrtPage(parent), d(new WrtBrowserContainerPrivate(this, this)) |
108 QWebPage(parent), d(new WrtBrowserContainerPrivate(this, this)) |
105 { |
109 { |
|
110 |
|
111 settings()->setAttribute(QWebSettings::PluginsEnabled, true); |
|
112 settings()->setAttribute(QWebSettings::JavascriptCanOpenWindows, !BEDROCK_PROVISIONING::BedrockProvisioning::createBedrockProvisioning()->value("PopupBlocking").toInt()); |
106 // Download related enable "forwardUnsupportedContent" to redirect unsupported content to download manager |
113 // Download related enable "forwardUnsupportedContent" to redirect unsupported content to download manager |
107 setForwardUnsupportedContent(true); |
114 setForwardUnsupportedContent(true); |
|
115 #ifdef BEDROCK_TILED_BACKING_STORE |
|
116 settings()->setAttribute(QWebSettings::TiledBackingStoreEnabled, true); |
|
117 settings()->setAttribute(QWebSettings::ZoomTextOnly, false); |
|
118 settings()->setAttribute(QWebSettings::FrameFlatteningEnabled, true); |
|
119 |
|
120 //Configure tiling properties |
|
121 //This would set tile size to (256, 256) and add 25ms delay between constructing |
|
122 //individual tiles. The settings would try to cache an area 1.5x width and 1.5x height |
|
123 //of the current viewport (centered to the viewport) with tiles and would drop tiles |
|
124 //after they are outside an area 2x the width and 2.5x the height of the viewport. |
|
125 //Refer https://bugs.webkit.org/show_bug.cgi?id=39874 |
|
126 |
|
127 setProperty("_q_TiledBackingStoreTileSize", QSize(256, 256)); |
|
128 setProperty("_q_TiledBackingStoreTileCreationDelay", 25); |
|
129 setProperty("_q_TiledBackingStoreCoverAreaMultiplier", QSizeF(1.5, 1.5)); |
|
130 setProperty("_q_TiledBackingStoreKeepAreaMultiplier", QSizeF(2., 2.5)); |
|
131 #endif |
108 |
132 |
109 #ifndef NO_NETWORK_ACCESS_MANAGER |
133 #ifndef NO_NETWORK_ACCESS_MANAGER |
110 setNetworkAccessManager(new WebNetworkAccessManager(this,this)); |
134 setNetworkAccessManager(new WebNetworkAccessManager(this,this)); |
111 #endif |
135 #endif |
112 |
136 |
113 #ifdef QT_MOBILITY_BEARER_MANAGEMENT |
|
114 setNetworkConnectionManager(new WebNetworkConnectionManager(this)); |
|
115 #endif // QT_MOBILITY_BEARER_MANAGEMENT |
|
116 history()->setMaximumItemCount(historyItemsCount); |
137 history()->setMaximumItemCount(historyItemsCount); |
117 |
|
118 connect(this, |
|
119 SIGNAL(saveFrameStateRequested(QWebFrame*, QWebHistoryItem*)), |
|
120 this, SLOT(savePageDataToHistoryItem(QWebFrame*, QWebHistoryItem*))); |
|
121 |
138 |
122 /* Connect secure related signals and slots */ |
139 /* Connect secure related signals and slots */ |
123 connect(mainFrame(), SIGNAL(urlChanged(QUrl)), d->m_secureController, SLOT(setTopLevelScheme(const QUrl &))); |
140 connect(mainFrame(), SIGNAL(urlChanged(QUrl)), d->m_secureController, SLOT(setTopLevelScheme(const QUrl &))); |
124 connect(this, SIGNAL(loadFinished(bool)), d->m_secureController, SLOT( endSecureCheck(bool) ) ); |
141 connect(this, SIGNAL(loadFinished(bool)), d->m_secureController, SLOT( endSecureCheck(bool) ) ); |
125 connect(d->m_secureController, SIGNAL(pageSecureState(int)), this, SLOT(pageSecureState(int))); |
142 connect(d->m_secureController, SIGNAL(pageSecureState(int)), this, SLOT(pageSecureState(int))); |
128 connect(this, SIGNAL(loadStarted()), d->m_loadController, SLOT(loadStarted())); |
145 connect(this, SIGNAL(loadStarted()), d->m_loadController, SLOT(loadStarted())); |
129 connect(this, SIGNAL(loadProgress(int)), d->m_loadController, SLOT(loadProgress(int))); |
146 connect(this, SIGNAL(loadProgress(int)), d->m_loadController, SLOT(loadProgress(int))); |
130 connect(this, SIGNAL(loadFinished(bool)), d->m_loadController, SLOT(loadFinished(bool))); |
147 connect(this, SIGNAL(loadFinished(bool)), d->m_loadController, SLOT(loadFinished(bool))); |
131 connect(mainFrame(), SIGNAL(urlChanged(QUrl)), d->m_loadController, SLOT(urlChanged(QUrl))); |
148 connect(mainFrame(), SIGNAL(urlChanged(QUrl)), d->m_loadController, SLOT(urlChanged(QUrl))); |
132 |
149 |
133 // All pages in the browser share the same pageGroup. |
|
134 d->m_pageGroupName = "nokia_page_group"; |
|
135 setPageGroupName(d->m_pageGroupName); |
|
136 } |
150 } |
137 |
151 |
138 /*! |
152 /*! |
139 * WrtBrowserContainer destructor |
153 * WrtBrowserContainer destructor |
140 */ |
154 */ |
144 if (!disconnect()) |
158 if (!disconnect()) |
145 qWarning("WrtPage destructor blanket disconnect failed"); |
159 qWarning("WrtPage destructor blanket disconnect failed"); |
146 |
160 |
147 //setNetworkAccessManager(NULL); |
161 //setNetworkAccessManager(NULL); |
148 delete d; |
162 delete d; |
|
163 |
|
164 // |
|
165 QList<QWebHistoryItem> items = history()->items(); |
|
166 |
|
167 for (int i = 0; i < history()->count(); i++) { |
|
168 QWebHistoryItem item = items.at(i); |
|
169 WebPageData* data = (WebPageData*)(item.userData().value<void*>()); |
|
170 if(data){ |
|
171 QVariant variant; |
|
172 item.setUserData(variant); |
|
173 delete data; |
|
174 } |
|
175 } |
149 } |
176 } |
150 |
177 |
151 QGraphicsWidget* WrtBrowserContainer::webWidget() const |
178 QGraphicsWidget* WrtBrowserContainer::webWidget() const |
152 { |
179 { |
153 return d->m_widget; |
180 return d->m_widget; |
154 } |
181 } |
155 |
182 |
156 void WrtBrowserContainer::setWebWidget(QGraphicsWidget* view) |
183 void WrtBrowserContainer::setWebWidget(QGraphicsWidget* view) |
157 { |
184 { |
158 if(d->m_widget) { |
|
159 disconnect(static_cast<WebContentWidget*>(webWidget()), SIGNAL(pageZoomMetaDataChange(QWebFrame*, ZoomMetaData)), this, SLOT(pageZoomMetaDataChange(QWebFrame*, ZoomMetaData))); |
|
160 } |
|
161 |
|
162 d->m_widget = view; |
185 d->m_widget = view; |
163 |
186 |
164 if (view) |
187 if (view) |
165 { |
188 { |
166 QGraphicsWebView* webView = static_cast<QGraphicsWebView*>(view); |
189 QGraphicsWebView* webView = static_cast<QGraphicsWebView*>(view); |
167 if(webView) |
190 if(webView) |
168 webView->setPage(this); |
191 webView->setPage(this); |
169 |
192 |
170 /* Currently connecting it here. Need to revisit if the dialog is enabled in the |
|
171 * context of multiple windows */ |
|
172 connect( d->m_secureController, SIGNAL( showMessageBox(WRT::MessageBoxProxy*)), static_cast<WebContentWidget*>(webWidget())->view(), SLOT( showMessageBox(WRT::MessageBoxProxy*))); |
|
173 |
|
174 connect(static_cast<WebContentWidget*>(webWidget()), SIGNAL(pageZoomMetaDataChange(QWebFrame*, ZoomMetaData)), this, SLOT(pageZoomMetaDataChange(QWebFrame*, ZoomMetaData))); |
|
175 } |
193 } |
176 } |
194 } |
177 |
195 |
178 /*! |
196 /*! |
179 * Handles pageSecureState state |
197 * Handles pageSecureState state |
188 * Returns schemeHandler |
206 * Returns schemeHandler |
189 */ |
207 */ |
190 SchemeHandler* WrtBrowserContainer::schemeHandler() const |
208 SchemeHandler* WrtBrowserContainer::schemeHandler() const |
191 { |
209 { |
192 return d->m_schemeHandler; |
210 return d->m_schemeHandler; |
193 } |
|
194 |
|
195 /*! |
|
196 * Gets the history count for this page, i.e gets the number of urls loaded |
|
197 * onto this page |
|
198 * @return History count of this page |
|
199 */ |
|
200 int WrtBrowserContainer::getHistoryCount() const |
|
201 { |
|
202 return history()->count(); |
|
203 } |
|
204 |
|
205 /*! |
|
206 * Triggers public Action |
|
207 * @param WebAction : web action to be triggred |
|
208 * @param checked : true/false |
|
209 * @see WebAction |
|
210 */ |
|
211 /*void WrtBrowserContainer::triggerAction(QWebPage::WebAction action, bool checked) |
|
212 { |
|
213 triggerAction(action, checked); |
|
214 } |
|
215 */ |
|
216 |
|
217 /*! |
|
218 * clears cookies |
|
219 */ |
|
220 void WrtBrowserContainer::clearCookies() |
|
221 { |
|
222 return ((CookieJar*) networkAccessManager()->cookieJar())->clear(); |
|
223 } |
|
224 |
|
225 bool WrtBrowserContainer::clearNetworkCache() |
|
226 { |
|
227 bool ok = false; |
|
228 QAbstractNetworkCache* diskCache = networkAccessManager()->cache(); |
|
229 diskCache->clear(); |
|
230 if (!diskCache->cacheSize()) { |
|
231 // Unless there was failures clearing the cache cacheSize() should return 0 after a call to clear |
|
232 ok = true; |
|
233 } |
|
234 return ok; |
|
235 } |
211 } |
236 |
212 |
237 /*! |
213 /*! |
238 * This function page thumbnail for this page as specified by X & Y co-ordinate scale factors |
214 * This function page thumbnail for this page as specified by X & Y co-ordinate scale factors |
239 * @param scaleX : X Co-ordinate scale factor for the page thumbnail |
215 * @param scaleX : X Co-ordinate scale factor for the page thumbnail |
251 painter.save(); |
227 painter.save(); |
252 painter.setBrush(Qt::white); |
228 painter.setBrush(Qt::white); |
253 painter.drawRect(r); |
229 painter.drawRect(r); |
254 painter.restore(); |
230 painter.restore(); |
255 mainFrame()->render(&painter, clip); |
231 mainFrame()->render(&painter, clip); |
256 return image; |
232 QImage thumbnail = image.scaled(scaleX * size.width(), scaleY * size.height()); |
257 } |
233 return thumbnail; |
258 |
234 } |
259 /*! |
|
260 * sets the page zoom factor as specified by zoom |
|
261 * @param zoom : page zoom factor to be set |
|
262 */ |
|
263 void WrtBrowserContainer::setPageZoomFactor(qreal zoom) |
|
264 { |
|
265 // FiX ME ... canvas zoom doesn't seem to support text-only zooming. |
|
266 //static_cast<WebCanvasWidget*>(webWidget())->canvas()->setPageZoomFactor(zoom); |
|
267 |
|
268 bool isZoomTextOnly = BEDROCK_PROVISIONING::BedrockProvisioning::createBedrockProvisioning()->value( |
|
269 "ZoomTextOnly").toBool(); |
|
270 |
|
271 if (!isZoomTextOnly) |
|
272 { |
|
273 // mainFrame()->setZoomFactor(zoom); |
|
274 static_cast<WebContentWidget*> (webWidget())->setZoomFactor(zoom); |
|
275 } |
|
276 else |
|
277 { |
|
278 //mainFrame()->setTextSizeMultiplier(zoom); |
|
279 static_cast<WebContentWidget*> (webWidget())->setTextSizeMultiplier( |
|
280 zoom); |
|
281 } |
|
282 } |
|
283 |
|
284 /*! |
|
285 * setpageDirtyZoomFactor |
|
286 * @param zoom: page zoom factor to be set |
|
287 */ |
|
288 void WrtBrowserContainer::setPageDirtyZoomFactor(qreal zoom) |
|
289 { |
|
290 // FIXME: dirty page zoom is not supported yet in single-buffer mode. |
|
291 static_cast<WebContentWidget*> (webWidget())->setDirtyZoomFactor(zoom); |
|
292 } |
|
293 |
|
294 /*! |
|
295 * setpageCenterZoomFactor |
|
296 * @param zoom: center page zoom factor to be set |
|
297 */ |
|
298 // TODO: hold on this change until zoom/scrolling improvement |
|
299 /* |
|
300 void WrtBrowserContainer::setPageCenterZoomFactor(qreal zoom) |
|
301 { |
|
302 static_cast<WebCanvasWidget*>(webWidget())->canvas()->setPageCenterZoomFactor(zoom); |
|
303 } |
|
304 */ |
|
305 /*! |
|
306 * returns the current page zoom factor of this page |
|
307 * @return current zoom factor |
|
308 */ |
|
309 qreal WrtBrowserContainer::pageZoomFactor() const |
|
310 { |
|
311 return static_cast<WebContentWidget*> (webWidget())->zoomFactor(); |
|
312 } |
|
313 |
|
314 /*! |
|
315 * sets the Canvas ScaleFactor for this page |
|
316 * @param scaleX : X Co-ordinate scale factor |
|
317 * @param scaleY : Y Co-ordinate scale factor |
|
318 */ |
|
319 void WrtBrowserContainer::setCanvasScaleFactor(qreal scaleX, qreal scaleY) |
|
320 { |
|
321 QTransform transform; |
|
322 transform.scale(scaleX, scaleY); |
|
323 // static_cast<ContentView*>(webWidget())->setTransform(transform); |
|
324 } |
|
325 |
|
326 /*! |
|
327 * allows offlineStorage for url |
|
328 * @param url : url for which offlinestorage has to be enabled |
|
329 */ |
|
330 bool WrtBrowserContainer::allowOfflineStorage(const QUrl& url) |
|
331 { |
|
332 if (BEDROCK_PROVISIONING::BedrockProvisioning::createBedrockProvisioning()->value("SecurityLevel").toInt() |
|
333 != SecurityHigh) |
|
334 return true; |
|
335 |
|
336 QStringList yesno; |
|
337 yesno << "Yes" << "No"; |
|
338 return (WebDialogProvider::getButtonResponse( |
|
339 0, /* webWidget(), Check, that widget is required */ |
|
340 QString( |
|
341 "Offline Database: This host asking for storing data in offline database, allow?"), |
|
342 yesno)); |
|
343 } |
|
344 |
|
345 |
235 |
346 /*! |
236 /*! |
347 Pulic Slots: |
237 Pulic Slots: |
348 void savePageDataToHistoryItem(QWebFrame*, QWebHistoryItem* item); |
238 void savePageDataToHistoryItem(QWebFrame*, QWebHistoryItem* item); |
349 void slotAuthenticationRequired(QNetworkReply *, QAuthenticator *); |
239 void slotAuthenticationRequired(QNetworkReply *, QAuthenticator *); |
365 } |
255 } |
366 if (restoreSession()) return; |
256 if (restoreSession()) return; |
367 |
257 |
368 WebPageData data(this); |
258 WebPageData data(this); |
369 // WebPageData data = item->userData().value<WebPageData>(); |
259 // WebPageData data = item->userData().value<WebPageData>(); |
370 data.m_zoomFactor = pageZoomFactor(); |
260 data.m_zoomFactor = 1.0; // Need to find a way to get this. Not used right now anyway |
371 data.m_thumbnail = pageThumbnail(1.0, 1.0);//data.m_zoomFactor, data.m_zoomFactor); |
261 data.m_thumbnail = pageThumbnail(0.5, 0.5);//data.m_zoomFactor, data.m_zoomFactor); |
372 |
262 |
373 QPoint pos(0, 0); |
263 QPoint pos(0, 0); |
374 // pos = static_cast<WebCanvasWidget*>(webWidget())->canvas()->canvasToDocument(pos); |
264 // pos = static_cast<WebCanvasWidget*>(webWidget())->canvas()->canvasToDocument(pos); |
375 pos = mainFrame()->scrollPosition(); |
265 pos = mainFrame()->scrollPosition(); |
376 data.m_contentsPos = pos; |
266 data.m_contentsPos = pos; |
411 authenticator->setUser(username); |
301 authenticator->setUser(username); |
412 authenticator->setPassword(password); |
302 authenticator->setPassword(password); |
413 } |
303 } |
414 } |
304 } |
415 |
305 |
416 QWebPage* WrtBrowserContainer::createWindow( |
|
417 QWebPage::WebWindowType webWindowType) |
|
418 { |
|
419 |
|
420 /* When WrtPage is created, QWebSettings::JavascriptCanOpenWindows is initialized |
|
421 * to popup setting value. Need not do any check here |
|
422 */ |
|
423 if (d->m_pageFactory) |
|
424 { |
|
425 // no need to signal in this case |
|
426 return d->m_pageFactory->openPage(); |
|
427 } |
|
428 |
|
429 WrtBrowserContainer* wrtPage = new WrtBrowserContainer(); |
|
430 emit createNewWindow(wrtPage); |
|
431 return wrtPage; |
|
432 } |
|
433 |
|
434 void WrtBrowserContainer::setPageFactory(BrowserPageFactory* f) |
306 void WrtBrowserContainer::setPageFactory(BrowserPageFactory* f) |
435 { |
307 { |
436 d->m_pageFactory = f; |
308 d->m_pageFactory = f; |
437 } |
|
438 |
|
439 void WrtBrowserContainer::setElementType( |
|
440 wrtBrowserDefs::BrowserElementType& aElType) |
|
441 { |
|
442 m_elementType = aElType; |
|
443 } |
|
444 wrtBrowserDefs::BrowserElementType WrtBrowserContainer::getElementType() |
|
445 { |
|
446 return m_elementType; |
|
447 } |
309 } |
448 |
310 |
449 QString WrtBrowserContainer::pageTitle(){ |
311 QString WrtBrowserContainer::pageTitle(){ |
450 |
312 |
451 QString title = mainFrame()->title(); |
313 QString title = mainFrame()->title(); |
493 result = true; |
355 result = true; |
494 |
356 |
495 return result; |
357 return result; |
496 } |
358 } |
497 |
359 |
498 void WrtBrowserContainer::pageZoomMetaDataChange(QWebFrame* frame, ZoomMetaData zoomData ){ |
|
499 |
|
500 //qDebug() << __func__ << "Frame " << frame << "My Frame " << mainFrame(); |
|
501 if (frame == mainFrame()) { |
|
502 setPageZoomMetaData(zoomData); |
|
503 } |
|
504 } |
|
505 |
|
506 ZoomMetaData WrtBrowserContainer::pageZoomMetaData() { |
360 ZoomMetaData WrtBrowserContainer::pageZoomMetaData() { |
507 return d->m_zoomData ; |
361 return d->m_zoomData ; |
508 |
362 |
509 } |
363 } |
510 void WrtBrowserContainer::setPageZoomMetaData( ZoomMetaData zoomData ){ |
364 void WrtBrowserContainer::setPageZoomMetaData( ZoomMetaData zoomData ){ |
511 |
365 |
512 d->m_zoomData = zoomData; |
366 d->m_zoomData = zoomData; |
513 } |
367 } |
514 |
368 |
515 |
369 |
516 } |
370 WrtBrowserFileChooser::~WrtBrowserFileChooser() |
517 |
371 {} |
518 |
372 |
|
373 void WrtBrowserContainer::setFileChooser(WrtBrowserFileChooser * chooser) |
|
374 { |
|
375 if (d->m_fileChooser) { |
|
376 delete d->m_fileChooser; |
|
377 } |
|
378 |
|
379 d->m_fileChooser = chooser; |
|
380 } |
|
381 |
|
382 QString WrtBrowserContainer::chooseFile(QWebFrame * parentFrame, const QString & suggestedFile) |
|
383 { |
|
384 if (d->m_fileChooser != 0) { |
|
385 return d->m_fileChooser->chooseFile(parentFrame, suggestedFile); |
|
386 } |
|
387 |
|
388 return QWebPage::chooseFile(parentFrame, suggestedFile); |
|
389 } |
|
390 |
|
391 QString WrtBrowserContainer::userAgentForUrl(const QUrl& url) const |
|
392 { |
|
393 QString uaString = BEDROCK_PROVISIONING::BedrockProvisioning::createBedrockProvisioning()->valueAsString("UserAgentString"); |
|
394 |
|
395 if (uaString.isEmpty()) |
|
396 { |
|
397 QUrl url; |
|
398 return QWebPage::userAgentForUrl(url); |
|
399 } |
|
400 else |
|
401 return uaString; |
|
402 } |
|
403 |
|
404 WRT::WrtBrowserContainer* WrtBrowserContainer::createWindow( |
|
405 QWebPage::WebWindowType webWindowType) |
|
406 { |
|
407 |
|
408 /* When WrtPage is created, QWebSettings::JavascriptCanOpenWindows is initialized |
|
409 * to popup setting value. Need not do any check here |
|
410 */ |
|
411 if (d->m_pageFactory) |
|
412 { |
|
413 // no need to signal in this case |
|
414 return d->m_pageFactory->openPage(); |
|
415 } |
|
416 |
|
417 WrtBrowserContainer* wrtPage = new WrtBrowserContainer(); |
|
418 emit createNewWindow(wrtPage); |
|
419 return wrtPage; |
|
420 } |
|
421 |
|
422 |
|
423 } // namespace WRT |
|
424 |