107 }; |
110 }; |
108 |
111 |
109 static BrowserProxyFactory proxies; |
112 static BrowserProxyFactory proxies; |
110 #endif //NO_NETWORK_ACCESS_MANAGER |
113 #endif //NO_NETWORK_ACCESS_MANAGER |
111 |
114 |
112 #ifdef ENABLE_PERF_TRACE |
115 #ifdef ORBIT_UI |
113 WrtPerfTracer* perfTracer = 0; |
116 #include <hbapplication.h> |
114 #endif |
117 #endif // ORBIT_UI |
|
118 |
|
119 #ifdef OPENURL |
|
120 #include "BrowserMainS60.h" |
|
121 |
|
122 static CApaApplication *AppFactoryL() |
|
123 { |
|
124 return(&CBrowserMainAppSingleton::Instance()); |
|
125 } |
|
126 #endif // OPENURL |
|
127 |
|
128 |
|
129 static void configureHtml5OfflineStorage() |
|
130 { |
|
131 BEDROCK_PROVISIONING::BedrockProvisioning * provisioning = |
|
132 BEDROCK_PROVISIONING::BedrockProvisioning::createBedrockProvisioning(); |
|
133 |
|
134 QWebSettings * globalSettings = QWebSettings::globalSettings(); |
|
135 |
|
136 // Enable all kinds of persistent storage, then fine-tune using |
|
137 // bedrock provisioning attributes. |
|
138 |
|
139 QWebSettings::enablePersistentStorage(); |
|
140 |
|
141 // Local and database storage (using the global javascript localStorage |
|
142 // and openDatabase items) is shared across pages and browser invocations, |
|
143 // but it tied to the domain of the page in which the javascript code is |
|
144 // running. This allows webpages hosted at, say, cnn.com to store data |
|
145 // using the same keys as webpages hosted at bbc.co.uk without conflict. |
|
146 // |
|
147 // Note that local and database storage is persisted in directories |
|
148 // beneath the application's private directory, so it is not shared |
|
149 // with other browsers. |
|
150 |
|
151 bool localStorageEnabled = |
|
152 provisioning->valueAsInt("Html5LocalStorage") != 0; |
|
153 |
|
154 bool databaseStorageEnabled = |
|
155 provisioning->valueAsInt("Html5DatabaseStorage") != 0; |
|
156 |
|
157 globalSettings->setAttribute( |
|
158 QWebSettings::LocalStorageEnabled, |
|
159 localStorageEnabled); |
|
160 |
|
161 globalSettings->setAttribute( |
|
162 QWebSettings::OfflineStorageDatabaseEnabled, |
|
163 databaseStorageEnabled); |
|
164 |
|
165 // There is no separate QWebSettings method to configure |
|
166 // the default quota for local storage databases. |
|
167 // It appears that both local storage and database storage |
|
168 // use the same default quota. |
|
169 |
|
170 if (localStorageEnabled || databaseStorageEnabled) { |
|
171 globalSettings->setOfflineStorageDefaultQuota( |
|
172 provisioning->valueAsInt64("Html5DatabaseStorageMaxSize")); |
|
173 } |
|
174 |
|
175 // The application cache allows websites to specify a manifest file in |
|
176 // the outermost <html> element. The manifest file defines which files |
|
177 // may be stored at the client and used when the network is inaccessible. |
|
178 // |
|
179 // Webkit stores the application cache in a single SQLite database |
|
180 // named ApplicationCache.db. By default this database is located |
|
181 // in the application's private directory, so it is not shared with |
|
182 // other browsers. |
|
183 |
|
184 bool applicationCacheEnabled = |
|
185 provisioning->valueAsInt("Html5ApplicationCache") != 0; |
|
186 |
|
187 globalSettings->setAttribute( |
|
188 QWebSettings::OfflineWebApplicationCacheEnabled, |
|
189 applicationCacheEnabled); |
|
190 |
|
191 if (applicationCacheEnabled) { |
|
192 globalSettings->setOfflineWebApplicationCacheQuota( |
|
193 provisioning->valueAsInt64("Html5ApplicationCacheMaxSize")); |
|
194 } |
|
195 } |
|
196 |
115 |
197 |
116 int main(int argc, char * argv[]) |
198 int main(int argc, char * argv[]) |
117 { |
199 { |
118 #ifdef NO_NETWORK_ACCESS_MANAGER |
200 #ifdef NO_NETWORK_ACCESS_MANAGER |
119 QNetworkProxyFactory::setApplicationProxyFactory(&proxies); |
201 QNetworkProxyFactory::setApplicationProxyFactory(&proxies); |
120 #endif //NO_NETWORK_ACCESS_MANAGER |
202 #endif //NO_NETWORK_ACCESS_MANAGER |
121 int res=0; |
203 int res=0; |
122 |
204 |
123 #ifdef HARDWARE_DEBUG_TRACE |
205 #ifdef HARDWARE_DEBUG_TRACE |
124 initDebugOutput(); |
206 initDebugOutput(); |
125 qInstallMsgHandler(debugOutput); |
207 qInstallMsgHandler(debugOutput); |
126 #endif |
208 #endif |
127 |
209 |
|
210 // qDebug() << "main - before app, argc=" << argc; |
|
211 // for (int i = 0; i < argc; ++i) |
|
212 // { |
|
213 // qDebug() << "main - argv[" << i << "] = " << argv[i]; |
|
214 // } |
|
215 |
|
216 /* openurl should only work in Orbit UI application. */ |
|
217 #ifdef ORBIT_UI |
|
218 #ifdef OPENURL |
|
219 #ifdef NO_QSTM_GESTURE |
|
220 HbApplication app(AppFactoryL, argc, argv); |
|
221 #else |
|
222 BrowserApp app(AppFactoryL, argc, argv); |
|
223 #endif |
|
224 #else /* !OPENURL */ |
|
225 #ifdef NO_QSTM_GESTURE |
|
226 HbApplication app(argc, argv); |
|
227 #else // ORBIT_UI |
|
228 BrowserApp app(argc, argv); |
|
229 #endif |
|
230 #endif /* OPENURL */ |
|
231 #else |
128 #ifdef NO_QSTM_GESTURE |
232 #ifdef NO_QSTM_GESTURE |
129 QApplication app(argc, argv); |
233 QApplication app(argc, argv); |
130 #else |
234 #else |
131 BrowserApp app(argc, argv); |
235 BrowserApp app(argc, argv); |
132 #endif |
236 #endif |
133 |
237 #endif // ORBIT_UI |
|
238 |
|
239 // qDebug() << "main - after app"; |
134 #ifdef Q_OS_SYMBIAN |
240 #ifdef Q_OS_SYMBIAN |
135 //Object cache settings. NB: these need to be tuned per device |
241 //Object cache settings. NB: these need to be tuned per device |
136 QWebSettings::globalSettings()->setObjectCacheCapacities(128*1024, 1024*1024, 1024*1024); |
242 QWebSettings::globalSettings()->setObjectCacheCapacities(128*1024, 1024*1024, 1024*1024); |
137 #endif |
243 #endif |
|
244 |
|
245 if (BEDROCK_PROVISIONING::BedrockProvisioning::createBedrockProvisioning()->value("DnsPrefetchEnabled").toBool()) |
|
246 { |
|
247 // Specifies whether QtWebkit will try to pre-fetch DNS entries to speed up browsing. |
|
248 // Without this technique, the DNS lookup is performed only when you click on the link, |
|
249 // adding a wait of 250ms (on average) before the page even starts to show up. |
|
250 // This only works as a global attribute. |
|
251 QWebSettings::globalSettings()->setAttribute(QWebSettings::DnsPrefetchEnabled, true); |
|
252 } |
|
253 |
|
254 configureHtml5OfflineStorage(); |
138 |
255 |
139 QString lang = QLocale::system().name(); |
256 QString lang = QLocale::system().name(); |
140 |
257 |
141 //install the common translator from platform |
258 //install the common translator from platform |
142 QTranslator common; |
259 QTranslator common; |
143 common.load(":/resource/qt/translations/common_" + lang); |
260 common.load(":/resource/qt/translations/common_" + lang); |
144 QApplication::installTranslator(&common); |
261 QApplication::installTranslator(&common); |
145 |
262 |
146 |
263 |
147 //install the translator from Browser |
264 //install the translator from Browser |
148 QTranslator translator; |
265 QTranslator translator; |
149 QString transFilePath = ":/translations"; |
266 QString transFilePath = ":/translations"; |
150 //Todo: when platform delivers .ts file |
267 //Todo: when platform delivers .ts file |
151 //QString transFilePath = "Z:/resource/qt/translations/"; |
268 //QString transFilePath = "Z:/resource/qt/translations/"; |
152 QString transFile = QLatin1String("browserLoc_") + lang; |
269 QString transFile = QLatin1String("browserLoc_") + lang; |
153 translator.load(transFile, transFilePath); |
270 translator.load(transFile, transFilePath); |
154 QApplication::installTranslator(&translator); |
271 QApplication::installTranslator(&translator); |
|
272 |
|
273 // To make the native urlsearch bar selection visible, the following lines have to be removed |
|
274 // The keypad navigation still works for ginebra2 even without enabling keypad navigation |
|
275 /* |
155 #ifdef Q_OS_SYMBIAN |
276 #ifdef Q_OS_SYMBIAN |
156 QApplication::setKeypadNavigationEnabled(true); |
277 QApplication::setKeypadNavigationEnabled(true); |
157 #endif |
278 #endif |
|
279 */ |
|
280 #ifdef OPENURL |
|
281 // Handle QDesktopServices.openUrl (when browser wasn't already running) |
|
282 QString url = CBrowserMainAppSingleton::Instance().InitialUrl(); |
|
283 GinebraBrowser * browser = new GinebraBrowser(0, &url); // Pass the initial url so it will be loaded as soon as the browser chrome finishes |
|
284 // Set things up to handle QDesktopServices.openUrl calls when browser is already running |
|
285 CBrowserMainAppSingleton::Instance().setUrlHandler(browser); |
|
286 #else |
158 GinebraBrowser * browser = new GinebraBrowser(); |
287 GinebraBrowser * browser = new GinebraBrowser(); |
|
288 #endif |
|
289 |
159 |
290 |
160 #ifdef ENABLE_PERF_TRACE |
291 #ifdef ENABLE_PERF_TRACE |
161 g_wrtPerfTracing = new WrtPerfTracer(0); |
292 #if defined(NO_NETWORK_ACCESS_MANAGER) |
|
293 PERF_TRACE_OUT() << "NO_NETWORK_ACCESS_MANAGER\n"; |
|
294 #endif |
|
295 #if defined(NO_RESIZE_ON_LOAD) |
|
296 PERF_TRACE_OUT() << "NO_RESIZE_ON_LOAD\n"; |
|
297 #endif |
|
298 #if defined(NO_QSTM_GESTURE) |
|
299 PERF_TRACE_OUT() << "NO_QSTM_GESTURE\n"; |
|
300 #endif |
|
301 #if defined(__gva_no_chrome__) |
|
302 PERF_TRACE_OUT() << "__gva_no_chrome__\n"; |
|
303 #endif |
|
304 #if defined(SET_DEFAULT_IAP) |
|
305 PERF_TRACE_OUT() << "SET_DEFAULT_IAP\n"; |
|
306 #endif |
|
307 #if defined(NO_HISTORY) |
|
308 PERF_TRACE_OUT() << "NO_HISTORY\n"; |
|
309 #endif |
|
310 |
162 #endif //ENABLE_PERF_TRACE |
311 #endif //ENABLE_PERF_TRACE |
163 |
312 |
164 browser->show(); |
313 browser->show(); |
165 res = app.exec(); |
314 res = app.exec(); |
166 delete browser; |
315 delete browser; |
167 |
316 |
168 #ifdef ENABLE_PERF_TRACE |
317 #ifdef ENABLE_PERF_TRACE |
169 // delete g_wrtPerfTracing instance |
318 WrtPerfTracer::tracer()->close(); |
170 if (g_wrtPerfTracing) { |
|
171 g_wrtPerfTracing->close(); |
|
172 delete g_wrtPerfTracing; |
|
173 } |
|
174 #endif //ENABLE_PERF_TRACE |
319 #endif //ENABLE_PERF_TRACE |
175 |
320 |
176 return res; |
321 return res; |
177 } |
322 } |