CLOSED FIXED Bug 36451
[Qt] User Agent Switcher on QtLauncher
https://bugs.webkit.org/show_bug.cgi?id=36451
Summary [Qt] User Agent Switcher on QtLauncher
Diego Gonzalez
Reported 2010-03-22 10:23:42 PDT
Make possible QtLauncher access pages that restrict access based on the browser being used and/or simply test the browser with different user agents.
Attachments
user agent dialog (249.17 KB, image/png)
2010-03-22 10:29 PDT, Diego Gonzalez
no flags
user agents predefined list (212.97 KB, image/png)
2010-03-22 10:32 PDT, Diego Gonzalez
no flags
edit manually the user agent string (245.22 KB, image/png)
2010-03-22 10:35 PDT, Diego Gonzalez
no flags
Proposed patch (6.07 KB, patch)
2010-03-22 10:58 PDT, Diego Gonzalez
hausmann: review-
Proposed patch (6.95 KB, patch)
2010-03-23 11:31 PDT, Diego Gonzalez
no flags
Proposed patch (6.48 KB, patch)
2010-03-24 10:23 PDT, Diego Gonzalez
hausmann: review+
Safari Develop->User Agent menu (45.08 KB, image/png)
2010-03-24 14:37 PDT, Daniel Bates
no flags
Safari Develop->User Agent->Other (20.74 KB, image/png)
2010-03-24 14:39 PDT, Daniel Bates
no flags
Diego Gonzalez
Comment 1 2010-03-22 10:29:26 PDT
Created attachment 51302 [details] user agent dialog
Diego Gonzalez
Comment 2 2010-03-22 10:32:08 PDT
Created attachment 51303 [details] user agents predefined list
Diego Gonzalez
Comment 3 2010-03-22 10:35:02 PDT
Created attachment 51304 [details] edit manually the user agent string If the edited string is not in the user agents list it will be stored
Diego Gonzalez
Comment 4 2010-03-22 10:58:04 PDT
Created attachment 51309 [details] Proposed patch
Simon Hausmann
Comment 5 2010-03-22 14:37:25 PDT
Comment on attachment 51309 [details] Proposed patch > +void LauncherWindow::showUserAgentDialog() > +{ > + QFile file("WebKitTools/QtLauncher/useragentlist.txt"); Instead of requiring that QtLauncher is started from the top-level directory by using a relative path here, I think it would be better to compile the user agent list into the application using a Qt resource. > + , m_userAgent(QString()) This initialization isn't necessary. > + void setUserAgent(QString ua) { m_userAgent = ua; } The parameter should be a const QString&. r- until the above issues are addressed. The rest looks good to me! It's great that you're adding this, it really helps for development/testing.
Diego Gonzalez
Comment 6 2010-03-22 16:28:45 PDT
(In reply to comment #5) > (From update of attachment 51309 [details]) > > > +void LauncherWindow::showUserAgentDialog() > > +{ > > + QFile file("WebKitTools/QtLauncher/useragentlist.txt"); > > Instead of requiring that QtLauncher is started from the top-level directory by > using a relative path here, I think it would be better to compile the user > agent list > into the application using a Qt resource. > Thanks for the feedback Simon! Using Qt resource is a good way if I want to only read the data from useragentlist.txt, because afaik we only can open it in ReadOnly mode, so is not possible to store a new user agent in useragentlist at runtime and is needed to recompile if we want the edit the list manually. Do you know if is possible do it usinf Qt Resource or do you have other suggestion? :)
Diego Gonzalez
Comment 7 2010-03-23 11:31:35 PDT
Created attachment 51440 [details] Proposed patch Changed according Simon's suggestions
Diego Gonzalez
Comment 8 2010-03-23 11:32:57 PDT
> Using Qt resource is a good way if I want to only read the data from > useragentlist.txt, because afaik we only can open it in ReadOnly mode, so is > not possible to store a new user agent in useragentlist at runtime and is > needed to recompile if we want the edit the list manually. Do you know if is > possible do it usinf Qt Resource or do you have other suggestion? :) I am using now QSettings to store and keep the data persistence :)
Diego Gonzalez
Comment 9 2010-03-24 10:23:57 PDT
Created attachment 51518 [details] Proposed patch Simplifying the patch to only read and show the user agents from the predefined list for this moment.
Daniel Bates
Comment 10 2010-03-24 14:37:00 PDT
Created attachment 51541 [details] Safari Develop->User Agent menu Instead of a combined list and (custom user agent text field)?, I would suggest that we add the sub-menu User Agent to the Develop menu in QtLauncher and that it has at least the same options and behavior as the identical menu found in Safari. This will make QtLauncher consistent with Safari. Notice, the last option in the Safari User Agent menu is "Other..." which opens a dialog with an text field that is initially populated with the value of the currently active user agent string.
Daniel Bates
Comment 11 2010-03-24 14:39:06 PDT
Created attachment 51542 [details] Safari Develop->User Agent->Other
Diego Gonzalez
Comment 12 2010-03-24 15:28:47 PDT
(In reply to comment #10) > Created an attachment (id=51541) [details] > Safari Develop->User Agent menu > > Instead of a combined list and (custom user agent text field)?, I would suggest > that we add the sub-menu User Agent to the Develop menu in QtLauncher and that > it has at least the same options and behavior as the identical menu found in > Safari. This will make QtLauncher consistent with Safari. Notice, the last > option in the Safari User Agent menu is "Other..." which opens a dialog with an > text field that is initially populated with the value of the currently active > user agent string. I thing it can be considered. Kenneth? Simon?
Kenneth Rohde Christiansen
Comment 13 2010-03-24 15:30:20 PDT
Sounds fine with me!
Simon Hausmann
Comment 14 2010-03-25 15:41:47 PDT
Absolutely! :) Please create a new bugzilla entry for the custom UA entry
Simon Hausmann
Comment 15 2010-03-25 15:46:18 PDT
Comment on attachment 51518 [details] Proposed patch > +void LauncherWindow::showUserAgentDialog() > +{ > + QStringList items; > + QFile file(":/useragentlist.txt"); > + if (file.open(QIODevice::ReadOnly)) { > + while (!file.atEnd()) > + items << file.readLine().trimmed(); > + file.close(); > + } > + > + QDialog* dialog = new QDialog(this); > + dialog->setWindowTitle("Change User Agent"); > + > + QVBoxLayout* layout = new QVBoxLayout(dialog); > + dialog->setLayout(layout); > + > + QComboBox* combo = new QComboBox(dialog); > + combo->setMaximumWidth(size().width() * 0.7); > + combo->insertItems(0, items); > + layout->addWidget(combo); > + > + QDialogButtonBox* buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok > + | QDialogButtonBox::Cancel, Qt::Horizontal, dialog); > + connect(buttonBox, SIGNAL(accepted()), dialog, SLOT(accept())); > + connect(buttonBox, SIGNAL(rejected()), dialog, SLOT(reject())); > + layout->addWidget(buttonBox); > + > + if (dialog->exec() && !combo->currentText().isEmpty()) > + page()->setUserAgent(combo->currentText()); > +} > + Please delete the dialog object after use. Otherwise r=me :)
Diego Gonzalez
Comment 16 2010-03-26 13:01:13 PDT
Landed by tonikitoo at r56636 > Please delete the dialog object after use. > > Otherwise r=me :)
Simon Hausmann
Comment 17 2010-03-28 14:46:46 PDT
cherry-pick-for-backport: <r56636>
Simon Hausmann
Comment 18 2010-03-28 14:48:55 PDT
Revision r56636 cherry-picked into qtwebkit-2.0 with commit 0b6b1ebafb42ed11323faf42afb5eaa4b2ef1df1
Note You need to log in before you can comment on or make changes to this bug.