diff --git a/.gitignore b/.gitignore index 67a9d4d04c1d1f999d42630cd2c0286434d5c809..9f362ff0fe8e3e81bf95b8103dfc06b054415ff9 100644 --- a/.gitignore +++ b/.gitignore @@ -9,7 +9,6 @@ src/core/api/Release src/core/api/Debug src/core/core_generated.gyp src/core/gypfiles -src/core/qmake_extras.gypi examples/webengine/quicknanobrowser/quicknanobrowser examples/webengine/quicknanobrowser/quicknanobrowser.app examples/webenginewidgets/browser/browser diff --git a/LICENSE.GPLv3 b/LICENSE.GPLv3 new file mode 100644 index 0000000000000000000000000000000000000000..4e49b122ae13285f9e398495ec04c1c786cddd63 --- /dev/null +++ b/LICENSE.GPLv3 @@ -0,0 +1,686 @@ + GNU GENERAL PUBLIC LICENSE + + The Qt Toolkit is Copyright (C) 2015 The Qt Company Ltd. + Contact: http://www.qt.io/licensing/ + + You may use, distribute and copy the Qt GUI Toolkit under the terms of + GNU Lesser General Public License version 3. That license references + the General Public License version 3, that is displayed below. Other + portions of the Qt Toolkit may be licensed directly under this license. + +------------------------------------------------------------------------- + + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/> + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + <one line to give the program's name and a brief idea of what it does.> + Copyright (C) <year> <name of author> + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + <program> Copyright (C) <year> <name of author> + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +<http://www.gnu.org/licenses/>. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +<http://www.gnu.org/philosophy/why-not-lgpl.html>. diff --git a/LICENSE.LGPLv3 b/LICENSE.LGPLv3 index 65c5ca88a67c30becee01c5a8816d964b03862f9..26d0bf16f0aa49767f94f22aa1fe6bd21dbcc740 100644 --- a/LICENSE.LGPLv3 +++ b/LICENSE.LGPLv3 @@ -1,3 +1,15 @@ + GNU LESSER GENERAL PUBLIC LICENSE + + The Qt Toolkit is Copyright (C) 2015 The Qt Company Ltd. + Contact: http://www.qt.io/licensing/ + + You may use, distribute and copy the Qt GUI Toolkit under the terms of + GNU Lesser General Public License version 3, which is displayed below. + This license makes reference to the version 3 of the GNU General + Public License, which you can find in the LICENSE.GPLv3 file. + +------------------------------------------------------------------------- + GNU LESSER GENERAL PUBLIC LICENSE Version 3, 29 June 2007 diff --git a/dist/changes-5.5.1 b/dist/changes-5.5.1 new file mode 100644 index 0000000000000000000000000000000000000000..550115008c8a9d92d6f5338fc335ddd449a6fda1 --- /dev/null +++ b/dist/changes-5.5.1 @@ -0,0 +1,47 @@ +Qt 5.5.1 is a bug-fix release. It maintains both forward and backward +compatibility (source and binary) with Qt 5.5.0. + +Qt 5.5 introduces many new features and improvements as well as bugfixes +over the 5.4.x series. For more details, refer to the online documentation +included in this distribution. The documentation is also available online: + + http://doc.qt.io/qt-5/index.html + +The Qt version 5.5 series is binary compatible with the 5.4.x series. +Applications compiled for 5.4 will continue to run with 5.5. + +Some of the changes listed in this file include issue tracking numbers +corresponding to tasks in the Qt Bug Tracker: + + https://bugreports.qt.io/ + +Each of these identifiers can be entered in the bug tracker to obtain more +information about a particular change. + +**************************************************************************** +* General * +**************************************************************************** + +QtWebEngineCore +-------- + - Security fixes + * ICU: CVE-2014-8146, CVE-2014-8147 + * Blink: CVE-2015-1284, CVE-2015-1291, CVE-2015-1292 + * Skia: CVE-2015-1294 + * V8: CVE-2015-1290 + - [QTBUG-47945, QTBUG-48088] Fixed crashes and asserts on exit + + +**************************************************************************** +* Platform Specific Changes * +**************************************************************************** + +Linux +----- + - [QTBUG-47301] Fixed crash on XCB GLES2 and Wayland + - [QTBUG-45801] Find libEGL and libEGLES2v2 without development packages + +Windows +------- + - [QTBUG-44763] Fix slow proxy resolution with multiple network interfaces + - [QTBUG-47129] Make QtWebEngineProcess use full 4GB memory on 32-bit diff --git a/examples/examples.pro b/examples/examples.pro index 3d6872d554a13fa2d72f4d20e368d8d001bcd3a0..8345fded6643210eb42c1a2f3dd5ac7b4201a087 100644 --- a/examples/examples.pro +++ b/examples/examples.pro @@ -6,6 +6,6 @@ qtHaveModule(webengine) { qtHaveModule(webenginewidgets) { SUBDIRS += \ - webenginewidgets/browser \ + webenginewidgets/demobrowser \ webenginewidgets/fancybrowser } diff --git a/examples/webengine/quicknanobrowser/BrowserWindow.qml b/examples/webengine/quicknanobrowser/BrowserWindow.qml index bdee68d17482cf573681ff014ed3222fb26c5491..4d7513fae98c612056bc96eae244f7a4f33460c7 100644 --- a/examples/webengine/quicknanobrowser/BrowserWindow.qml +++ b/examples/webengine/quicknanobrowser/BrowserWindow.qml @@ -393,6 +393,35 @@ ApplicationWindow { } request.accept() } + + onRenderProcessTerminated: { + var status = "" + switch (terminationStatus) { + case WebEngineView.NormalTerminationStatus: + status = "(normal exit)" + break; + case WebEngineView.AbnormalTerminationStatus: + status = "(abnormal exit)" + break; + case WebEngineView.CrashedTerminationStatus: + status = "(crashed)" + break; + case WebEngineView.KilledTerminationStatus: + status = "(killed)" + break; + } + + print("Render process exited with code " + exitCode + " " + status) + reloadTimer.running = true + } + + Timer { + id: reloadTimer + interval: 0 + running: false + repeat: false + onTriggered: currentWebView.reload() + } } } } diff --git a/examples/webenginewidgets/browser/browser.rc b/examples/webenginewidgets/browser/browser.rc deleted file mode 100644 index 39e17e9732b5fdb7153d2459a78ebe442e3a5698..0000000000000000000000000000000000000000 --- a/examples/webenginewidgets/browser/browser.rc +++ /dev/null @@ -1 +0,0 @@ -IDI_ICON1 ICON DISCARDABLE "browser.ico" diff --git a/examples/webenginewidgets/browser/Info_mac.plist b/examples/webenginewidgets/demobrowser/Info_mac.plist similarity index 100% rename from examples/webenginewidgets/browser/Info_mac.plist rename to examples/webenginewidgets/demobrowser/Info_mac.plist diff --git a/examples/webenginewidgets/browser/addbookmarkdialog.ui b/examples/webenginewidgets/demobrowser/addbookmarkdialog.ui similarity index 100% rename from examples/webenginewidgets/browser/addbookmarkdialog.ui rename to examples/webenginewidgets/demobrowser/addbookmarkdialog.ui diff --git a/examples/webenginewidgets/browser/autosaver.cpp b/examples/webenginewidgets/demobrowser/autosaver.cpp similarity index 100% rename from examples/webenginewidgets/browser/autosaver.cpp rename to examples/webenginewidgets/demobrowser/autosaver.cpp diff --git a/examples/webenginewidgets/browser/autosaver.h b/examples/webenginewidgets/demobrowser/autosaver.h similarity index 100% rename from examples/webenginewidgets/browser/autosaver.h rename to examples/webenginewidgets/demobrowser/autosaver.h diff --git a/examples/webenginewidgets/browser/bookmarks.cpp b/examples/webenginewidgets/demobrowser/bookmarks.cpp similarity index 100% rename from examples/webenginewidgets/browser/bookmarks.cpp rename to examples/webenginewidgets/demobrowser/bookmarks.cpp diff --git a/examples/webenginewidgets/browser/bookmarks.h b/examples/webenginewidgets/demobrowser/bookmarks.h similarity index 100% rename from examples/webenginewidgets/browser/bookmarks.h rename to examples/webenginewidgets/demobrowser/bookmarks.h diff --git a/examples/webenginewidgets/browser/bookmarks.ui b/examples/webenginewidgets/demobrowser/bookmarks.ui similarity index 100% rename from examples/webenginewidgets/browser/bookmarks.ui rename to examples/webenginewidgets/demobrowser/bookmarks.ui diff --git a/examples/webenginewidgets/browser/browserapplication.cpp b/examples/webenginewidgets/demobrowser/browserapplication.cpp similarity index 86% rename from examples/webenginewidgets/browser/browserapplication.cpp rename to examples/webenginewidgets/demobrowser/browserapplication.cpp index 84d8a0e3a0a42a7f752fd37fd071b84f3925228b..a85bce2c366e2e0e8fb7e43585045979ec67a30c 100644 --- a/examples/webenginewidgets/browser/browserapplication.cpp +++ b/examples/webenginewidgets/demobrowser/browserapplication.cpp @@ -63,6 +63,7 @@ #include <QtNetwork/QLocalServer> #include <QtNetwork/QLocalSocket> #include <QtNetwork/QNetworkProxy> +#include <QtNetwork/QNetworkReply> #include <QtNetwork/QSslSocket> #include <QWebEngineProfile> @@ -190,25 +191,24 @@ BrowserApplication::~BrowserApplication() delete s_bookmarksManager; } -#if defined(Q_OS_OSX) void BrowserApplication::lastWindowClosed() { +#if defined(Q_OS_OSX) clean(); BrowserMainWindow *mw = new BrowserMainWindow; mw->slotHome(); m_mainWindows.prepend(mw); -} #endif +} BrowserApplication *BrowserApplication::instance() { return (static_cast<BrowserApplication *>(QCoreApplication::instance())); } -#if defined(Q_OS_OSX) -#include <QtWidgets/QMessageBox> void BrowserApplication::quitBrowser() { +#if defined(Q_OS_OSX) clean(); int tabCount = 0; for (int i = 0; i < m_mainWindows.count(); ++i) { @@ -226,8 +226,8 @@ void BrowserApplication::quitBrowser() } exit(0); -} #endif +} /*! Any actions that can be delayed until the window is visible @@ -242,7 +242,7 @@ void BrowserApplication::postLaunch() QWebEngineSettings::setOfflineStoragePath(directory); #endif - setWindowIcon(QIcon(QLatin1String(":browser.svg"))); + setWindowIcon(QIcon(QLatin1String(":demobrowser.svg"))); loadSettings(); @@ -284,6 +284,8 @@ void BrowserApplication::loadSettings() defaultSettings->setAttribute(QWebEngineSettings::PluginsEnabled, settings.value(QLatin1String("enablePlugins"), true).toBool()); + defaultSettings->setAttribute(QWebEngineSettings::FullScreenSupportEnabled, true); + QString css = settings.value(QLatin1String("userStyleSheet")).toString(); setUserStyleSheet(defaultProfile, css, mainWindow()); @@ -490,6 +492,10 @@ QNetworkAccessManager *BrowserApplication::networkAccessManager() { if (!s_networkAccessManager) { s_networkAccessManager = new QNetworkAccessManager(); + connect(s_networkAccessManager, &QNetworkAccessManager::authenticationRequired, + BrowserApplication::instance(), &BrowserApplication::authenticationRequired); + connect(s_networkAccessManager, &QNetworkAccessManager::proxyAuthenticationRequired, + BrowserApplication::instance(), &BrowserApplication::proxyAuthenticationRequired); } return s_networkAccessManager; } @@ -548,3 +554,68 @@ void BrowserApplication::setPrivateBrowsing(bool privateBrowsing) } emit privateBrowsingChanged(privateBrowsing); } + +void BrowserApplication::setLastAuthenticator(QAuthenticator *authenticator) +{ + m_lastAuthenticator = QAuthenticator(*authenticator); +} + +void BrowserApplication::setLastProxyAuthenticator(QAuthenticator *authenticator) +{ + m_lastProxyAuthenticator = QAuthenticator(*authenticator); +} + +void BrowserApplication::authenticationRequired(QNetworkReply *reply, QAuthenticator *authenticator) +{ + if (m_lastAuthenticator.isNull()) + return; + + + Q_ASSERT(m_lastAuthenticator.option("key").isValid()); + QByteArray lastKey = m_lastAuthenticator.option("key").toByteArray(); + QByteArray key = BrowserApplication::authenticationKey(reply->url(), authenticator->realm()); + + if (lastKey == key) + *authenticator = m_lastAuthenticator; +} + +void BrowserApplication::proxyAuthenticationRequired(const QNetworkProxy &proxy, QAuthenticator *authenticator) +{ + if (m_lastProxyAuthenticator.isNull()) + return; + + QNetworkProxy::ProxyType proxyType = proxy.type(); + if (proxyType != QNetworkProxy::HttpProxy || proxyType != QNetworkProxy::HttpCachingProxy) + return; + + Q_ASSERT(m_lastProxyAuthenticator.option("host").isValid()); + QByteArray lastKey = m_lastProxyAuthenticator.option("key").toByteArray(); + QByteArray key = BrowserApplication::proxyAuthenticationKey(proxy, authenticator->realm()); + + if (lastKey == key) + *authenticator = m_lastAuthenticator; +} + +// TODO: Remove these functions (QTBUG-47967) +QByteArray BrowserApplication::authenticationKey(const QUrl &url, const QString &realm) +{ + QUrl copy = url; + copy.setFragment(realm); + return "auth:" + copy.toEncoded(QUrl::RemovePassword | QUrl::RemovePath | QUrl::RemoveQuery); +} + +QByteArray BrowserApplication::proxyAuthenticationKey(const QNetworkProxy &proxy, const QString &realm) +{ + QString host = QString("%1:%2").arg(proxy.hostName()).arg(proxy.port()); + return BrowserApplication::proxyAuthenticationKey(proxy.user(), host, realm); +} + +QByteArray BrowserApplication::proxyAuthenticationKey(const QString &user, const QString &host, const QString &realm) +{ + QUrl key; + key.setScheme(QLatin1String("proxy-http")); + key.setUserName(user); + key.setHost(host); + key.setFragment(realm); + return "auth:" + key.toEncoded(); +} diff --git a/examples/webenginewidgets/browser/browserapplication.h b/examples/webenginewidgets/demobrowser/browserapplication.h similarity index 84% rename from examples/webenginewidgets/browser/browserapplication.h rename to examples/webenginewidgets/demobrowser/browserapplication.h index 26557b8f9ab997f3c2cdf34821ec4dc48bc09b53..75ae57c640afe27dd11456289e3ab5f2c5dd1a52 100644 --- a/examples/webenginewidgets/browser/browserapplication.h +++ b/examples/webenginewidgets/demobrowser/browserapplication.h @@ -49,9 +49,13 @@ #include <QtGui/QIcon> +#include <QtNetwork/QAuthenticator> + QT_BEGIN_NAMESPACE class QLocalServer; class QNetworkAccessManager; +class QNetworkProxy; +class QNetworkReply; class QWebEngineProfile; QT_END_NAMESPACE @@ -80,6 +84,14 @@ public: bool canRestoreSession() const; bool privateBrowsing() const { return m_privateBrowsing; } + void setLastAuthenticator(QAuthenticator *); + void setLastProxyAuthenticator(QAuthenticator *); + + // TODO: Remove these functions (QTBUG-47967) + static QByteArray authenticationKey(const QUrl &, const QString &); + static QByteArray proxyAuthenticationKey(const QNetworkProxy &, const QString &); + static QByteArray proxyAuthenticationKey(const QString &, const QString &, const QString &); + static HistoryManager *historyManager(); static CookieJar *cookieJar(); static DownloadManager *downloadManager(); @@ -93,11 +105,11 @@ public: public slots: BrowserMainWindow *newMainWindow(); void restoreLastSession(); -#if defined(Q_OS_OSX) void lastWindowClosed(); void quitBrowser(); -#endif void setPrivateBrowsing(bool); + void authenticationRequired(QNetworkReply *, QAuthenticator *); + void proxyAuthenticationRequired(const QNetworkProxy &, QAuthenticator *); signals: void privateBrowsingChanged(bool); @@ -122,6 +134,9 @@ private: QWebEngineProfile *m_privateProfile; bool m_privateBrowsing; mutable QIcon m_defaultIcon; + + QAuthenticator m_lastAuthenticator; + QAuthenticator m_lastProxyAuthenticator; }; #endif // BROWSERAPPLICATION_H diff --git a/examples/webenginewidgets/browser/browsermainwindow.cpp b/examples/webenginewidgets/demobrowser/browsermainwindow.cpp similarity index 100% rename from examples/webenginewidgets/browser/browsermainwindow.cpp rename to examples/webenginewidgets/demobrowser/browsermainwindow.cpp diff --git a/examples/webenginewidgets/browser/browsermainwindow.h b/examples/webenginewidgets/demobrowser/browsermainwindow.h similarity index 100% rename from examples/webenginewidgets/browser/browsermainwindow.h rename to examples/webenginewidgets/demobrowser/browsermainwindow.h diff --git a/examples/webenginewidgets/browser/chasewidget.cpp b/examples/webenginewidgets/demobrowser/chasewidget.cpp similarity index 100% rename from examples/webenginewidgets/browser/chasewidget.cpp rename to examples/webenginewidgets/demobrowser/chasewidget.cpp diff --git a/examples/webenginewidgets/browser/chasewidget.h b/examples/webenginewidgets/demobrowser/chasewidget.h similarity index 100% rename from examples/webenginewidgets/browser/chasewidget.h rename to examples/webenginewidgets/demobrowser/chasewidget.h diff --git a/examples/webenginewidgets/browser/cookiejar.cpp b/examples/webenginewidgets/demobrowser/cookiejar.cpp similarity index 100% rename from examples/webenginewidgets/browser/cookiejar.cpp rename to examples/webenginewidgets/demobrowser/cookiejar.cpp diff --git a/examples/webenginewidgets/browser/cookiejar.h b/examples/webenginewidgets/demobrowser/cookiejar.h similarity index 100% rename from examples/webenginewidgets/browser/cookiejar.h rename to examples/webenginewidgets/demobrowser/cookiejar.h diff --git a/examples/webenginewidgets/browser/cookies.ui b/examples/webenginewidgets/demobrowser/cookies.ui similarity index 100% rename from examples/webenginewidgets/browser/cookies.ui rename to examples/webenginewidgets/demobrowser/cookies.ui diff --git a/examples/webenginewidgets/browser/cookiesexceptions.ui b/examples/webenginewidgets/demobrowser/cookiesexceptions.ui similarity index 100% rename from examples/webenginewidgets/browser/cookiesexceptions.ui rename to examples/webenginewidgets/demobrowser/cookiesexceptions.ui diff --git a/examples/webenginewidgets/browser/data/addtab.png b/examples/webenginewidgets/demobrowser/data/addtab.png similarity index 100% rename from examples/webenginewidgets/browser/data/addtab.png rename to examples/webenginewidgets/demobrowser/data/addtab.png diff --git a/examples/webenginewidgets/browser/data/closetab.png b/examples/webenginewidgets/demobrowser/data/closetab.png similarity index 100% rename from examples/webenginewidgets/browser/data/closetab.png rename to examples/webenginewidgets/demobrowser/data/closetab.png diff --git a/examples/webenginewidgets/browser/data/data.qrc b/examples/webenginewidgets/demobrowser/data/data.qrc similarity index 88% rename from examples/webenginewidgets/browser/data/data.qrc rename to examples/webenginewidgets/demobrowser/data/data.qrc index c7d0294c1a1cf09e655d6c1bd1c50a25555dc953..5cb8a97c0f2cb0481e030089f59bcaa6e3273b7a 100644 --- a/examples/webenginewidgets/browser/data/data.qrc +++ b/examples/webenginewidgets/demobrowser/data/data.qrc @@ -3,7 +3,7 @@ <file>addtab.png</file> <file>closetab.png</file> <file>history.png</file> - <file>browser.svg</file> + <file>demobrowser.svg</file> <file>defaultbookmarks.xbel</file> <file>loading.gif</file> <file>defaulticon.png</file> diff --git a/examples/webenginewidgets/browser/data/defaultbookmarks.xbel b/examples/webenginewidgets/demobrowser/data/defaultbookmarks.xbel similarity index 100% rename from examples/webenginewidgets/browser/data/defaultbookmarks.xbel rename to examples/webenginewidgets/demobrowser/data/defaultbookmarks.xbel diff --git a/examples/webenginewidgets/browser/data/defaulticon.png b/examples/webenginewidgets/demobrowser/data/defaulticon.png similarity index 100% rename from examples/webenginewidgets/browser/data/defaulticon.png rename to examples/webenginewidgets/demobrowser/data/defaulticon.png diff --git a/examples/webenginewidgets/browser/data/browser.svg b/examples/webenginewidgets/demobrowser/data/demobrowser.svg similarity index 99% rename from examples/webenginewidgets/browser/data/browser.svg rename to examples/webenginewidgets/demobrowser/data/demobrowser.svg index 2127a0a6e3d18e4a9486c4f456f0e402d9519071..f61a54c67001f1ac219f85ba4e9ff68e9841c462 100644 --- a/examples/webenginewidgets/browser/data/browser.svg +++ b/examples/webenginewidgets/demobrowser/data/demobrowser.svg @@ -14,11 +14,10 @@ id="svg2160" sodipodi:version="0.32" inkscape:version="0.46" - inkscape:export-filename="c:\icons\qtbrowser48.png" inkscape:export-xdpi="90" inkscape:export-ydpi="90" sodipodi:docbase="C:\icons" - sodipodi:docname="browser.svg" + sodipodi:docname="demobrowser.svg" inkscape:output_extension="org.inkscape.output.svg.inkscape"> <defs id="defs2162"><linearGradient diff --git a/examples/webenginewidgets/browser/data/history.png b/examples/webenginewidgets/demobrowser/data/history.png similarity index 100% rename from examples/webenginewidgets/browser/data/history.png rename to examples/webenginewidgets/demobrowser/data/history.png diff --git a/examples/webenginewidgets/browser/data/loading.gif b/examples/webenginewidgets/demobrowser/data/loading.gif similarity index 100% rename from examples/webenginewidgets/browser/data/loading.gif rename to examples/webenginewidgets/demobrowser/data/loading.gif diff --git a/examples/webenginewidgets/browser/browser.icns b/examples/webenginewidgets/demobrowser/demobrowser.icns similarity index 100% rename from examples/webenginewidgets/browser/browser.icns rename to examples/webenginewidgets/demobrowser/demobrowser.icns diff --git a/examples/webenginewidgets/browser/browser.ico b/examples/webenginewidgets/demobrowser/demobrowser.ico similarity index 100% rename from examples/webenginewidgets/browser/browser.ico rename to examples/webenginewidgets/demobrowser/demobrowser.ico diff --git a/examples/webenginewidgets/browser/browser.pro b/examples/webenginewidgets/demobrowser/demobrowser.pro similarity index 85% rename from examples/webenginewidgets/browser/browser.pro rename to examples/webenginewidgets/demobrowser/demobrowser.pro index 6b31d7ef29d026747a6a077861d34f7fe43f48cf..0893fe649c7fcdaaffacfe3f705b8ec3f931ec03 100644 --- a/examples/webenginewidgets/browser/browser.pro +++ b/examples/webenginewidgets/demobrowser/demobrowser.pro @@ -1,6 +1,7 @@ TEMPLATE = app -TARGET = browser +TARGET = demobrowser QT += webenginewidgets network widgets printsupport +CONFIG += c++11 qtHaveModule(uitools):!embedded: QT += uitools else: DEFINES += QT_NO_UITOOLS @@ -68,17 +69,17 @@ build_all:!build_pass { } win32 { - RC_FILE = browser.rc + RC_FILE = demobrowser.rc } mac { - ICON = browser.icns + ICON = demobrowser.icns QMAKE_INFO_PLIST = Info_mac.plist TARGET = Browser } -EXAMPLE_FILES = Info_mac.plist browser.icns browser.ico browser.rc +EXAMPLE_FILES = Info_mac.plist demobrowser.icns demobrowser.ico demobrowser.rc # install -target.path = $$[QT_INSTALL_EXAMPLES]/webenginewidgets/browser +target.path = $$[QT_INSTALL_EXAMPLES]/webenginewidgets/demobrowser INSTALLS += target diff --git a/examples/webenginewidgets/demobrowser/demobrowser.rc b/examples/webenginewidgets/demobrowser/demobrowser.rc new file mode 100644 index 0000000000000000000000000000000000000000..70cd8bb1cd1aee46439f3ce9c2bda1bfd6eb052a --- /dev/null +++ b/examples/webenginewidgets/demobrowser/demobrowser.rc @@ -0,0 +1 @@ +IDI_ICON1 ICON DISCARDABLE "demobrowser.ico" diff --git a/examples/webenginewidgets/browser/doc/images/browser-demo.png b/examples/webenginewidgets/demobrowser/doc/images/browser-demo.png similarity index 100% rename from examples/webenginewidgets/browser/doc/images/browser-demo.png rename to examples/webenginewidgets/demobrowser/doc/images/browser-demo.png diff --git a/examples/webenginewidgets/browser/doc/src/browser.qdoc b/examples/webenginewidgets/demobrowser/doc/src/demobrowser.qdoc similarity index 87% rename from examples/webenginewidgets/browser/doc/src/browser.qdoc rename to examples/webenginewidgets/demobrowser/doc/src/demobrowser.qdoc index 99581d8a9d215b8c5544890ec0b9e1f592a8aa38..1264606dbd7911a37ec815022f8a6dc47cc873b7 100644 --- a/examples/webenginewidgets/browser/doc/src/browser.qdoc +++ b/examples/webenginewidgets/demobrowser/doc/src/demobrowser.qdoc @@ -26,12 +26,12 @@ ****************************************************************************/ /*! - \example browser - \title WebEngine Tab Browser Example + \example demobrowser + \title WebEngine Demo Browser Example \ingroup webengine-widgetexamples - \brief The QtWebKit browser example ported to use QtWebEngine + \brief A demo browser based on Qt WebEngine Widgets - The Tab Browser example shows the \l{Qt WebEngine Widgets} module in action, + The Demo Browser example shows the \l{Qt WebEngine Widgets} module in action, providing a little Web browser application with support for tabs. \image browser-demo.png diff --git a/examples/webenginewidgets/browser/downloaditem.ui b/examples/webenginewidgets/demobrowser/downloaditem.ui similarity index 100% rename from examples/webenginewidgets/browser/downloaditem.ui rename to examples/webenginewidgets/demobrowser/downloaditem.ui diff --git a/examples/webenginewidgets/browser/downloadmanager.cpp b/examples/webenginewidgets/demobrowser/downloadmanager.cpp similarity index 100% rename from examples/webenginewidgets/browser/downloadmanager.cpp rename to examples/webenginewidgets/demobrowser/downloadmanager.cpp diff --git a/examples/webenginewidgets/browser/downloadmanager.h b/examples/webenginewidgets/demobrowser/downloadmanager.h similarity index 100% rename from examples/webenginewidgets/browser/downloadmanager.h rename to examples/webenginewidgets/demobrowser/downloadmanager.h diff --git a/examples/webenginewidgets/browser/downloads.ui b/examples/webenginewidgets/demobrowser/downloads.ui similarity index 100% rename from examples/webenginewidgets/browser/downloads.ui rename to examples/webenginewidgets/demobrowser/downloads.ui diff --git a/examples/webenginewidgets/browser/edittableview.cpp b/examples/webenginewidgets/demobrowser/edittableview.cpp similarity index 100% rename from examples/webenginewidgets/browser/edittableview.cpp rename to examples/webenginewidgets/demobrowser/edittableview.cpp diff --git a/examples/webenginewidgets/browser/edittableview.h b/examples/webenginewidgets/demobrowser/edittableview.h similarity index 100% rename from examples/webenginewidgets/browser/edittableview.h rename to examples/webenginewidgets/demobrowser/edittableview.h diff --git a/examples/webenginewidgets/browser/edittreeview.cpp b/examples/webenginewidgets/demobrowser/edittreeview.cpp similarity index 100% rename from examples/webenginewidgets/browser/edittreeview.cpp rename to examples/webenginewidgets/demobrowser/edittreeview.cpp diff --git a/examples/webenginewidgets/browser/edittreeview.h b/examples/webenginewidgets/demobrowser/edittreeview.h similarity index 100% rename from examples/webenginewidgets/browser/edittreeview.h rename to examples/webenginewidgets/demobrowser/edittreeview.h diff --git a/examples/webenginewidgets/browser/featurepermissionbar.cpp b/examples/webenginewidgets/demobrowser/featurepermissionbar.cpp similarity index 100% rename from examples/webenginewidgets/browser/featurepermissionbar.cpp rename to examples/webenginewidgets/demobrowser/featurepermissionbar.cpp diff --git a/examples/webenginewidgets/browser/featurepermissionbar.h b/examples/webenginewidgets/demobrowser/featurepermissionbar.h similarity index 100% rename from examples/webenginewidgets/browser/featurepermissionbar.h rename to examples/webenginewidgets/demobrowser/featurepermissionbar.h diff --git a/examples/webenginewidgets/browser/history.cpp b/examples/webenginewidgets/demobrowser/history.cpp similarity index 98% rename from examples/webenginewidgets/browser/history.cpp rename to examples/webenginewidgets/demobrowser/history.cpp index d9d76cd294f82c711b71d6dd38b0b298cc500022..ce104e9826126d75c7ca45e5255fdbf89bb41d6f 100644 --- a/examples/webenginewidgets/browser/history.cpp +++ b/examples/webenginewidgets/demobrowser/history.cpp @@ -59,9 +59,6 @@ #include <QtWidgets/QHeaderView> #include <QtWidgets/QStyle> -#if defined(QWEBENGINEHISTORYINTERFACE) -#include <QWebEngineHistoryInterface> -#endif #include <QWebEngineSettings> #include <QtCore/QDebug> @@ -69,11 +66,8 @@ static const unsigned int HISTORY_VERSION = 23; HistoryManager::HistoryManager(QObject *parent) - : -#if defined(QWEBENGINEHISTORYINTERFACE) - QWebEngineHistoryInterface(parent), -#endif - m_saveTimer(new AutoSaver(this)) + : QObject(parent) + , m_saveTimer(new AutoSaver(this)) , m_historyLimit(30) , m_historyModel(0) , m_historyFilterModel(0) @@ -91,13 +85,6 @@ HistoryManager::HistoryManager(QObject *parent) m_historyModel = new HistoryModel(this, this); m_historyFilterModel = new HistoryFilterModel(m_historyModel, this); m_historyTreeModel = new HistoryTreeModel(m_historyFilterModel, this); - -#if defined(QWEBENGINEHISTORYINTERFACE) - // QWebEngineHistoryInterface will delete the history manager - QWebEngineHistoryInterface::setDefaultInterface(this); -#else - Q_UNUSED(parent); -#endif } HistoryManager::~HistoryManager() diff --git a/examples/webenginewidgets/browser/history.h b/examples/webenginewidgets/demobrowser/history.h similarity index 98% rename from examples/webenginewidgets/browser/history.h rename to examples/webenginewidgets/demobrowser/history.h index 3519d31b67198419cf232f274692679e5d8dd6d2..bcb9c9b287848707ddaf90823310f6fc3e437432 100644 --- a/examples/webenginewidgets/browser/history.h +++ b/examples/webenginewidgets/demobrowser/history.h @@ -52,10 +52,6 @@ #include <QtCore/QSortFilterProxyModel> -#if defined(QWEBENGINEHISTORYINTERFACE) -#include <QWebEngineHistoryInterface> -#endif - class HistoryItem { public: @@ -82,12 +78,7 @@ class HistoryModel; class HistoryFilterModel; class HistoryTreeModel; -class HistoryManager -#if defined(QWEBENGINEHISTORYINTERFACE) - : public QWebEngineHistoryInterface -#else - : public QObject -#endif +class HistoryManager : public QObject { Q_OBJECT Q_PROPERTY(int historyLimit READ historyLimit WRITE setHistoryLimit) diff --git a/examples/webenginewidgets/browser/history.ui b/examples/webenginewidgets/demobrowser/history.ui similarity index 100% rename from examples/webenginewidgets/browser/history.ui rename to examples/webenginewidgets/demobrowser/history.ui diff --git a/examples/webenginewidgets/browser/htmls/htmls.qrc b/examples/webenginewidgets/demobrowser/htmls/htmls.qrc similarity index 100% rename from examples/webenginewidgets/browser/htmls/htmls.qrc rename to examples/webenginewidgets/demobrowser/htmls/htmls.qrc diff --git a/examples/webenginewidgets/browser/htmls/notfound.html b/examples/webenginewidgets/demobrowser/htmls/notfound.html similarity index 100% rename from examples/webenginewidgets/browser/htmls/notfound.html rename to examples/webenginewidgets/demobrowser/htmls/notfound.html diff --git a/examples/webenginewidgets/browser/main.cpp b/examples/webenginewidgets/demobrowser/main.cpp similarity index 100% rename from examples/webenginewidgets/browser/main.cpp rename to examples/webenginewidgets/demobrowser/main.cpp diff --git a/examples/webenginewidgets/browser/modelmenu.cpp b/examples/webenginewidgets/demobrowser/modelmenu.cpp similarity index 100% rename from examples/webenginewidgets/browser/modelmenu.cpp rename to examples/webenginewidgets/demobrowser/modelmenu.cpp diff --git a/examples/webenginewidgets/browser/modelmenu.h b/examples/webenginewidgets/demobrowser/modelmenu.h similarity index 100% rename from examples/webenginewidgets/browser/modelmenu.h rename to examples/webenginewidgets/demobrowser/modelmenu.h diff --git a/examples/webenginewidgets/browser/passworddialog.ui b/examples/webenginewidgets/demobrowser/passworddialog.ui similarity index 100% rename from examples/webenginewidgets/browser/passworddialog.ui rename to examples/webenginewidgets/demobrowser/passworddialog.ui diff --git a/examples/webenginewidgets/browser/proxy.ui b/examples/webenginewidgets/demobrowser/proxy.ui similarity index 100% rename from examples/webenginewidgets/browser/proxy.ui rename to examples/webenginewidgets/demobrowser/proxy.ui diff --git a/examples/webenginewidgets/browser/searchlineedit.cpp b/examples/webenginewidgets/demobrowser/searchlineedit.cpp similarity index 100% rename from examples/webenginewidgets/browser/searchlineedit.cpp rename to examples/webenginewidgets/demobrowser/searchlineedit.cpp diff --git a/examples/webenginewidgets/browser/searchlineedit.h b/examples/webenginewidgets/demobrowser/searchlineedit.h similarity index 100% rename from examples/webenginewidgets/browser/searchlineedit.h rename to examples/webenginewidgets/demobrowser/searchlineedit.h diff --git a/examples/webenginewidgets/browser/settings.cpp b/examples/webenginewidgets/demobrowser/settings.cpp similarity index 100% rename from examples/webenginewidgets/browser/settings.cpp rename to examples/webenginewidgets/demobrowser/settings.cpp diff --git a/examples/webenginewidgets/browser/settings.h b/examples/webenginewidgets/demobrowser/settings.h similarity index 100% rename from examples/webenginewidgets/browser/settings.h rename to examples/webenginewidgets/demobrowser/settings.h diff --git a/examples/webenginewidgets/browser/settings.ui b/examples/webenginewidgets/demobrowser/settings.ui similarity index 100% rename from examples/webenginewidgets/browser/settings.ui rename to examples/webenginewidgets/demobrowser/settings.ui diff --git a/examples/webenginewidgets/browser/squeezelabel.cpp b/examples/webenginewidgets/demobrowser/squeezelabel.cpp similarity index 100% rename from examples/webenginewidgets/browser/squeezelabel.cpp rename to examples/webenginewidgets/demobrowser/squeezelabel.cpp diff --git a/examples/webenginewidgets/browser/squeezelabel.h b/examples/webenginewidgets/demobrowser/squeezelabel.h similarity index 100% rename from examples/webenginewidgets/browser/squeezelabel.h rename to examples/webenginewidgets/demobrowser/squeezelabel.h diff --git a/examples/webenginewidgets/browser/tabwidget.cpp b/examples/webenginewidgets/demobrowser/tabwidget.cpp similarity index 96% rename from examples/webenginewidgets/browser/tabwidget.cpp rename to examples/webenginewidgets/demobrowser/tabwidget.cpp index 3df1628e011e8e702b82344554fb604506b53ad0..4532683b5c3c576d2a8863bf21389dd69a48da3b 100644 --- a/examples/webenginewidgets/browser/tabwidget.cpp +++ b/examples/webenginewidgets/demobrowser/tabwidget.cpp @@ -73,11 +73,8 @@ TabBar::TabBar(QWidget *parent) this, SLOT(contextMenuRequested(QPoint))); QString ctrl = QLatin1String("Ctrl+%1"); - for (int i = 1; i <= 10; ++i) { - int key = i; - if (key == 10) - key = 0; - QShortcut *shortCut = new QShortcut(ctrl.arg(key), this); + for (int i = 1; i < 10; ++i) { + QShortcut *shortCut = new QShortcut(ctrl.arg(i), this); m_tabShortcuts.append(shortCut); connect(shortCut, SIGNAL(activated()), this, SLOT(selectTabAction())); } @@ -88,12 +85,15 @@ TabBar::TabBar(QWidget *parent) setMovable(true); } +TabWidget::~TabWidget() +{ + delete m_fullScreenView; +} + void TabBar::selectTabAction() { if (QShortcut *shortCut = qobject_cast<QShortcut*>(sender())) { int index = m_tabShortcuts.indexOf(shortCut); - if (index == 0) - index = 10; setCurrentIndex(index); } } @@ -218,6 +218,7 @@ TabWidget::TabWidget(QWidget *parent) , m_lineEdits(0) , m_tabBar(new TabBar(this)) , m_profile(QWebEngineProfile::defaultProfile()) + , m_fullScreenView(0) { setElideMode(Qt::ElideRight); @@ -320,6 +321,8 @@ void TabWidget::currentChanged(int index) this, SIGNAL(loadProgress(int))); disconnect(oldWebView->page()->profile(), SIGNAL(downloadRequested(QWebEngineDownloadItem*)), this, SLOT(downloadRequested(QWebEngineDownloadItem*))); + disconnect(oldWebView->page(), SIGNAL(fullScreenRequested(bool)), + this, SLOT(fullScreenRequested(bool))); } #if defined(QWEBENGINEVIEW_STATUSBARMESSAGE) @@ -332,6 +335,8 @@ void TabWidget::currentChanged(int index) this, SIGNAL(loadProgress(int))); connect(webView->page()->profile(), SIGNAL(downloadRequested(QWebEngineDownloadItem*)), this, SLOT(downloadRequested(QWebEngineDownloadItem*))); + connect(webView->page(), SIGNAL(fullScreenRequested(bool)), + this, SLOT(fullScreenRequested(bool))); for (int i = 0; i < m_actions.count(); ++i) { WebActionMapper *mapper = m_actions[i]; @@ -347,6 +352,26 @@ void TabWidget::currentChanged(int index) webView->setFocus(); } +void TabWidget::fullScreenRequested(bool fullscreen) +{ + if (fullscreen) { + if (!m_fullScreenView) + m_fullScreenView = new QWebEngineView(); + WebPage *webPage = qobject_cast<WebPage*>(sender()); + webPage->setView(m_fullScreenView); + m_fullScreenView->showFullScreen(); + m_fullScreenView->raise(); + } else { + if (!m_fullScreenView) + return; + WebPage *webPage = qobject_cast<WebPage*>(sender()); + WebView *oldWebView = this->webView(m_lineEdits->currentIndex()); + webPage->setView(oldWebView); + raise(); + m_fullScreenView->hide(); + } +} + QAction *TabWidget::newTabAction() const { return m_newTabAction; diff --git a/examples/webenginewidgets/browser/tabwidget.h b/examples/webenginewidgets/demobrowser/tabwidget.h similarity index 98% rename from examples/webenginewidgets/browser/tabwidget.h rename to examples/webenginewidgets/demobrowser/tabwidget.h index 5d7f1e2c55abded27fbbf2573b583e80678bd089..f6c4edba264540a4fc67ec0bbcc2f01bc96ea820 100644 --- a/examples/webenginewidgets/browser/tabwidget.h +++ b/examples/webenginewidgets/demobrowser/tabwidget.h @@ -49,6 +49,7 @@ QT_BEGIN_NAMESPACE class QWebEngineDownloadItem; class QWebEngineProfile; +class QWebEngineView; QT_END_NAMESPACE /* @@ -164,6 +165,7 @@ signals: public: TabWidget(QWidget *parent = 0); + ~TabWidget(); void clear(); void addWebAction(QAction *action, QWebEnginePage::WebAction webAction); @@ -213,6 +215,7 @@ private slots: void lineEditReturnPressed(); void windowCloseRequested(); void moveTab(int fromIndex, int toIndex); + void fullScreenRequested(bool); private: QAction *m_recentlyClosedTabsAction; @@ -230,6 +233,7 @@ private: QStackedWidget *m_lineEdits; TabBar *m_tabBar; QWebEngineProfile *m_profile; + QWebEngineView *m_fullScreenView; }; #endif // TABWIDGET_H diff --git a/examples/webenginewidgets/browser/toolbarsearch.cpp b/examples/webenginewidgets/demobrowser/toolbarsearch.cpp similarity index 100% rename from examples/webenginewidgets/browser/toolbarsearch.cpp rename to examples/webenginewidgets/demobrowser/toolbarsearch.cpp diff --git a/examples/webenginewidgets/browser/toolbarsearch.h b/examples/webenginewidgets/demobrowser/toolbarsearch.h similarity index 100% rename from examples/webenginewidgets/browser/toolbarsearch.h rename to examples/webenginewidgets/demobrowser/toolbarsearch.h diff --git a/examples/webenginewidgets/browser/urllineedit.cpp b/examples/webenginewidgets/demobrowser/urllineedit.cpp similarity index 100% rename from examples/webenginewidgets/browser/urllineedit.cpp rename to examples/webenginewidgets/demobrowser/urllineedit.cpp diff --git a/examples/webenginewidgets/browser/urllineedit.h b/examples/webenginewidgets/demobrowser/urllineedit.h similarity index 100% rename from examples/webenginewidgets/browser/urllineedit.h rename to examples/webenginewidgets/demobrowser/urllineedit.h diff --git a/examples/webenginewidgets/browser/webview.cpp b/examples/webenginewidgets/demobrowser/webview.cpp similarity index 91% rename from examples/webenginewidgets/browser/webview.cpp rename to examples/webenginewidgets/demobrowser/webview.cpp index 00ec40874a867a2f0cf81b6cad7377ad0703569d..c12f3db36cc98d5c4b0b95314581ba428c2bb6d9 100644 --- a/examples/webenginewidgets/browser/webview.cpp +++ b/examples/webenginewidgets/demobrowser/webview.cpp @@ -66,6 +66,7 @@ #include <QtCore/QDebug> #include <QtCore/QBuffer> +#include <QtCore/QTimer> WebPage::WebPage(QWebEngineProfile *profile, QObject *parent) : QWebEnginePage(profile, parent) @@ -271,8 +272,14 @@ void WebPage::authenticationRequired(const QUrl &requestUrl, QAuthenticator *aut passwordDialog.introLabel->setWordWrap(true); if (dialog.exec() == QDialog::Accepted) { + QByteArray key = BrowserApplication::authenticationKey(requestUrl, auth->realm()); auth->setUser(passwordDialog.userNameLineEdit->text()); auth->setPassword(passwordDialog.passwordLineEdit->text()); + auth->setOption("key", key); + BrowserApplication::instance()->setLastAuthenticator(auth); + } else { + // Set authenticator null if dialog is cancelled + *auth = QAuthenticator(); } } @@ -296,8 +303,15 @@ void WebPage::proxyAuthenticationRequired(const QUrl &requestUrl, QAuthenticator proxyDialog.introLabel->setWordWrap(true); if (dialog.exec() == QDialog::Accepted) { - auth->setUser(proxyDialog.userNameLineEdit->text()); + QString user = proxyDialog.userNameLineEdit->text(); + QByteArray key = BrowserApplication::proxyAuthenticationKey(user, proxyHost, auth->realm()); + auth->setUser(user); auth->setPassword(proxyDialog.passwordLineEdit->text()); + auth->setOption("key", key); + BrowserApplication::instance()->setLastProxyAuthenticator(auth); + } else { + // Set authenticator null if dialog is cancelled + *auth = QAuthenticator(); } } @@ -328,6 +342,27 @@ WebView::WebView(QWidget* parent) this, SLOT(setProgress(int))); connect(this, SIGNAL(loadFinished(bool)), this, SLOT(loadFinished(bool))); + connect(this, &QWebEngineView::renderProcessTerminated, + [=](QWebEnginePage::RenderProcessTerminationStatus termStatus, int statusCode) { + const char *status = ""; + switch (termStatus) { + case QWebEnginePage::NormalTerminationStatus: + status = "(normal exit)"; + break; + case QWebEnginePage::AbnormalTerminationStatus: + status = "(abnormal exit)"; + break; + case QWebEnginePage::CrashedTerminationStatus: + status = "(crashed)"; + break; + case QWebEnginePage::KilledTerminationStatus: + status = "(killed)"; + break; + } + + qInfo() << "Render process exited with code" << statusCode << status; + QTimer::singleShot(0, [this] { reload(); }); + }); } void WebView::setPage(WebPage *_page) diff --git a/examples/webenginewidgets/browser/webview.h b/examples/webenginewidgets/demobrowser/webview.h similarity index 100% rename from examples/webenginewidgets/browser/webview.h rename to examples/webenginewidgets/demobrowser/webview.h diff --git a/examples/webenginewidgets/browser/xbel.cpp b/examples/webenginewidgets/demobrowser/xbel.cpp similarity index 100% rename from examples/webenginewidgets/browser/xbel.cpp rename to examples/webenginewidgets/demobrowser/xbel.cpp diff --git a/examples/webenginewidgets/browser/xbel.h b/examples/webenginewidgets/demobrowser/xbel.h similarity index 100% rename from examples/webenginewidgets/browser/xbel.h rename to examples/webenginewidgets/demobrowser/xbel.h diff --git a/src/3rdparty b/src/3rdparty index 154d7a3611197845352b3e1d3ebeaf429d37e656..2ac2926e6c73bbb9b9897ed6d7a472031a0a8c65 160000 --- a/src/3rdparty +++ b/src/3rdparty @@ -1 +1 @@ -Subproject commit 154d7a3611197845352b3e1d3ebeaf429d37e656 +Subproject commit 2ac2926e6c73bbb9b9897ed6d7a472031a0a8c65 diff --git a/src/core/api/core_api.pro b/src/core/api/core_api.pro index d72b27229854d5a9e984ae67202578f26212c4c3..6a37b2ac3b9e8b28b8ef38e417cf1fcc46eb43d8 100644 --- a/src/core/api/core_api.pro +++ b/src/core/api/core_api.pro @@ -1,4 +1,4 @@ -TARGET = qtwebenginecoreapi +TARGET = qtwebenginecoreapi$$qtPlatformTargetSuffix() DESTDIR = $$OUT_PWD/$$getConfigDir() TEMPLATE = lib @@ -37,8 +37,21 @@ HEADERS = \ qwebenginecookiestoreclient_p.h \ qwebengineurlrequestinterceptor.h \ qwebengineurlrequestinfo.h \ - qwebengineurlrequestinfo_p.h + qwebengineurlrequestinfo_p.h \ + qwebengineurlrequestjob.h \ + qwebengineurlschemehandler.h \ + qwebengineurlschemehandler_p.h SOURCES = \ qwebenginecookiestoreclient.cpp \ - qwebengineurlrequestinfo.cpp + qwebengineurlrequestinfo.cpp \ + qwebengineurlrequestjob.cpp \ + qwebengineurlschemehandler.cpp + +msvc { + # Create a list of object files that can be used as response file for the linker. + # This is done to simulate -whole-archive on MSVC. + QMAKE_POST_LINK = \ + "if exist $(DESTDIR_TARGET).objects del $(DESTDIR_TARGET).objects$$escape_expand(\\n\\t)" \ + "for %%a in ($(OBJECTS)) do echo $$shell_quote($$shell_path($$OUT_PWD))\\%%a >> $(DESTDIR_TARGET).objects" +} diff --git a/src/core/api/qwebenginecookiestoreclient.cpp b/src/core/api/qwebenginecookiestoreclient.cpp index f4770927e4c0cce40865585374f0eac0fcbc7092..3a003ff3e5b5cdd365d15f4618028834b033bc75 100644 --- a/src/core/api/qwebenginecookiestoreclient.cpp +++ b/src/core/api/qwebenginecookiestoreclient.cpp @@ -37,6 +37,8 @@ #include "qwebenginecookiestoreclient.h" #include "qwebenginecookiestoreclient_p.h" +#include <cookie_monster_delegate_qt.h> + #include <QByteArray> #include <QUrl> @@ -171,6 +173,44 @@ void QWebEngineCookieStoreClientPrivate::onCookieChanged(const QNetworkCookie &c Q_EMIT q->cookieAdded(cookie); } +bool QWebEngineCookieStoreClientPrivate::canSetCookie(const QUrl &firstPartyUrl, const QByteArray &cookieLine, const QUrl &url) +{ + Q_Q(QWebEngineCookieStoreClient); + return q->acceptCookie(firstPartyUrl, cookieLine, url); +} + +/*! + \class QWebEngineCookieStoreClient + \inmodule QtWebEngineCore + \since 5.6 + \brief The QWebEngineCookieStoreClient class provides access to Chromium's cookies. + + By subclassing the QWebEngineCookieStoreClient and installing it on the profile, the user can + access HTTP cookies of Chromium. + It can be used to synchronize cookies of Chromium and the QNetworkAccessManager, as well as + to set, delete, and intercept cookies during navigation. + Because cookie operations are asynchronous, the user can choose to provide a callback function + to get notified about the success of the operation. + The signal handlers for removal and addition should not be used to execute heavy tasks, + because they might block the IO thread in case of a blocking connection. +*/ + +/*! + \fn void QWebEngineCookieStoreClient::cookieAdded(const QNetworkCookie &cookie) + + This signal is emitted whenever a new \a cookie is added to the cookie store. +*/ + +/*! + \fn void QWebEngineCookieStoreClient::cookieRemoved(const QNetworkCookie &cookie) + + This signal is emitted whenever a \a cookie is deleted from the cookie store. +*/ + +/*! + Creates a new QWebEngineCookieStoreClient object with \a parent. +*/ + QWebEngineCookieStoreClient::QWebEngineCookieStoreClient(QObject *parent) : QObject(parent) , d_ptr(new QWebEngineCookieStoreClientPrivate(this)) @@ -178,28 +218,69 @@ QWebEngineCookieStoreClient::QWebEngineCookieStoreClient(QObject *parent) } +/*! + Destroys this QWebEngineCookieStoreClient object. +*/ + QWebEngineCookieStoreClient::~QWebEngineCookieStoreClient() { } +/*! + \fn void setCookieWithCallback(const QNetworkCookie &cookie, FunctorOrLambda resultCallback, const QUrl &origin = QUrl()) + + Adds \a cookie to the cookie store. When the operation finishes, \a resultCallback will be executed + on the caller thread. + It is possible to provide an optional \a origin URL argument to limit the scope of the cookie. + The provided URL should also include the scheme. + + \sa setCookie() +*/ + void QWebEngineCookieStoreClient::setCookieWithCallback(const QNetworkCookie &cookie, const QWebEngineCallback<bool> &resultCallback, const QUrl &origin) { Q_D(QWebEngineCookieStoreClient); d->setCookie(resultCallback, cookie, origin); } +/*! + Adds \a cookie to the cookie store. This function is provided for convenience and is + equivalent to calling setCookieWithCallback() with an empty callback. + It is possible to provide an optional \a origin URL argument to limit the scope of the cookie. + The provided URL should also include the scheme. + + \sa setCookieWithCallback() +*/ + void QWebEngineCookieStoreClient::setCookie(const QNetworkCookie &cookie, const QUrl &origin) { setCookieWithCallback(cookie, QWebEngineCallback<bool>(), origin); } +/*! + Deletes \a cookie from the cookie store. + It is possible to provide an optional \a origin URL argument to limit the scope of the + cookie to be deleted. + The provided URL should also include the scheme. +*/ + void QWebEngineCookieStoreClient::deleteCookie(const QNetworkCookie &cookie, const QUrl &origin) { Q_D(QWebEngineCookieStoreClient); d->deleteCookie(cookie, origin); } +/*! + \fn void QWebEngineCookieStoreClient::getAllCookies(FunctorOrLambda resultCallback) + + Requests all the cookies in the cookie store. When the asynchronous operation finishes, + \a resultCallback will be called with a QByteArray as the argument containing the cookies. + This QByteArray can be parsed using QNetworkCookie::parseCookies(). + + \sa deleteCookie() +*/ + void QWebEngineCookieStoreClient::getAllCookies(const QWebEngineCallback<const QByteArray&> &resultCallback) { Q_D(QWebEngineCookieStoreClient); @@ -211,6 +292,15 @@ void QWebEngineCookieStoreClient::getAllCookies(const QWebEngineCallback<const Q d->getAllCookies(); } +/*! + \fn void QWebEngineCookieStoreClient::deleteSessionCookiesWithCallback(FunctorOrLambda resultCallback) + + Deletes all the session cookies in the cookie store. Session cookies do not have an + expiration date assigned to them. + When the asynchronous operation finishes, \a resultCallback will be called with the + number of cookies deleted as the argument. +*/ + void QWebEngineCookieStoreClient::deleteSessionCookiesWithCallback(const QWebEngineCallback<int> &resultCallback) { Q_D(QWebEngineCookieStoreClient); @@ -222,6 +312,15 @@ void QWebEngineCookieStoreClient::deleteSessionCookiesWithCallback(const QWebEng d->deleteSessionCookies(); } +/*! + \fn void QWebEngineCookieStoreClient::deleteAllCookiesWithCallback(FunctorOrLambda resultCallback) + + Deletes all the cookies in the cookie store. When the asynchronous operation finishes, + \a resultCallback will be called with the number of cookies deleted as the argument. + + \sa deleteSessionCookiesWithCallback(), getAllCookies() +*/ + void QWebEngineCookieStoreClient::deleteAllCookiesWithCallback(const QWebEngineCallback<int> &resultCallback) { Q_D(QWebEngineCookieStoreClient); @@ -233,14 +332,43 @@ void QWebEngineCookieStoreClient::deleteAllCookiesWithCallback(const QWebEngineC d->deleteAllCookies(); } +/*! + Deletes all the session cookies in the cookie store. + + \sa deleteSessionCookiesWithCallback() +*/ + void QWebEngineCookieStoreClient::deleteSessionCookies() { deleteSessionCookiesWithCallback(QWebEngineCallback<int>()); } +/*! + Deletes all the cookies in the cookie store. + + \sa deleteAllCookiesWithCallback(), getAllCookies() +*/ + void QWebEngineCookieStoreClient::deleteAllCookies() { deleteAllCookiesWithCallback(QWebEngineCallback<int>()); } +/*! + This virtual function is called before a new cookie is added to the cookie store. + By overriding this function and returning \c false the user can decide to deny + from \a firstPartyUrl the cookie \a cookieLine with the source \a cookieSource. + The request's \a firstPartyUrl can be used to identify a third-party cookie. + This function should not be used to execute heavy tasks since it is running on the + IO thread and therefore blocks the Chromium networking. +*/ + +bool QWebEngineCookieStoreClient::acceptCookie(const QUrl &firstPartyUrl, const QByteArray &cookieLine, const QUrl &cookieSource) +{ + Q_UNUSED(firstPartyUrl); + Q_UNUSED(cookieLine); + Q_UNUSED(cookieSource); + return true; +} + QT_END_NAMESPACE diff --git a/src/core/api/qwebenginecookiestoreclient.h b/src/core/api/qwebenginecookiestoreclient.h index 929584c869802fabfbd9bf5de2e41e9b0360db39..3a6f54ea74fb0030519b5fd5d7c280e9c11aefc8 100644 --- a/src/core/api/qwebenginecookiestoreclient.h +++ b/src/core/api/qwebenginecookiestoreclient.h @@ -74,17 +74,21 @@ public: void deleteSessionCookies(); void deleteAllCookies(); + virtual bool acceptCookie(const QUrl &firstPartyUrl, const QByteArray &cookieLine, const QUrl &cookieSource); + Q_SIGNALS: void cookieAdded(const QNetworkCookie &cookie); void cookieRemoved(const QNetworkCookie &cookie); private: friend class QtWebEngineCore::CookieMonsterDelegateQt; - + Q_DISABLE_COPY(QWebEngineCookieStoreClient) Q_DECLARE_PRIVATE(QWebEngineCookieStoreClient) QScopedPointer<QWebEngineCookieStoreClientPrivate> d_ptr; }; QT_END_NAMESPACE +Q_DECLARE_METATYPE(QWebEngineCookieStoreClient*) + #endif // QWEBENGINECOOKIESTORECLIENT_H diff --git a/src/core/api/qwebenginecookiestoreclient_p.h b/src/core/api/qwebenginecookiestoreclient_p.h index ba7914d94c8843ffc8a104bf2868efba5b7659ed..a5b0a7068372838cf9287d7ba3a129d963354d3e 100644 --- a/src/core/api/qwebenginecookiestoreclient_p.h +++ b/src/core/api/qwebenginecookiestoreclient_p.h @@ -50,7 +50,6 @@ #include "qtwebenginecoreglobal_p.h" -#include "cookie_monster_delegate_qt.h" #include "qwebenginecallback_p.h" #include "qwebenginecookiestoreclient.h" @@ -59,6 +58,10 @@ #include <QNetworkCookie> #include <QUrl> +namespace QtWebEngineCore { +class CookieMonsterDelegateQt; +} + QT_BEGIN_NAMESPACE class QWEBENGINE_PRIVATE_EXPORT QWebEngineCookieStoreClientPrivate { @@ -90,6 +93,8 @@ public: void deleteAllCookies(); void getAllCookies(); + bool canSetCookie(const QUrl &firstPartyUrl, const QByteArray &cookieLine, const QUrl &url); + void onGetAllCallbackResult(qint64 callbackId, const QByteArray &cookieList); void onSetCallbackResult(qint64 callbackId, bool success); void onDeleteCallbackResult(qint64 callbackId, int numCookies); diff --git a/src/core/api/qwebengineurlrequestinfo.cpp b/src/core/api/qwebengineurlrequestinfo.cpp index e97b0c7b92f0b73857ec485ad60ece937706a46a..b769081f8a37293b8ccc0b2b41b6381e43c15b41 100644 --- a/src/core/api/qwebengineurlrequestinfo.cpp +++ b/src/core/api/qwebengineurlrequestinfo.cpp @@ -68,6 +68,57 @@ ASSERT_ENUMS_MATCH(QtWebEngineCore::WebContentsAdapterClient::BackForwardNavigat ASSERT_ENUMS_MATCH(QtWebEngineCore::WebContentsAdapterClient::ReloadNavigation, QWebEngineUrlRequestInfo::NavigationTypeReload) ASSERT_ENUMS_MATCH(QtWebEngineCore::WebContentsAdapterClient::OtherNavigation, QWebEngineUrlRequestInfo::NavigationTypeOther) +/*! + \class QWebEngineUrlRequestInfo + \inmodule QtWebEngineCore + \since 5.6 + \brief The QWebEngineUrlRequestInfo class provides information about URL requests. + + The QWebEngineUrlRequestInfo is useful for setting extra header fields for requests + or for redirecting certain requests without payload data to another URL. + This class cannot be instantiated or copied by the user, instead it will + be created by Qt WebEngine and sent through the virtual function + QWebEngineUrlRequestInterceptor::interceptRequest() if an interceptor has been set. +*/ + +/*! + \class QWebEngineUrlRequestInterceptor + \inmodule QtWebEngineCore + \since 5.6 + \brief The QWebEngineUrlRequestInterceptor class provides an abstract base class for URL interception. + + Implementing the \l{QWebEngineUrlRequestInterceptor} interface and installing the + interceptor on the profile enables intercepting, blocking, and modifying URL requests + before they reach the networking stack of Chromium. + + \sa QWebEngineUrlRequestInterceptor::interceptRequest, QWebEngineUrlRequestInfo +*/ + +/*! + \fn QWebEngineUrlRequestInterceptor::QWebEngineUrlRequestInterceptor(QObject * p = 0) + + Creates a new QWebEngineUrlRequestInterceptor object with \a p as parent. +*/ + +/*! + \fn QWebEngineUrlRequestInterceptor::~QWebEngineUrlRequestInterceptor() + + Destroys this QWebEngineUrlRequestInterceptor object. +*/ + +/*! + \fn bool QWebEngineUrlRequestInterceptor::interceptRequest(QWebEngineUrlRequestInfo &info) + + Reimplementing this virtual function and setting the interceptor on a profile makes + it possible to intercept URL requests. This function is executed on the IO thread, + and therefore running long tasks here will block networking. + If this function is only used for inspection, it should return \c false, in which + case any modification to \a info will be ignored. + + \sa QWebEngineProfile::setRequestInterceptor +*/ + + QWebEngineUrlRequestInfoPrivate::QWebEngineUrlRequestInfoPrivate(QWebEngineUrlRequestInfo::ResourceType resource, QWebEngineUrlRequestInfo::NavigationType navigation, const QUrl &u, const QByteArray &m) : resourceType(resource) , navigationType(navigation) @@ -77,53 +128,134 @@ QWebEngineUrlRequestInfoPrivate::QWebEngineUrlRequestInfoPrivate(QWebEngineUrlRe { } +/*! + \internal +*/ + QWebEngineUrlRequestInfo::~QWebEngineUrlRequestInfo() { } +/*! + \internal +*/ + QWebEngineUrlRequestInfo::QWebEngineUrlRequestInfo(QWebEngineUrlRequestInfoPrivate *p) : d_ptr(p) { d_ptr->q_ptr = this; } +/*! + \enum QWebEngineUrlRequestInfo::ResourceType + + This enum type holds the type of the requested resource: + + \value ResourceTypeMainFrame Top level page. + \value ResourceTypeSubFrame Frame or iframe. + \value ResourceTypeStylesheet A CSS stylesheet. + \value ResourceTypeScript An external script. + \value ResourceTypeImage An image (JPG, GIF, PNG, and so on). + \value ResourceTypeFontResource A font. + \value ResourceTypeSubResource An "other" subresource. + \value ResourceTypeObject An object (or embed) tag for a plugin or a resource that a plugin requested. + \value ResourceTypeMedia A media resource. + \value ResourceTypeWorker The main resource of a dedicated worker. + \value ResourceTypeSharedWorker The main resource of a shared worker. + \value ResourceTypePrefetch An explicitly requested prefetch. + \value ResourceTypeFavicon A favicon. + \value ResourceTypeXhr An XMLHttpRequest. + \value ResourceTypePing A ping request for <a ping>. + \value ResourceTypeServiceWorker The main resource of a service worker. + \value ResourceTypeUnknown Unknown request type. +*/ + +/*! + Returns the resource type of the request. + + \sa QWebEngineUrlRequestInfo::ResourceType +*/ + QWebEngineUrlRequestInfo::ResourceType QWebEngineUrlRequestInfo::resourceType() const { Q_D(const QWebEngineUrlRequestInfo); return d->resourceType; } +/*! + \enum QWebEngineUrlRequestInfo::NavigationType + + This enum type describes the navigation type of the request: + + \value NavigationTypeLink Navigation initiated by clicking a link. + \value NavigationTypeTyped Navigation explicitly initiated by typing a URL. + \value NavigationTypeFormSubmitted Navigation submits a form. + \value NavigationTypeBackForward Navigation initiated by a history action. + \value NavigationTypeReload Navigation initiated by refreshing the page. + \value NavigationTypeOther None of the above. +*/ + +/*! + Returns the navigation type of the request. + + \sa QWebEngineUrlRequestInfo::NavigationType +*/ + QWebEngineUrlRequestInfo::NavigationType QWebEngineUrlRequestInfo::navigationType() const { Q_D(const QWebEngineUrlRequestInfo); return d->navigationType; } -const QUrl &QWebEngineUrlRequestInfo::url() const +/*! + Returns the requested URL. +*/ + +QUrl QWebEngineUrlRequestInfo::requestUrl() const { Q_D(const QWebEngineUrlRequestInfo); return d->url; } -const QByteArray &QWebEngineUrlRequestInfo::method() const + +/*! + Returns the HTTP method of the request (for example, GET or POST). +*/ + +QByteArray QWebEngineUrlRequestInfo::requestMethod() const { Q_D(const QWebEngineUrlRequestInfo); return d->method; } -void QWebEngineUrlRequestInfo::redirectTo(const QUrl &url) +/*! + Redirects this request to \a url. + It is only possible to redirect requests that do not have payload data, such as GET requests. +*/ + +void QWebEngineUrlRequestInfo::redirect(const QUrl &url) { Q_D(QWebEngineUrlRequestInfo); d->url = url; } -void QWebEngineUrlRequestInfo::blockRequest(bool shouldBlock) +/*! + Blocks this request if \a shouldBlock is true, so that it will not proceed. + + This function can be used to prevent navigating away from a given domain, for example. +*/ + +void QWebEngineUrlRequestInfo::block(bool shouldBlock) { Q_D(QWebEngineUrlRequestInfo); d->shouldBlockRequest = shouldBlock; } +/*! + Sets an extra request header for this request with \a name and \a value. +*/ + void QWebEngineUrlRequestInfo::setExtraHeader(const QByteArray &name, const QByteArray &value) { Q_D(QWebEngineUrlRequestInfo); diff --git a/src/core/api/qwebengineurlrequestinfo.h b/src/core/api/qwebengineurlrequestinfo.h index dd1e57ebd7a59ccb5052311a08b9a8ece0f00b0f..7c016d20d9645b2ca31cba9ea904cca98b14edcb 100644 --- a/src/core/api/qwebengineurlrequestinfo.h +++ b/src/core/api/qwebengineurlrequestinfo.h @@ -85,11 +85,11 @@ public: ResourceType resourceType() const; NavigationType navigationType() const; - const QUrl &url() const; - const QByteArray &method() const; + QUrl requestUrl() const; + QByteArray requestMethod() const; - void blockRequest(bool shouldBlock); - void redirectTo(const QUrl &url); + void block(bool shouldBlock); + void redirect(const QUrl &url); void setExtraHeader(const QByteArray &name, const QByteArray &value); private: diff --git a/src/core/api/qwebengineurlrequestinterceptor.h b/src/core/api/qwebengineurlrequestinterceptor.h index 3eac74bb6ce1bb9ca13ef57499d554702429c340..72f3452d0ca4c5fb6bd2b4cc592bb833d3b437cb 100644 --- a/src/core/api/qwebengineurlrequestinterceptor.h +++ b/src/core/api/qwebengineurlrequestinterceptor.h @@ -50,6 +50,7 @@ QT_BEGIN_NAMESPACE class QWEBENGINE_EXPORT QWebEngineUrlRequestInterceptor : public QObject { Q_OBJECT + Q_DISABLE_COPY(QWebEngineUrlRequestInterceptor) public: explicit QWebEngineUrlRequestInterceptor(QObject *p = 0) : QObject (p) diff --git a/src/webenginewidgets/api/qwebengineurlrequestjob.cpp b/src/core/api/qwebengineurlrequestjob.cpp similarity index 71% rename from src/webenginewidgets/api/qwebengineurlrequestjob.cpp rename to src/core/api/qwebengineurlrequestjob.cpp index 4a813236cc9fdebf96fcf5422b098f691094e6cd..d9f3833b921c0db61ae592e944a4430d077767ee 100644 --- a/src/webenginewidgets/api/qwebengineurlrequestjob.cpp +++ b/src/core/api/qwebengineurlrequestjob.cpp @@ -10,15 +10,15 @@ ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 3 as published by the Free Software ** Foundation and appearing in the file LICENSE.LGPLv3 included in the -** packaging of this file. Please review the following information to +** packaging of this file. Please review the following information to ** ensure the GNU Lesser General Public License version 3 requirements ** will be met: https://www.gnu.org/licenses/lgpl.html. ** @@ -26,7 +26,7 @@ ** Alternatively, this file may be used under the terms of the GNU ** General Public License version 2.0 or later as published by the Free ** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information to +** the packaging of this file. Please review the following information to ** ensure the GNU General Public License version 2.0 requirements will be ** met: http://www.gnu.org/licenses/gpl-2.0.html. ** @@ -34,9 +34,7 @@ ** ****************************************************************************/ -#include "qwebengineurlrequestjob_p.h" - -#include "qwebengineprofile.h" +#include "qwebengineurlrequestjob.h" #include "url_request_custom_job_delegate.h" @@ -47,19 +45,18 @@ QT_BEGIN_NAMESPACE /*! \class QWebEngineUrlRequestJob \brief The QWebEngineUrlRequestJob class represents a custom URL request. - \since 5.5 - \internal + \since 5.6 A QWebEngineUrlRequestJob is given to QWebEngineUrlSchemeHandler::requestStarted() and must - be handled by the derived implementations of class. + be handled by the derived implementations of the class. - A job can be handled by calling either setReply(), redirect() or setError(). + A job can be handled by calling either reply(), redirect() or fail(). The class is owned by QtWebEngine and does not need to be deleted. Note QtWebEngine may delete the job when it is no longer needed, so the signal QObject::destroyed() must be monitored if a pointer to the object is stored. - \inmodule QtWebEngineWidgets + \inmodule QtWebEngineCore */ /*! @@ -79,17 +76,25 @@ QWebEngineUrlRequestJob::~QWebEngineUrlRequestJob() } /*! - Returns the url requested. - */ + Returns the requested URL. +*/ QUrl QWebEngineUrlRequestJob::requestUrl() const { return d_ptr->url(); } /*! - Sets the reply for the request to \a device with the mime-type \a contentType. + Returns the HTTP method of the request (for example, GET or POST). +*/ +QByteArray QWebEngineUrlRequestJob::requestMethod() const +{ + return d_ptr->method(); +} + +/*! + Replies the request with \a device with the mime-type \a contentType. */ -void QWebEngineUrlRequestJob::setReply(const QByteArray &contentType, QIODevice *device) +void QWebEngineUrlRequestJob::reply(const QByteArray &contentType, QIODevice *device) { d_ptr->setReply(contentType, device); } @@ -97,7 +102,7 @@ void QWebEngineUrlRequestJob::setReply(const QByteArray &contentType, QIODevice /*! Fails the request with error \a error. */ -void QWebEngineUrlRequestJob::setError(Error r) +void QWebEngineUrlRequestJob::fail(Error r) { d_ptr->fail((URLRequestCustomJobDelegate::Error)r); } @@ -105,7 +110,7 @@ void QWebEngineUrlRequestJob::setError(Error r) /*! Tell the request is redirected to \a url. */ -void QWebEngineUrlRequestJob::setRedirect(const QUrl &url) +void QWebEngineUrlRequestJob::redirect(const QUrl &url) { d_ptr->redirect(url); } diff --git a/src/webenginewidgets/api/qwebengineurlrequestjob_p.h b/src/core/api/qwebengineurlrequestjob.h similarity index 68% rename from src/webenginewidgets/api/qwebengineurlrequestjob_p.h rename to src/core/api/qwebengineurlrequestjob.h index e496e4051273cd5a76aff02fe26499e8169e4258..098d46c93c52d80aab1d8e96eb0673bd31380874 100644 --- a/src/webenginewidgets/api/qwebengineurlrequestjob_p.h +++ b/src/core/api/qwebengineurlrequestjob.h @@ -10,15 +10,15 @@ ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 3 as published by the Free Software ** Foundation and appearing in the file LICENSE.LGPLv3 included in the -** packaging of this file. Please review the following information to +** packaging of this file. Please review the following information to ** ensure the GNU Lesser General Public License version 3 requirements ** will be met: https://www.gnu.org/licenses/lgpl.html. ** @@ -26,7 +26,7 @@ ** Alternatively, this file may be used under the terms of the GNU ** General Public License version 2.0 or later as published by the Free ** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information to +** the packaging of this file. Please review the following information to ** ensure the GNU General Public License version 2.0 requirements will be ** met: http://www.gnu.org/licenses/gpl-2.0.html. ** @@ -37,11 +37,22 @@ #ifndef QWEBENGINEURLREQUESTJOB_H #define QWEBENGINEURLREQUESTJOB_H -#include "qtwebenginewidgetsglobal.h" +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// -#include <QtCore/QByteArray> -#include <QtCore/QObject> -#include <QtCore/QUrl> +#include "qtwebenginecoreglobal.h" + +#include <QtCore/qbytearray.h> +#include <QtCore/qobject.h> +#include <QtCore/qurl.h> namespace QtWebEngineCore { class URLRequestCustomJobDelegate; @@ -51,7 +62,7 @@ QT_BEGIN_NAMESPACE class QIODevice; -class QWEBENGINEWIDGETS_EXPORT QWebEngineUrlRequestJob : public QObject { +class QWEBENGINE_EXPORT QWebEngineUrlRequestJob : public QObject { Q_OBJECT public: ~QWebEngineUrlRequestJob(); @@ -64,11 +75,14 @@ public: RequestDenied, RequestFailed }; + Q_ENUM(Error) QUrl requestUrl() const; - void setReply(const QByteArray &contentType, QIODevice *device); - void setError(Error error); - void setRedirect(const QUrl &url); + QByteArray requestMethod() const; + + void reply(const QByteArray &contentType, QIODevice *device); + void fail(Error error); + void redirect(const QUrl &url); private: QWebEngineUrlRequestJob(QtWebEngineCore::URLRequestCustomJobDelegate *); diff --git a/src/webenginewidgets/api/qwebengineurlschemehandler.cpp b/src/core/api/qwebengineurlschemehandler.cpp similarity index 66% rename from src/webenginewidgets/api/qwebengineurlschemehandler.cpp rename to src/core/api/qwebengineurlschemehandler.cpp index 65dd8f0001ccc2bd8e5620d0c0ea93360e537b25..33064889389d5a35d98d15da16503b5a8de2dc31 100644 --- a/src/webenginewidgets/api/qwebengineurlschemehandler.cpp +++ b/src/core/api/qwebengineurlschemehandler.cpp @@ -10,15 +10,15 @@ ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 3 as published by the Free Software ** Foundation and appearing in the file LICENSE.LGPLv3 included in the -** packaging of this file. Please review the following information to +** packaging of this file. Please review the following information to ** ensure the GNU Lesser General Public License version 3 requirements ** will be met: https://www.gnu.org/licenses/lgpl.html. ** @@ -26,7 +26,7 @@ ** Alternatively, this file may be used under the terms of the GNU ** General Public License version 2.0 or later as published by the Free ** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information to +** the packaging of this file. Please review the following information to ** ensure the GNU General Public License version 2.0 requirements will be ** met: http://www.gnu.org/licenses/gpl-2.0.html. ** @@ -34,36 +34,28 @@ ** ****************************************************************************/ +#include "qwebengineurlschemehandler.h" #include "qwebengineurlschemehandler_p.h" -#include "qwebengineurlschemehandler_p_p.h" -#include "qwebengineprofile.h" -#include "qwebengineprofile_p.h" -#include "qwebengineurlrequestjob_p.h" +#include "qwebengineurlrequestjob.h" QT_BEGIN_NAMESPACE /*! \class QWebEngineUrlSchemeHandler - \brief The QWebEngineUrlSchemeHandler Base class for handling custom URL schemes. - \since 5.5 - \internal + \brief The QWebEngineUrlSchemeHandler base class for handling custom URL schemes. + \since 5.6 To implement a custom URL scheme for QtWebEngine you must write a class derived from this class, and reimplement requestStarted(). - To install a custom URL scheme handler into a QtWebProfile, you only need to call the constructor - with the correct profile. Each instance of a QWebEngineUrlSchemeHandler can only handle requests - from a single profile. - - \inmodule QtWebEngineWidgets + \inmodule QtWebEngineCore */ -QWebEngineUrlSchemeHandlerPrivate::QWebEngineUrlSchemeHandlerPrivate(const QByteArray &scheme, QWebEngineUrlSchemeHandler *q, QWebEngineProfile *profile) +QWebEngineUrlSchemeHandlerPrivate::QWebEngineUrlSchemeHandlerPrivate(const QByteArray &scheme, QWebEngineUrlSchemeHandler *q) : CustomUrlSchemeHandler(scheme) , q_ptr(q) - , m_profile(profile) { } @@ -81,20 +73,18 @@ bool QWebEngineUrlSchemeHandlerPrivate::handleJob(QtWebEngineCore::URLRequestCus /*! Constructs a new URL scheme handler. - The handler is created for \a scheme and for the \a profile. + The handler is created for \a scheme with the parent \a parent. */ -QWebEngineUrlSchemeHandler::QWebEngineUrlSchemeHandler(const QByteArray &scheme, QWebEngineProfile *profile, QObject *parent) +QWebEngineUrlSchemeHandler::QWebEngineUrlSchemeHandler(const QByteArray &scheme, QObject *parent) : QObject(parent) - , d_ptr(new QWebEngineUrlSchemeHandlerPrivate(scheme, this, profile)) + , d_ptr(new QWebEngineUrlSchemeHandlerPrivate(scheme, this)) { - profile->d_func()->installUrlSchemeHandler(this); } QWebEngineUrlSchemeHandler::~QWebEngineUrlSchemeHandler() { - if (d_ptr->m_profile) - d_ptr->m_profile->d_func()->removeUrlSchemeHandler(this); + delete d_ptr; } /*! @@ -108,7 +98,7 @@ QByteArray QWebEngineUrlSchemeHandler::scheme() const /*! \fn void QWebEngineUrlSchemeHandler::requestStarted(QWebEngineUrlRequestJob *request) - This method is called whenever a request for the registered scheme is started. + This method is called whenever a request \a request for the registered scheme is started. This method must be reimplemented by all custom URL scheme handlers. The request is asynchronous and does not need to be handled right away. diff --git a/src/webenginewidgets/api/qwebengineurlschemehandler_p.h b/src/core/api/qwebengineurlschemehandler.h similarity index 66% rename from src/webenginewidgets/api/qwebengineurlschemehandler_p.h rename to src/core/api/qwebengineurlschemehandler.h index 153b78f813543ab9d0b169ebd335a81228836e54..b6f6a69f071f492f3ae0edc599c55952c9b65f50 100644 --- a/src/webenginewidgets/api/qwebengineurlschemehandler_p.h +++ b/src/core/api/qwebengineurlschemehandler.h @@ -10,15 +10,15 @@ ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 3 as published by the Free Software ** Foundation and appearing in the file LICENSE.LGPLv3 included in the -** packaging of this file. Please review the following information to +** packaging of this file. Please review the following information to ** ensure the GNU Lesser General Public License version 3 requirements ** will be met: https://www.gnu.org/licenses/lgpl.html. ** @@ -26,7 +26,7 @@ ** Alternatively, this file may be used under the terms of the GNU ** General Public License version 2.0 or later as published by the Free ** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information to +** the packaging of this file. Please review the following information to ** ensure the GNU General Public License version 2.0 requirements will be ** met: http://www.gnu.org/licenses/gpl-2.0.html. ** @@ -37,34 +37,32 @@ #ifndef QWEBENGINEURLSCHEMEHANDLER_H #define QWEBENGINEURLSCHEMEHANDLER_H -#include "qtwebenginewidgetsglobal.h" +#include "qtwebenginecoreglobal.h" -#include <QtCore/QByteArray> -#include <QtCore/QIODevice> -#include <QtCore/QObject> -#include <QtCore/QScopedPointer> -#include <QtCore/QUrl> +#include <QtCore/qbytearray.h> +#include <QtCore/qobject.h> QT_BEGIN_NAMESPACE -class QWebEngineProfile; class QWebEngineUrlRequestJob; class QWebEngineUrlSchemeHandlerPrivate; -class QWEBENGINEWIDGETS_EXPORT QWebEngineUrlSchemeHandler : public QObject { +class QWEBENGINE_EXPORT QWebEngineUrlSchemeHandler : public QObject { Q_OBJECT public: - QWebEngineUrlSchemeHandler(const QByteArray &scheme, QWebEngineProfile *profile, QObject *parent = 0); - virtual ~QWebEngineUrlSchemeHandler(); + QWebEngineUrlSchemeHandler(const QByteArray &scheme, QObject *parent = 0); + ~QWebEngineUrlSchemeHandler(); QByteArray scheme() const; virtual void requestStarted(QWebEngineUrlRequestJob*) = 0; private: + Q_DISABLE_COPY(QWebEngineUrlSchemeHandler) Q_DECLARE_PRIVATE(QWebEngineUrlSchemeHandler) - friend class QWebEngineProfilePrivate; - QScopedPointer<QWebEngineUrlSchemeHandlerPrivate> d_ptr; + friend class QWebEngineProfile; + friend class QQuickWebEngineProfile; + QWebEngineUrlSchemeHandlerPrivate *d_ptr; }; QT_END_NAMESPACE diff --git a/src/webenginewidgets/api/qwebengineurlschemehandler_p_p.h b/src/core/api/qwebengineurlschemehandler_p.h similarity index 72% rename from src/webenginewidgets/api/qwebengineurlschemehandler_p_p.h rename to src/core/api/qwebengineurlschemehandler_p.h index b15171edc3b4ebc6c24d451bec49007f3e7b3ad5..dc4b272b328895ae9c18e78ca7c9b0b5c96c81b9 100644 --- a/src/webenginewidgets/api/qwebengineurlschemehandler_p_p.h +++ b/src/core/api/qwebengineurlschemehandler_p.h @@ -10,15 +10,15 @@ ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 3 as published by the Free Software ** Foundation and appearing in the file LICENSE.LGPLv3 included in the -** packaging of this file. Please review the following information to +** packaging of this file. Please review the following information to ** ensure the GNU Lesser General Public License version 3 requirements ** will be met: https://www.gnu.org/licenses/lgpl.html. ** @@ -26,7 +26,7 @@ ** Alternatively, this file may be used under the terms of the GNU ** General Public License version 2.0 or later as published by the Free ** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information to +** the packaging of this file. Please review the following information to ** ensure the GNU General Public License version 2.0 requirements will be ** met: http://www.gnu.org/licenses/gpl-2.0.html. ** @@ -37,11 +37,20 @@ #ifndef QWEBENGINEURLSCHEMEHANDLER_P_H #define QWEBENGINEURLSCHEMEHANDLER_P_H -#include "qwebengineurlschemehandler_p.h" +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// -#include "custom_url_scheme_handler.h" +#include "qwebengineurlschemehandler.h" -#include <QPointer> +#include "custom_url_scheme_handler.h" QT_BEGIN_NAMESPACE @@ -49,18 +58,17 @@ class QWebEngineProfile; class QWebEngineUrlRequestJob; class QWebEngineUrlSchemeHandler; -class QWebEngineUrlSchemeHandlerPrivate : public QtWebEngineCore::CustomUrlSchemeHandler { +class QWEBENGINE_EXPORT QWebEngineUrlSchemeHandlerPrivate : public QtWebEngineCore::CustomUrlSchemeHandler { public: Q_DECLARE_PUBLIC(QWebEngineUrlSchemeHandler) - QWebEngineUrlSchemeHandlerPrivate(const QByteArray &, QWebEngineUrlSchemeHandler *, QWebEngineProfile *); + QWebEngineUrlSchemeHandlerPrivate(const QByteArray &, QWebEngineUrlSchemeHandler *); virtual ~QWebEngineUrlSchemeHandlerPrivate(); virtual bool handleJob(QtWebEngineCore::URLRequestCustomJobDelegate*) Q_DECL_OVERRIDE; private: QWebEngineUrlSchemeHandler *q_ptr; - QPointer<QWebEngineProfile> m_profile; }; QT_END_NAMESPACE diff --git a/src/core/proxy_resolver_qt.cpp b/src/core/authentication_dialog_controller.cpp similarity index 50% rename from src/core/proxy_resolver_qt.cpp rename to src/core/authentication_dialog_controller.cpp index 9db76e9101b9e2b480595e49faf0539a872ba0e4..db534a24ed3ed06f920debef79d45736a99ae8e1 100644 --- a/src/core/proxy_resolver_qt.cpp +++ b/src/core/authentication_dialog_controller.cpp @@ -34,60 +34,63 @@ ** ****************************************************************************/ -#include "proxy_resolver_qt.h" +#include "authentication_dialog_controller.h" +#include "authentication_dialog_controller_p.h" -#include "proxy_config_service_qt.h" -#include "type_conversion.h" +#include "content/public/browser/browser_thread.h" -#include "net/base/load_states.h" -#include "net/base/net_errors.h" -#include "net/proxy/proxy_info.h" +namespace QtWebEngineCore { -#include <QNetworkProxyFactory> -#include <QNetworkProxyQuery> +AuthenticationDialogControllerPrivate::AuthenticationDialogControllerPrivate(ResourceDispatcherHostLoginDelegateQt *loginDelegate) + : loginDelegate(loginDelegate) +{ +} -ProxyResolverQt::ProxyResolverQt() - : net::ProxyResolver(/*expects_pac_bytes = */ false) +void AuthenticationDialogControllerPrivate::dialogFinished(bool accepted, const QString &user, const QString &password) { + content::BrowserThread::PostTask( + content::BrowserThread::IO, FROM_HERE, + base::Bind(&ResourceDispatcherHostLoginDelegateQt::sendAuthToRequester, loginDelegate, accepted, user, password)); } -int ProxyResolverQt::GetProxyForURL(const GURL &url, net::ProxyInfo *results, const net::CompletionCallback &, net::ProxyResolver::RequestHandle *, const net::BoundNetLog &) +AuthenticationDialogController::AuthenticationDialogController(AuthenticationDialogControllerPrivate *dd) { - QList<QNetworkProxy> proxies = QNetworkProxyFactory::systemProxyForQuery(QNetworkProxyQuery(QtWebEngineCore::toQt(url))); - if (proxies.empty()) - return net::ERR_FAILED; - if (proxies.size() == 1) { - const QNetworkProxy &qtProxy = proxies.first(); - if (qtProxy.type() == QNetworkProxy::NoProxy) - results->UseDirect(); - else - results->UseProxyServer(ProxyConfigServiceQt::fromQNetworkProxy(qtProxy)); - return net::OK; - } - net::ProxyList proxyList; - Q_FOREACH (const QNetworkProxy &qtProxy, proxies) - proxyList.AddProxyServer(ProxyConfigServiceQt::fromQNetworkProxy(qtProxy)); - results->UseProxyList(proxyList); - return net::OK; + Q_ASSERT(dd); + d.reset(dd); } -void ProxyResolverQt::CancelRequest(net::ProxyResolver::RequestHandle) +AuthenticationDialogController::~AuthenticationDialogController() { - // This is a synchronous ProxyResolver; no possibility for async requests. - NOTREACHED(); } -net::LoadState ProxyResolverQt::GetLoadState(net::ProxyResolver::RequestHandle) const +QUrl AuthenticationDialogController::url() const { - NOTREACHED(); - return net::LOAD_STATE_IDLE; + return d->loginDelegate->url(); } -void ProxyResolverQt::CancelSetPacScript() +QString AuthenticationDialogController::realm() const { - NOTREACHED(); + return d->loginDelegate->realm(); } -int ProxyResolverQt::SetPacScript(const scoped_refptr<net::ProxyResolverScriptData> &, const net::CompletionCallback &) { - return net::OK; +QString AuthenticationDialogController::host() const +{ + return d->loginDelegate->host(); } + +bool AuthenticationDialogController::isProxy() const +{ + return d->loginDelegate->isProxy(); +} + +void AuthenticationDialogController::accept(const QString &user, const QString &password) +{ + d->dialogFinished(true, user, password); +} + +void AuthenticationDialogController::reject() +{ + d->dialogFinished(false); +} + +} // namespace QtWebEngineCore diff --git a/src/core/proxy_resolver_qt.h b/src/core/authentication_dialog_controller.h similarity index 59% rename from src/core/proxy_resolver_qt.h rename to src/core/authentication_dialog_controller.h index 4d419fb6e964fd77f68bcd501d97874dacc9d8ec..ae741f537a201586e905ffc480c20474dbf44184 100644 --- a/src/core/proxy_resolver_qt.h +++ b/src/core/authentication_dialog_controller.h @@ -34,41 +34,38 @@ ** ****************************************************************************/ -#ifndef PROXY_RESOLVER_QT_H -#define PROXY_RESOLVER_QT_H +#ifndef AUTHENTICATION_DIALOG_CONTROLLER_H +#define AUTHENTICATION_DIALOG_CONTROLLER_H -#include "net/proxy/proxy_resolver.h" -#include "net/proxy/proxy_resolver_factory.h" -#include <qglobal.h> +#include "qtwebenginecoreglobal.h" +#include <QObject> -class ProxyResolverQt : public net::ProxyResolver { -public: - static bool useProxyResolverQt() { return qEnvironmentVariableIsSet("QTWEBENGINE_USE_QT_PROXYRESOLVER"); } +namespace QtWebEngineCore { - ProxyResolverQt(); +class AuthenticationDialogControllerPrivate; - int GetProxyForURL(const GURL &url, net::ProxyInfo *results, const net::CompletionCallback & - , RequestHandle*, const net::BoundNetLog&) override; +class QWEBENGINE_EXPORT AuthenticationDialogController : public QObject { + Q_OBJECT +public: + ~AuthenticationDialogController(); - void CancelRequest(RequestHandle) override; + QUrl url() const; + QString realm() const; + QString host() const; + bool isProxy() const; - net::LoadState GetLoadState(RequestHandle) const override; +public Q_SLOTS: + void accept(const QString &user, const QString &password); + void reject(); - void CancelSetPacScript() override; +private: + AuthenticationDialogController(AuthenticationDialogControllerPrivate *); - int SetPacScript(const scoped_refptr<net::ProxyResolverScriptData>& /*script_data*/, const net::CompletionCallback& /*callback*/) override; + QScopedPointer<AuthenticationDialogControllerPrivate> d; + friend class ResourceDispatcherHostLoginDelegateQt; }; -class ProxyResolverFactoryQt : public net::LegacyProxyResolverFactory { -public: - ProxyResolverFactoryQt(bool expects_pac_bytes) : net::LegacyProxyResolverFactory(expects_pac_bytes) - { - } - scoped_ptr<net::ProxyResolver> CreateProxyResolver() override - { - return scoped_ptr<net::ProxyResolver>(new ProxyResolverQt()); - } -}; +} // namespace QtWebEngineCore -#endif // PROXY_RESOLVER_QT_H +#endif // AUTHENTICATION_DIALOG_CONTROLLER_H diff --git a/src/core/authentication_dialog_controller_p.h b/src/core/authentication_dialog_controller_p.h new file mode 100644 index 0000000000000000000000000000000000000000..5b1d21ae04274cbb8f3747cd8c9586737ffb7684 --- /dev/null +++ b/src/core/authentication_dialog_controller_p.h @@ -0,0 +1,56 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the QtWebEngine module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef AUTHENTICATION_DIALOG_CONTROLLER_P_H +#define AUTHENTICATION_DIALOG_CONTROLLER_P_H + +#include "base/memory/ref_counted.h" +#include "resource_dispatcher_host_delegate_qt.h" + +namespace QtWebEngineCore { + +class AuthenticationDialogControllerPrivate { + +public: + AuthenticationDialogControllerPrivate(ResourceDispatcherHostLoginDelegateQt *loginDelegate); + void dialogFinished(bool accepted, const QString &user = QString(), const QString &password = QString()); + + scoped_refptr<ResourceDispatcherHostLoginDelegateQt> loginDelegate; +}; + +} // namespace QtWebEngineCore + +#endif // AUTHENTICATION_DIALOG_CONTROLLER_H diff --git a/src/core/browser_accessibility_qt.cpp b/src/core/browser_accessibility_qt.cpp index 9d4fdfe00a814ef483b82041b7d207fb3c725e60..ebf99e9507fd8b912e86c485189e24f1585de29d 100644 --- a/src/core/browser_accessibility_qt.cpp +++ b/src/core/browser_accessibility_qt.cpp @@ -59,6 +59,84 @@ BrowserAccessibilityQt::BrowserAccessibilityQt() QAccessible::registerAccessibleInterface(this); } +// This function is taken from chromium/content/browser/accessibility/browser_accessibility_win.cc +// see also http://www.w3.org/TR/html-aapi +void BrowserAccessibilityQt::OnDataChanged() +{ + BrowserAccessibility::OnDataChanged(); + + // The calculation of the accessible name of an element has been + // standardized in the HTML to Platform Accessibility APIs Implementation + // Guide (http://www.w3.org/TR/html-aapi/). In order to return the + // appropriate accessible name on Windows, we need to apply some logic + // to the fields we get from WebKit. + // + // TODO(dmazzoni): move most of this logic into WebKit. + // + // WebKit gives us: + // + // name: the default name, e.g. inner text + // title ui element: a reference to a <label> element on the same + // page that labels this node. + // description: accessible labels that override the default name: + // aria-label or aria-labelledby or aria-describedby + // help: the value of the "title" attribute + // + // On Windows, the logic we apply lets some fields take precedence and + // always returns the primary name in "name" and the secondary name, + // if any, in "description". + + int title_elem_id = GetIntAttribute(ui::AX_ATTR_TITLE_UI_ELEMENT); + base::string16 name = GetString16Attribute(ui::AX_ATTR_NAME); + base::string16 description = GetString16Attribute(ui::AX_ATTR_DESCRIPTION); + base::string16 help = GetString16Attribute(ui::AX_ATTR_HELP); + base::string16 value = GetString16Attribute(ui::AX_ATTR_VALUE); + + // WebKit annoyingly puts the title in the description if there's no other + // description, which just confuses the rest of the logic. Put it back. + // Now "help" is always the value of the "title" attribute, if present. + base::string16 title_attr; + if (GetHtmlAttribute("title", &title_attr) && + description == title_attr && + help.empty()) { + help = description; + description.clear(); + } + + // Now implement the main logic: the descripion should become the name if + // it's nonempty, and the help should become the description if + // there's no description - or the name if there's no name or description. + if (!description.empty()) { + name = description; + description.clear(); + } + if (!help.empty() && description.empty()) { + description = help; + help.clear(); + } + if (!description.empty() && name.empty() && !title_elem_id) { + name = description; + description.clear(); + } + + // If it's a text field, also consider the placeholder. + base::string16 placeholder; + if (GetRole() == ui::AX_ROLE_TEXT_FIELD && + HasState(ui::AX_STATE_FOCUSABLE) && + GetHtmlAttribute("placeholder", &placeholder)) { + if (name.empty() && !title_elem_id) { + name = placeholder; + } else if (description.empty()) { + description = placeholder; + } + } + + m_name = toQt(name); + m_description = toQt(description); + m_help = toQt(help); + m_value = toQt(value); +} + bool BrowserAccessibilityQt::isValid() const { return true; @@ -151,13 +229,13 @@ QString BrowserAccessibilityQt::text(QAccessible::Text t) const { switch (t) { case QAccessible::Name: - return toQt(GetStringAttribute(ui::AX_ATTR_NAME)); + return name(); case QAccessible::Description: - return toQt(GetStringAttribute(ui::AX_ATTR_DESCRIPTION)); + return description(); case QAccessible::Help: - return toQt(GetStringAttribute(ui::AX_ATTR_HELP)); + return help(); case QAccessible::Value: - return toQt(GetStringAttribute(ui::AX_ATTR_VALUE)); + return value(); case QAccessible::Accelerator: return toQt(GetStringAttribute(ui::AX_ATTR_SHORTCUT)); default: diff --git a/src/core/browser_accessibility_qt.h b/src/core/browser_accessibility_qt.h index d4f8ac0a511444b002db3d27a996698dd24cec3f..b7b4c39bcd798db6489ddc0cdc420068e72d26e1 100644 --- a/src/core/browser_accessibility_qt.h +++ b/src/core/browser_accessibility_qt.h @@ -55,6 +55,9 @@ class BrowserAccessibilityQt public: BrowserAccessibilityQt(); + // BrowserAccessibility + virtual void OnDataChanged() Q_DECL_OVERRIDE; + // QAccessibleInterface virtual bool isValid() const Q_DECL_OVERRIDE; virtual QObject *object() const Q_DECL_OVERRIDE; @@ -139,6 +142,18 @@ public: virtual QAccessibleInterface* table() const Q_DECL_OVERRIDE; virtual void modelChange(QAccessibleTableModelChangeEvent *event) Q_DECL_OVERRIDE; + + QString name() const { return m_name; } + QString description() const { return m_description; } + QString help() const { return m_help; } + QString value() const { return m_value; } + +private: + // IAccessible name, description, help, value. + QString m_name; + QString m_description; + QString m_help; + QString m_value; }; } diff --git a/src/core/browser_context_adapter.cpp b/src/core/browser_context_adapter.cpp index 14f3b1c6cbbcb31700e267a68eaa3d1610abd071..660c6ffb23e6dabf8b00f35f9c51f1f6e4ea0436 100644 --- a/src/core/browser_context_adapter.cpp +++ b/src/core/browser_context_adapter.cpp @@ -36,6 +36,7 @@ #include "browser_context_adapter.h" +#include "content/browser/web_contents/web_contents_impl.h" #include "content/public/browser/browser_thread.h" #include "browser_context_qt.h" #include "content_client_qt.h" @@ -54,6 +55,8 @@ #include <QStringBuilder> #include <QStandardPaths> +#include <numeric> + namespace { inline QString buildLocationFromStandardPath(const QString &standardPath, const QString &name) { QString location = standardPath; @@ -253,6 +256,12 @@ void BrowserContextAdapter::setHttpUserAgent(const QString &userAgent) if (m_httpUserAgent == userAgent) return; m_httpUserAgent = userAgent; + + std::vector<content::WebContentsImpl *> list = content::WebContentsImpl::GetAllWebContents(); + Q_FOREACH (content::WebContentsImpl *web_contents, list) + if (web_contents->GetBrowserContext() == m_browserContext.data()) + web_contents->SetUserAgentOverride(userAgent.toStdString()); + if (m_browserContext->url_request_getter_.get()) m_browserContext->url_request_getter_->updateUserAgent(); } @@ -356,6 +365,12 @@ void BrowserContextAdapter::updateCustomUrlSchemeHandlers() m_browserContext->url_request_getter_->updateStorageSettings(); } +void BrowserContextAdapter::removeCustomUrlSchemeHandler(CustomUrlSchemeHandler *handler) +{ + m_customUrlSchemeHandlers.removeOne(handler); + Q_ASSERT(!m_customUrlSchemeHandlers.contains(handler)); +} + UserScriptControllerHost *BrowserContextAdapter::userScriptController() { if (!m_userScriptController) @@ -368,6 +383,16 @@ void BrowserContextAdapter::permissionRequestReply(const QUrl &origin, Permissio static_cast<PermissionManagerQt*>(browserContext()->GetPermissionManager())->permissionRequestReply(origin, type, reply); } +QString BrowserContextAdapter::httpAcceptLanguageWithoutQualities() const +{ + const QStringList list = m_httpAcceptLanguage.split(QLatin1Char(',')); + return std::accumulate(list.constBegin(), list.constEnd(), QString(), + [](const QString &r, const QString &e) { + return (r.isEmpty() ? r : r + QString(QLatin1Char(','))) + + e.split(QLatin1Char(';')).first(); + }); +} + QString BrowserContextAdapter::httpAcceptLanguage() const { return m_httpAcceptLanguage; diff --git a/src/core/browser_context_adapter.h b/src/core/browser_context_adapter.h index d58d8a4befe5debddb0044b828a801991a754432..0bca1bf8b0b40ed1bd2de577cdb852570b7b6877 100644 --- a/src/core/browser_context_adapter.h +++ b/src/core/browser_context_adapter.h @@ -147,10 +147,12 @@ public: QVector<CustomUrlSchemeHandler*> &customUrlSchemeHandlers(); void updateCustomUrlSchemeHandlers(); + void removeCustomUrlSchemeHandler(CustomUrlSchemeHandler*); UserScriptControllerHost *userScriptController(); void permissionRequestReply(const QUrl &origin, PermissionType type, bool reply); + QString httpAcceptLanguageWithoutQualities() const; QString httpAcceptLanguage() const; void setHttpAcceptLanguage(const QString &httpAcceptLanguage); diff --git a/src/core/certificate_error_controller_p.h b/src/core/certificate_error_controller_p.h index 505e77905fd235c94255ae9b0708ecaf6b67b0bf..08b51f30fd66a020b40adbce3ae66cb6602edcb9 100644 --- a/src/core/certificate_error_controller_p.h +++ b/src/core/certificate_error_controller_p.h @@ -37,6 +37,17 @@ #ifndef CERTIFICATE_ERROR_CONTROLLER_P_H #define CERTIFICATE_ERROR_CONTROLLER_P_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include "content/public/browser/content_browser_client.h" #include "certificate_error_controller.h" diff --git a/src/core/clipboard_qt.cpp b/src/core/clipboard_qt.cpp index 85235acce0ed4a97964a271c85864c95938f1563..2063928405372437169adea3a2fffb79307774e2 100644 --- a/src/core/clipboard_qt.cpp +++ b/src/core/clipboard_qt.cpp @@ -208,7 +208,7 @@ void ClipboardQt::WriteObjects(ui::ClipboardType type, const ObjectMap& objects) if (uncommittedData) QGuiApplication::clipboard()->setMimeData(uncommittedData.take(), type == ui::CLIPBOARD_TYPE_COPY_PASTE ? QClipboard::Clipboard : QClipboard::Selection); - if (type == ui::CLIPBOARD_TYPE_COPY_PASTE) { + if (type == ui::CLIPBOARD_TYPE_COPY_PASTE && IsSupportedClipboardType(ui::CLIPBOARD_TYPE_SELECTION)) { ObjectMap::const_iterator text_iter = objects.find(CBF_TEXT); if (text_iter != objects.end()) { // Copy text and SourceTag to the selection clipboard. diff --git a/src/core/config/desktop_linux.pri b/src/core/config/desktop_linux.pri index cb4efa607c33b7b67260fb067cb8b26cf94e95a3..f0bf6cb23b8286fa22df062bfbc2a1de9dc48ea8 100644 --- a/src/core/config/desktop_linux.pri +++ b/src/core/config/desktop_linux.pri @@ -1,37 +1,10 @@ GYP_ARGS += "-D qt_os=\"desktop_linux\"" +include(linux.pri) + GYP_CONFIG += \ desktop_linux=1 \ - toolkit_uses_gtk=0 \ - use_aura=1 \ - use_ash=0 \ - use_cairo=0 \ - use_clipboard_aurax11=0 \ - use_cups=0 \ - use_gconf=0 \ - use_gio=0 \ - use_gnome_keyring=0 \ - use_kerberos=0 \ - use_pango=0 \ - host_clang=0 \ - clang=0 \ enable_plugins=1 \ -contains(QT_CONFIG, system-zlib): config_system_minizip: GYP_CONFIG += use_system_zlib=1 -contains(QT_CONFIG, system-png): GYP_CONFIG += use_system_libpng=1 -contains(QT_CONFIG, system-jpeg): GYP_CONFIG += use_system_libjpeg=1 -config_system_libevent: GYP_CONFIG += use_system_libevent=1 -config_system_libwebp: GYP_CONFIG += use_system_libwebp=1 -config_system_libsrtp: GYP_CONFIG += use_system_libsrtp=1 -config_system_libxslt: GYP_CONFIG += use_system_libxml=1 -config_system_flac: GYP_CONFIG += use_system_flac=1 -config_system_jsoncpp: GYP_CONFIG += use_system_jsoncpp=1 -config_system_opus: GYP_CONFIG += use_system_opus=1 -config_system_snappy: GYP_CONFIG += use_system_snappy=1 -config_system_speex: GYP_CONFIG += use_system_speex=1 -config_system_vpx: GYP_CONFIG += use_system_libvpx=1 - -contains(WEBENGINE_CONFIG, use_system_icu): GYP_CONFIG += use_system_icu=1 -contains(WEBENGINE_CONFIG, use_system_ffmpeg): GYP_CONFIG += use_system_ffmpeg=1 - -!contains(QT_CONFIG, pulseaudio): GYP_CONFIG += use_pulseaudio=0 +linux-clang: GYP_CONFIG += clang=1 host_clang=1 clang_use_chrome_plugins=0 make_clang_dir=/usr +else: GYP_CONFIG += clang=0 host_clang=0 diff --git a/src/core/config/embedded_linux.pri b/src/core/config/embedded_linux.pri index 0133dc6b09a53d2de81fa83676bc318857e5e19d..cd12204f9fbb521eae08805d6e84978d39bb25cf 100644 --- a/src/core/config/embedded_linux.pri +++ b/src/core/config/embedded_linux.pri @@ -1,5 +1,7 @@ GYP_ARGS += "-D qt_os=\"embedded_linux\" -I config/embedded_linux.gypi" +include(linux.pri) + GYP_CONFIG += \ clang=0 \ desktop_linux=0 \ @@ -23,45 +25,20 @@ GYP_CONFIG += \ gtest_target_type=none \ host_clang=0 \ notifications=0 \ + ozone_auto_platforms=0 \ ozone_platform_dri=0 \ ozone_platform_test=0 \ p2p_apis=0 \ safe_browsing=0 \ toolkit_views=1 \ - use_ash=0 \ - use_aura=1 \ - use_cairo=0 \ - use_clipboard_aurax11=0 \ - use_cups=0 \ use_custom_freetype=0 \ - use_gconf=0 \ - use_gio=0 \ - use_gnome_keyring=0 \ - use_kerberos=0 \ use_libpci=0 \ + use_nss_certs=0 \ use_openssl=1 \ + use_openssl_certs=1 \ use_ozone=1 \ - use_pango=0 \ use_system_fontconfig=1 \ icu_use_data_file_flag=0 \ use_x11=0 \ v8_use_snapshot=false \ want_separate_host_toolset=1 \ - -contains(QT_CONFIG, system-zlib): config_system_minizip: GYP_CONFIG += use_system_zlib=1 -contains(QT_CONFIG, system-png): GYP_CONFIG += use_system_libpng=1 -contains(QT_CONFIG, system-jpeg): GYP_CONFIG += use_system_libjpeg=1 -!contains(QT_CONFIG, pulseaudio): GYP_CONFIG += use_pulseaudio=0 -config_system_libevent: GYP_CONFIG += use_system_libevent=1 -config_system_libwebp: GYP_CONFIG += use_system_libwebp=1 -config_system_libsrtp: GYP_CONFIG += use_system_libsrtp=1 -config_system_libxslt: GYP_CONFIG += use_system_libxml=1 -config_system_flac: GYP_CONFIG += use_system_flac=1 -config_system_jsoncpp: GYP_CONFIG += use_system_jsoncpp=1 -config_system_opus: GYP_CONFIG += use_system_opus=1 -config_system_snappy: GYP_CONFIG += use_system_snappy=1 -config_system_speex: GYP_CONFIG += use_system_speex=1 -config_system_vpx: GYP_CONFIG += use_system_libvpx=1 - -contains(WEBENGINE_CONFIG, use_system_icu): GYP_CONFIG += use_system_icu=1 -contains(WEBENGINE_CONFIG, use_system_ffmpeg): GYP_CONFIG += use_system_ffmpeg=1 diff --git a/src/core/config/linux.pri b/src/core/config/linux.pri new file mode 100644 index 0000000000000000000000000000000000000000..4c2e70daf265cb21b4526651ffb168613157d11f --- /dev/null +++ b/src/core/config/linux.pri @@ -0,0 +1,40 @@ +# linux_use_bundled_gold currently relies on a hardcoded relative path from chromium/src/out/(Release|Debug) +# Disable it along with the -Wl,--threads flag just in case gold isn't installed on the system. +GYP_CONFIG += \ + linux_use_bundled_gold=0 \ + linux_use_bundled_binutils=0 \ + linux_use_gold_flags=0 \ + +GYP_CONFIG += \ + toolkit_uses_gtk=0 \ + use_ash=0 \ + use_aura=1 \ + use_cairo=0 \ + use_clipboard_aurax11=0 \ + use_cups=0 \ + use_gconf=0 \ + use_gio=0 \ + use_gnome_keyring=0 \ + use_kerberos=0 \ + use_pango=0 + +contains(QT_CONFIG, system-zlib): config_system_minizip: GYP_CONFIG += use_system_zlib=1 +contains(QT_CONFIG, system-png): GYP_CONFIG += use_system_libpng=1 +contains(QT_CONFIG, system-jpeg): GYP_CONFIG += use_system_libjpeg=1 +contains(QT_CONFIG, system-harfbuzz): GYP_CONFIG += use_system_harfbuzz=1 +!contains(QT_CONFIG, pulseaudio): GYP_CONFIG += use_pulseaudio=0 + +config_system_libevent: GYP_CONFIG += use_system_libevent=1 +config_system_libwebp: GYP_CONFIG += use_system_libwebp=1 +config_system_libsrtp: GYP_CONFIG += use_system_libsrtp=1 +config_system_libxslt: GYP_CONFIG += use_system_libxml=1 +config_system_flac: GYP_CONFIG += use_system_flac=1 +config_system_jsoncpp: GYP_CONFIG += use_system_jsoncpp=1 +config_system_opus: GYP_CONFIG += use_system_opus=1 +config_system_snappy: GYP_CONFIG += use_system_snappy=1 +config_system_speex: GYP_CONFIG += use_system_speex=1 +config_system_vpx: GYP_CONFIG += use_system_libvpx=1 + +contains(WEBENGINE_CONFIG, use_system_icu): GYP_CONFIG += use_system_icu=1 +contains(WEBENGINE_CONFIG, use_system_ffmpeg): GYP_CONFIG += use_system_ffmpeg=1 + diff --git a/src/core/content_browser_client_qt.cpp b/src/core/content_browser_client_qt.cpp index a8cb54c0ce97ead09e61f3a26a19a5b258bbbc16..91cd0b0c4b67d7730dc4fde4323773479cc88818 100644 --- a/src/core/content_browser_client_qt.cpp +++ b/src/core/content_browser_client_qt.cpp @@ -72,6 +72,7 @@ #include "resource_dispatcher_host_delegate_qt.h" #include "user_script_controller_host.h" #include "web_contents_delegate_qt.h" +#include "web_engine_context.h" #include "web_engine_library_info.h" #if defined(ENABLE_PLUGINS) @@ -225,6 +226,9 @@ public: void PostMainMessageLoopRun() { + // The BrowserContext's destructor uses the MessageLoop so it should be deleted + // right before the RenderProcessHostImpl's destructor destroys it. + WebEngineContext::current()->destroyBrowserContext(); } int PreCreateThreads() Q_DECL_OVERRIDE diff --git a/src/core/cookie_monster_delegate_qt.cpp b/src/core/cookie_monster_delegate_qt.cpp index 6b808e76cb45a15901b180132669d0bfc518e095..7838617ba22a7c5795436978f96c96ebe2a49090 100644 --- a/src/core/cookie_monster_delegate_qt.cpp +++ b/src/core/cookie_monster_delegate_qt.cpp @@ -158,6 +158,14 @@ void CookieMonsterDelegateQt::setClient(QWebEngineCookieStoreClient *client) m_client->d_func()->processPendingUserCookies(); } +bool CookieMonsterDelegateQt::canSetCookie(const QUrl &firstPartyUrl, const QByteArray &cookieLine, const QUrl &url) +{ + if (!m_client) + return true; + + return m_client->d_ptr->canSetCookie(firstPartyUrl, cookieLine, url); +} + void CookieMonsterDelegateQt::OnCookieChanged(const net::CanonicalCookie& cookie, bool removed, ChangeCause cause) { if (!m_client) diff --git a/src/core/cookie_monster_delegate_qt.h b/src/core/cookie_monster_delegate_qt.h index e5e29585345cec4b509eac80c8fb4c15a79eb000..7592d57fa2d9ad60c50aa6cd2e2f1d6766216f8c 100644 --- a/src/core/cookie_monster_delegate_qt.h +++ b/src/core/cookie_monster_delegate_qt.h @@ -80,6 +80,7 @@ public: void setCookieMonster(net::CookieMonster* monster); void setClient(QWebEngineCookieStoreClient *client); + bool canSetCookie(const QUrl &firstPartyUrl, const QByteArray &cookieLine, const QUrl &url); void OnCookieChanged(const net::CanonicalCookie& cookie, bool removed, ChangeCause cause) override; }; diff --git a/src/core/core.pro b/src/core/core.pro index 7f19a48ce93a4646f35e4e71d7697a15ff4e6899..7ddad4ed6336cc8b5e46837e5c615b36c246f0ef 100644 --- a/src/core/core.pro +++ b/src/core/core.pro @@ -15,10 +15,7 @@ core_api.depends = gyp_run core_module.file = core_module.pro core_module.depends = core_api -SUBDIRS += core_gyp_generator \ - gyp_run \ - core_api \ - core_module +SUBDIRS += core_gyp_generator !win32 { # gyp_configure_host.pro and gyp_configure_target.pro are phony pro files that @@ -32,3 +29,7 @@ SUBDIRS += core_gyp_generator \ gyp_run.depends += gyp_configure_host gyp_configure_target SUBDIRS += gyp_configure_host gyp_configure_target } + +SUBDIRS += gyp_run \ + core_api \ + core_module diff --git a/src/core/core_gyp_generator.pro b/src/core/core_gyp_generator.pro index 1a2679a60e790c1da2dcf0d65ed3e3b7b4367b6e..c1b8179e0b94d3d6fd88cec75ce4d7be88dc7025 100644 --- a/src/core/core_gyp_generator.pro +++ b/src/core/core_gyp_generator.pro @@ -29,6 +29,7 @@ INCLUDEPATH += $$PWD $$PWD/api SOURCES = \ access_token_store_qt.cpp \ + authentication_dialog_controller.cpp \ browser_accessibility_manager_qt.cpp \ browser_accessibility_qt.cpp \ browser_context_adapter.cpp \ @@ -61,7 +62,6 @@ SOURCES = \ permission_manager_qt.cpp \ process_main.cpp \ proxy_config_service_qt.cpp \ - proxy_resolver_qt.cpp \ qrc_protocol_handler_qt.cpp \ qt_render_view_observer_host.cpp \ render_widget_host_view_qt.cpp \ @@ -99,6 +99,8 @@ SOURCES = \ HEADERS = \ access_token_store_qt.h \ + authentication_dialog_controller_p.h \ + authentication_dialog_controller.h \ browser_accessibility_manager_qt.h \ browser_accessibility_qt.h \ browser_context_adapter.h \ @@ -133,7 +135,6 @@ HEADERS = \ permission_manager_qt.h \ process_main.h \ proxy_config_service_qt.h \ - proxy_resolver_qt.h \ qrc_protocol_handler_qt.h \ qt_render_view_observer_host.h \ render_widget_host_view_qt.h \ diff --git a/src/core/core_module.pro b/src/core/core_module.pro index dafeb0b367ba935f51171a2d34844a1f64423c9a..cf253a7355b6c83b5f357a9b43b61da93bf6e064 100644 --- a/src/core/core_module.pro +++ b/src/core/core_module.pro @@ -9,18 +9,21 @@ QMAKE_INFO_PLIST = Info_mac.plist error("Could not find the linking information that gyp should have generated.") } -QMAKE_DOCS = $$PWD/doc/qtwebenginecore.qdocconf - load(qt_module) -api_library_name = qtwebenginecoreapi +api_library_name = qtwebenginecoreapi$$qtPlatformTargetSuffix() api_library_path = $$OUT_PWD/api/$$getConfigDir() + + LIBS_PRIVATE += -L$$api_library_path CONFIG *= no_smart_library_merge osx { LIBS_PRIVATE += -Wl,-force_load,$${api_library_path}$${QMAKE_DIR_SEP}lib$${api_library_name}.a -} else:win32-msvc* { - LIBS_PRIVATE += /OPT:REF -l$$api_library_name +} else:msvc { + # Simulate -whole-archive by passing the list of object files that belong to the public + # API library as response file to the linker. + LIBS_PRIVATE += /OPT:REF + QMAKE_LFLAGS += @$${api_library_path}$${QMAKE_DIR_SEP}$${api_library_name}.lib.objects } else { LIBS_PRIVATE += -Wl,-whole-archive -l$$api_library_name -Wl,-no-whole-archive } @@ -45,7 +48,9 @@ LOCALE_LIST = am ar bg bn ca cs da de el en-GB en-US es-419 es et fa fi fil fr g for(LOC, LOCALE_LIST) { locales.files += $$REPACK_DIR/qtwebengine_locales/$${LOC}.pak } -resources.files = $$REPACK_DIR/qtwebengine_resources.pak +resources.files = $$REPACK_DIR/qtwebengine_resources.pak \ + $$REPACK_DIR/qtwebengine_resources_100p.pak \ + $$REPACK_DIR/qtwebengine_resources_200p.pak icu.files = $$OUT_PWD/$$getConfigDir()/icudtl.dat diff --git a/src/core/custom_protocol_handler.cpp b/src/core/custom_protocol_handler.cpp index 5deadf18532b9101f5fa61e244745a7a29a7f5b7..f140f98cf141980ae5804aae939aaf434e6a7edb 100644 --- a/src/core/custom_protocol_handler.cpp +++ b/src/core/custom_protocol_handler.cpp @@ -10,15 +10,15 @@ ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 3 as published by the Free Software ** Foundation and appearing in the file LICENSE.LGPLv3 included in the -** packaging of this file. Please review the following information to +** packaging of this file. Please review the following information to ** ensure the GNU Lesser General Public License version 3 requirements ** will be met: https://www.gnu.org/licenses/lgpl.html. ** @@ -26,7 +26,7 @@ ** Alternatively, this file may be used under the terms of the GNU ** General Public License version 2.0 or later as published by the Free ** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information to +** the packaging of this file. Please review the following information to ** ensure the GNU General Public License version 2.0 requirements will be ** met: http://www.gnu.org/licenses/gpl-2.0.html. ** diff --git a/src/core/custom_protocol_handler.h b/src/core/custom_protocol_handler.h index 923cac79dbe797b691edd6b9af4f0fd2103a66ac..225bb0567cca18f04c709e21d9675fb7843a6aab 100644 --- a/src/core/custom_protocol_handler.h +++ b/src/core/custom_protocol_handler.h @@ -10,15 +10,15 @@ ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 3 as published by the Free Software ** Foundation and appearing in the file LICENSE.LGPLv3 included in the -** packaging of this file. Please review the following information to +** packaging of this file. Please review the following information to ** ensure the GNU Lesser General Public License version 3 requirements ** will be met: https://www.gnu.org/licenses/lgpl.html. ** @@ -26,7 +26,7 @@ ** Alternatively, this file may be used under the terms of the GNU ** General Public License version 2.0 or later as published by the Free ** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information to +** the packaging of this file. Please review the following information to ** ensure the GNU General Public License version 2.0 requirements will be ** met: http://www.gnu.org/licenses/gpl-2.0.html. ** diff --git a/src/core/custom_url_scheme_handler.cpp b/src/core/custom_url_scheme_handler.cpp index 591cad32e589a80ed2dd542549d11bb2954de470..29791b55590e72b26000d2dc619422034d54fe2c 100644 --- a/src/core/custom_url_scheme_handler.cpp +++ b/src/core/custom_url_scheme_handler.cpp @@ -10,15 +10,15 @@ ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 3 as published by the Free Software ** Foundation and appearing in the file LICENSE.LGPLv3 included in the -** packaging of this file. Please review the following information to +** packaging of this file. Please review the following information to ** ensure the GNU Lesser General Public License version 3 requirements ** will be met: https://www.gnu.org/licenses/lgpl.html. ** @@ -26,7 +26,7 @@ ** Alternatively, this file may be used under the terms of the GNU ** General Public License version 2.0 or later as published by the Free ** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information to +** the packaging of this file. Please review the following information to ** ensure the GNU General Public License version 2.0 requirements will be ** met: http://www.gnu.org/licenses/gpl-2.0.html. ** @@ -44,10 +44,6 @@ CustomUrlSchemeHandler::CustomUrlSchemeHandler(const QByteArray &scheme) { } -CustomUrlSchemeHandler::~CustomUrlSchemeHandler() -{ -} - QByteArray CustomUrlSchemeHandler::scheme() const { return m_scheme; diff --git a/src/core/custom_url_scheme_handler.h b/src/core/custom_url_scheme_handler.h index 0079095d88999f4772b9bfd9c92b42703ee2bc3e..d866628dea73254e4551e822356085f938ee305d 100644 --- a/src/core/custom_url_scheme_handler.h +++ b/src/core/custom_url_scheme_handler.h @@ -10,15 +10,15 @@ ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 3 as published by the Free Software ** Foundation and appearing in the file LICENSE.LGPLv3 included in the -** packaging of this file. Please review the following information to +** packaging of this file. Please review the following information to ** ensure the GNU Lesser General Public License version 3 requirements ** will be met: https://www.gnu.org/licenses/lgpl.html. ** @@ -26,7 +26,7 @@ ** Alternatively, this file may be used under the terms of the GNU ** General Public License version 2.0 or later as published by the Free ** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information to +** the packaging of this file. Please review the following information to ** ensure the GNU General Public License version 2.0 requirements will be ** met: http://www.gnu.org/licenses/gpl-2.0.html. ** @@ -53,7 +53,7 @@ class URLRequestCustomJobDelegate; class QWEBENGINE_EXPORT CustomUrlSchemeHandler { public: explicit CustomUrlSchemeHandler(const QByteArray &); - ~CustomUrlSchemeHandler(); + virtual ~CustomUrlSchemeHandler() { } QByteArray scheme() const; void setScheme(const QByteArray &); diff --git a/src/core/delegated_frame_node.cpp b/src/core/delegated_frame_node.cpp index dee381e15fbba2aaeaf45a230cef352d8f40dde8..aebdfd0273afa166171a84b335f840f8b8b699ce 100644 --- a/src/core/delegated_frame_node.cpp +++ b/src/core/delegated_frame_node.cpp @@ -165,9 +165,9 @@ static QSGNode *buildLayerChain(QSGNode *chainParent, const cc::SharedQuadState layerChain->appendChildNode(clipNode); layerChain = clipNode; } - if (!layerState->content_to_target_transform.IsIdentity()) { + if (!layerState->quad_to_target_transform.IsIdentity()) { QSGTransformNode *transformNode = new QSGTransformNode; - transformNode->setMatrix(toQt(layerState->content_to_target_transform.matrix())); + transformNode->setMatrix(toQt(layerState->quad_to_target_transform.matrix())); layerChain->appendChildNode(transformNode); layerChain = transformNode; } @@ -571,7 +571,7 @@ void DelegatedFrameNode::commit(ChromiumCompositorData *chromiumCompositorData, break; } case cc::DrawQuad::TEXTURE_CONTENT: { const cc::TextureDrawQuad *tquad = cc::TextureDrawQuad::MaterialCast(quad); - ResourceHolder *resource = findAndHoldResource(tquad->resource_id, resourceCandidates); + ResourceHolder *resource = findAndHoldResource(tquad->resource_id(), resourceCandidates); QSGSimpleTextureNode *textureNode = new QSGSimpleTextureNode; textureNode->setTextureCoordinatesTransform(tquad->y_flipped ? QSGSimpleTextureNode::MirrorVertically : QSGSimpleTextureNode::NoTransform); @@ -619,7 +619,7 @@ void DelegatedFrameNode::commit(ChromiumCompositorData *chromiumCompositorData, break; } case cc::DrawQuad::TILED_CONTENT: { const cc::TileDrawQuad *tquad = cc::TileDrawQuad::MaterialCast(quad); - ResourceHolder *resource = findAndHoldResource(tquad->resource_id, resourceCandidates); + ResourceHolder *resource = findAndHoldResource(tquad->resource_id(), resourceCandidates); QSGSimpleTextureNode *textureNode = new QSGSimpleTextureNode; textureNode->setRect(toQt(quad->rect)); @@ -630,13 +630,13 @@ void DelegatedFrameNode::commit(ChromiumCompositorData *chromiumCompositorData, break; } case cc::DrawQuad::YUV_VIDEO_CONTENT: { const cc::YUVVideoDrawQuad *vquad = cc::YUVVideoDrawQuad::MaterialCast(quad); - ResourceHolder *yResource = findAndHoldResource(vquad->y_plane_resource_id, resourceCandidates); - ResourceHolder *uResource = findAndHoldResource(vquad->u_plane_resource_id, resourceCandidates); - ResourceHolder *vResource = findAndHoldResource(vquad->v_plane_resource_id, resourceCandidates); + ResourceHolder *yResource = findAndHoldResource(vquad->y_plane_resource_id(), resourceCandidates); + ResourceHolder *uResource = findAndHoldResource(vquad->u_plane_resource_id(), resourceCandidates); + ResourceHolder *vResource = findAndHoldResource(vquad->v_plane_resource_id(), resourceCandidates); ResourceHolder *aResource = 0; // This currently requires --enable-vp8-alpha-playback and needs a video with alpha data to be triggered. - if (vquad->a_plane_resource_id) - aResource = findAndHoldResource(vquad->a_plane_resource_id, resourceCandidates); + if (vquad->a_plane_resource_id()) + aResource = findAndHoldResource(vquad->a_plane_resource_id(), resourceCandidates); YUVVideoNode *videoNode = new YUVVideoNode( initAndHoldTexture(yResource, quad->ShouldDrawWithBlending()), @@ -651,7 +651,7 @@ void DelegatedFrameNode::commit(ChromiumCompositorData *chromiumCompositorData, #ifdef GL_OES_EGL_image_external } case cc::DrawQuad::STREAM_VIDEO_CONTENT: { const cc::StreamVideoDrawQuad *squad = cc::StreamVideoDrawQuad::MaterialCast(quad); - ResourceHolder *resource = findAndHoldResource(squad->resource_id, resourceCandidates); + ResourceHolder *resource = findAndHoldResource(squad->resource_id(), resourceCandidates); MailboxTexture *texture = static_cast<MailboxTexture *>(initAndHoldTexture(resource, quad->ShouldDrawWithBlending())); texture->setTarget(GL_TEXTURE_EXTERNAL_OES); // since this is not default TEXTURE_2D type diff --git a/src/core/dev_tools_http_handler_delegate_qt.cpp b/src/core/dev_tools_http_handler_delegate_qt.cpp index 2afd75e6e416a81d7448bd0c88f6a93fbbde68b8..793ed09813851897a8e004e5af25f6916b7eb834 100644 --- a/src/core/dev_tools_http_handler_delegate_qt.cpp +++ b/src/core/dev_tools_http_handler_delegate_qt.cpp @@ -62,7 +62,6 @@ #include "content/public/common/content_switches.h" #include "net/base/ip_endpoint.h" #include "net/base/net_errors.h" -#include "net/socket/stream_listen_socket.h" #include "net/socket/tcp_server_socket.h" using namespace content; diff --git a/src/core/dev_tools_http_handler_delegate_qt.h b/src/core/dev_tools_http_handler_delegate_qt.h index b998359fd1640659561022c852d560ae8f23b78a..0fe9ad0cee50bd606d8e48f64490d1471227d38b 100644 --- a/src/core/dev_tools_http_handler_delegate_qt.h +++ b/src/core/dev_tools_http_handler_delegate_qt.h @@ -39,7 +39,6 @@ #include "components/devtools_http_handler/devtools_http_handler_delegate.h" #include "content/public/browser/devtools_manager_delegate.h" -#include "net/socket/stream_listen_socket.h" #include <QString> #include <QtCore/qcompilerdetection.h> // needed for Q_DECL_OVERRIDE diff --git a/src/core/doc/qtwebenginecore.qdocconf b/src/core/doc/qtwebenginecore.qdocconf deleted file mode 100644 index 49144770692ab340e39e3be075e66d736c053360..0000000000000000000000000000000000000000 --- a/src/core/doc/qtwebenginecore.qdocconf +++ /dev/null @@ -1,32 +0,0 @@ -include($QT_INSTALL_DOCS/global/qt-module-defaults.qdocconf) - -project = QtWebEngineCore -description = Qt WebEngineCore Reference Documentation -version = $QT_VERSION - -qhp.projects = QtWebEngineCore - -qhp.QtWebEngineCore.file = qtwebenginecore.qhp -qhp.QtWebEngineCore.namespace = org.qt-project.qtwebenginecore.$QT_VERSION_TAG -qhp.QtWebEngineCore.virtualFolder = qtwebenginecore -qhp.QtWebEngineCore.indexTitle = Qt WebEngine Core -qhp.QtWebEngineCore.indexRoot = - -qhp.QtWebEngineCore.filterAttributes = qtwebenginecore $QT_VERSION qtrefdoc -qhp.QtWebEngineCore.customFilters.Qt.name = QtWebEngineCore $QT_VERSION -qhp.QtWebEngineCore.customFilters.Qt.filterAttributes = qtwebenginecore $QT_VERSION -qhp.QtWebEngineCore.subprojects = classes -qhp.QtWebEngineCore.subprojects.classes.title = C++ Classes -qhp.QtWebEngineCore.subprojects.classes.indexTitle = Qt WebEngine Core C++ Classes -qhp.QtWebEngineCore.subprojects.classes.selectors = class fake:headerfile -qhp.QtWebEngineCore.subprojects.classes.sortPages = true - -depends += qtcore qtdoc qmake - -headerdirs += ../api -sourcedirs += ../api src - -exampledirs += snippets - -navigation.landingpage = "Qt WebEngine Core" -navigation.cppclassespage = "Qt WebEngine Core C++ Class Types" diff --git a/src/core/doc/src/qtwebenginecore.qdoc b/src/core/doc/src/qtwebenginecore-index.qdoc similarity index 86% rename from src/core/doc/src/qtwebenginecore.qdoc rename to src/core/doc/src/qtwebenginecore-index.qdoc index a690d3f0e7a0386ba8698693d07ada62637b5870..49231c8f2671ec9078dbbab08636fbf0b93ad41f 100644 --- a/src/core/doc/src/qtwebenginecore.qdoc +++ b/src/core/doc/src/qtwebenginecore-index.qdoc @@ -25,35 +25,40 @@ ** ****************************************************************************/ - /*! - \module QtWebEngineCore - \title Qt WebEngine Core C++ Classes - \brief Provides public API shared by both QtWebEngine and QtWebEngineWidgets - \since 5.6 + \page qtwebenginecore-index.html + \title Qt WebEngine Core + \ingroup modules + + \brief Provides common API shared by Qt WebEngine and Qt WebEngine Widgets. + + Qt WebEngine Core provides API shared by \l {Qt WebEngine} and \l {Qt WebEngine Widgets}. + + \section1 Getting Started To include the definitions of the module's classes, use the following directive: \snippet qtwebenginecore_build_snippet.qdoc 1 - If you use qmake to build your projects, Qt WebEngine Core is usually - indirectly included through the \l[QtWebEngine]{Qt WebEngine} or - \l[QtWebEngineWidgets]{Qt WebEngine Widgets} modules. -*/ + To link against the module, add this line to your qmake project file: -/*! - \page qtwebenginecore-index.html - \title Qt WebEngine Core - \ingroup modules + \snippet qtwebenginecore_build_snippet.qdoc 0 + + \section1 Articles and Guides - \brief Common API shared by both Qt WebEngine and Qt WebEngine Widgets. + \list + \li \l{Qt WebEngine Overview} + \endlist - Qt WebEngine Core provides API shared by both Qt WebEngine and - Qt WebEngine Widgets. + \section1 API Reference + \list + \li \l{Qt WebEngine Core C++ Classes} + \endlist \section1 License Information + This is a snapshot of the integration of Chromium into Qt. Qt Commercial Edition licensees that wish to distribute applications that diff --git a/src/core/doc/src/qtwebenginecore-module.qdoc b/src/core/doc/src/qtwebenginecore-module.qdoc new file mode 100644 index 0000000000000000000000000000000000000000..750a0244e84731f8818cfb279c1f89b6b22edc23 --- /dev/null +++ b/src/core/doc/src/qtwebenginecore-module.qdoc @@ -0,0 +1,44 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: http://www.gnu.org/copyleft/fdl.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + + +/*! + \module QtWebEngineCore + \title Qt WebEngine Core C++ Classes + \brief Provides public API shared by both QtWebEngine and QtWebEngineWidgets + \since 5.6 + \ingroup qtwebengine-modules + + To include the definitions of the module's classes, use the + following directive: + + \snippet qtwebenginecore_build_snippet.qdoc 1 + + If you use qmake to build your projects, Qt WebEngine Core is usually + indirectly included through the \l[QtWebEngine]{Qt WebEngine} or + \l[QtWebEngineWidgets]{Qt WebEngine Widgets} modules. +*/ diff --git a/src/core/gl_context_qt.cpp b/src/core/gl_context_qt.cpp index baccddc9d64aefe8e51382fb1f2eb4e7ddb04ccf..b350c3c5bcdb4123d98993411799193913fafa41 100644 --- a/src/core/gl_context_qt.cpp +++ b/src/core/gl_context_qt.cpp @@ -60,7 +60,11 @@ namespace { inline void *resourceForContext(const QByteArray &resource) { - return qApp->platformNativeInterface()->nativeResourceForContext(resource, qt_gl_global_share_context()); + QOpenGLContext *shareContext = qt_gl_global_share_context(); + if (!shareContext) { + qFatal("QWebEngine: OpenGL resource sharing is not set up in QtQuick. Please make sure to call QtWebEngine::initialize() in your main() function."); + } + return qApp->platformNativeInterface()->nativeResourceForContext(resource, shareContext); } inline void *resourceForIntegration(const QByteArray &resource) diff --git a/src/core/gl_surface_qt.cpp b/src/core/gl_surface_qt.cpp index 19ce59f7eb0277ea773c61e7c6351aca07493564..86bb4fda9b0fa542b2637bb7d198c9556079cc85 100644 --- a/src/core/gl_surface_qt.cpp +++ b/src/core/gl_surface_qt.cpp @@ -324,13 +324,7 @@ bool GLSurfaceQtEGL::InitializeOneOff() if (initialized) return true; -#if defined(USE_X11) - EGLNativeDisplayType nativeDisplay = reinterpret_cast<EGLNativeDisplayType>(GLContextHelper::getXDisplay()); - g_display = eglGetDisplay(nativeDisplay); -#else g_display = GLContextHelper::getEGLDisplay(); -#endif - if (!g_display) { LOG(ERROR) << "GLContextHelper::getEGLDisplay() failed."; return false; @@ -445,11 +439,11 @@ bool GLSurfaceQt::IsOffscreen() return true; } -bool GLSurfaceQt::SwapBuffers() +gfx::SwapResult GLSurfaceQt::SwapBuffers() { LOG(ERROR) << "Attempted to call SwapBuffers on a pbuffer."; Q_UNREACHABLE(); - return false; + return gfx::SwapResult::SWAP_FAILED; } gfx::Size GLSurfaceQt::GetSize() @@ -541,12 +535,7 @@ GLSurface::CreateViewGLSurface(gfx::AcceleratedWidget window) std::string DriverEGL::GetPlatformExtensions() { -#if defined(USE_X11) - EGLNativeDisplayType nativeDisplay = reinterpret_cast<EGLNativeDisplayType>(GLContextHelper::getXDisplay()); - EGLDisplay display = eglGetDisplay(nativeDisplay); -#else EGLDisplay display = GLContextHelper::getEGLDisplay(); -#endif if (display == EGL_NO_DISPLAY) return ""; diff --git a/src/core/gl_surface_qt.h b/src/core/gl_surface_qt.h index 4b5da207e0a8740fa9d78494bd2a8565467b2200..7646063b21a482b471bfc7591c737f580011a7a9 100644 --- a/src/core/gl_surface_qt.h +++ b/src/core/gl_surface_qt.h @@ -56,7 +56,7 @@ public: virtual void* GetDisplay() Q_DECL_OVERRIDE; virtual void* GetConfig() Q_DECL_OVERRIDE; virtual bool IsOffscreen() Q_DECL_OVERRIDE; - virtual bool SwapBuffers() Q_DECL_OVERRIDE; + virtual gfx::SwapResult SwapBuffers() Q_DECL_OVERRIDE; virtual gfx::Size GetSize() Q_DECL_OVERRIDE; protected: diff --git a/src/core/gyp_configure_host.pro b/src/core/gyp_configure_host.pro index 3eb67389f3d1e8f07e3ce099097850d100c78e56..eb94cb8024efddabd3d75f9cbd894ed386078b25 100644 --- a/src/core/gyp_configure_host.pro +++ b/src/core/gyp_configure_host.pro @@ -10,7 +10,7 @@ GYPI_CONTENTS = "{" \ " ['CXX.host', '$$which($$QMAKE_CXX)']," \ " ['LD.host', '$$which($$QMAKE_LINK)']," -GYPI_FILE = $$absolute_path('qmake_extras.gypi') +GYPI_FILE = $$OUT_PWD/qmake_extras.gypi !build_pass { write_file($$GYPI_FILE, GYPI_CONTENTS) } diff --git a/src/core/gyp_configure_target.pro b/src/core/gyp_configure_target.pro index 4d5204407be5593a70e6769333a9f6ba18cac2a7..2a59966367e62e82ad3f8422011c06da2df171cf 100644 --- a/src/core/gyp_configure_target.pro +++ b/src/core/gyp_configure_target.pro @@ -26,7 +26,7 @@ GYPI_CONTENTS += " ]," \ GYPI_CONTENTS += "}" -GYPI_FILE = $$absolute_path('qmake_extras.gypi') +GYPI_FILE = $$OUT_PWD/qmake_extras.gypi !exists($$GYPI_FILE): error("-- $$GYPI_FILE not found --") diff --git a/src/core/gyp_run.pro b/src/core/gyp_run.pro index bb19a679d93a3cc39996523eef6184c6f095cdcc..def7d46987ddebdcdb1461da4a0d0c65ee82c9d4 100644 --- a/src/core/gyp_run.pro +++ b/src/core/gyp_run.pro @@ -28,9 +28,6 @@ force_debug_info { else: GYP_CONFIG += release_extra_cflags=-g } -# Append additional platform options defined in GYP_CONFIG -for (config, GYP_CONFIG): GYP_ARGS += "-D $$config" - # Copy this logic from qt_module.prf so that ninja can run according # to the same rules as the final module linking in core_module.pro. !host_build:if(win32|mac):!macx-xcode { @@ -40,58 +37,63 @@ for (config, GYP_CONFIG): GYP_ARGS += "-D $$config" cross_compile { TOOLCHAIN_SYSROOT = $$[QT_SYSROOT] + !isEmpty(TOOLCHAIN_SYSROOT): GYP_CONFIG += sysroot=\"$${TOOLCHAIN_SYSROOT}\" + + # Needed for v8, see chromium/v8/build/toolchain.gypi + GYP_CONFIG += CXX=\"$$which($$QMAKE_CXX)\" +} + +contains(QT_ARCH, "arm") { + # Chromium will set a default sysroot on arm unless we give it one. + !cross_compile: GYP_CONFIG += sysroot=\"\" + + GYP_CONFIG += target_arch=arm + + # Extract ARM specific compiler options that we have to pass to gyp, + # but let gyp figure out a default if an option is not present. + MARCH = $$extractCFlag("-march=.*") + !isEmpty(MARCH): GYP_CONFIG += arm_arch=\"$$MARCH\" - !isEmpty(TOOLCHAIN_SYSROOT): GYP_ARGS += "-D sysroot=\"$${TOOLCHAIN_SYSROOT}\"" - - contains(QT_ARCH, "arm") { - GYP_ARGS += "-D target_arch=arm" - - # Extract ARM specific compiler options that we have to pass to gyp, - # but let gyp figure out a default if an option is not present. - MARCH = $$extractCFlag("-march=.*") - !isEmpty(MARCH): GYP_ARGS += "-D arm_arch=\"$$MARCH\"" - - MTUNE = $$extractCFlag("-mtune=.*") - GYP_ARGS += "-D arm_tune=\"$$MTUNE\"" - - MFLOAT = $$extractCFlag("-mfloat-abi=.*") - !isEmpty(MFLOAT): GYP_ARGS += "-D arm_float_abi=\"$$MFLOAT\"" - - MARMV = $$replace(MARCH, "armv",) - !isEmpty(MARMV) { - MARMV = $$split(MARMV,) - MARMV = $$member(MARMV, 0) - lessThan(MARMV, 6): error("$$MARCH architecture is not supported") - GYP_ARGS += "-D arm_version=\"$$MARMV\"" - } - - MFPU = $$extractCFlag("-mfpu=.*") - !isEmpty(MFPU) { - # If the toolchain does not explicitly specify to use NEON instructions - # we use arm_neon_optional for ARMv7 and newer and let chromium decide - # about the mfpu option. - contains(MFPU, "neon")|contains(MFPU, "neon-vfpv4"): GYP_ARGS += "-D arm_fpu=\"$$MFPU\" -D arm_neon=1" - else:!lessThan(MARMV, 7): GYP_ARGS += "-D arm_neon=0 -D arm_neon_optional=1" - else: GYP_ARGS += "-D arm_fpu=\"$$MFPU\" -D arm_neon=0 -D arm_neon_optional=0" - } - - contains(QMAKE_CFLAGS, "-mthumb"): GYP_ARGS += "-D arm_thumb=1" + MTUNE = $$extractCFlag("-mtune=.*") + !isEmpty(MTUNE): GYP_CONFIG += arm_tune=\"$$MTUNE\" + + MFLOAT = $$extractCFlag("-mfloat-abi=.*") + !isEmpty(MFLOAT): GYP_CONFIG += arm_float_abi=\"$$MFLOAT\" + + MARMV = $$replace(MARCH, "armv",) + !isEmpty(MARMV) { + MARMV = $$split(MARMV,) + MARMV = $$member(MARMV, 0) + lessThan(MARMV, 6): error("$$MARCH architecture is not supported") + GYP_CONFIG += arm_version=\"$$MARMV\" } - # Needed for v8, see chromium/v8/build/toolchain.gypi - GYP_ARGS += "-D CXX=\"$$which($$QMAKE_CXX)\"" + MFPU = $$extractCFlag("-mfpu=.*") + !isEmpty(MFPU) { + # If the toolchain does not explicitly specify to use NEON instructions + # we use arm_neon_optional for ARMv7 and newer and let chromium decide + # about the mfpu option. + contains(MFPU, "neon")|contains(MFPU, "neon-vfpv4"): GYP_CONFIG += arm_fpu=\"$$MFPU\" arm_neon=1 + else:!lessThan(MARMV, 7): GYP_CONFIG += arm_neon=0 arm_neon_optional=1 + else: GYP_CONFIG += arm_fpu=\"$$MFPU\" arm_neon=0 arm_neon_optional=0 + } + + contains(QMAKE_CFLAGS, "-mthumb"): GYP_CONFIG += arm_thumb=1 } -contains(QT_ARCH, "x86_64"): GYP_ARGS += "-D target_arch=x64" -contains(QT_ARCH, "i386"): GYP_ARGS += "-D target_arch=ia32" +contains(QT_ARCH, "x86_64"): GYP_CONFIG += target_arch=x64 +contains(QT_ARCH, "i386"): GYP_CONFIG += target_arch=ia32 -contains(WEBENGINE_CONFIG, use_proprietary_codecs): GYP_ARGS += "-Dproprietary_codecs=1 -Dffmpeg_branding=Chrome -Duse_system_ffmpeg=0" +contains(WEBENGINE_CONFIG, use_proprietary_codecs): GYP_CONFIG += proprietary_codecs=1 ffmpeg_branding=Chrome !contains(QT_CONFIG, qt_framework): contains(QT_CONFIG, private_tests) { - GYP_ARGS += "-D qt_install_data=\"$$[QT_INSTALL_DATA/get]\"" - GYP_ARGS += "-D qt_install_translations=\"$$[QT_INSTALL_TRANSLATIONS/get]\"" + GYP_CONFIG += qt_install_data=\"$$[QT_INSTALL_DATA/get]\" + GYP_CONFIG += qt_install_translations=\"$$[QT_INSTALL_TRANSLATIONS/get]\" } +# Append additional platform options defined in GYP_CONFIG +for (config, GYP_CONFIG): GYP_ARGS += "-D $$config" + !build_pass { message("Running gyp_qtwebengine \"$$OUT_PWD\" $${GYP_ARGS}...") !system("python $$QTWEBENGINE_ROOT/tools/buildscripts/gyp_qtwebengine \"$$OUT_PWD\" $${GYP_ARGS}"): error("-- running gyp_qtwebengine failed --") diff --git a/src/core/javascript_dialog_controller_p.h b/src/core/javascript_dialog_controller_p.h index 504c5783e9f28049f8e5d29a1843299f5f2e01b0..5c3bd39f59e5d27b265b69028c44ea9cc3eace06 100644 --- a/src/core/javascript_dialog_controller_p.h +++ b/src/core/javascript_dialog_controller_p.h @@ -37,6 +37,17 @@ #ifndef JAVASCRIPT_DIALOG_CONTROLLER_P_H #define JAVASCRIPT_DIALOG_CONTROLLER_P_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include "content/public/browser/javascript_dialog_manager.h" #include "web_contents_adapter_client.h" #include <QString> diff --git a/src/core/media_capture_devices_dispatcher.cpp b/src/core/media_capture_devices_dispatcher.cpp index 605a17948b4a7a7e827a5fe5ad6bd6915ee2c705..b31d22a761a2a3e9f6022a1659424cd0ccb806db 100644 --- a/src/core/media_capture_devices_dispatcher.cpp +++ b/src/core/media_capture_devices_dispatcher.cpp @@ -304,8 +304,8 @@ void MediaCaptureDevicesDispatcher::processScreenCaptureAccessRequest(content::W base::Unretained(this), base::Unretained(webContents)); QUrl securityOrigin(toQt(request.security_origin)); - QString message = QObject::tr("Do you want %1 to share your screen?").arg(securityOrigin.toString()); - QString title = QObject::tr("%1 Screen Sharing request").arg(securityOrigin.toString()); + QString message = QCoreApplication::translate("MediaCaptureDevicesDispatcher", "Do you want %1 to share your screen?").arg(securityOrigin.toString()); + QString title = QCoreApplication::translate("MediaCaptureDevicesDispatcher", "%1 Screen Sharing request").arg(securityOrigin.toString()); JavaScriptDialogManagerQt::GetInstance()->runDialogForContents(webContents, WebContentsAdapterClient::InternalAuthorizationDialog, message , QString(), securityOrigin, dialogCallback, title); } else diff --git a/src/core/network_delegate_qt.cpp b/src/core/network_delegate_qt.cpp index 5af781007b5ce0af86a29ef7fbaed881dc81a17e..38fd3c710484ef2f4b833a4a92cc1c943cef026c 100644 --- a/src/core/network_delegate_qt.cpp +++ b/src/core/network_delegate_qt.cpp @@ -221,7 +221,8 @@ bool NetworkDelegateQt::OnCanSetCookie(const net::URLRequest& request, const std::string& cookie_line, net::CookieOptions*) { - return true; + Q_ASSERT(m_requestContextGetter); + return m_requestContextGetter->m_cookieDelegate->canSetCookie(toQt(request.first_party_for_cookies()), QByteArray::fromStdString(cookie_line), toQt(request.url())); } void NetworkDelegateQt::OnResolveProxy(const GURL&, int, const net::ProxyService&, net::ProxyInfo*) @@ -285,11 +286,6 @@ bool NetworkDelegateQt::OnCanAccessFile(const net::URLRequest& request, const ba return true; } -bool NetworkDelegateQt::OnCanThrottleRequest(const net::URLRequest&) const -{ - return false; -} - bool NetworkDelegateQt::OnCanEnablePrivacyMode(const GURL&, const GURL&) const { return false; diff --git a/src/core/network_delegate_qt.h b/src/core/network_delegate_qt.h index 1176f99d96c26fa7b368605e1d050f400f860597..41b5b98b6d6ab6274a749b9d8dd0f03e0ce25de3 100644 --- a/src/core/network_delegate_qt.h +++ b/src/core/network_delegate_qt.h @@ -87,7 +87,6 @@ public: virtual net::NetworkDelegate::AuthRequiredResponse OnAuthRequired(net::URLRequest*, const net::AuthChallengeInfo&, const AuthCallback&, net::AuthCredentials*) override; virtual bool OnCanGetCookies(const net::URLRequest&, const net::CookieList&) override; virtual bool OnCanAccessFile(const net::URLRequest& request, const base::FilePath& path) const override; - virtual bool OnCanThrottleRequest(const net::URLRequest&) const override; virtual bool OnCanEnablePrivacyMode(const GURL&, const GURL&) const override; virtual bool OnFirstPartyOnlyCookieExperimentEnabled() const override; virtual bool OnCancelURLRequestWithPolicyViolatingReferrerHeader(const net::URLRequest&, const GURL&, const GURL&) const override; diff --git a/src/core/ozone_platform_eglfs.cpp b/src/core/ozone_platform_eglfs.cpp index 43a3e4a116eabacfdb8a29c6ce8488b31857b793..834e41fdf1c69d02c77053d1b4ba112dbf7e8f14 100644 --- a/src/core/ozone_platform_eglfs.cpp +++ b/src/core/ozone_platform_eglfs.cpp @@ -45,6 +45,7 @@ #include "ui/events/ozone/events_ozone.h" #include "ui/events/platform/platform_event_dispatcher.h" #include "ui/ozone/common/native_display_delegate_ozone.h" +#include "ui/ozone/common/stub_overlay_manager.h" #include "ui/ozone/public/ozone_platform.h" #include "ui/ozone/public/cursor_factory_ozone.h" #include "ui/ozone/public/gpu_platform_support.h" @@ -95,6 +96,7 @@ public: void Restore() override { } void SetCursor(PlatformCursor) override { } void MoveCursorTo(const gfx::Point&) override { } + void ConfineCursorToBounds(const gfx::Rect&) override { } // PlatformEventDispatcher: bool CanDispatchEvent(const PlatformEvent& event) override; @@ -160,6 +162,18 @@ scoped_ptr<PlatformWindow> OzonePlatformEglfs::CreatePlatformWindow( bounds)); } +ui::InputController* OzonePlatformEglfs::GetInputController() { + return input_controller_.get(); +} + +scoped_ptr<ui::SystemInputInjector> OzonePlatformEglfs::CreateSystemInputInjector() { + return nullptr; // no input injection support. +} + +ui::OverlayManagerOzone* OzonePlatformEglfs::GetOverlayManager() { + return overlay_manager_.get(); +} + scoped_ptr<ui::NativeDisplayDelegate> OzonePlatformEglfs::CreateNativeDisplayDelegate() { return scoped_ptr<NativeDisplayDelegate>(new NativeDisplayDelegateOzone()); @@ -168,10 +182,12 @@ scoped_ptr<ui::NativeDisplayDelegate> OzonePlatformEglfs::CreateNativeDisplayDel OzonePlatform* CreateOzonePlatformEglfs() { return new OzonePlatformEglfs; } void OzonePlatformEglfs::InitializeUI() { + overlay_manager_.reset(new StubOverlayManager()); device_manager_ = CreateDeviceManager(); cursor_factory_ozone_.reset(new CursorFactoryOzone()); - event_factory_ozone_.reset(new EventFactoryEvdev(NULL, device_manager_.get())); + event_factory_ozone_.reset(new EventFactoryEvdev(NULL, device_manager_.get(), NULL)); gpu_platform_support_host_.reset(CreateStubGpuPlatformSupportHost()); + input_controller_ = CreateStubInputController(); } void OzonePlatformEglfs::InitializeGPU() { diff --git a/src/core/ozone_platform_eglfs.h b/src/core/ozone_platform_eglfs.h index 6954595dd59298b5b83abe5ecdb2a5e72d990334..69ff2508ff37a03cfce1e0b74f411f76adbb9c37 100644 --- a/src/core/ozone_platform_eglfs.h +++ b/src/core/ozone_platform_eglfs.h @@ -62,6 +62,9 @@ class OzonePlatformEglfs : public OzonePlatform { PlatformWindowDelegate* delegate, const gfx::Rect& bounds) override; virtual scoped_ptr<ui::NativeDisplayDelegate> CreateNativeDisplayDelegate() override; + virtual ui::InputController* GetInputController() override; + virtual scoped_ptr<ui::SystemInputInjector> CreateSystemInputInjector() override; + virtual ui::OverlayManagerOzone* GetOverlayManager() override; private: virtual void InitializeUI() override; @@ -74,6 +77,8 @@ class OzonePlatformEglfs : public OzonePlatform { scoped_ptr<GpuPlatformSupport> gpu_platform_support_; scoped_ptr<GpuPlatformSupportHost> gpu_platform_support_host_; + scoped_ptr<InputController> input_controller_; + scoped_ptr<OverlayManagerOzone> overlay_manager_; DISALLOW_COPY_AND_ASSIGN(OzonePlatformEglfs); }; diff --git a/src/core/permission_manager_qt.cpp b/src/core/permission_manager_qt.cpp index 865874fe6964bc243d4b795c866189c9ea61d94d..d89b530ee1e010a80cdc4d72b7910c8f040e4ff1 100644 --- a/src/core/permission_manager_qt.cpp +++ b/src/core/permission_manager_qt.cpp @@ -36,7 +36,10 @@ #include "permission_manager_qt.h" +#include "content/browser/renderer_host/render_view_host_delegate.h" #include "content/public/browser/permission_type.h" +#include "content/public/browser/render_frame_host.h" +#include "content/public/browser/render_view_host.h" #include "content/public/browser/web_contents.h" #include "type_conversion.h" @@ -90,7 +93,7 @@ void PermissionManagerQt::permissionRequestReply(const QUrl &origin, BrowserCont } void PermissionManagerQt::RequestPermission(content::PermissionType permission, - content::WebContents* web_contents, + content::RenderFrameHost *frameHost, int request_id, const GURL& requesting_origin, bool user_gesture, @@ -103,7 +106,8 @@ void PermissionManagerQt::RequestPermission(content::PermissionType permission, return; } - WebContentsDelegateQt* contentsDelegate = static_cast<WebContentsDelegateQt*>(web_contents->GetDelegate()); + content::WebContents *webContents = frameHost->GetRenderViewHost()->GetDelegate()->GetAsWebContents(); + WebContentsDelegateQt* contentsDelegate = static_cast<WebContentsDelegateQt*>(webContents->GetDelegate()); Q_ASSERT(contentsDelegate); Request request = { request_id, @@ -117,11 +121,11 @@ void PermissionManagerQt::RequestPermission(content::PermissionType permission, } void PermissionManagerQt::CancelPermissionRequest(content::PermissionType permission, - content::WebContents* web_contents, + content::RenderFrameHost *frameHost, int request_id, const GURL& requesting_origin) { - Q_UNUSED(web_contents); + Q_UNUSED(frameHost); const BrowserContextAdapter::PermissionType permissionType = toQt(permission); if (permissionType == BrowserContextAdapter::UnsupportedPermission) return; diff --git a/src/core/permission_manager_qt.h b/src/core/permission_manager_qt.h index 75f88f9a9c8ff3a798aacb1ac8500db1eed92048..d4ee72bae810b35c9e09707f742432f91c8fdb22 100644 --- a/src/core/permission_manager_qt.h +++ b/src/core/permission_manager_qt.h @@ -58,7 +58,7 @@ public: // content::PermissionManager implementation: void RequestPermission( content::PermissionType permission, - content::WebContents* web_contents, + content::RenderFrameHost* render_frame_host, int request_id, const GURL& requesting_origin, bool user_gesture, @@ -66,7 +66,7 @@ public: void CancelPermissionRequest( content::PermissionType permission, - content::WebContents* web_contents, + content::RenderFrameHost* render_frame_host, int request_id, const GURL& requesting_origin) override; diff --git a/src/core/proxy_config_service_qt.cpp b/src/core/proxy_config_service_qt.cpp index 933b1a10eebad2e7fd93edb7d5b654e24d3a7422..fc0959eef43f5cd31b4e1291267c88aa60c031fd 100644 --- a/src/core/proxy_config_service_qt.cpp +++ b/src/core/proxy_config_service_qt.cpp @@ -39,8 +39,6 @@ #include "proxy_config_service_qt.h" -#include "proxy_resolver_qt.h" - #include "base/bind.h" #include "content/public/browser/browser_thread.h" @@ -107,15 +105,9 @@ net::ProxyConfigService::ConfigAvailability ProxyConfigServiceQt::GetLatestProxy return CONFIG_VALID; } m_qtApplicationProxy = qtProxy; - m_qtProxyConfig = (systemAvailability == CONFIG_VALID) ? systemConfig : net::ProxyConfig(); - const bool useProxyResolver = ProxyResolverQt::useProxyResolverQt(); - + m_qtProxyConfig = net::ProxyConfig(); if (qtProxy.type() == QNetworkProxy::NoProxy) { *config = systemConfig; - if (useProxyResolver) { - config->set_auto_detect(true); - config->set_pac_mandatory(true); - } return systemAvailability; } @@ -140,10 +132,6 @@ net::ProxyConfigService::ConfigAvailability ProxyConfigServiceQt::GetLatestProxy } m_qtProxyConfig.proxy_rules() = qtRules; - if (useProxyResolver) { - m_qtProxyConfig.set_pac_mandatory(true); - m_qtProxyConfig.set_auto_detect(true); - } *config = m_qtProxyConfig; return CONFIG_VALID; } diff --git a/src/core/proxy_config_service_qt.h b/src/core/proxy_config_service_qt.h index f2f06d3fabe578fe8a201475b69d4afe1b5413f1..ee426331445a0adc1a2c7ed8594387f360a5d3a6 100644 --- a/src/core/proxy_config_service_qt.h +++ b/src/core/proxy_config_service_qt.h @@ -72,7 +72,7 @@ private: void RegisterObserver(); scoped_ptr<net::ProxyConfigService> m_baseService; - ObserverList<net::ProxyConfigService::Observer, true> m_observers; + base::ObserverList<net::ProxyConfigService::Observer, true> m_observers; // Keep the last QNetworkProxy::applicationProxy state around. QNetworkProxy m_qtApplicationProxy; diff --git a/src/core/qtwebengine.gypi b/src/core/qtwebengine.gypi index 2c433f614008c6b7319ae7f37bd91d3d86d95a18..a420918a018c8d669a44ea82ac08fcf2ab59b9ee 100644 --- a/src/core/qtwebengine.gypi +++ b/src/core/qtwebengine.gypi @@ -26,6 +26,7 @@ '<(chromium_src_dir)/media/media.gyp:media', '<(chromium_src_dir)/net/net.gyp:net', '<(chromium_src_dir)/net/net.gyp:net_resources', + '<(chromium_src_dir)/net/net.gyp:net_with_v8', '<(chromium_src_dir)/skia/skia.gyp:skia', '<(chromium_src_dir)/third_party/WebKit/Source/web/web.gyp:blink_web', '<(chromium_src_dir)/ui/base/ui_base.gyp:ui_base', @@ -47,6 +48,9 @@ 'CHROMIUM_VERSION=\"<!(python <(version_script_location) -f <(chromium_src_dir)/chrome/VERSION -t "@MAJOR@.@MINOR@.@BUILD@.@PATCH@")\"', ], 'msvs_settings': { + 'VCCLCompilerTool': { + 'RuntimeTypeInfo': 'true', + }, 'VCLinkerTool': { 'SubSystem': '2', # Set /SUBSYSTEM:WINDOWS }, @@ -80,6 +84,14 @@ ], }, }, + 'dependencies': [ + '<(chromium_src_dir)/ui/events/ozone/events_ozone.gyp:events_ozone_evdev' + ] + }], + ['qt_os=="win32" and qt_gl=="opengl"', { + 'include_dirs': [ + '<(chromium_src_dir)/third_party/khronos', + ], }], ['OS=="win"', { 'resource_include_dirs': [ @@ -102,5 +114,8 @@ '<(chromium_src_dir)/build/linux/system.gyp:fontconfig', ], }], + ['OS=="mac"', { + 'xcode_settings': {'OTHER_LDFLAGS': ['-Wl,-ObjC']}, + }], ], } diff --git a/src/core/qtwebengine_extras.gypi b/src/core/qtwebengine_extras.gypi index 86a4c17bba166aeba394fc4ca8e9986113261f7c..a5de08b557eb92ca3233b8235f1b598568f544c9 100644 --- a/src/core/qtwebengine_extras.gypi +++ b/src/core/qtwebengine_extras.gypi @@ -57,6 +57,7 @@ ['exclude', 'win/accessibility_ids_win\\.h$'], ['exclude', 'win/accessibility_misc_utils\\.(cc|h)$'], ['exclude', 'win/atl_module\\.h$'], + ['exclude', 'platform/ax_platform_node_win\\.(cc|h)$'], ['exclude', 'audio_classifier\\.(cc|h)$'], ], 'defines': [ diff --git a/src/core/render_widget_host_view_qt.cpp b/src/core/render_widget_host_view_qt.cpp index ef6610ecb663e4f2a40187001e1216b15895deab..26ea4f4ae81b215933470d63530a9cfd5ecefcc6 100644 --- a/src/core/render_widget_host_view_qt.cpp +++ b/src/core/render_widget_host_view_qt.cpp @@ -567,8 +567,11 @@ void RenderWidgetHostViewQt::ImeCompositionRangeChanged(const gfx::Range&, const QT_NOT_YET_IMPLEMENTED } -void RenderWidgetHostViewQt::RenderProcessGone(base::TerminationStatus, int) +void RenderWidgetHostViewQt::RenderProcessGone(base::TerminationStatus terminationStatus, + int exitCode) { + m_adapterClient->renderProcessTerminated( + m_adapterClient->renderProcessExitStatus(terminationStatus), exitCode); Destroy(); } @@ -806,7 +809,7 @@ QVariant RenderWidgetHostViewQt::inputMethodQuery(Qt::InputMethodQuery query) co void RenderWidgetHostViewQt::ProcessAckedTouchEvent(const content::TouchEventWithLatencyInfo &touch, content::InputEventAckState ack_result) { Q_UNUSED(touch); const bool eventConsumed = ack_result == content::INPUT_EVENT_ACK_STATE_CONSUMED; - m_gestureProvider.OnAsyncTouchEventAck(eventConsumed); + m_gestureProvider.OnTouchEventAck(touch.event.uniqueTouchEventId, eventConsumed); } void RenderWidgetHostViewQt::sendDelegatedFrameAck() @@ -923,14 +926,9 @@ void RenderWidgetHostViewQt::handleInputMethodEvent(QInputMethodEvent *ev) if (preeditString.isEmpty()) break; - QTextCharFormat textCharFormat = attribute.value.value<QTextFormat>().toCharFormat(); - QColor qcolor = textCharFormat.underlineColor(); - QColor qBackgroundColor = textCharFormat.background().color(); - blink::WebColor color = SkColorSetARGB(qcolor.alpha(), qcolor.red(), qcolor.green(), qcolor.blue()); - blink::WebColor backgroundColor = SkColorSetARGB(qBackgroundColor.alpha(), qBackgroundColor.red(), qBackgroundColor.green(), qBackgroundColor.blue()); int start = qMin(attribute.start, (attribute.start + attribute.length)); int end = qMax(attribute.start, (attribute.start + attribute.length)); - underlines.push_back(blink::WebCompositionUnderline(start, end, color, false, backgroundColor)); + underlines.push_back(blink::WebCompositionUnderline(start, end, /*color*/ SK_ColorBLACK, /*thick*/ false, /*backgroundColor*/ SK_ColorTRANSPARENT)); break; } case QInputMethodEvent::Cursor: diff --git a/src/core/renderer/content_renderer_client_qt.cpp b/src/core/renderer/content_renderer_client_qt.cpp index 32ba4d55f5ac8361b2ae97fb5688c63e8f84d899..72ca29be9ffdbffc710add555a9f3a46bed58945 100644 --- a/src/core/renderer/content_renderer_client_qt.cpp +++ b/src/core/renderer/content_renderer_client_qt.cpp @@ -44,8 +44,10 @@ #include "content/public/renderer/render_thread.h" #include "content/public/renderer/render_view.h" #include "net/base/net_errors.h" +#include "third_party/WebKit/public/platform/WebString.h" #include "third_party/WebKit/public/platform/WebURLError.h" #include "third_party/WebKit/public/platform/WebURLRequest.h" +#include "third_party/WebKit/public/web/WebSecurityPolicy.h" #include "ui/base/resource/resource_bundle.h" #include "ui/base/webui/jstemplate_builder.h" #include "content/public/common/web_preferences.h" @@ -60,6 +62,7 @@ namespace QtWebEngineCore { static const char kHttpErrorDomain[] = "http"; +static const char kQrcSchemeQt[] = "qrc"; ContentRendererClientQt::ContentRendererClientQt() { @@ -76,6 +79,9 @@ void ContentRendererClientQt::RenderThreadStarted() m_visitedLinkSlave.reset(new visitedlink::VisitedLinkSlave); renderThread->AddObserver(m_visitedLinkSlave.data()); renderThread->AddObserver(UserScriptController::instance()); + + // mark qrc as a secure scheme (avoids deprecation warnings) + blink::WebSecurityPolicy::registerURLSchemeAsSecure(blink::WebString::fromLatin1(kQrcSchemeQt)); } void ContentRendererClientQt::RenderViewCreated(content::RenderView* render_view) @@ -111,7 +117,7 @@ bool ContentRendererClientQt::ShouldSuppressErrorPage(content::RenderFrame *fram void ContentRendererClientQt::GetNavigationErrorStrings(content::RenderView* renderView, blink::WebFrame *frame, const blink::WebURLRequest &failedRequest, const blink::WebURLError &error, std::string *errorHtml, base::string16 *errorDescription) { Q_UNUSED(frame) - const bool isPost = EqualsASCII(failedRequest.httpMethod(), "POST"); + const bool isPost = base::EqualsASCII(failedRequest.httpMethod(), "POST"); if (errorHtml) { // Use a local error page. diff --git a/src/core/resource_bundle_qt.cpp b/src/core/resource_bundle_qt.cpp index 3e9c6ad43102c675935d5e188cb5a9574cd5ca0e..932f40af85e071a22ab24173a616d94b95565268 100644 --- a/src/core/resource_bundle_qt.cpp +++ b/src/core/resource_bundle_qt.cpp @@ -44,7 +44,9 @@ namespace ui { void ResourceBundle::LoadCommonResources() { // We repacked the resources we need and installed them. now let chromium mmap that file. - AddDataPackFromPath(WebEngineLibraryInfo::getPath(QT_RESOURCES_PAK), SCALE_FACTOR_100P); + AddDataPackFromPath(WebEngineLibraryInfo::getPath(QT_RESOURCES_PAK), SCALE_FACTOR_NONE); + AddDataPackFromPath(WebEngineLibraryInfo::getPath(QT_RESOURCES_100P_PAK), SCALE_FACTOR_100P); + AddDataPackFromPath(WebEngineLibraryInfo::getPath(QT_RESOURCES_200P_PAK), SCALE_FACTOR_200P); } gfx::Image& ResourceBundle::GetNativeImageNamed(int resource_id, ImageRTL rtl) diff --git a/src/core/resource_dispatcher_host_delegate_qt.cpp b/src/core/resource_dispatcher_host_delegate_qt.cpp index faed58954bbba35e3b372a1723e17d31c6971887..b63ecd5c7d0343894af5d9590aa721f75339a367 100644 --- a/src/core/resource_dispatcher_host_delegate_qt.cpp +++ b/src/core/resource_dispatcher_host_delegate_qt.cpp @@ -46,22 +46,20 @@ #include "content/public/browser/resource_request_info.h" #include "net/url_request/url_request.h" +#include "authentication_dialog_controller.h" +#include "authentication_dialog_controller_p.h" #include "type_conversion.h" #include "web_contents_view_qt.h" namespace QtWebEngineCore { ResourceDispatcherHostLoginDelegateQt::ResourceDispatcherHostLoginDelegateQt(net::AuthChallengeInfo *authInfo, net::URLRequest *request) - : m_request(request) + : m_authInfo(authInfo) + , m_request(request) { Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); content::ResourceRequestInfo::GetRenderFrameForRequest(request, &m_renderProcessId, &m_renderFrameId); - m_url = toQt(request->url()); - m_realm = QString::fromStdString(authInfo->realm); - m_isProxy = authInfo->is_proxy; - m_host = QString::fromStdString(authInfo->challenger.ToString()); - content::BrowserThread::PostTask( content::BrowserThread::UI, FROM_HERE, base::Bind(&ResourceDispatcherHostLoginDelegateQt::triggerDialog, this)); @@ -69,13 +67,34 @@ ResourceDispatcherHostLoginDelegateQt::ResourceDispatcherHostLoginDelegateQt(net ResourceDispatcherHostLoginDelegateQt::~ResourceDispatcherHostLoginDelegateQt() { + Q_ASSERT(m_dialogController.isNull()); // We must have called ClearLoginDelegateForRequest if we didn't receive an OnRequestCancelled. Q_ASSERT(!m_request); } void ResourceDispatcherHostLoginDelegateQt::OnRequestCancelled() { - m_request = 0; + destroy(); +} + +QUrl ResourceDispatcherHostLoginDelegateQt::url() const +{ + return toQt(m_request->url()); +} + +QString ResourceDispatcherHostLoginDelegateQt::realm() const +{ + return QString::fromStdString(m_authInfo->realm); +} + +QString ResourceDispatcherHostLoginDelegateQt::host() const +{ + return QString::fromStdString(m_authInfo->challenger.ToString()); +} + +bool ResourceDispatcherHostLoginDelegateQt::isProxy() const +{ + return m_authInfo->is_proxy; } void ResourceDispatcherHostLoginDelegateQt::triggerDialog() @@ -85,17 +104,9 @@ void ResourceDispatcherHostLoginDelegateQt::triggerDialog() content::WebContentsImpl *webContents = static_cast<content::WebContentsImpl *>(content::WebContents::FromRenderViewHost(renderViewHost)); WebContentsAdapterClient *client = WebContentsViewQt::from(webContents->GetView())->client(); - // The widgets API will ask for credentials synchronouly, keep it simple for now. - // We'll have to figure out a mechanism to keep a ref to the ResourceDispatcherHostLoginDelegateQt - // to avoid crashing in the OnRequestCancelled case if we want to allow the credentials to - // come back asynchronously in the QtQuick API. - QString user, password; - client->authenticationRequired(m_url , m_realm , m_isProxy , m_host, &user, &password); - - bool success = !user.isEmpty() || !password.isEmpty(); - content::BrowserThread::PostTask( - content::BrowserThread::IO, FROM_HERE, - base::Bind(&ResourceDispatcherHostLoginDelegateQt::sendAuthToRequester, this, success, user, password)); + AuthenticationDialogControllerPrivate *dialogControllerData = new AuthenticationDialogControllerPrivate(this); + m_dialogController.reset(new AuthenticationDialogController(dialogControllerData)); + client->authenticationRequired(m_dialogController); } void ResourceDispatcherHostLoginDelegateQt::sendAuthToRequester(bool success, const QString &user, const QString &password) @@ -110,6 +121,12 @@ void ResourceDispatcherHostLoginDelegateQt::sendAuthToRequester(bool success, co m_request->CancelAuth(); content::ResourceDispatcherHost::Get()->ClearLoginDelegateForRequest(m_request); + destroy(); +} + +void ResourceDispatcherHostLoginDelegateQt::destroy() +{ + m_dialogController.reset(); m_request = 0; } diff --git a/src/core/resource_dispatcher_host_delegate_qt.h b/src/core/resource_dispatcher_host_delegate_qt.h index 2cba210d39c8be5ae446bb28e9d65610d6ad17e4..d62292995e84f95ea9c493b7e0a1d549aec9a43e 100644 --- a/src/core/resource_dispatcher_host_delegate_qt.h +++ b/src/core/resource_dispatcher_host_delegate_qt.h @@ -44,6 +44,8 @@ namespace QtWebEngineCore { +class AuthenticationDialogController; + class ResourceDispatcherHostLoginDelegateQt : public content::ResourceDispatcherHostLoginDelegate { public: ResourceDispatcherHostLoginDelegateQt(net::AuthChallengeInfo *authInfo, net::URLRequest *request); @@ -52,9 +54,16 @@ public: // ResourceDispatcherHostLoginDelegate implementation virtual void OnRequestCancelled(); + QUrl url() const; + QString realm() const; + QString host() const; + bool isProxy() const; + + void sendAuthToRequester(bool success, const QString &user, const QString &password); + private: void triggerDialog(); - void sendAuthToRequester(bool success, const QString &user, const QString &password); + void destroy(); QUrl m_url; QString m_realm; @@ -64,9 +73,15 @@ private: int m_renderProcessId; int m_renderFrameId; + net::AuthChallengeInfo *m_authInfo; + // The request that wants login data. // Must only be accessed on the IO thread. net::URLRequest *m_request; + + // This member is used to keep authentication dialog controller alive until + // authorization is sent or cancelled. + QSharedPointer<AuthenticationDialogController> m_dialogController; }; class ResourceDispatcherHostDelegateQt : public content::ResourceDispatcherHostDelegate { diff --git a/src/core/resources/repack_resources.gypi b/src/core/resources/repack_resources.gypi index fdf317a7c5c045d70c1f2865d1b4ff61a8670dad..ce224e6250309d34d01e871ef6a00c1cedfdbe7c 100644 --- a/src/core/resources/repack_resources.gypi +++ b/src/core/resources/repack_resources.gypi @@ -4,23 +4,13 @@ { 'variables': { 'repack_path': '<(chromium_src_dir)/tools/grit/grit/format/repack.py', - 'pak_inputs': [ - '<(SHARED_INTERMEDIATE_DIR)/net/net_resources.pak', - '<(SHARED_INTERMEDIATE_DIR)/blink/devtools_resources.pak', - '<(SHARED_INTERMEDIATE_DIR)/content/content_resources.pak', - '<(SHARED_INTERMEDIATE_DIR)/ui/resources/ui_resources_100_percent.pak', - '<(SHARED_INTERMEDIATE_DIR)/blink/public/resources/blink_resources.pak', - '<(SHARED_INTERMEDIATE_DIR)/content/app/resources/content_resources_100_percent.pak', - '<(SHARED_INTERMEDIATE_DIR)/ui/resources/webui_resources.pak', - '<(SHARED_INTERMEDIATE_DIR)/chrome/renderer_resources_100_percent.pak', - ], }, 'inputs': [ '<(repack_path)', '<@(pak_inputs)', ], 'outputs': [ - '<(SHARED_INTERMEDIATE_DIR)/repack/qtwebengine_resources.pak', + '<@(pak_outputs)', ], 'action': ['python', '<(repack_path)', '<@(_outputs)', '<@(pak_inputs)'], } diff --git a/src/core/resources/resources.gyp b/src/core/resources/resources.gyp index 5d4d83c052438682f82bbf2cb819493a7d4da05b..6293cdf3b51bd652212a41a2d8a681da2a42763c 100644 --- a/src/core/resources/resources.gyp +++ b/src/core/resources/resources.gyp @@ -15,7 +15,7 @@ }, 'dependencies': [ '<(chromium_src_dir)/content/app/strings/content_strings.gyp:content_strings', - '<(chromium_src_dir)/webkit/blink_resources.gyp:blink_resources', + '<(chromium_src_dir)/blink/public/blink_resources.gyp:blink_resources', '<(chromium_src_dir)/content/browser/devtools/devtools_resources.gyp:devtools_resources', '../chrome_qt.gyp:chrome_resources', ], @@ -26,6 +26,46 @@ 'actions' : [ { 'action_name': 'repack_resources', + 'variables': { + 'pak_inputs': [ + '<(SHARED_INTERMEDIATE_DIR)/net/net_resources.pak', + '<(SHARED_INTERMEDIATE_DIR)/blink/devtools_resources.pak', + '<(SHARED_INTERMEDIATE_DIR)/content/content_resources.pak', + '<(SHARED_INTERMEDIATE_DIR)/blink/public/resources/blink_resources.pak', + '<(SHARED_INTERMEDIATE_DIR)/ui/resources/webui_resources.pak', + ], + 'pak_outputs': [ + '<(SHARED_INTERMEDIATE_DIR)/repack/qtwebengine_resources.pak' + ] + }, + 'includes': [ 'repack_resources.gypi' ], + }, + { + 'action_name': 'repack_resources_100_percent', + 'variables': { + 'pak_inputs': [ + '<(SHARED_INTERMEDIATE_DIR)/ui/resources/ui_resources_100_percent.pak', + '<(SHARED_INTERMEDIATE_DIR)/content/app/resources/content_resources_100_percent.pak', + '<(SHARED_INTERMEDIATE_DIR)/chrome/renderer_resources_100_percent.pak', + ], + 'pak_outputs': [ + '<(SHARED_INTERMEDIATE_DIR)/repack/qtwebengine_resources_100p.pak' + ] + }, + 'includes': [ 'repack_resources.gypi' ], + }, + { + 'action_name': 'repack_resources_200_percent', + 'variables': { + 'pak_inputs': [ + '<(SHARED_INTERMEDIATE_DIR)/ui/resources/ui_resources_200_percent.pak', + '<(SHARED_INTERMEDIATE_DIR)/content/app/resources/content_resources_200_percent.pak', + '<(SHARED_INTERMEDIATE_DIR)/chrome/renderer_resources_200_percent.pak', + ], + 'pak_outputs': [ + '<(SHARED_INTERMEDIATE_DIR)/repack/qtwebengine_resources_200p.pak' + ] + }, 'includes': [ 'repack_resources.gypi' ], }, { @@ -40,7 +80,15 @@ 'destination': '<(qt_install_data)', 'files': [ '<(SHARED_INTERMEDIATE_DIR)/repack/qtwebengine_resources.pak' ], }, - ], + { + 'destination': '<(qt_install_data)', + 'files': [ '<(SHARED_INTERMEDIATE_DIR)/repack/qtwebengine_resources_100p.pak' ], + }, + { + 'destination': '<(qt_install_data)', + 'files': [ '<(SHARED_INTERMEDIATE_DIR)/repack/qtwebengine_resources_200p.pak' ], + }, + ], }], ['qt_install_translations != ""', { 'copies': [ diff --git a/src/core/surface_factory_qt.cpp b/src/core/surface_factory_qt.cpp index 40c65d9d3b49d3b382fc2bcd9203cd8cba2d1fd1..db10be070cea969826ba13fac3447a4689343c9b 100644 --- a/src/core/surface_factory_qt.cpp +++ b/src/core/surface_factory_qt.cpp @@ -71,13 +71,13 @@ base::NativeLibrary LoadLibrary(const base::FilePath& filename) { bool SurfaceFactoryQt::LoadEGLGLES2Bindings(AddGLLibraryCallback add_gl_library, SetGLGetProcAddressProcCallback set_gl_get_proc_address) { base::FilePath libEGLPath = QtWebEngineCore::toFilePath(QT_LIBDIR_EGL); - libEGLPath = libEGLPath.Append("libEGL.so"); + libEGLPath = libEGLPath.Append("libEGL.so.1"); base::NativeLibrary eglLibrary = LoadLibrary(libEGLPath); if (!eglLibrary) return false; base::FilePath libGLES2Path = QtWebEngineCore::toFilePath(QT_LIBDIR_GLES2); - libGLES2Path = libGLES2Path.Append("libGLESv2.so"); + libGLES2Path = libGLES2Path.Append("libGLESv2.so.2"); base::NativeLibrary gles2Library = LoadLibrary(libGLES2Path); if (!gles2Library) return false; diff --git a/src/core/url_request_context_getter_qt.cpp b/src/core/url_request_context_getter_qt.cpp index 0eb5163f944e6532c3948257f7837f91bf8cb35d..c9ebf7f3b1a3f14f61075fce2acff0b1c4f1ab20 100644 --- a/src/core/url_request_context_getter_qt.cpp +++ b/src/core/url_request_context_getter_qt.cpp @@ -36,11 +36,13 @@ #include "url_request_context_getter_qt.h" +#include "base/command_line.h" #include "base/strings/string_util.h" #include "base/threading/worker_pool.h" #include "base/threading/sequenced_worker_pool.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/cookie_store_factory.h" +#include "content/public/common/content_switches.h" #include "net/base/cache_type.h" #include "net/cert/cert_verifier.h" #include "net/dns/host_resolver.h" @@ -49,7 +51,11 @@ #include "net/http/http_cache.h" #include "net/http/http_network_session.h" #include "net/http/http_server_properties_impl.h" +#include "net/proxy/dhcp_proxy_script_fetcher_factory.h" +#include "net/proxy/proxy_script_fetcher_impl.h" #include "net/proxy/proxy_service.h" +#include "net/proxy/proxy_service_v8.h" +#include "net/proxy/proxy_resolver_v8.h" #include "net/ssl/channel_id_service.h" #include "net/ssl/default_channel_id_store.h" #include "net/ssl/ssl_config_service_defaults.h" @@ -67,7 +73,6 @@ #include "content_client_qt.h" #include "network_delegate_qt.h" #include "proxy_config_service_qt.h" -#include "proxy_resolver_qt.h" #include "qrc_protocol_handler_qt.h" #include "qwebenginecookiestoreclient.h" #include "qwebenginecookiestoreclient_p.h" @@ -154,17 +159,25 @@ void URLRequestContextGetterQt::generateStorage() base::WorkerPool::GetTaskRunner(true)))); m_storage->set_cert_verifier(net::CertVerifier::CreateDefault()); - net::ProxyService *proxyService = nullptr; - if (ProxyResolverQt::useProxyResolverQt()) { - scoped_ptr<ProxyResolverFactoryQt> factory(new ProxyResolverFactoryQt(false)); - proxyService = new net::ProxyService(proxyConfigService, factory.Pass(), nullptr); - } else - proxyService = net::ProxyService::CreateUsingSystemProxyResolver(proxyConfigService, /*num_pac_threads = */0 /*default*/, NULL); - m_storage->set_proxy_service(proxyService); + + scoped_ptr<net::HostResolver> host_resolver(net::HostResolver::CreateDefaultResolver(NULL)); + + // The System Proxy Resolver has issues on Windows with unconfigured network cards, + // which is why we want to use the v8 one + if (!m_dhcpProxyScriptFetcherFactory) + m_dhcpProxyScriptFetcherFactory.reset(new net::DhcpProxyScriptFetcherFactory); + + m_storage->set_proxy_service(net::CreateProxyServiceUsingV8ProxyResolver( + proxyConfigService, + new net::ProxyScriptFetcherImpl(m_urlRequestContext.get()), + m_dhcpProxyScriptFetcherFactory->Create(m_urlRequestContext.get()), + host_resolver.get(), + NULL /* NetLog */, + m_networkDelegate.get())); + m_storage->set_ssl_config_service(new net::SSLConfigServiceDefaults); m_storage->set_transport_security_state(new net::TransportSecurityState()); - scoped_ptr<net::HostResolver> host_resolver(net::HostResolver::CreateDefaultResolver(NULL)); m_storage->set_http_auth_handler_factory(net::HttpAuthHandlerFactory::CreateDefault(host_resolver.get())); m_storage->set_http_server_properties(scoped_ptr<net::HttpServerProperties>(new net::HttpServerPropertiesImpl)); diff --git a/src/core/url_request_context_getter_qt.h b/src/core/url_request_context_getter_qt.h index be9567f4bb4ede4558fdc08dac01357487bc8e11..c7a4366ec541d2586d93778f067a51298bed0254 100644 --- a/src/core/url_request_context_getter_qt.h +++ b/src/core/url_request_context_getter_qt.h @@ -47,6 +47,7 @@ #include "content/public/common/url_constants.h" #include "net/url_request/url_request_context_storage.h" #include "net/url_request/url_request_job_factory_impl.h" +#include "net/proxy/dhcp_proxy_script_fetcher_factory.h" #include "cookie_monster_delegate_qt.h" #include "network_delegate_qt.h" @@ -97,7 +98,7 @@ private: scoped_ptr<NetworkDelegateQt> m_networkDelegate; scoped_ptr<net::URLRequestContextStorage> m_storage; scoped_ptr<net::URLRequestJobFactoryImpl> m_jobFactory; - + scoped_ptr<net::DhcpProxyScriptFetcherFactory> m_dhcpProxyScriptFetcherFactory; scoped_refptr<CookieMonsterDelegateQt> m_cookieDelegate; friend class NetworkDelegateQt; }; diff --git a/src/core/url_request_custom_job.cpp b/src/core/url_request_custom_job.cpp index cd71b6900afca6314d6b243ae9ec95326d145599..afdcecdfe2b5a68f852b29063e86dff83bd7d24e 100644 --- a/src/core/url_request_custom_job.cpp +++ b/src/core/url_request_custom_job.cpp @@ -10,15 +10,15 @@ ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 3 as published by the Free Software ** Foundation and appearing in the file LICENSE.LGPLv3 included in the -** packaging of this file. Please review the following information to +** packaging of this file. Please review the following information to ** ensure the GNU Lesser General Public License version 3 requirements ** will be met: https://www.gnu.org/licenses/lgpl.html. ** @@ -26,7 +26,7 @@ ** Alternatively, this file may be used under the terms of the GNU ** General Public License version 2.0 or later as published by the Free ** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information to +** the packaging of this file. Please review the following information to ** ensure the GNU General Public License version 2.0 requirements will be ** met: http://www.gnu.org/licenses/gpl-2.0.html. ** diff --git a/src/core/url_request_custom_job.h b/src/core/url_request_custom_job.h index 4975e71d2306566a7964beb337f2d648ea9ad05c..60a1d60b92a99fa321d606c4cc264bdecc6539ba 100644 --- a/src/core/url_request_custom_job.h +++ b/src/core/url_request_custom_job.h @@ -10,15 +10,15 @@ ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 3 as published by the Free Software ** Foundation and appearing in the file LICENSE.LGPLv3 included in the -** packaging of this file. Please review the following information to +** packaging of this file. Please review the following information to ** ensure the GNU Lesser General Public License version 3 requirements ** will be met: https://www.gnu.org/licenses/lgpl.html. ** @@ -26,7 +26,7 @@ ** Alternatively, this file may be used under the terms of the GNU ** General Public License version 2.0 or later as published by the Free ** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information to +** the packaging of this file. Please review the following information to ** ensure the GNU General Public License version 2.0 requirements will be ** met: http://www.gnu.org/licenses/gpl-2.0.html. ** diff --git a/src/core/url_request_custom_job_delegate.cpp b/src/core/url_request_custom_job_delegate.cpp index caf7a0e3ef30f1db583a64abacc0c5962ff0a767..0650242c8f0fc886f9e55a9a66f4a878144b1840 100644 --- a/src/core/url_request_custom_job_delegate.cpp +++ b/src/core/url_request_custom_job_delegate.cpp @@ -10,15 +10,15 @@ ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 3 as published by the Free Software ** Foundation and appearing in the file LICENSE.LGPLv3 included in the -** packaging of this file. Please review the following information to +** packaging of this file. Please review the following information to ** ensure the GNU Lesser General Public License version 3 requirements ** will be met: https://www.gnu.org/licenses/lgpl.html. ** @@ -26,7 +26,7 @@ ** Alternatively, this file may be used under the terms of the GNU ** General Public License version 2.0 or later as published by the Free ** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information to +** the packaging of this file. Please review the following information to ** ensure the GNU General Public License version 2.0 requirements will be ** met: http://www.gnu.org/licenses/gpl-2.0.html. ** @@ -58,6 +58,11 @@ QUrl URLRequestCustomJobDelegate::url() const return toQt(m_job->request()->url()); } +QByteArray URLRequestCustomJobDelegate::method() const +{ + return QByteArray::fromStdString(m_job->request()->method()); +} + void URLRequestCustomJobDelegate::setReply(const QByteArray &contentType, QIODevice *device) { m_job->setReplyMimeType(contentType.toStdString()); diff --git a/src/core/url_request_custom_job_delegate.h b/src/core/url_request_custom_job_delegate.h index 580149ecf90409f06a4b5d3761f91e596850d2a6..5b613782012f981634d7158f5d853b921a40ed45 100644 --- a/src/core/url_request_custom_job_delegate.h +++ b/src/core/url_request_custom_job_delegate.h @@ -10,15 +10,15 @@ ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 3 as published by the Free Software ** Foundation and appearing in the file LICENSE.LGPLv3 included in the -** packaging of this file. Please review the following information to +** packaging of this file. Please review the following information to ** ensure the GNU Lesser General Public License version 3 requirements ** will be met: https://www.gnu.org/licenses/lgpl.html. ** @@ -26,7 +26,7 @@ ** Alternatively, this file may be used under the terms of the GNU ** General Public License version 2.0 or later as published by the Free ** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information to +** the packaging of this file. Please review the following information to ** ensure the GNU General Public License version 2.0 requirements will be ** met: http://www.gnu.org/licenses/gpl-2.0.html. ** @@ -63,6 +63,7 @@ public: }; QUrl url() const; + QByteArray method() const; void setReply(const QByteArray &contentType, QIODevice *device); void redirect(const QUrl& url); diff --git a/src/core/web_contents_adapter.cpp b/src/core/web_contents_adapter.cpp index 999fc881c437d0764439a80c02e3afc9c40b1a50..2b2512fc3b51dab7943f5f723b18fca4cafa1af6 100644 --- a/src/core/web_contents_adapter.cpp +++ b/src/core/web_contents_adapter.cpp @@ -58,6 +58,7 @@ #include "content/browser/renderer_host/render_view_host_impl.h" #include "content/browser/web_contents/web_contents_impl.h" #include "content/public/browser/child_process_security_policy.h" +#include "content/public/browser/devtools_agent_host.h" #include <content/public/browser/download_manager.h> #include "content/public/browser/host_zoom_map.h" #include "content/public/browser/navigation_entry.h" @@ -209,7 +210,7 @@ static void serializeNavigationHistory(const content::NavigationController &cont } } -static void deserializeNavigationHistory(QDataStream &input, int *currentIndex, std::vector<content::NavigationEntry*> *entries, content::BrowserContext *browserContext) +static void deserializeNavigationHistory(QDataStream &input, int *currentIndex, ScopedVector<content::NavigationEntry> *entries, content::BrowserContext *browserContext) { int version; input >> version; @@ -250,13 +251,13 @@ static void deserializeNavigationHistory(QDataStream &input, int *currentIndex, // If we couldn't unpack the entry successfully, abort everything. if (input.status() != QDataStream::Ok) { *currentIndex = -1; - Q_FOREACH (content::NavigationEntry *entry, *entries) + for (content::NavigationEntry *entry : *entries) delete entry; entries->clear(); return; } - content::NavigationEntry *entry = content::NavigationController::CreateNavigationEntry( + scoped_ptr<content::NavigationEntry> entry = content::NavigationController::CreateNavigationEntry( toGurl(virtualUrl), content::Referrer(toGurl(referrerUrl), static_cast<blink::WebReferrerPolicy>(referrerPolicy)), // Use a transition type of reload so that we don't incorrectly @@ -275,7 +276,7 @@ static void deserializeNavigationHistory(QDataStream &input, int *currentIndex, entry->SetIsOverridingUserAgent(isOverridingUserAgent); entry->SetTimestamp(base::Time::FromInternalValue(timestamp)); entry->SetHttpStatusCode(httpStatusCode); - entries->push_back(entry); + entries->push_back(entry.release()); } } @@ -315,12 +316,14 @@ WebContentsAdapterPrivate::WebContentsAdapterPrivate() WebContentsAdapterPrivate::~WebContentsAdapterPrivate() { + // Destroy the WebContents first + webContents.reset(); } QExplicitlySharedDataPointer<WebContentsAdapter> WebContentsAdapter::createFromSerializedNavigationHistory(QDataStream &input, WebContentsAdapterClient *adapterClient) { int currentIndex; - std::vector<content::NavigationEntry*> entries; + ScopedVector<content::NavigationEntry> entries; deserializeNavigationHistory(input, ¤tIndex, &entries, adapterClient->browserContextAdapter()->browserContext()); if (currentIndex == -1) @@ -377,6 +380,7 @@ void WebContentsAdapter::initialize(WebContentsAdapterClient *adapterClient) const int qtCursorFlashTime = QGuiApplication::styleHints()->cursorFlashTime(); rendererPrefs->caret_blink_interval = 0.5 * static_cast<double>(qtCursorFlashTime) / 1000; rendererPrefs->user_agent_override = d->browserContextAdapter->httpUserAgent().toStdString(); + rendererPrefs->accept_languages = d->browserContextAdapter->httpAcceptLanguageWithoutQualities().toStdString(); d->webContents->GetRenderViewHost()->SyncRendererPrefs(); // Create and attach observers to the WebContents. @@ -394,7 +398,7 @@ void WebContentsAdapter::initialize(WebContentsAdapterClient *adapterClient) content::RenderViewHost *rvh = d->webContents->GetRenderViewHost(); Q_ASSERT(rvh); if (!rvh->IsRenderViewLive()) - static_cast<content::WebContentsImpl*>(d->webContents.get())->CreateRenderViewForRenderManager(rvh, MSG_ROUTING_NONE, MSG_ROUTING_NONE, true); + static_cast<content::WebContentsImpl*>(d->webContents.get())->CreateRenderViewForRenderManager(rvh, MSG_ROUTING_NONE, MSG_ROUTING_NONE, content::FrameReplicationState(), true); } void WebContentsAdapter::reattachRWHV() @@ -482,6 +486,7 @@ void WebContentsAdapter::setContent(const QByteArray &data, const QString &mimeT params.can_load_local_resources = true; params.transition_type = ui::PageTransitionFromInt(ui::PAGE_TRANSITION_TYPED | ui::PAGE_TRANSITION_FROM_API); d->webContents->GetController().LoadURLWithParams(params); + d->webContents->Focus(); } QUrl WebContentsAdapter::activeUrl() const @@ -790,6 +795,28 @@ void WebContentsAdapter::executeMediaPlayerActionAt(const QPoint &location, Medi d->webContents->GetRenderViewHost()->ExecuteMediaPlayerActionAtLocation(toGfx(location), blinkAction); } +void WebContentsAdapter::inspectElementAt(const QPoint &location) +{ + Q_D(WebContentsAdapter); + if (content::DevToolsAgentHost::HasFor(d->webContents.get())) { + content::DevToolsAgentHost::GetOrCreateFor(d->webContents.get())->InspectElement(location.x(), location.y()); + } +} + +bool WebContentsAdapter::hasInspector() const +{ + const Q_D(WebContentsAdapter); + if (content::DevToolsAgentHost::HasFor(d->webContents.get())) + return content::DevToolsAgentHost::GetOrCreateFor(d->webContents.get())->IsAttached(); + return false; +} + +void WebContentsAdapter::exitFullScreen() +{ + Q_D(WebContentsAdapter); + d->webContents->ExitFullscreen(); +} + void WebContentsAdapter::wasShown() { Q_D(WebContentsAdapter); @@ -875,4 +902,36 @@ void WebContentsAdapter::setWebChannel(QWebChannel *channel) channel->connectTo(d->webChannelTransport.get()); } +WebContentsAdapterClient::RenderProcessTerminationStatus +WebContentsAdapterClient::renderProcessExitStatus(int terminationStatus) { + auto status = WebContentsAdapterClient::RenderProcessTerminationStatus(-1); + switch (terminationStatus) { + case base::TERMINATION_STATUS_NORMAL_TERMINATION: + status = WebContentsAdapterClient::NormalTerminationStatus; + break; + case base::TERMINATION_STATUS_ABNORMAL_TERMINATION: + status = WebContentsAdapterClient::AbnormalTerminationStatus; + break; + case base::TERMINATION_STATUS_PROCESS_WAS_KILLED: +#if defined(OS_CHROMEOS) + case base::TERMINATION_STATUS_PROCESS_WAS_KILLED_BY_OOM: +#endif + status = WebContentsAdapterClient::KilledTerminationStatus; + break; + case base::TERMINATION_STATUS_PROCESS_CRASHED: +#if defined(OS_ANDROID) + case base::TERMINATION_STATUS_OOM_PROTECTED: +#endif + status = WebContentsAdapterClient::CrashedTerminationStatus; + break; + case base::TERMINATION_STATUS_STILL_RUNNING: + case base::TERMINATION_STATUS_MAX_ENUM: + // should be unreachable since Chromium asserts status != TERMINATION_STATUS_STILL_RUNNING + // before calling this method + break; + } + + return status; +} + } // namespace QtWebEngineCore diff --git a/src/core/web_contents_adapter.h b/src/core/web_contents_adapter.h index 902cc61ffaf522c1247ad5c110bcd318cbfd3195..ecb084e56efeddda0abeff66f622aca00759a630 100644 --- a/src/core/web_contents_adapter.h +++ b/src/core/web_contents_adapter.h @@ -125,6 +125,10 @@ public: void copyImageAt(const QPoint &location); void executeMediaPlayerActionAt(const QPoint &location, MediaPlayerAction action, bool enable); + void inspectElementAt(const QPoint &location); + bool hasInspector() const; + void exitFullScreen(); + void wasShown(); void wasHidden(); void grantMediaAccessPermission(const QUrl &securityOrigin, WebContentsAdapterClient::MediaRequestFlags flags); diff --git a/src/core/web_contents_adapter_client.h b/src/core/web_contents_adapter_client.h index 86b5d1b79f81cfaca8b73f84b360194b2d7fe198..3ae84f9c8773a9207060f0b00f87bb64e924b470 100644 --- a/src/core/web_contents_adapter_client.h +++ b/src/core/web_contents_adapter_client.h @@ -52,6 +52,7 @@ QT_FORWARD_DECLARE_CLASS(CertificateErrorController) namespace QtWebEngineCore { +class AuthenticationDialogController; class BrowserContextAdapter; class FilePickerController; class JavaScriptDialogController; @@ -171,6 +172,13 @@ public: Error }; + enum RenderProcessTerminationStatus { + NormalTerminationStatus = 0, + AbnormalTerminationStatus, + CrashedTerminationStatus, + KilledTerminationStatus + }; + enum MediaRequestFlag { MediaNone = 0, MediaAudioCapture = 0x01, @@ -216,7 +224,7 @@ public: virtual QObject *accessibilityParentObject() = 0; #endif // QT_NO_ACCESSIBILITY virtual void javaScriptConsoleMessage(JavaScriptConsoleMessageLevel level, const QString& message, int lineNumber, const QString& sourceID) = 0; - virtual void authenticationRequired(const QUrl &requestUrl, const QString &realm, bool isProxy, const QString &challengingHost, QString *outUser, QString *outPassword) = 0; + virtual void authenticationRequired(QSharedPointer<AuthenticationDialogController>) = 0; virtual void runGeolocationPermissionRequest(const QUrl &securityOrigin) = 0; virtual void runMediaAccessPermissionRequest(const QUrl &securityOrigin, MediaRequestFlags requestFlags) = 0; virtual void runMouseLockPermissionRequest(const QUrl &securityOrigin) = 0; @@ -224,6 +232,8 @@ public: virtual void showValidationMessage(const QRect &anchor, const QString &mainText, const QString &subText) = 0; virtual void hideValidationMessage() = 0; virtual void moveValidationMessage(const QRect &anchor) = 0; + RenderProcessTerminationStatus renderProcessExitStatus(int); + virtual void renderProcessTerminated(RenderProcessTerminationStatus terminationStatus, int exitCode) = 0; virtual void allowCertificateError(const QSharedPointer<CertificateErrorController> &errorController) = 0; diff --git a/src/core/web_contents_adapter_p.h b/src/core/web_contents_adapter_p.h index 52bade3a5fb11ea60e5de2a43778418ec63e491a..505f803b2fb8ea601ab68355769a9e0d9aff0925 100644 --- a/src/core/web_contents_adapter_p.h +++ b/src/core/web_contents_adapter_p.h @@ -37,6 +37,17 @@ #ifndef WEB_CONTENTS_ADAPTER_P_H #define WEB_CONTENTS_ADAPTER_P_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include "web_contents_adapter.h" #include "base/memory/ref_counted.h" diff --git a/src/core/web_contents_delegate_qt.cpp b/src/core/web_contents_delegate_qt.cpp index 93fabf15a0d03091c16c9a858329fff96bf15319..eb9c42edcd30248c1ee7b4119896c0b7d4a5fedb 100644 --- a/src/core/web_contents_delegate_qt.cpp +++ b/src/core/web_contents_delegate_qt.cpp @@ -144,6 +144,11 @@ void WebContentsDelegateQt::HandleKeyboardEvent(content::WebContents *, const co m_viewClient->unhandledKeyEvent(reinterpret_cast<QKeyEvent *>(event.os_event)); } +void WebContentsDelegateQt::RenderFrameDeleted(content::RenderFrameHost *render_frame_host) +{ + m_loadingErrorFrameList.removeOne(render_frame_host->GetRoutingID()); +} + void WebContentsDelegateQt::DidStartProvisionalLoadForFrame(content::RenderFrameHost* render_frame_host, const GURL& validated_url, bool is_error_page, bool is_iframe_srcdoc) { if (is_error_page) { @@ -172,13 +177,14 @@ void WebContentsDelegateQt::DidCommitProvisionalLoadForFrame(content::RenderFram m_viewClient->loadCommitted(); } -void WebContentsDelegateQt::DidFailProvisionalLoad(content::RenderFrameHost* render_frame_host, const GURL& validated_url, int error_code, const base::string16& error_description) +void WebContentsDelegateQt::DidFailProvisionalLoad(content::RenderFrameHost* render_frame_host, const GURL& validated_url, int error_code, const base::string16& error_description, bool was_ignored_by_handler) { - DidFailLoad(render_frame_host, validated_url, error_code, error_description); + DidFailLoad(render_frame_host, validated_url, error_code, error_description, was_ignored_by_handler); } -void WebContentsDelegateQt::DidFailLoad(content::RenderFrameHost* render_frame_host, const GURL& validated_url, int error_code, const base::string16& error_description) +void WebContentsDelegateQt::DidFailLoad(content::RenderFrameHost* render_frame_host, const GURL& validated_url, int error_code, const base::string16& error_description, bool was_ignored_by_handler) { + Q_UNUSED(was_ignored_by_handler); if (m_loadingErrorFrameList.removeOne(render_frame_host->GetRoutingID()) || render_frame_host->GetParent()) return; diff --git a/src/core/web_contents_delegate_qt.h b/src/core/web_contents_delegate_qt.h index b983738e92e8970acfadc0a396060b42d97c06c9..3fda96113c197bb73d93887c524175d4042c7968 100644 --- a/src/core/web_contents_delegate_qt.h +++ b/src/core/web_contents_delegate_qt.h @@ -93,10 +93,13 @@ public: virtual void MoveValidationMessage(content::WebContents *web_contents, const gfx::Rect &anchor_in_root_view) Q_DECL_OVERRIDE; // WebContentsObserver overrides + virtual void RenderFrameDeleted(content::RenderFrameHost *render_frame_host) Q_DECL_OVERRIDE; virtual void DidStartProvisionalLoadForFrame(content::RenderFrameHost *render_frame_host, const GURL &validated_url, bool is_error_page, bool is_iframe_srcdoc) Q_DECL_OVERRIDE; virtual void DidCommitProvisionalLoadForFrame(content::RenderFrameHost *render_frame_host, const GURL &url, ui::PageTransition transition_type) Q_DECL_OVERRIDE; - virtual void DidFailProvisionalLoad(content::RenderFrameHost *render_frame_host, const GURL &validated_url, int error_code, const base::string16 &error_description) Q_DECL_OVERRIDE; - virtual void DidFailLoad(content::RenderFrameHost *render_frame_host, const GURL &validated_url, int error_code, const base::string16 &error_description) Q_DECL_OVERRIDE; + virtual void DidFailProvisionalLoad(content::RenderFrameHost *render_frame_host, const GURL &validated_url, + int error_code, const base::string16 &error_description, bool was_ignored_by_handler) Q_DECL_OVERRIDE; + virtual void DidFailLoad(content::RenderFrameHost *render_frame_host, const GURL &validated_url, + int error_code, const base::string16 &error_description, bool was_ignored_by_handler) Q_DECL_OVERRIDE; virtual void DidFinishLoad(content::RenderFrameHost *render_frame_host, const GURL &validated_url) Q_DECL_OVERRIDE; virtual void DidUpdateFaviconURL(const std::vector<content::FaviconURL> &candidates) Q_DECL_OVERRIDE; virtual void DidNavigateAnyFrame(content::RenderFrameHost *render_frame_host, const content::LoadCommittedDetails &details, const content::FrameNavigateParams ¶ms) Q_DECL_OVERRIDE; diff --git a/src/core/web_contents_view_qt.cpp b/src/core/web_contents_view_qt.cpp index c32753435bb1ea0bf696a6a63a7a19dcdc3521f8..67addacd51e2866591bb68dde79cff37d5a03ed2 100644 --- a/src/core/web_contents_view_qt.cpp +++ b/src/core/web_contents_view_qt.cpp @@ -113,6 +113,8 @@ void WebContentsViewQt::GetContainerBounds(gfx::Rect* out) const void WebContentsViewQt::Focus() { + if (content::RenderWidgetHostView *rwhv = m_webContents->GetRenderWidgetHostView()) + rwhv->Focus(); m_client->focusContainer(); } diff --git a/src/core/web_engine_context.cpp b/src/core/web_engine_context.cpp index db4cec1fcabbb652990656b23238e4608fac2e9b..4e4159cefb659daaffe64da7ff6de08b791c3da7 100644 --- a/src/core/web_engine_context.cpp +++ b/src/core/web_engine_context.cpp @@ -91,6 +91,10 @@ scoped_refptr<WebEngineContext> sContext; void destroyContext() { + // Destroy WebEngineContext before its static pointer is zeroed and destructor called. + // Before destroying MessageLoop via destroying BrowserMainRunner destructor + // WebEngineContext's pointer is used. + sContext->destroy(); sContext = 0; } @@ -136,16 +140,30 @@ bool usingQtQuick2DRenderer() } // namespace -WebEngineContext::~WebEngineContext() +void WebEngineContext::destroyBrowserContext() { m_defaultBrowserContext = 0; +} + +void WebEngineContext::destroy() +{ delete m_globalQObject; m_globalQObject = 0; base::MessagePump::Delegate *delegate = m_runLoop->loop_; // Flush the UI message loop before quitting. while (delegate->DoWork()) { } GLContextHelper::destroy(); + m_devtools.reset(0); m_runLoop->AfterRun(); + + // Force to destroy RenderProcessHostImpl by destroying BrowserMainRunner. + // RenderProcessHostImpl should be destroyed before WebEngineContext since + // default BrowserContext might be used by the RenderprocessHostImpl's destructor. + m_browserRunner.reset(0); +} + +WebEngineContext::~WebEngineContext() +{ } scoped_refptr<WebEngineContext> WebEngineContext::current() diff --git a/src/core/web_engine_context.h b/src/core/web_engine_context.h index f78791f275d9c25f1021bc08732dc11a8038e568..8f034f18fabf2b3fc9c5a43376466bc003b1939d 100644 --- a/src/core/web_engine_context.h +++ b/src/core/web_engine_context.h @@ -71,6 +71,9 @@ public: QtWebEngineCore::BrowserContextAdapter *defaultBrowserContext(); QObject *globalQObject(); + void destroyBrowserContext(); + void destroy(); + private: friend class base::RefCounted<WebEngineContext>; WebEngineContext(); diff --git a/src/core/web_engine_library_info.cpp b/src/core/web_engine_library_info.cpp index 69fa418c6de8cb7e809e58a268beb87a7e624124..bc030d8f717d3856004a6963e6ae7aac5aa3f2a9 100644 --- a/src/core/web_engine_library_info.cpp +++ b/src/core/web_engine_library_info.cpp @@ -112,54 +112,71 @@ static QString getResourcesPath(CFBundleRef frameworkBundle) QString subProcessPath() { - static bool initialized = false; + static QString processPath; + if (processPath.isEmpty()) { #if defined(OS_WIN) - static QString processBinary (QLatin1String(QTWEBENGINEPROCESS_NAME) % QLatin1String(".exe")); + const QString processBinary = QLatin1String(QTWEBENGINEPROCESS_NAME) % QLatin1String(".exe"); #else - static QString processBinary (QLatin1String(QTWEBENGINEPROCESS_NAME)); + const QString processBinary = QLatin1String(QTWEBENGINEPROCESS_NAME); #endif + + QStringList candidatePaths; + const QByteArray fromEnv = qgetenv("QTWEBENGINEPROCESS_PATH"); + if (!fromEnv.isEmpty()) { + // Only search in QTWEBENGINEPROCESS_PATH if set + candidatePaths << QString::fromLocal8Bit(fromEnv); + } else { #if defined(OS_MACOSX) && defined(QT_MAC_FRAMEWORK_BUILD) - static QString processPath (getPath(frameworkBundle()) - % QStringLiteral("/Helpers/" QTWEBENGINEPROCESS_NAME ".app/Contents/MacOS/" QTWEBENGINEPROCESS_NAME)); + candidatePaths << getPath(frameworkBundle()) + % QStringLiteral("/Helpers/" QTWEBENGINEPROCESS_NAME ".app/Contents/MacOS/" QTWEBENGINEPROCESS_NAME); #else - static QString processPath (QLibraryInfo::location(QLibraryInfo::LibraryExecutablesPath) - % QLatin1Char('/') % processBinary); + candidatePaths << QLibraryInfo::location(QLibraryInfo::LibraryExecutablesPath) + % QLatin1Char('/') % processBinary; + candidatePaths << QCoreApplication::applicationDirPath() + % QLatin1Char('/') % processBinary; #endif - if (!initialized) { - // Allow overriding at runtime for the time being. - const QByteArray fromEnv = qgetenv("QTWEBENGINEPROCESS_PATH"); - if (!fromEnv.isEmpty()) - processPath = QString::fromLatin1(fromEnv); - if (!QFileInfo(processPath).exists()) { - qWarning("QtWebEngineProcess not found at location %s. Trying fallback path...", qPrintable(processPath)); - processPath = QCoreApplication::applicationDirPath() % QLatin1Char('/') % processBinary; } - if (!QFileInfo(processPath).exists()) - qFatal("QtWebEngineProcess not found at location %s. Try setting the QTWEBENGINEPROCESS_PATH environment variable.", qPrintable(processPath)); - initialized = true; + + Q_FOREACH (const QString &candidate, candidatePaths) { + if (QFileInfo(candidate).exists()) { + processPath = candidate; + break; + } + } + if (processPath.isEmpty()) + qFatal("Could not find %s", processBinary.toUtf8().constData()); + } + return processPath; } QString pluginsPath() { #if defined(OS_MACOSX) && defined(QT_MAC_FRAMEWORK_BUILD) - return getPath(frameworkBundle()) % QLatin1String("/Libraries"); + static QString pluginsPath = getPath(frameworkBundle()) % QLatin1String("/Libraries"); #else static bool initialized = false; - static QString potentialPluginsPath = QLibraryInfo::location(QLibraryInfo::PluginsPath) % QDir::separator() % QLatin1String("qtwebengine"); + static QString pluginsPath; if (!initialized) { initialized = true; - if (!QFileInfo::exists(potentialPluginsPath)) - potentialPluginsPath = QCoreApplication::applicationDirPath() % QDir::separator() % QLatin1String("qtwebengine"); - if (!QFileInfo::exists(potentialPluginsPath)) - potentialPluginsPath = fallbackDir(); - } + const QStringList directories = QCoreApplication::libraryPaths(); + Q_FOREACH (const QString &dir, directories) { + const QString candidate = dir % "/" % QLatin1String("qtwebengine"); + if (QFileInfo(candidate).exists()) { + pluginsPath = candidate; + break; + } + } - return potentialPluginsPath; + if (pluginsPath.isEmpty()) { + pluginsPath = fallbackDir(); + } + } #endif + return pluginsPath; } QString localesPath() @@ -215,11 +232,11 @@ base::FilePath WebEngineLibraryInfo::getPath(int key) QString directory; switch (key) { case QT_RESOURCES_PAK: -#if defined(OS_MACOSX) && defined(QT_MAC_FRAMEWORK_BUILD) - return toFilePath(getResourcesPath(frameworkBundle()) % QLatin1String("/qtwebengine_resources.pak")); -#else - return toFilePath(QLibraryInfo::location(QLibraryInfo::DataPath) % QDir::separator() % QLatin1String("qtwebengine_resources.pak")); -#endif + return toFilePath(libraryDataPath() % QLatin1String("/qtwebengine_resources.pak")); + case QT_RESOURCES_100P_PAK: + return toFilePath(libraryDataPath() % QLatin1String("/qtwebengine_resources_100p.pak")); + case QT_RESOURCES_200P_PAK: + return toFilePath(libraryDataPath() % QLatin1String("/qtwebengine_resources_200p.pak")); case base::FILE_EXE: case content::CHILD_PROCESS_EXE: return toFilePath(subProcessPath()); diff --git a/src/core/web_engine_library_info.h b/src/core/web_engine_library_info.h index e85258078e75547cdab0d62053f9f572990f3c49..cd3e5be94a22d7ee0e10732cb2678a69bda92d2d 100644 --- a/src/core/web_engine_library_info.h +++ b/src/core/web_engine_library_info.h @@ -41,7 +41,9 @@ #include "base/files/file_path.h" #include "base/strings/string16.h" enum { - QT_RESOURCES_PAK = 5000 + QT_RESOURCES_PAK = 5000, + QT_RESOURCES_100P_PAK = 5001, + QT_RESOURCES_200P_PAK = 5002 }; class WebEngineLibraryInfo { diff --git a/src/core/web_engine_settings.cpp b/src/core/web_engine_settings.cpp index b59ec73115f79162bf1b4897fd60d48587e36745..19558980be0360dc7c16b14e4f275eb4a8ab674f 100644 --- a/src/core/web_engine_settings.cpp +++ b/src/core/web_engine_settings.cpp @@ -214,7 +214,7 @@ void WebEngineSettings::initDefaults(bool offTheRecord) m_attributes.insert(ScrollAnimatorEnabled, false); m_attributes.insert(ErrorPageEnabled, true); m_attributes.insert(PluginsEnabled, false); - m_attributes.insert(FullscreenSupportEnabled, false); + m_attributes.insert(FullScreenSupportEnabled, false); // Default fonts QFont defaultFont; @@ -280,7 +280,7 @@ void WebEngineSettings::applySettingsToWebPreferences(content::WebPreferences *p prefs->enable_scroll_animator = testAttribute(ScrollAnimatorEnabled); prefs->enable_error_page = testAttribute(ErrorPageEnabled); prefs->plugins_enabled = testAttribute(PluginsEnabled); - prefs->fullscreen_supported = testAttribute(FullscreenSupportEnabled); + prefs->fullscreen_supported = testAttribute(FullScreenSupportEnabled); // Fonts settings. prefs->standard_font_family_map[content::kCommonScript] = toString16(fontFamily(StandardFont)); diff --git a/src/core/web_engine_settings.h b/src/core/web_engine_settings.h index 1d8f83184bf757f762a25342cde1d1e3a495cd7e..29ef079b7652c55920a5815762f95d9ff635faa8 100644 --- a/src/core/web_engine_settings.h +++ b/src/core/web_engine_settings.h @@ -72,7 +72,7 @@ public: ScrollAnimatorEnabled, ErrorPageEnabled, PluginsEnabled, - FullscreenSupportEnabled, + FullScreenSupportEnabled, }; // Must match the values from the public API in qwebenginesettings.h. diff --git a/src/core/web_event_factory.cpp b/src/core/web_event_factory.cpp index e022d02ef5cc6c2a92f6edc1e9ce1e6282864137..1a58ae385a816d070a210a73e611bb076bdbd89e 100644 --- a/src/core/web_event_factory.cpp +++ b/src/core/web_event_factory.cpp @@ -534,8 +534,6 @@ static inline WebInputEvent::Modifiers modifiersForEvent(const QInputEvent* even result |= WebInputEvent::ShiftKey; if (modifiers & Qt::AltModifier) result |= WebInputEvent::AltKey; - if (modifiers & Qt::MetaModifier) - result |= WebInputEvent::MetaKey; if (modifiers & Qt::KeypadModifier) result |= WebInputEvent::IsKeyPad; diff --git a/src/process/process.pro b/src/process/process.pro index 1a62a4f2cdac199aafc81e2166790ed269de0eba..7bf06a37689a1ac8d51b05c1817e7e3c805981ba 100644 --- a/src/process/process.pro +++ b/src/process/process.pro @@ -9,23 +9,7 @@ contains(QT_CONFIG, qt_framework) { # Deploy the QtWebEngineProcess app bundle into the QtWebEngineCore framework. DESTDIR = $$MODULE_BASE_OUTDIR/lib/QtWebEngineCore.framework/Versions/5/Helpers - # FIXME: We can remove those steps in Qt 5.5 once @rpath works - # "QT += webenginecore" would pull all dependencies that we'd also need to update - # with install_name_tool on OSX, but we only need access to the private - # QtWebEngine::processMain. qtAddModule will take care of finding where - # the library is without pulling additional librarie. - QT = core - qtAddModule(webenginecore, LIBS) - CONFIG -= link_prl - QMAKE_POST_LINK = \ - "xcrun install_name_tool -change " \ - "`xcrun otool -X -L $(TARGET) | grep QtWebEngineCore | cut -d ' ' -f 1` " \ - "@executable_path/../../../../QtWebEngineCore " \ - "$(TARGET); " \ - "xcrun install_name_tool -change " \ - "`xcrun otool -X -L $(TARGET) | grep QtCore | cut -d ' ' -f 1` " \ - "@executable_path/../../../../../../../QtCore.framework/QtCore " \ - "$(TARGET) " + QT += webenginecore } else { CONFIG -= app_bundle win32: DESTDIR = $$MODULE_BASE_OUTDIR/bin @@ -34,6 +18,8 @@ contains(QT_CONFIG, qt_framework) { QT_PRIVATE += webenginecore } +msvc: QMAKE_LFLAGS *= /LARGEADDRESSAWARE + INCLUDEPATH += ../core SOURCES = main.cpp diff --git a/src/webengine/api/qquickwebenginecertificateerror.cpp b/src/webengine/api/qquickwebenginecertificateerror.cpp index 010c66be56eaf5316343bdc29be5d2ba758b3d37..202d201b3a23c8ba0fad61d739fe7cb4ad3b555b 100644 --- a/src/webengine/api/qquickwebenginecertificateerror.cpp +++ b/src/webengine/api/qquickwebenginecertificateerror.cpp @@ -69,7 +69,7 @@ public: This class contains information about a certificate error that happened and provides a way to accept or deny a certificate exception. - \sa WebEngineCertificateError::certificateError + \sa WebEngineView::certificateError */ QQuickWebEngineCertificateError::QQuickWebEngineCertificateError(const QSharedPointer<CertificateErrorController> &controller, QObject *parent) : QObject(parent) diff --git a/src/webengine/api/qquickwebenginecertificateerror_p.h b/src/webengine/api/qquickwebenginecertificateerror_p.h index 18a1f90e50cc8baf7c00f0b1e34df0b85134b8a9..6f54528d4cb62cd6b4447078294fe498334aa788 100644 --- a/src/webengine/api/qquickwebenginecertificateerror_p.h +++ b/src/webengine/api/qquickwebenginecertificateerror_p.h @@ -37,6 +37,17 @@ #ifndef QQUICKWEBENGINECERTIFICATEERROR_P_H #define QQUICKWEBENGINECERTIFICATEERROR_P_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include <QObject> #include "qquickwebengineview_p.h" diff --git a/src/webengine/api/qquickwebenginedownloaditem.cpp b/src/webengine/api/qquickwebenginedownloaditem.cpp index 64e75a086960cea88e3538b79bdcdda7dd9101f2..da47388ee4293c4f1fc04f45bfcf794cbebcf974 100644 --- a/src/webengine/api/qquickwebenginedownloaditem.cpp +++ b/src/webengine/api/qquickwebenginedownloaditem.cpp @@ -58,7 +58,7 @@ static inline QQuickWebEngineDownloadItem::DownloadState toDownloadState(int sta } } -QQuickWebEngineDownloadItemPrivate::QQuickWebEngineDownloadItemPrivate(QQuickWebEngineProfilePrivate *p) +QQuickWebEngineDownloadItemPrivate::QQuickWebEngineDownloadItemPrivate(QQuickWebEngineProfile *p) : profile(p) , downloadId(-1) , downloadState(QQuickWebEngineDownloadItem::DownloadCancelled) @@ -69,7 +69,8 @@ QQuickWebEngineDownloadItemPrivate::QQuickWebEngineDownloadItemPrivate(QQuickWeb QQuickWebEngineDownloadItemPrivate::~QQuickWebEngineDownloadItemPrivate() { - profile->downloadDestroyed(downloadId); + if (profile) + profile->d_ptr->downloadDestroyed(downloadId); } /*! @@ -77,11 +78,11 @@ QQuickWebEngineDownloadItemPrivate::~QQuickWebEngineDownloadItemPrivate() \instantiates QQuickWebEngineDownloadItem \inqmlmodule QtWebEngine 1.1 \since QtWebEngine 1.1 - \brief A WebEngineDownloadItem provides information about a download. + \brief Provides information about a download. - WebEngineDownloadItem stores the state of a download to be used to manage requested downloads. + Stores the state of a download to be used to manage requested downloads. - By default the download is rejected unless the user explicitly accepts it with + By default, the download is rejected unless the user explicitly accepts it with WebEngineDownloadItem::accept(). */ @@ -150,14 +151,16 @@ void QQuickWebEngineDownloadItem::cancel() // We directly cancel the download if the user cancels before // it even started, so no need to notify the profile here. - if (state == QQuickWebEngineDownloadItem::DownloadInProgress) - d->profile->cancelDownload(d->downloadId); + if (state == QQuickWebEngineDownloadItem::DownloadInProgress) { + if (d->profile) + d->profile->d_ptr->cancelDownload(d->downloadId); + } } /*! \qmlproperty quint32 WebEngineDownloadItem::id - The download item's id. + Holds the download item's ID. */ quint32 QQuickWebEngineDownloadItem::id() const @@ -169,33 +172,16 @@ quint32 QQuickWebEngineDownloadItem::id() const /*! \qmlproperty enumeration WebEngineDownloadItem::state - This property describes the state in which the download is in. - - The state can be one of: - - \table - - \header - \li Constant - \li Description - - \row - \li DownloadRequested - \li The download has been requested, but has not been accepted yet. - - \row - \li DownloadInProgress - \li The download is in progress. - - \row - \li DownloadCompleted - \li The download completed successfully. - - \row - \li DownloadInterrupted - \li The download has been interrupted (by the server or because of lost connectivity). + Describes the state of the download: - \endtable + \value DownloadRequested + Download has been requested, but it has not been accepted yet. + \value DownloadInProgress + Download is in progress. + \value DownloadCompleted + Download completed successfully. + \value DownloadInterrupted + Download has been interrupted (by the server or because of lost connectivity). */ QQuickWebEngineDownloadItem::DownloadState QQuickWebEngineDownloadItem::state() const @@ -207,9 +193,9 @@ QQuickWebEngineDownloadItem::DownloadState QQuickWebEngineDownloadItem::state() /*! \qmlproperty int WebEngineDownloadItem::totalBytes - The download's total size in bytes. + Holds the total amount of data to download in bytes. - -1 means the total size is unknown. + \c -1 means the total size is unknown. */ qint64 QQuickWebEngineDownloadItem::totalBytes() const @@ -221,7 +207,7 @@ qint64 QQuickWebEngineDownloadItem::totalBytes() const /*! \qmlproperty int WebEngineDownloadItem::receivedBytes - The download's bytes that have been received so far. + Holds the amount of data in bytes that has been downloaded so far. */ qint64 QQuickWebEngineDownloadItem::receivedBytes() const @@ -233,7 +219,7 @@ qint64 QQuickWebEngineDownloadItem::receivedBytes() const /*! \qmlproperty QString WebEngineDownloadItem::path - The download item's full target path where it is being downloaded to. + Holds the full target path where data is being downloaded to. The path includes the file name. The default suggested path is the standard download location and file name is deduced not to overwrite already existing files. @@ -241,7 +227,7 @@ qint64 QQuickWebEngineDownloadItem::receivedBytes() const The download path can only be set in the \c WebEngineProfile.onDownloadRequested handler before the download is accepted. - \sa WebEngineProfile::downloadRequested(WebEngineDownloadItem download), WebEngineDownloadItem::accept() + \sa WebEngineProfile::downloadRequested(), accept() */ QString QQuickWebEngineDownloadItem::path() const diff --git a/src/webengine/api/qquickwebenginedownloaditem_p.h b/src/webengine/api/qquickwebenginedownloaditem_p.h index 63048557f7a195dfa7b30ed896346a073c77790e..9a30eb4ca98945e56031b6ebbf781187fe2444be 100644 --- a/src/webengine/api/qquickwebenginedownloaditem_p.h +++ b/src/webengine/api/qquickwebenginedownloaditem_p.h @@ -37,6 +37,17 @@ #ifndef QQUICKWEBENGINEDOWNLOADITEM_P_H #define QQUICKWEBENGINEDOWNLOADITEM_P_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include <private/qtwebengineglobal_p.h> #include <QObject> #include <QScopedPointer> @@ -60,7 +71,7 @@ public: }; Q_ENUMS(DownloadState) - Q_PROPERTY(quint32 id READ id() CONSTANT FINAL) + Q_PROPERTY(quint32 id READ id CONSTANT FINAL) Q_PROPERTY(DownloadState state READ state NOTIFY stateChanged) Q_PROPERTY(qint64 totalBytes READ totalBytes NOTIFY totalBytesChanged) Q_PROPERTY(qint64 receivedBytes READ receivedBytes NOTIFY receivedBytesChanged) diff --git a/src/webengine/api/qquickwebenginedownloaditem_p_p.h b/src/webengine/api/qquickwebenginedownloaditem_p_p.h index fe45ca2a3608079c30902598c1f8088be9ecf9bc..230f322b50f23a9225e396380bb5a353d2435b10 100644 --- a/src/webengine/api/qquickwebenginedownloaditem_p_p.h +++ b/src/webengine/api/qquickwebenginedownloaditem_p_p.h @@ -37,21 +37,34 @@ #ifndef QQUICKWEBENGINEDOWNLOADITEM_P_P_H #define QQUICKWEBENGINEDOWNLOADITEM_P_P_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include "browser_context_adapter_client.h" #include "qquickwebenginedownloaditem_p.h" +#include "qquickwebengineprofile_p.h" #include <private/qtwebengineglobal_p.h> #include <QString> +#include <QPointer> QT_BEGIN_NAMESPACE class QQuickWebEngineProfilePrivate; class QQuickWebEngineDownloadItemPrivate { QQuickWebEngineDownloadItem *q_ptr; - QQuickWebEngineProfilePrivate* profile; + QPointer<QQuickWebEngineProfile> profile; friend class QQuickWebEngineProfilePrivate; public: Q_DECLARE_PUBLIC(QQuickWebEngineDownloadItem) - QQuickWebEngineDownloadItemPrivate(QQuickWebEngineProfilePrivate *p); + QQuickWebEngineDownloadItemPrivate(QQuickWebEngineProfile *p); ~QQuickWebEngineDownloadItemPrivate(); quint32 downloadId; diff --git a/src/webengine/api/qquickwebenginehistory_p.h b/src/webengine/api/qquickwebenginehistory_p.h index 9b3eeb617a177109aa0c6a9d94f387a959085055..fdde01737fe249460b602197c1179ce702ffc90e 100644 --- a/src/webengine/api/qquickwebenginehistory_p.h +++ b/src/webengine/api/qquickwebenginehistory_p.h @@ -37,6 +37,17 @@ #ifndef QQUICKWEBENGINEHISTORY_P_H #define QQUICKWEBENGINEHISTORY_P_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include <qtwebengineglobal.h> #include <QAbstractListModel> #include <QtCore/qshareddata.h> diff --git a/src/webengine/api/qquickwebenginehistory_p_p.h b/src/webengine/api/qquickwebenginehistory_p_p.h index 0d714b1b6a343cb0a1de3704312a8bce68914c9d..2280d05fc98efcb602094359bfd546fa1be22882 100644 --- a/src/webengine/api/qquickwebenginehistory_p_p.h +++ b/src/webengine/api/qquickwebenginehistory_p_p.h @@ -37,6 +37,17 @@ #ifndef QQUICKWEBENGINEHISTORY_P_P_H #define QQUICKWEBENGINEHISTORY_P_P_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + namespace QtWebEngineCore { class WebContentsAdapter; } diff --git a/src/webengine/api/qquickwebengineloadrequest.cpp b/src/webengine/api/qquickwebengineloadrequest.cpp index c85d0d76f0b8389e78ad08a002d556cdf7e93361..e94fa7eb9aff08e332656427a648061cfec52f9e 100644 --- a/src/webengine/api/qquickwebengineloadrequest.cpp +++ b/src/webengine/api/qquickwebengineloadrequest.cpp @@ -62,10 +62,10 @@ public: \inqmlmodule QtWebEngine 1.0 \since QtWebEngine 1.0 - \brief A utility class for the WebEngineView::loadingChanged signal. + \brief A utility type for the WebEngineView::loadingChanged signal. - This class contains information about a requested load of a web page, such as the URL and - current loading status (started, finished, failed). + Contains information about a request for loading a web page, such as the URL and + current loading status (started, succeeded, failed). \sa WebEngineView::loadingChanged */ @@ -81,7 +81,7 @@ QQuickWebEngineLoadRequest::~QQuickWebEngineLoadRequest() /*! \qmlproperty url WebEngineLoadRequest::url - \brief The URL of the load request. + \brief Holds the URL of the load request. */ QUrl QQuickWebEngineLoadRequest::url() const { @@ -92,11 +92,11 @@ QUrl QQuickWebEngineLoadRequest::url() const /*! \qmlproperty enumeration WebEngineLoadRequest::status - This enumeration represents the load status of a web page load request. + This enumeration represents the load status of a web page load request: - \value WebEngineView::LoadStartedStatus The page is currently loading. - \value WebEngineView::LoadSucceededStatus The page has been loaded with success. - \value WebEngineView::LoadFailedStatus The page has failed loading. + \value WebEngineView::LoadStartedStatus Page is currently loading. + \value WebEngineView::LoadSucceededStatus Page has been loaded with success. + \value WebEngineView::LoadFailedStatus Page could not be loaded. \sa WebEngineView::loadingChanged */ @@ -108,6 +108,7 @@ QQuickWebEngineView::LoadStatus QQuickWebEngineLoadRequest::status() const /*! \qmlproperty string WebEngineLoadRequest::errorString + \brief Holds the error message. */ QString QQuickWebEngineLoadRequest::errorString() const { @@ -123,6 +124,7 @@ QQuickWebEngineView::ErrorDomain QQuickWebEngineLoadRequest::errorDomain() const /*! \qmlproperty int WebEngineLoadRequest::errorCode + \brief Holds the error code. */ int QQuickWebEngineLoadRequest::errorCode() const { diff --git a/src/webengine/api/qquickwebengineloadrequest_p.h b/src/webengine/api/qquickwebengineloadrequest_p.h index 5aae6b81fb8cbb49bd8cb371d3fd1beecef515a6..744d0362513a9cd543e19b7ab1d16853313ccb95 100644 --- a/src/webengine/api/qquickwebengineloadrequest_p.h +++ b/src/webengine/api/qquickwebengineloadrequest_p.h @@ -37,6 +37,17 @@ #ifndef QQUICKWEBENGINELOADREQUEST_P_H #define QQUICKWEBENGINELOADREQUEST_P_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include "qtwebengineglobal_p.h" #include "qquickwebengineview_p.h" diff --git a/src/webengine/api/qquickwebenginenavigationrequest_p.h b/src/webengine/api/qquickwebenginenavigationrequest_p.h index ab39ed13a60f389e0e113c9a5c98e79b686ac5a8..9b6da49694189bfbb676e92edecbcd9194aad347 100644 --- a/src/webengine/api/qquickwebenginenavigationrequest_p.h +++ b/src/webengine/api/qquickwebenginenavigationrequest_p.h @@ -37,6 +37,17 @@ #ifndef QQUICKWEBENGINENAVIGATIONREQUEST_P_H #define QQUICKWEBENGINENAVIGATIONREQUEST_P_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include "qtwebengineglobal_p.h" #include "qquickwebengineview_p.h" diff --git a/src/webengine/api/qquickwebenginenewviewrequest.cpp b/src/webengine/api/qquickwebenginenewviewrequest.cpp index dd197dfe49ddddd3e14158fbcec2bb9e6bfae53c..893df7f46aff160789b3ef0a13dade2fd65b0c96 100644 --- a/src/webengine/api/qquickwebenginenewviewrequest.cpp +++ b/src/webengine/api/qquickwebenginenewviewrequest.cpp @@ -45,9 +45,9 @@ \inqmlmodule QtWebEngine 1.1 \since QtWebEngine 1.1 - \brief A utility class for the WebEngineView::newViewRequested signal. + \brief A utility type for the WebEngineView::newViewRequested signal. - This class contains information about the request of a page to open a new window. + Contains information about a request to load a page in a separate web engine view. \sa WebEngineView::newViewRequested */ @@ -61,7 +61,7 @@ QQuickWebEngineNewViewRequest::~QQuickWebEngineNewViewRequest() /*! \qmlproperty WebEngineView::NewViewDestination WebEngineNewViewRequest::destination - \brief The type of view that is requested by the page. + The type of the view that is requested by the page. */ QQuickWebEngineView::NewViewDestination QQuickWebEngineNewViewRequest::destination() const { @@ -70,9 +70,9 @@ QQuickWebEngineView::NewViewDestination QQuickWebEngineNewViewRequest::destinati /*! \qmlproperty bool WebEngineNewViewRequest::isUserInitiated - \brief Whether this window request was directly triggered as the result of a keyboard or mouse event. + Whether this window request was directly triggered as the result of a keyboard or mouse event. - Use this property to block possibly unwanted "popups". + Use this property to block possibly unwanted \e popups. */ bool QQuickWebEngineNewViewRequest::isUserInitiated() const { @@ -82,9 +82,8 @@ bool QQuickWebEngineNewViewRequest::isUserInitiated() const /*! \qmlmethod WebEngineNewViewRequest::openIn(WebEngineView view) - Call this method to fulfill the request and determine which WebEngineView - should be used to contain the new page. Any state, history or loaded page - within \a view will be lost as result of this. + Opens the requested page in the new web engine view \a view. State and history of the + view and the page possibly loaded in it will be lost. \sa WebEngineView::newViewRequested */ diff --git a/src/webengine/api/qquickwebenginenewviewrequest_p.h b/src/webengine/api/qquickwebenginenewviewrequest_p.h index 9c82f46d6cd67270eb3e3778b04b826b45a5b782..b408812bafc62e14fa4308706be392260bc4b5b3 100644 --- a/src/webengine/api/qquickwebenginenewviewrequest_p.h +++ b/src/webengine/api/qquickwebenginenewviewrequest_p.h @@ -37,6 +37,17 @@ #ifndef QQUICKWEBENGINENEWVIEWREQUEST_P_H #define QQUICKWEBENGINENEWVIEWREQUEST_P_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include "qtwebengineglobal_p.h" #include "qquickwebengineview_p.h" diff --git a/src/webengine/api/qquickwebengineprofile.cpp b/src/webengine/api/qquickwebengineprofile.cpp index 38b042fff38375d44f7d21a7e0adecc562339022..b06345b83a5987618565e4b74120f955f99fc8a0 100644 --- a/src/webengine/api/qquickwebengineprofile.cpp +++ b/src/webengine/api/qquickwebengineprofile.cpp @@ -40,6 +40,7 @@ #include "qquickwebenginedownloaditem_p_p.h" #include "qquickwebengineprofile_p_p.h" #include "qquickwebenginesettings_p.h" +#include "qwebenginecookiestoreclient.h" #include <QQmlEngine> @@ -58,7 +59,7 @@ QQuickWebEngineProfilePrivate::QQuickWebEngineProfilePrivate(BrowserContextAdapt m_settings->d_ptr->initDefaults(browserContext->isOffTheRecord()); // Fullscreen API was implemented before the supported setting, so we must // make it default true to avoid change in default API behavior. - m_settings->d_ptr->setAttribute(QtWebEngineCore::WebEngineSettings::FullscreenSupportEnabled, true); + m_settings->d_ptr->setAttribute(QtWebEngineCore::WebEngineSettings::FullScreenSupportEnabled, true); } QQuickWebEngineProfilePrivate::~QQuickWebEngineProfilePrivate() @@ -88,7 +89,7 @@ void QQuickWebEngineProfilePrivate::downloadRequested(DownloadItemInfo &info) Q_Q(QQuickWebEngineProfile); Q_ASSERT(!m_ongoingDownloads.contains(info.id)); - QQuickWebEngineDownloadItemPrivate *itemPrivate = new QQuickWebEngineDownloadItemPrivate(this); + QQuickWebEngineDownloadItemPrivate *itemPrivate = new QQuickWebEngineDownloadItemPrivate(q); itemPrivate->downloadId = info.id; itemPrivate->downloadState = QQuickWebEngineDownloadItem::DownloadRequested; itemPrivate->totalBytes = info.totalBytes; @@ -134,13 +135,14 @@ void QQuickWebEngineProfilePrivate::downloadUpdated(const DownloadItemInfo &info \instantiates QQuickWebEngineProfile \inqmlmodule QtWebEngine 1.1 \since QtWebEngine 1.1 - \brief A WebEngineProfile contains common settings for multiple WebEngineView. + \brief Contains settings, scripts, and visited links common to multiple web engine views. - WebEngineProfile contains settings and history shared by all WebEngineView that belong - to the profile. + WebEngineProfile contains settings, scripts, and the list of visited links shared by all + views that belong to the profile. As such, profiles can be used to isolate views + from each other. A typical use case is a dedicated profile for a 'private browsing' mode. - A default profile is built-in that all web pages not specifically created with another profile - belongs to. + Each web engine view has an associated profile. Views that do not have a specific profile set + share a common default one. */ /*! @@ -148,16 +150,15 @@ void QQuickWebEngineProfilePrivate::downloadUpdated(const DownloadItemInfo &info This signal is emitted whenever a download has been triggered. The \a download argument holds the state of the download. - The \a download has to be explicitly accepted with WebEngineDownloadItem::accept(), - else the download will be cancelled by default. + The download has to be explicitly accepted with WebEngineDownloadItem::accept() or the + download will be cancelled by default. */ /*! \qmlsignal WebEngineProfile::downloadFinished(WebEngineDownloadItem download) - This signal is emitted whenever a download finishes downloading. - This can be due to the download finishing successfully, being cancelled or - interrupted by lost connectivity for example. + This signal is emitted whenever downloading stops, because it finished successfully, was + cancelled, or was interrupted (for example, because connectivity was lost). The \a download argument holds the state of the finished download instance. */ @@ -181,7 +182,10 @@ QQuickWebEngineProfile::~QQuickWebEngineProfile() /*! \qmlproperty QString WebEngineProfile::storageName - The storage name is used to give each profile that uses the disk separate subdirectories for persistent data and cache. + The storage name that is used to create separate subdirectories for each profile that uses + the disk for storing persistent data and cache. + + \sa WebEngineProfile::persistentStoragePath, WebEngineProfile::cachePath */ QString QQuickWebEngineProfile::storageName() const @@ -210,8 +214,9 @@ void QQuickWebEngineProfile::setStorageName(const QString &name) /*! \qmlproperty bool WebEngineProfile::offTheRecord - An offTheRecord profile forces cookies and HTTP cache to be in memory, but also force - all other normally persistent data to be stored in memory. + Whether the web engine profile is \e off-the-record. + An off-the-record profile forces cookies, the HTTP cache, and other normally persistent data + to be stored only in memory. */ bool QQuickWebEngineProfile::isOffTheRecord() const { @@ -237,10 +242,12 @@ void QQuickWebEngineProfile::setOffTheRecord(bool offTheRecord) /*! \qmlproperty QString WebEngineProfile::persistentStoragePath - The persistent storage path is where persistent data for the browser and web content is stored. - Persistent data includes persistent cookies, HTML5 local storage and visited links. + The path to the location where the persistent data for the browser and web content are + stored. Persistent data includes persistent cookies, HTML5 local storage, and visited links. - By default this is below QStandardPaths::writableLocation(QStandardPaths::DataLocation) in a storageName specific directory. + By default, the storage is located below + QStandardPaths::writableLocation(QStandardPaths::DataLocation) in a directory named using + storageName. */ QString QQuickWebEngineProfile::persistentStoragePath() const { @@ -260,7 +267,11 @@ void QQuickWebEngineProfile::setPersistentStoragePath(const QString &path) /*! \qmlproperty QString WebEngineProfile::cachePath - By default this is below QStandardPaths::writableLocation(QStandardPaths::CacheLocation) in a storageName specific directory. + The path to the location where the profile's caches are stored, in particular the HTTP cache. + + By default, the caches are stored + below QStandardPaths::writableLocation(QStandardPaths::CacheLocation) in a directory named using + storageName. */ QString QQuickWebEngineProfile::cachePath() const { @@ -280,7 +291,7 @@ void QQuickWebEngineProfile::setCachePath(const QString &path) /*! \qmlproperty QString WebEngineProfile::httpUserAgent - The user-agent string send with HTTP to identify the browser. + The user-agent string sent with HTTP to identify the browser. */ QString QQuickWebEngineProfile::httpUserAgent() const { @@ -301,23 +312,13 @@ void QQuickWebEngineProfile::setHttpUserAgent(const QString &userAgent) /*! \qmlproperty enumeration WebEngineProfile::httpCacheType - The type of the HTTP cache. - - \table - - \header - \li Constant - \li Description + This enumeration describes the type of the HTTP cache: - \row - \li MemoryHttpCache - \li Use a in-memory cache. This is the only setting possible if offTheRecord is set or no cachePath is available. - - \row - \li DiskHttpCache - \li DiskHttpCache Use a disk cache. This is the default. - - \endtable + \value MemoryHttpCache + Uses an in-memory cache. This is the only setting possible if offTheRecord is set or + no persistentStoragePath is available. + \value DiskHttpCache + Uses a disk cache. This is the default value. */ QQuickWebEngineProfile::HttpCacheType QQuickWebEngineProfile::httpCacheType() const @@ -338,27 +339,16 @@ void QQuickWebEngineProfile::setHttpCacheType(QQuickWebEngineProfile::HttpCacheT /*! \qmlproperty enumeration WebEngineProfile::persistentCookiesPolicy - The policy of cookie persistency. - - \table - - \header - \li Constant - \li Description + This enumeration describes the policy of cookie persistency: - \row - \li NoPersistentCookies - \li Both session and persistent cookies are stored in memory. This is the only setting possible if offTheRecord is set or no persistentStoragePath is available. - - \row - \li AllowPersistentCookies - \li Cookies marked persistent are save and restored from disk, session cookies are only stored to disk for crash recovery. This is the default setting. - - \row - \li ForcePersistentCookies - \li Both session and persistent cookies are save and restored from disk. - - \endtable + \value NoPersistentCookies + Both session and persistent cookies are stored in memory. This is the only setting + possible if offTheRecord is set or no persistentStoragePath is available. + \value AllowPersistentCookies + Cookies marked persistent are saved to and restored from disk, whereas session cookies + are only stored to disk for crash recovery. This is the default setting. + \value ForcePersistentCookies + Both session and persistent cookies are saved to and restored from disk. */ QQuickWebEngineProfile::PersistentCookiesPolicy QQuickWebEngineProfile::persistentCookiesPolicy() const @@ -379,8 +369,8 @@ void QQuickWebEngineProfile::setPersistentCookiesPolicy(QQuickWebEngineProfile:: /*! \qmlproperty int WebEngineProfile::httpCacheMaximumSize - The maximum size of the HTTP cache. If 0 it means the size will be controlled automatically by QtWebEngine. - The default value is 0. + The maximum size of the HTTP cache. If \c 0, the size will be controlled automatically by + QtWebEngine. The default value is \c 0. \sa httpCacheType */ @@ -435,4 +425,10 @@ QQuickWebEngineSettings *QQuickWebEngineProfile::settings() const return d->settings(); } +void QQuickWebEngineProfile::setCookieStoreClient(QWebEngineCookieStoreClient* client) +{ + Q_D(QQuickWebEngineProfile); + d->browserContext()->setCookieStoreClient(client); +} + QT_END_NAMESPACE diff --git a/src/webengine/api/qquickwebengineprofile_p.h b/src/webengine/api/qquickwebengineprofile_p.h index 72e5716d0fb84111975e23b29ec815da2ab21c98..af5762032789899e8e840cf0ecab0631b2e89a8a 100644 --- a/src/webengine/api/qquickwebengineprofile_p.h +++ b/src/webengine/api/qquickwebengineprofile_p.h @@ -37,6 +37,17 @@ #ifndef QQUICKWEBENGINEPROFILE_P_H #define QQUICKWEBENGINEPROFILE_P_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include <private/qtwebengineglobal_p.h> #include <QObject> @@ -52,6 +63,7 @@ QT_BEGIN_NAMESPACE class QQuickWebEngineDownloadItem; class QQuickWebEngineProfilePrivate; class QQuickWebEngineSettings; +class QWebEngineCookieStoreClient; class Q_WEBENGINE_PRIVATE_EXPORT QQuickWebEngineProfile : public QObject { Q_OBJECT @@ -110,6 +122,8 @@ public: static QQuickWebEngineProfile *defaultProfile(); + Q_REVISION(1) Q_INVOKABLE void setCookieStoreClient(QWebEngineCookieStoreClient* client); + signals: void storageNameChanged(); void offTheRecordChanged(); @@ -132,6 +146,8 @@ private: friend class QQuickWebEngineSettings; friend class QQuickWebEngineSingleton; friend class QQuickWebEngineViewPrivate; + friend class QQuickWebEngineDownloadItem; + friend class QQuickWebEngineDownloadItemPrivate; QScopedPointer<QQuickWebEngineProfilePrivate> d_ptr; }; diff --git a/src/webengine/api/qquickwebengineprofile_p_p.h b/src/webengine/api/qquickwebengineprofile_p_p.h index a702a8a1d1ee226e1a5a660004ad4d490d10bc2a..4df5f19340bdee02d6291def8e9063bd539d0558 100644 --- a/src/webengine/api/qquickwebengineprofile_p_p.h +++ b/src/webengine/api/qquickwebengineprofile_p_p.h @@ -37,6 +37,17 @@ #ifndef QQUICKWEBENGINEPROFILE_P_P_H #define QQUICKWEBENGINEPROFILE_P_P_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include "browser_context_adapter_client.h" #include "qquickwebengineprofile_p.h" diff --git a/src/webengine/api/qquickwebenginescript_p.h b/src/webengine/api/qquickwebenginescript_p.h index f1d7a01dc9061d6ebf8cf0788b2be99091e514a3..de91134eff9dbfaff5f0ad4694505884ff0ea00c 100644 --- a/src/webengine/api/qquickwebenginescript_p.h +++ b/src/webengine/api/qquickwebenginescript_p.h @@ -37,6 +37,17 @@ #ifndef QQUICKWEBENGINESCRIPT_P_H #define QQUICKWEBENGINESCRIPT_P_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include <private/qtwebengineglobal_p.h> #include <QtCore/QObject> #include <QtCore/QUrl> diff --git a/src/webengine/api/qquickwebenginescript_p_p.h b/src/webengine/api/qquickwebenginescript_p_p.h index f8a957579add0c499a0f8b3ce50c48202e6243f9..133e2dc0ba3f5543cea68111ed83418299cdbb63 100644 --- a/src/webengine/api/qquickwebenginescript_p_p.h +++ b/src/webengine/api/qquickwebenginescript_p_p.h @@ -1,7 +1,7 @@ /**************************************************************************** ** -** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ ** ** This file is part of the QtWebEngine module of the Qt Toolkit. ** @@ -37,6 +37,17 @@ #ifndef QQUICKWEBENGINESCRIPT_P_P_H #define QQUICKWEBENGINESCRIPT_P_P_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include "qquickwebenginescript_p.h" #include <QtCore/QBasicTimer> diff --git a/src/webengine/api/qquickwebenginesettings.cpp b/src/webengine/api/qquickwebenginesettings.cpp index 6a012ba39f3dc69aa85631642074a02b5042c3f3..539f211b0bbf5e54d8383b40fd8d4c0714fb80bf 100644 --- a/src/webengine/api/qquickwebenginesettings.cpp +++ b/src/webengine/api/qquickwebenginesettings.cpp @@ -56,8 +56,8 @@ QQuickWebEngineSettings::QQuickWebEngineSettings(QQuickWebEngineSettings *parent \since QtWebEngine 1.1 \brief WebEngineSettings allows configuration of browser properties and attributes. - WebEngineSettings allows configuration of browser properties and generic attributes like for example - JavaScript, focus behavior and access to remote content. + WebEngineSettings allows configuration of browser properties and generic attributes, such as + JavaScript support, focus behavior, and access to remote content. Each WebEngineView can have individual settings. @@ -70,9 +70,9 @@ QQuickWebEngineSettings::~QQuickWebEngineSettings() /*! \qmlproperty bool WebEngineSettings::autoLoadImages - Specifies whether images are automatically loaded in web pages. + Automatically loads images on web pages. - This is enabled by default. + Enabled by default. */ bool QQuickWebEngineSettings::autoLoadImages() const { @@ -82,9 +82,9 @@ bool QQuickWebEngineSettings::autoLoadImages() const /*! \qmlproperty bool WebEngineSettings::javascriptEnabled - Enables or disables the running of JavaScript programs. + Enables the running of JavaScript programs. - This is enabled by default. + Enabled by default. */ bool QQuickWebEngineSettings::javascriptEnabled() const { @@ -94,9 +94,9 @@ bool QQuickWebEngineSettings::javascriptEnabled() const /*! \qmlproperty bool WebEngineSettings::javascriptCanOpenWindows - Specifies whether JavaScript programs can open new windows. + Allows JavaScript programs to open new windows. - This is enabled by default. + Enabled by default. */ bool QQuickWebEngineSettings::javascriptCanOpenWindows() const { @@ -106,9 +106,9 @@ bool QQuickWebEngineSettings::javascriptCanOpenWindows() const /*! \qmlproperty bool WebEngineSettings::javascriptCanAccessClipboard - Specifies whether JavaScript programs can read or write to the clipboard. + Allows JavaScript programs to read from or write to the clipboard. - This is disabled by default. + Disabled by default. */ bool QQuickWebEngineSettings::javascriptCanAccessClipboard() const { @@ -118,9 +118,9 @@ bool QQuickWebEngineSettings::javascriptCanAccessClipboard() const /*! \qmlproperty bool WebEngineSettings::linksIncludedInFocusChain - Specifies whether hyperlinks should be included in the keyboard focus chain. + Includes hyperlinks in the keyboard focus chain. - This is enabled by default. + Enabled by default. */ bool QQuickWebEngineSettings::linksIncludedInFocusChain() const { @@ -130,9 +130,9 @@ bool QQuickWebEngineSettings::linksIncludedInFocusChain() const /*! \qmlproperty bool WebEngineSettings::localStorageEnabled - Specifies whether support for the HTML 5 local storage feature is enabled or not. + Enables support for the HTML 5 local storage feature. - This is enabled by default. + Enabled by default. */ bool QQuickWebEngineSettings::localStorageEnabled() const { @@ -142,10 +142,9 @@ bool QQuickWebEngineSettings::localStorageEnabled() const /*! \qmlproperty bool WebEngineSettings::localContentCanAccessRemoteUrls - Specifies whether locally loaded documents are allowed to access remote urls. - For more information about security origins and local vs. remote content see QWebEngineSecurityOrigin. + Allows locally loaded documents to access remote URLs. - This is disabled by default. + Disabled by default. */ bool QQuickWebEngineSettings::localContentCanAccessRemoteUrls() const { @@ -155,15 +154,14 @@ bool QQuickWebEngineSettings::localContentCanAccessRemoteUrls() const /*! \qmlproperty bool WebEngineSettings::spatialNavigationEnabled - Enables or disables the Spatial Navigation feature, which consists in the - ability to navigate between focusable elements in a Web page, such as hyperlinks - and form controls, by using Left, Right, Up and Down arrow keys. + Enables the Spatial Navigation feature, which means the ability to navigate between focusable + elements, such as hyperlinks and form controls, on a web page by using the Left, Right, Up and + Down arrow keys. - For example, if a user presses the Right key, heuristics determine whether there - is an element they might be trying to reach towards the right and which element - they probably want. + For example, if a user presses the Right key, heuristics determine whether there is an element + they might be trying to reach towards the right and which element they probably want. - This is disabled by default. + Disabled by default. */ bool QQuickWebEngineSettings::spatialNavigationEnabled() const @@ -174,10 +172,9 @@ bool QQuickWebEngineSettings::spatialNavigationEnabled() const /*! \qmlproperty bool WebEngineSettings::localContentCanAccessFileUrls - Specifies whether locally loaded documents are allowed to access other local urls. - For more information about security origins and local vs. remote content see QWebEngineSecurityOrigin. + Allows locally loaded documents to access other local URLs. - This is enabled by default. + Enabled by default. */ bool QQuickWebEngineSettings::localContentCanAccessFileUrls() const { @@ -187,9 +184,9 @@ bool QQuickWebEngineSettings::localContentCanAccessFileUrls() const /*! \qmlproperty bool WebEngineSettings::hyperlinkAuditingEnabled - This setting enables support for the ping attribute for hyperlinks. + Enables support for the \c ping attribute for hyperlinks. - It is disabled by default. + Disabled by default. */ bool QQuickWebEngineSettings::hyperlinkAuditingEnabled() const { @@ -199,9 +196,9 @@ bool QQuickWebEngineSettings::hyperlinkAuditingEnabled() const /*! \qmlproperty bool WebEngineSettings::errorPageEnabled - This setting enables built-in error pages of Chromium. + Enables displaying the built-in error pages of Chromium. - It is enabled by default. + Enabled by default. */ bool QQuickWebEngineSettings::errorPageEnabled() const { @@ -211,9 +208,9 @@ bool QQuickWebEngineSettings::errorPageEnabled() const /*! \qmlproperty bool WebEngineSettings::pluginsEnabled - This setting enables general support for plugins. + Enables support for Pepper plugins, such as the Flash player. - It is disabled by default. + Disabled by default. */ bool QQuickWebEngineSettings::pluginsEnabled() const { @@ -224,22 +221,22 @@ bool QQuickWebEngineSettings::pluginsEnabled() const \qmlproperty bool WebEngineSettings::fullscreenSupportEnabled \since QtWebEngine 1.2 - This setting tells the web engine if fullscreen is supported in this application or not. + Tells the web engine whether fullscreen is supported in this application or not. - It is enabled by default. + Enabled by default. */ -bool QQuickWebEngineSettings::fullscreenSupportEnabled() const +bool QQuickWebEngineSettings::fullScreenSupportEnabled() const { - return d_ptr->testAttribute(WebEngineSettings::FullscreenSupportEnabled); + return d_ptr->testAttribute(WebEngineSettings::FullScreenSupportEnabled); } /*! \qmlproperty QString WebEngineSettings::defaultTextEncoding - The \a encoding, must be a string describing an encoding such as "utf-8", - "iso-8859-1", etc. + Sets the default encoding. The value must be a string describing an encoding such as "utf-8" or + "iso-8859-1". - If left empty a default value will be used. + If left empty, a default value will be used. */ QString QQuickWebEngineSettings::defaultTextEncoding() const { @@ -345,12 +342,12 @@ void QQuickWebEngineSettings::setPluginsEnabled(bool on) Q_EMIT pluginsEnabledChanged(); } -void QQuickWebEngineSettings::setFullscreenSupportEnabled(bool on) +void QQuickWebEngineSettings::setFullScreenSupportEnabled(bool on) { - bool wasOn = d_ptr->testAttribute(WebEngineSettings::FullscreenSupportEnabled); - d_ptr->setAttribute(WebEngineSettings::FullscreenSupportEnabled, on); + bool wasOn = d_ptr->testAttribute(WebEngineSettings::FullScreenSupportEnabled); + d_ptr->setAttribute(WebEngineSettings::FullScreenSupportEnabled, on); if (wasOn != on) - Q_EMIT fullscreenSupportEnabledChanged(); + Q_EMIT fullScreenSupportEnabledChanged(); } void QQuickWebEngineSettings::setDefaultTextEncoding(QString encoding) diff --git a/src/webengine/api/qquickwebenginesettings_p.h b/src/webengine/api/qquickwebenginesettings_p.h index dce060c9f34ae816a6b31b71d5f7de30834c9230..604e5693dc2f59a74d76c1dc9223390ff96bc523 100644 --- a/src/webengine/api/qquickwebenginesettings_p.h +++ b/src/webengine/api/qquickwebenginesettings_p.h @@ -37,6 +37,17 @@ #ifndef QQUICKWEBENGINESETTINGS_P_H #define QQUICKWEBENGINESETTINGS_P_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include <private/qtwebengineglobal_p.h> #include <QObject> #include <QScopedPointer> @@ -61,7 +72,7 @@ class Q_WEBENGINE_PRIVATE_EXPORT QQuickWebEngineSettings : public QObject { Q_PROPERTY(bool hyperlinkAuditingEnabled READ hyperlinkAuditingEnabled WRITE setHyperlinkAuditingEnabled NOTIFY hyperlinkAuditingEnabledChanged) Q_PROPERTY(bool errorPageEnabled READ errorPageEnabled WRITE setErrorPageEnabled NOTIFY errorPageEnabledChanged) Q_PROPERTY(bool pluginsEnabled READ pluginsEnabled WRITE setPluginsEnabled NOTIFY pluginsEnabledChanged) - Q_PROPERTY(bool fullscreenSupportEnabled READ fullscreenSupportEnabled WRITE setFullscreenSupportEnabled NOTIFY fullscreenSupportEnabledChanged REVISION 1) + Q_PROPERTY(bool fullScreenSupportEnabled READ fullScreenSupportEnabled WRITE setFullScreenSupportEnabled NOTIFY fullScreenSupportEnabledChanged REVISION 1) Q_PROPERTY(QString defaultTextEncoding READ defaultTextEncoding WRITE setDefaultTextEncoding NOTIFY defaultTextEncodingChanged) public: @@ -79,7 +90,7 @@ public: bool hyperlinkAuditingEnabled() const; bool errorPageEnabled() const; bool pluginsEnabled() const; - bool fullscreenSupportEnabled() const; + bool fullScreenSupportEnabled() const; QString defaultTextEncoding() const; void setAutoLoadImages(bool on); @@ -94,7 +105,7 @@ public: void setHyperlinkAuditingEnabled(bool on); void setErrorPageEnabled(bool on); void setPluginsEnabled(bool on); - void setFullscreenSupportEnabled(bool on); + void setFullScreenSupportEnabled(bool on); void setDefaultTextEncoding(QString encoding); signals: @@ -110,7 +121,7 @@ signals: void hyperlinkAuditingEnabledChanged(); void errorPageEnabledChanged(); void pluginsEnabledChanged(); - Q_REVISION(1) void fullscreenSupportEnabledChanged(); + Q_REVISION(1) void fullScreenSupportEnabledChanged(); void defaultTextEncodingChanged(); private: diff --git a/src/webengine/api/qquickwebenginesingleton_p.h b/src/webengine/api/qquickwebenginesingleton_p.h index a653116e406a19cae6598d7ce07de2c98ab2e8c2..64668420c3ae93b0c84ed9f82696e8ed4428f41e 100644 --- a/src/webengine/api/qquickwebenginesingleton_p.h +++ b/src/webengine/api/qquickwebenginesingleton_p.h @@ -37,8 +37,19 @@ #ifndef QQUICKWEBENGINESINGLETON_P_H #define QQUICKWEBENGINESINGLETON_P_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include <QObject> -#include <qtwebengineglobal_p.h> +#include "qtwebengineglobal_p.h" QT_BEGIN_NAMESPACE class QQuickWebEngineProfile; diff --git a/src/webengine/api/qquickwebenginetestsupport.cpp b/src/webengine/api/qquickwebenginetestsupport.cpp index d85e56e59521c5ae043fa288cf9c977cf8765f57..c081257e66d534534f1f6caaa9a4f11c157a364d 100644 --- a/src/webengine/api/qquickwebenginetestsupport.cpp +++ b/src/webengine/api/qquickwebenginetestsupport.cpp @@ -1,7 +1,7 @@ /**************************************************************************** ** -** Copyright (C) 2015 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ ** ** This file is part of the QtWebEngine module of the Qt Toolkit. ** @@ -10,15 +10,15 @@ ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 3 as published by the Free Software ** Foundation and appearing in the file LICENSE.LGPLv3 included in the -** packaging of this file. Please review the following information to +** packaging of this file. Please review the following information to ** ensure the GNU Lesser General Public License version 3 requirements ** will be met: https://www.gnu.org/licenses/lgpl.html. ** @@ -26,7 +26,7 @@ ** Alternatively, this file may be used under the terms of the GNU ** General Public License version 2.0 or later as published by the Free ** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information to +** the packaging of this file. Please review the following information to ** ensure the GNU General Public License version 2.0 requirements will be ** met: http://www.gnu.org/licenses/gpl-2.0.html. ** diff --git a/src/webengine/api/qquickwebenginetestsupport_p.h b/src/webengine/api/qquickwebenginetestsupport_p.h index dcda2d78f9dcc20a09c661fad40da09ed649cdbf..9690e538d0be9d704886a6a74f6d12b4132d73da 100644 --- a/src/webengine/api/qquickwebenginetestsupport_p.h +++ b/src/webengine/api/qquickwebenginetestsupport_p.h @@ -1,7 +1,7 @@ /**************************************************************************** ** -** Copyright (C) 2015 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ ** ** This file is part of the QtWebEngine module of the Qt Toolkit. ** @@ -10,15 +10,15 @@ ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 3 as published by the Free Software ** Foundation and appearing in the file LICENSE.LGPLv3 included in the -** packaging of this file. Please review the following information to +** packaging of this file. Please review the following information to ** ensure the GNU Lesser General Public License version 3 requirements ** will be met: https://www.gnu.org/licenses/lgpl.html. ** @@ -26,7 +26,7 @@ ** Alternatively, this file may be used under the terms of the GNU ** General Public License version 2.0 or later as published by the Free ** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information to +** the packaging of this file. Please review the following information to ** ensure the GNU General Public License version 2.0 requirements will be ** met: http://www.gnu.org/licenses/gpl-2.0.html. ** @@ -37,6 +37,17 @@ #ifndef QQUICKWEBENGINETESTSUPPORT_P_H #define QQUICKWEBENGINETESTSUPPORT_P_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include <private/qtwebengineglobal_p.h> #include <QObject> diff --git a/src/webengine/api/qquickwebengineview.cpp b/src/webengine/api/qquickwebengineview.cpp index 45bb5a140ed454eb4c6898e51f247cfc6ea71c90..b22b2798eb32c10ab475860a49380bcf37f6789e 100644 --- a/src/webengine/api/qquickwebengineview.cpp +++ b/src/webengine/api/qquickwebengineview.cpp @@ -37,6 +37,7 @@ #include "qquickwebengineview_p.h" #include "qquickwebengineview_p_p.h" +#include "authentication_dialog_controller.h" #include "browser_context_adapter.h" #include "certificate_error_controller.h" #include "file_picker_controller.h" @@ -188,47 +189,47 @@ bool QQuickWebEngineViewPrivate::contextMenuRequested(const WebEngineContextMenu if (!data.linkText.isEmpty() && data.linkUrl.isValid()) { item = new MenuItemHandler(menu); QObject::connect(item, &MenuItemHandler::triggered, [q] { q->triggerWebAction(QQuickWebEngineView::OpenLinkInThisWindow); }); - ui()->addMenuItem(item, QObject::tr("Follow Link")); + ui()->addMenuItem(item, QQuickWebEngineView::tr("Follow Link")); } if (data.selectedText.isEmpty()) { item = new MenuItemHandler(menu); QObject::connect(item, &MenuItemHandler::triggered, q, &QQuickWebEngineView::goBack); - ui()->addMenuItem(item, QObject::tr("Back"), QStringLiteral("go-previous"), q->canGoBack()); + ui()->addMenuItem(item, QQuickWebEngineView::tr("Back"), QStringLiteral("go-previous"), q->canGoBack()); item = new MenuItemHandler(menu); QObject::connect(item, &MenuItemHandler::triggered, q, &QQuickWebEngineView::goForward); - ui()->addMenuItem(item, QObject::tr("Forward"), QStringLiteral("go-next"), q->canGoForward()); + ui()->addMenuItem(item, QQuickWebEngineView::tr("Forward"), QStringLiteral("go-next"), q->canGoForward()); item = new MenuItemHandler(menu); QObject::connect(item, &MenuItemHandler::triggered, q, &QQuickWebEngineView::reload); - ui()->addMenuItem(item, QObject::tr("Reload"), QStringLiteral("view-refresh")); + ui()->addMenuItem(item, QQuickWebEngineView::tr("Reload"), QStringLiteral("view-refresh")); } else { item = new MenuItemHandler(menu); QObject::connect(item, &MenuItemHandler::triggered, [q] { q->triggerWebAction(QQuickWebEngineView::Copy); }); - ui()->addMenuItem(item, QObject::tr("Copy")); + ui()->addMenuItem(item, QQuickWebEngineView::tr("Copy")); } if (!contextMenuData.linkText.isEmpty() && contextMenuData.linkUrl.isValid()) { item = new MenuItemHandler(menu); QObject::connect(item, &MenuItemHandler::triggered, [q] { q->triggerWebAction(QQuickWebEngineView::CopyLinkToClipboard); }); - ui()->addMenuItem(item, QObject::tr("Copy Link URL")); + ui()->addMenuItem(item, QQuickWebEngineView::tr("Copy Link URL")); item = new MenuItemHandler(menu); QObject::connect(item, &MenuItemHandler::triggered, [q] { q->triggerWebAction(QQuickWebEngineView::DownloadLinkToDisk); }); - ui()->addMenuItem(item, QObject::tr("Save Link...")); + ui()->addMenuItem(item, QQuickWebEngineView::tr("Save Link")); } if (contextMenuData.mediaUrl.isValid()) { switch (contextMenuData.mediaType) { case WebEngineContextMenuData::MediaTypeImage: item = new MenuItemHandler(menu); QObject::connect(item, &MenuItemHandler::triggered, [q] { q->triggerWebAction(QQuickWebEngineView::CopyImageUrlToClipboard); }); - ui()->addMenuItem(item, QObject::tr("Copy Image URL")); + ui()->addMenuItem(item, QQuickWebEngineView::tr("Copy Image URL")); item = new MenuItemHandler(menu); QObject::connect(item, &MenuItemHandler::triggered, [q] { q->triggerWebAction(QQuickWebEngineView::CopyImageToClipboard); }); - ui()->addMenuItem(item, QObject::tr("Copy Image")); + ui()->addMenuItem(item, QQuickWebEngineView::tr("Copy Image")); item = new MenuItemHandler(menu); QObject::connect(item, &MenuItemHandler::triggered, [q] { q->triggerWebAction(QQuickWebEngineView::DownloadImageToDisk); }); - ui()->addMenuItem(item, QObject::tr("Save Image")); + ui()->addMenuItem(item, QQuickWebEngineView::tr("Save Image")); break; case WebEngineContextMenuData::MediaTypeCanvas: Q_UNREACHABLE(); // mediaUrl is invalid for canvases @@ -237,25 +238,25 @@ bool QQuickWebEngineViewPrivate::contextMenuRequested(const WebEngineContextMenu case WebEngineContextMenuData::MediaTypeVideo: item = new MenuItemHandler(menu); QObject::connect(item, &MenuItemHandler::triggered, [q] { q->triggerWebAction(QQuickWebEngineView::CopyMediaUrlToClipboard); }); - ui()->addMenuItem(item, QObject::tr("Copy Media URL")); + ui()->addMenuItem(item, QQuickWebEngineView::tr("Copy Media URL")); item = new MenuItemHandler(menu); QObject::connect(item, &MenuItemHandler::triggered, [q] { q->triggerWebAction(QQuickWebEngineView::DownloadMediaToDisk); }); - ui()->addMenuItem(item, QObject::tr("Download Media")); + ui()->addMenuItem(item, QQuickWebEngineView::tr("Save Media")); item = new MenuItemHandler(menu); QObject::connect(item, &MenuItemHandler::triggered, [q] { q->triggerWebAction(QQuickWebEngineView::ToggleMediaPlayPause); }); - ui()->addMenuItem(item, QObject::tr("Toggle Play/Pause")); + ui()->addMenuItem(item, QQuickWebEngineView::tr("Toggle Play/Pause")); item = new MenuItemHandler(menu); QObject::connect(item, &MenuItemHandler::triggered, [q] { q->triggerWebAction(QQuickWebEngineView::ToggleMediaLoop); }); - ui()->addMenuItem(item, QObject::tr("Toggle Looping")); + ui()->addMenuItem(item, QQuickWebEngineView::tr("Toggle Looping")); if (contextMenuData.mediaFlags & WebEngineContextMenuData::MediaHasAudio) { item = new MenuItemHandler(menu); QObject::connect(item, &MenuItemHandler::triggered, [q] { q->triggerWebAction(QQuickWebEngineView::ToggleMediaMute); }); - ui()->addMenuItem(item, QObject::tr("Toggle Mute")); + ui()->addMenuItem(item, QQuickWebEngineView::tr("Toggle Mute")); } if (contextMenuData.mediaFlags & WebEngineContextMenuData::MediaCanToggleControls) { item = new MenuItemHandler(menu); QObject::connect(item, &MenuItemHandler::triggered, [q] { q->triggerWebAction(QQuickWebEngineView::ToggleMediaControls); }); - ui()->addMenuItem(item, QObject::tr("Toggle Media Controls")); + ui()->addMenuItem(item, QQuickWebEngineView::tr("Toggle Media Controls")); } break; default: @@ -264,7 +265,17 @@ bool QQuickWebEngineViewPrivate::contextMenuRequested(const WebEngineContextMenu } else if (contextMenuData.mediaType == WebEngineContextMenuData::MediaTypeCanvas) { item = new MenuItemHandler(menu); QObject::connect(item, &MenuItemHandler::triggered, [q] { q->triggerWebAction(QQuickWebEngineView::CopyImageToClipboard); }); - ui()->addMenuItem(item, QObject::tr("Copy Image")); + ui()->addMenuItem(item, QQuickWebEngineView::tr("Copy Image")); + } + if (adapter->hasInspector()) { + item = new MenuItemHandler(menu); + QObject::connect(item, &MenuItemHandler::triggered, [q] { q->triggerWebAction(QQuickWebEngineView::InspectElement); }); + ui()->addMenuItem(item, QQuickWebEngineView::tr("Inspect Element")); + } + if (isFullScreen()) { + item = new MenuItemHandler(menu); + QObject::connect(item, &MenuItemHandler::triggered, [q] { q->triggerWebAction(QQuickWebEngineView::ExitFullScreen); }); + ui()->addMenuItem(item, QQuickWebEngineView::tr("Exit Full Screen Mode")); } // FIXME: expose the context menu data as an attached property to make this more useful @@ -514,6 +525,11 @@ void QQuickWebEngineViewPrivate::javaScriptConsoleMessage(JavaScriptConsoleMessa Q_EMIT q->javaScriptConsoleMessage(static_cast<QQuickWebEngineView::JavaScriptConsoleMessageLevel>(level), message, lineNumber, sourceID); } +void QQuickWebEngineViewPrivate::authenticationRequired(QSharedPointer<AuthenticationDialogController> controller) +{ + ui()->showDialog(controller); +} + void QQuickWebEngineViewPrivate::runMediaAccessPermissionRequest(const QUrl &securityOrigin, WebContentsAdapterClient::MediaRequestFlags requestFlags) { Q_Q(QQuickWebEngineView); @@ -775,15 +791,6 @@ void QQuickWebEngineView::setProfile(QQuickWebEngineProfile *profile) Q_D(QQuickWebEngineView); d->setProfile(profile); } -/*! - * \qmlproperty WebEngineSettings QQuickWebEngineView::settings - * \readonly settings - * \since QtWebEngine 1.1 - * - * The \a settings property holds the settings used by this view. - * - * \sa WebEngineSettings - */ QQuickWebEngineSettings *QQuickWebEngineView::settings() const { @@ -886,6 +893,14 @@ void QQuickWebEngineViewPrivate::moveValidationMessage(const QRect &anchor) ui()->moveMessageBubble(anchor); } +void QQuickWebEngineViewPrivate::renderProcessTerminated( + RenderProcessTerminationStatus terminationStatus, int exitCode) +{ + Q_Q(QQuickWebEngineView); + Q_EMIT q->renderProcessTerminated(static_cast<QQuickWebEngineView::RenderProcessTerminationStatus>( + renderProcessExitStatus(terminationStatus)), exitCode); +} + bool QQuickWebEngineView::isLoading() const { Q_D(const QQuickWebEngineView); @@ -1021,19 +1036,6 @@ QQuickWebEngineHistory *QQuickWebEngineView::navigationHistory() const return d->m_history.data(); } -/*! - * \qmlproperty QQmlWebChannel WebEngineView::webChannel - * \since QtWebEngine 1.1 - * - * The web channel instance used by this view. - * This channel is automatically using the internal QtWebEngine transport mechanism over Chromium IPC, - * and exposed in the javascript context of the page it is rendering as \c qt.webChannelTransport. - * This transport object is used when instantiating the JavaScript counterpart of QWebChannel using - * the \l{Qt WebChannel JavaScript API}. - * - * \note The view does not take ownership when explicitly setting a webChannel object. - */ - QQmlWebChannel *QQuickWebEngineView::webChannel() { Q_D(QQuickWebEngineView); @@ -1289,6 +1291,12 @@ void QQuickWebEngineView::triggerWebAction(WebAction action) d->adapter->executeMediaPlayerActionAt(d->contextMenuData.pos, WebContentsAdapter::MediaPlayerMute, enable); } break; + case InspectElement: + d->adapter->inspectElementAt(d->contextMenuData.pos); + break; + case ExitFullScreen: + d->adapter->exitFullScreen(); + break; default: Q_UNREACHABLE(); } diff --git a/src/webengine/api/qquickwebengineview_p.h b/src/webengine/api/qquickwebengineview_p.h index e1c5eb25d9a84f78dc7f51a20b040f4938580ef3..22cca3277ac090fafc9d72a929853718b68b19f7 100644 --- a/src/webengine/api/qquickwebengineview_p.h +++ b/src/webengine/api/qquickwebengineview_p.h @@ -37,6 +37,17 @@ #ifndef QQUICKWEBENGINEVIEW_P_H #define QQUICKWEBENGINEVIEW_P_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include <private/qtwebengineglobal_p.h> #include "qquickwebenginescript_p.h" #include <QQuickItem> @@ -90,7 +101,7 @@ class Q_WEBENGINE_PRIVATE_EXPORT QQuickWebEngineView : public QQuickItem { Q_PROPERTY(QQuickWebEngineSettings *settings READ settings REVISION 1) Q_PROPERTY(QQuickWebEngineHistory *navigationHistory READ navigationHistory CONSTANT FINAL REVISION 1) Q_PROPERTY(QQmlWebChannel *webChannel READ webChannel WRITE setWebChannel NOTIFY webChannelChanged REVISION 1) - Q_PROPERTY(QQmlListProperty<QQuickWebEngineScript> userScripts READ userScripts FINAL) + Q_PROPERTY(QQmlListProperty<QQuickWebEngineScript> userScripts READ userScripts FINAL REVISION 1) Q_PROPERTY(bool activeFocusOnPress READ activeFocusOnPress WRITE setActiveFocusOnPress NOTIFY activeFocusOnPressChanged REVISION 2) Q_PROPERTY(QColor backgroundColor READ backgroundColor WRITE setBackgroundColor NOTIFY backgroundColorChanged REVISION 2) @@ -105,6 +116,7 @@ class Q_WEBENGINE_PRIVATE_EXPORT QQuickWebEngineView : public QQuickItem { Q_ENUMS(NewViewDestination); Q_ENUMS(Feature); Q_ENUMS(JavaScriptConsoleMessageLevel); + Q_ENUMS(RenderProcessTerminationStatus); Q_FLAGS(FindFlags); Q_ENUMS(WebAction); @@ -212,6 +224,9 @@ public: ToggleMediaMute, DownloadMediaToDisk, + InspectElement, + ExitFullScreen, + WebActionCount }; @@ -222,6 +237,14 @@ public: ErrorMessageLevel }; + // must match WebContentsAdapterClient::RenderProcessTerminationStatus + enum RenderProcessTerminationStatus { + NormalTerminationStatus = 0, + AbnormalTerminationStatus, + CrashedTerminationStatus, + KilledTerminationStatus + }; + enum FindFlag { FindBackward = 1, FindCaseSensitively = 2, @@ -252,9 +275,9 @@ public Q_SLOTS: void loadHtml(const QString &html, const QUrl &baseUrl = QUrl()); void goBack(); void goForward(); - void goBackOrForward(int index); + Q_REVISION(1) void goBackOrForward(int index); void reload(); - void reloadAndBypassCache(); + Q_REVISION(1) void reloadAndBypassCache(); void stop(); Q_REVISION(1) void findText(const QString &subString, FindFlags options = 0, const QJSValue &callback = QJSValue()); Q_REVISION(1) void fullScreenCancelled(); @@ -281,6 +304,7 @@ Q_SIGNALS: Q_REVISION(1) void webChannelChanged(); Q_REVISION(2) void activeFocusOnPressChanged(bool); Q_REVISION(2) void backgroundColorChanged(); + Q_REVISION(2) void renderProcessTerminated(RenderProcessTerminationStatus terminationStatus, int exitCode); protected: void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry); diff --git a/src/webengine/api/qquickwebengineview_p_p.h b/src/webengine/api/qquickwebengineview_p_p.h index 4d95de84ecad805e48c1a271c2649a2847b4962c..0140111b924a60bfa01bc4adc14114787ed23ede 100644 --- a/src/webengine/api/qquickwebengineview_p_p.h +++ b/src/webengine/api/qquickwebengineview_p_p.h @@ -37,6 +37,17 @@ #ifndef QQUICKWEBENGINEVIEW_P_P_H #define QQUICKWEBENGINEVIEW_P_P_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include "qquickwebengineview_p.h" #include "web_contents_adapter_client.h" @@ -144,7 +155,7 @@ public: virtual void didFindText(quint64, int) Q_DECL_OVERRIDE; virtual void passOnFocus(bool reverse) Q_DECL_OVERRIDE; virtual void javaScriptConsoleMessage(JavaScriptConsoleMessageLevel level, const QString& message, int lineNumber, const QString& sourceID) Q_DECL_OVERRIDE; - virtual void authenticationRequired(const QUrl&, const QString&, bool, const QString&, QString*, QString*) Q_DECL_OVERRIDE { } + virtual void authenticationRequired(QSharedPointer<QtWebEngineCore::AuthenticationDialogController>) Q_DECL_OVERRIDE; virtual void runMediaAccessPermissionRequest(const QUrl &securityOrigin, MediaRequestFlags requestFlags) Q_DECL_OVERRIDE; virtual void runMouseLockPermissionRequest(const QUrl &securityOrigin) Q_DECL_OVERRIDE; #ifndef QT_NO_ACCESSIBILITY @@ -156,6 +167,8 @@ public: virtual void showValidationMessage(const QRect &anchor, const QString &mainText, const QString &subText) Q_DECL_OVERRIDE; virtual void hideValidationMessage() Q_DECL_OVERRIDE; virtual void moveValidationMessage(const QRect &anchor) Q_DECL_OVERRIDE; + virtual void renderProcessTerminated(RenderProcessTerminationStatus terminationStatus, + int exitCode) Q_DECL_OVERRIDE; virtual QtWebEngineCore::BrowserContextAdapter *browserContextAdapter() Q_DECL_OVERRIDE; diff --git a/src/webengine/doc/images/qtwebengine-architecture.png b/src/webengine/doc/images/qtwebengine-architecture.png new file mode 100644 index 0000000000000000000000000000000000000000..37ca2da16dbe915910e2a82422375d803da1c6bc Binary files /dev/null and b/src/webengine/doc/images/qtwebengine-architecture.png differ diff --git a/src/webengine/doc/qtwebengine.qdocconf b/src/webengine/doc/qtwebengine.qdocconf index ad6898440d3a250696833ed463b5ee3492f3dfeb..f833cf0d225788e0cf38229df487f77ad3f9da2b 100644 --- a/src/webengine/doc/qtwebengine.qdocconf +++ b/src/webengine/doc/qtwebengine.qdocconf @@ -17,23 +17,51 @@ qhp.QtWebEngine.indexRoot = qhp.QtWebEngine.filterAttributes = qtwebengine $QT_VERSION qtrefdoc qhp.QtWebEngine.customFilters.Qt.name = QtWebEngine $QT_VERSION qhp.QtWebEngine.customFilters.Qt.filterAttributes = qtwebengine $QT_VERSION -qhp.QtWebEngine.subprojects = qmltypes examples + +qhp.QtWebEngine.subprojects = classes qmltypes examples + +qhp.QtWebEngine.subprojects.classes.title = C++ Classes +qhp.QtWebEngine.subprojects.classes.indexTitle = Qt WebEngine C++ Classes +qhp.QtWebEngine.subprojects.classes.selectors = class doc:headerfile +qhp.QtWebEngine.subprojects.classes.sortPages = true + qhp.QtWebEngine.subprojects.qmltypes.title = QML Types qhp.QtWebEngine.subprojects.qmltypes.indexTitle = Qt WebEngine QML Types -qhp.QtWebEngine.subprojects.qmltypes.selectors = qmlclass +qhp.QtWebEngine.subprojects.qmltypes.selectors = qmltype qhp.QtWebEngine.subprojects.qmltypes.sortPages = true + qhp.QtWebEngine.subprojects.examples.title = Examples qhp.QtWebEngine.subprojects.examples.indexTitle = Qt WebEngine Examples -qhp.QtWebEngine.subprojects.examples.selectors = fake:example +qhp.QtWebEngine.subprojects.examples.selectors = doc:example qhp.QtWebEngine.subprojects.examples.sortPages = true tagfile = ../../../doc/qtwebengine/qtwebengine.tags -depends += qtcore qtgui qtquick qtquickcontrols qtdoc +depends += qtcore \ + qtgui \ + qtqml \ + qtquick \ + qtquickcontrols \ + qtdoc \ + qtwebchannel \ + qtwebenginewidgets -headerdirs += . ../api -sourcedirs += . ../api -exampledirs += ../../../examples/webengine . +headerdirs += . \ + ../api \ + ../../core/api + +sourcedirs += . \ + ../api \ + ../../core/api \ + ../../core/doc/src + +exampledirs += . \ + ../../../examples/webengine \ + snippets \ + ../../core/doc/snippets navigation.landingpage = "Qt WebEngine" +navigation.cppclassespage = "Qt WebEngine C++ Classes" navigation.qmltypespage = "Qt WebEngine QML Types" + +Cpp.ignoretokens += QWEBENGINEWIDGETS_EXPORT diff --git a/src/webengine/doc/src/qtwebengine-devtools.qdoc b/src/webengine/doc/src/qtwebengine-devtools.qdoc new file mode 100644 index 0000000000000000000000000000000000000000..008fa925bae1128b7cd565fe5dd9f7107cd9fe1a --- /dev/null +++ b/src/webengine/doc/src/qtwebengine-devtools.qdoc @@ -0,0 +1,56 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: http://www.gnu.org/copyleft/fdl.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \page qtwebengine-devtools.html + \title Qt WebEngine Web Developer Tools + + The Qt WebEngine module provides web developer tools that make it easy + to inspect and debug layout and performance issues of any web content. + + The developer tools are accessed as a local web page using a Chromium or + Qt WebEngine based browser, such as the Chrome browser. + + To activate the developer tools, start an application that uses Qt + WebEngine with the command-line arguments: + \code + --remote-debugging-port=<port_number> + \endcode + Where \c <port_number> refers to a local network port. The web developer + tools can then be accessed by launching a browser at the address + \c http://localhost:<port_number>. + + Alternatively, the environment variable QTWEBENGINE_REMOTE_DEBUGGING + can be set. It can be set as either just a port working similarly to + \c --remote-debugging-port or given both a host address and a port. The + latter can be used to control which network interface to export the + interface on, so that you can access the developer tools from a remote + device. + + For a detailed explanation of the capabilities of developer tools, see the + \l{https://developers.google.com/web/tools/chrome-devtools}{Chrome DevTools page}. +*/ diff --git a/src/webengine/doc/src/qtwebengine.qdoc b/src/webengine/doc/src/qtwebengine-examples.qdoc similarity index 81% rename from src/webengine/doc/src/qtwebengine.qdoc rename to src/webengine/doc/src/qtwebengine-examples.qdoc index 8cd9b6367762a3445edae78dc6afc5012670a331..ec49577e4e99ece35d14132057e624eb4b3da108 100644 --- a/src/webengine/doc/src/qtwebengine.qdoc +++ b/src/webengine/doc/src/qtwebengine-examples.qdoc @@ -23,22 +23,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -/*! - \qmlmodule QtWebEngine 1.0 - \title Qt WebEngine QML Types - \brief Provides QML types for rendering web content within a QML application - - The QML types can be imported into your application using the following - import statement in your .qml file: - - \code - import QtQuick 2.0 - import QtWebEngine 1.0 - \endcode - - \sa {Qt WebEngine Examples} -*/ - /*! \group webengine-examples \title Qt WebEngine Examples @@ -49,5 +33,6 @@ from displaying Web pages within a QML user interface to an implementation of a basic function Web browser. - \sa {Qt WebEngine QML Types} + For widget-based applications, Qt provides an integrated Web browser component based on + Chromium, the popular open source browser engine. */ diff --git a/src/webengine/doc/src/qtwebengine-index.qdoc b/src/webengine/doc/src/qtwebengine-index.qdoc new file mode 100644 index 0000000000000000000000000000000000000000..20d2de48c6295e77166c98e7aa72e820bad9c558 --- /dev/null +++ b/src/webengine/doc/src/qtwebengine-index.qdoc @@ -0,0 +1,90 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: http://www.gnu.org/copyleft/fdl.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \page qtwebengine-index.html + \title Qt WebEngine + \ingroup modules + + \brief Provides functionality for rendering regions of dynamic web content. + + \e {Qt WebEngine} provides functionality for rendering regions of dynamic web content. + + The functionality in Qt WebEngine is divided into the following modules: + + \annotatedlist qtwebengine-modules + + For Qt Quick applications, Qt WebEngine provides the following QML modules: + + \annotatedlist qtwebengine-qmlmodules + + \section1 Getting Started + + To include the definitions of the Qt WebEngineCore and Qt WebEngineWidgets modules' classes, use + the following directives: + + \badcode + #include <QtWebEngineCore> + #include <QtWebEngineWidgets> + \endcode + + To import the Qt WebEngine module's QML types, add the following import statement to your .qml + file: + + \badcode + import QtWebEngine 1.2 + \endcode + + To link against the modules, add QT variables to your qmake .pro file: + + \badcode + QT += webengine webenginecore webenginewidgets + \endcode + + \section1 Articles and Guides + + \list + \li \l{Qt WebEngine Overview} + \li \l{Qt WebEngine Web Developer Tools} + \li \l{Porting from Qt WebKit to Qt WebEngine} + \endlist + + \section1 Examples + + \list + \li \l{Qt WebEngine Examples} + \li \l{Qt WebEngine Widgets Examples} + \endlist + + \section1 API References + + \list + \li \l{Qt WebEngine Core C++ Classes} + \li \l{Qt WebEngine Widgets C++ Classes} + \li \l{Qt WebEngine QML Types} + \endlist +*/ diff --git a/src/webengine/doc/src/qtwebengine-overview.qdoc b/src/webengine/doc/src/qtwebengine-overview.qdoc new file mode 100644 index 0000000000000000000000000000000000000000..656dd13f1da74ac75a2035f1774da101796ea08b --- /dev/null +++ b/src/webengine/doc/src/qtwebengine-overview.qdoc @@ -0,0 +1,171 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: http://www.gnu.org/copyleft/fdl.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \page qtwebengine-overview.html + \title Qt WebEngine Overview + + The Qt WebEngine module provides a web browser engine that makes it easy to embed content from + the World Wide Web into your Qt application on platforms that do not have a native web engine. + The web engine is not intended to function as a \e {Web Runtime}; to display web content in a + QML application by using APIs native to the platform, use the \l{Qt WebView} module, instead. + + Qt WebEngine provides C++ classes and QML types for rendering HTML, XHTML, and SVG documents, + styled using Cascading Style Sheets (CSS) and scripted with JavaScript. HTML documents can be + made fully editable by the user through the use of the \c{contenteditable} attribute on HTML + elements. + + Qt WebEngine supercedes the \l{Qt WebKit Widgets}{Qt WebKit} module, which is based on the + WebKit project, but has not been actively synchronized with the upstream WebKit code since + Qt 5.2 and has been deprecated in Qt 5.5. For tips on how to change a Qt WebKit widgets + application to use Qt WebEngine widgets, see \l{Porting from Qt WebKit to Qt WebEngine}. For new + applications, we recommend using Qt Quick and the WebEngineView QML type. + + \section1 Qt WebEngine Architecture + + \image qtwebengine-architecture.png + + The functionality in Qt WebEngine is divided into the following modules: + + \list + \li \l{Qt WebEngine Widgets}, which provides a web browser engine and C++ classes to render + web content and to interact with it + \li \l{Qt WebEngine}, which provides QML types for rendering web content within a QML + application + \li \l{Qt WebEngine Core}, which provides common API used by Qt WebEngine and + Qt WebEngine Widgets + \endlist + + The Qt WebEngine core is based on the \l{http://www.chromium.org}{Chromium Project}. Chromium + provides its own network and painting engines and is developed tightly together with its + dependent modules, and therefore Qt WebEngine provides better and more reliable support for the + latest HTML5 specification than Qt WebKit. However, Qt WebEngine is thus heavier than Qt WebKit + and does not provide direct access to the network stack and the HTML document through C++ APIs. + + Chromium is tightly integrated to the \l{Qt Quick Scene Graph}{Qt Quick scene graph}, which is + based on OpenGL ES 2.0 or OpenGL 2.0 for its rendering. This provides you with one-pass + compositing of web content and all the Qt Quick UI. The integration to Chromium is transparent + to developers, who just work with Qt and JavaScript. + + To expose QObjects to JavaScript, developers can use the \l {Qt WebChannel} module. + + \section1 Embedding Web Content into Widget Based Applications + + Use the QWebEngineView class to display web pages in the simplest way. Because it is a widget, + you can embed QWebEngineView into your forms and use its convenience functions to download and + display web sites. + + \code + QWebEngineView *view = new QWebEngineView(parent); + view->load(QUrl("http://www.qt.io/")); + view->show(); + \endcode + + An instance of QWebEngineView has one QWebEnginePage. QWebEnginePage provides access to the + page's navigation history and the ability to run JavaScript code in the context of the page's + main frame and enables customization of handlers for specific events like showing custom + authentication dialogs. + + \section1 Embedding Web Content into Qt Quick Applications + + The WebEngineView QML type allows QML applications to render regions of dynamic web content. A + \e{WebEngineView} type may share the screen with other QML types or encompass the full screen + as specified within the QML application. + + An application can load pages into the WebEngineView, using either an URL or HTML string, and + navigate within session history. By default, links to different pages load within the same + WebEngineView object, but web sites may request them to be opened as a new tab, window, or + dialog. + + The following sample QML application loads a web page and responds to session history context: + + \code + import QtQuick 2.1 + import QtQuick.Controls 1.1 + import QtWebEngine 1.1 + + ApplicationWindow { + width: 1280 + height: 720 + visible: true + WebEngineView { + id: webview + url: "http://www.qt.io" + anchors.fill: parent + } + } + \endcode + + \section1 Using WebEngine Core + + Qt WebEngine Core provides an API shared by Qt WebEngine and Qt WebEngine Widgets. + + \section1 License Information + + Qt WebEngine module is a snapshot of the integration of Chromium into Qt. + + Qt Commercial Edition licensees that wish to distribute applications that + use the Qt WebEngine module need to be aware of their obligations under the + GNU Library General Public License (LGPLv2). + + Developers using the Open Source Edition can choose to redistribute + the module under the GNU LGPLv3 or GPLv2 and up. + + \legalese + + Chromium is licensed under the following license: + + Copyright (c) 2013 The Chromium Authors. All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following disclaimer + in the documentation and/or other materials provided with the + distribution. + * Neither the name of Google Inc. nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + \endlegalese +*/ diff --git a/src/webengine/doc/src/qtwebengine-qmlmodule.qdoc b/src/webengine/doc/src/qtwebengine-qmlmodule.qdoc new file mode 100644 index 0000000000000000000000000000000000000000..6d3d718964a5e3f9daa1750a06333ff6eecde9d5 --- /dev/null +++ b/src/webengine/doc/src/qtwebengine-qmlmodule.qdoc @@ -0,0 +1,39 @@ +/* + Copyright (C) 2015 The Qt Company Ltd. + Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY + EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +/*! + \qmlmodule QtWebEngine 1.1 + \title Qt WebEngine QML Types + \brief Provides QML types for rendering web content within a QML application + \ingroup qtwebengine-qmlmodules + + The QML types can be imported into your application using the following import statements in + your .qml file: + + \code + import QtQuick 2.0 + import QtWebEngine 1.1 + \endcode +*/ diff --git a/src/webengine/doc/src/qquickwebengineview_lgpl.qdoc b/src/webengine/doc/src/webengineview.qdoc similarity index 83% rename from src/webengine/doc/src/qquickwebengineview_lgpl.qdoc rename to src/webengine/doc/src/webengineview.qdoc index 5f41fde6769320574a8fd1b736ec2e3e6ed7cb6b..f763227e4e33d9eaed851d7cb95fbb5f0761925c 100644 --- a/src/webengine/doc/src/qquickwebengineview_lgpl.qdoc +++ b/src/webengine/doc/src/webengineview.qdoc @@ -21,61 +21,12 @@ */ // The documentation in this file was imported from QtWebKit and is thus constrained -// by its LGPL license. Documentation written from scratch for new methods should be -// placed inline in the code as usual. - -/*! - \page qtwebengine-index.html - \title Qt WebEngine - - The Qt WebEngine module provides the WebEngineView API which allows QML applications - to render regions of dynamic web content. A \e{WebEngineView} component may share - the screen with other QML components or encompass the full screen as - specified within the QML application. - - It allows an application to load pages into the WebEngineView, either by URL or with - an HTML string, and navigate within session history. By default, - links to different pages load within the same WebEngineView, but web sites may - request them to be opened as a new tab, window or dialog. - - The following sample QML application loads a web page, responds to session - history context. - - \code - import QtQuick 2.1 - import QtQuick.Controls 1.1 - import QtWebEngine 1.0 - - ApplicationWindow { - width: 1280 - height: 720 - visible: true - WebEngineView { - id: webview - url: "http://www.qt-project.org" - anchors.fill: parent - } - } - \endcode - - \section1 API References - - \list - \li \l{Qt WebEngine QML Types}{QML Types} - \endlist - - \section1 Examples - - There are several Qt WebEngine examples located in the - \l{Qt WebEngine Examples} page. - -*/ - +// by its LGPL license. /*! \qmltype WebEngineView \instantiates QQuickWebEngineView - \inqmlmodule QtWebEngine 1.0 + \inqmlmodule QtWebEngine 1.1 \since QtWebEngine 1.0 \brief A WebEngineView renders web content within a QML application. */ @@ -86,7 +37,7 @@ Go backward within the browser's session history, if possible. This function is equivalent to the \c{window.history.back()} DOM method. - \sa WebEngineView::canGoBack + \sa canGoBack */ /*! @@ -96,6 +47,17 @@ This function is equivalent to the \c{window.history.forward()} DOM method. */ +/*! + \qmlmethod void WebEngineView::goBackOrForward(int offset) + \since QtWebEngine 1.1 + + If \a offset is positive, goes forward the specified number of offset + pages in the current session history. If offset is negative, it goes + back. If the offset is invalid, the page is not changed. + + \sa goBack(), goForward() +*/ + /*! \qmlmethod void WebEngineView::stop() @@ -107,6 +69,16 @@ Reloads the current page. This function is equivalent to the \c{window.location.reload()} DOM method. + + \sa reloadAndBypassCache() +*/ + +/*! + \qmlmethod void WebEngineView::reloadAndBypassCache() + + Reloads the current page, ignoring any cached content. + + \sa reload() */ /*! @@ -116,7 +88,7 @@ property offers the main interface to load a page into a web view. It functions the same as the \c{window.location} DOM property. - \sa WebEngineView::loadHtml() + \sa loadHtml() */ /*! @@ -142,6 +114,7 @@ /*! \qmlproperty int WebEngineView::loadProgress + \readonly This property holds the amount of the page that has been loaded, expressed as an integer percentage in the range from \c{0} to \c{100}. @@ -149,6 +122,7 @@ /*! \qmlproperty bool WebEngineView::canGoBack + \readonly Returns \c{true} if there are prior session history entries, \c{false} otherwise. @@ -156,6 +130,7 @@ /*! \qmlproperty bool WebEngineView::canGoForward + \readonly Returns \c{true} if there are subsequent session history entries, \c{false} otherwise. @@ -163,6 +138,7 @@ /*! \qmlproperty bool WebEngineView::loading + \readonly Returns \c{true} if the HTML page is currently loading, \c{false} otherwise. */ @@ -182,7 +158,65 @@ Returns \c{true} if the web view is in fullscreen mode, \c{false} otherwise. - \sa WebEngineView::fullScreenRequested(), WebEngineView::fullScreenCancelled() + \sa fullScreenRequested(), fullScreenCancelled() +*/ + +/*! + \qmlproperty WebEngineHistory WebEngineView::navigationHistory + \since QtWebEngine 1.1 + \readonly + + The navigation history of the current view. + + \sa WebEngineHistory +*/ + +/*! + \qmlproperty QQmlWebChannel WebEngineView::webChannel + \since QtWebEngine 1.1 + + The web channel instance used by this view. + This channel is automatically using the internal QtWebEngine transport mechanism over Chromium IPC, + and exposed in the javascript context of the page it is rendering as \c qt.webChannelTransport. + This transport object is used when instantiating the JavaScript counterpart of QWebChannel using + the \l{Qt WebChannel JavaScript API}. + + \note The view does not take ownership for an assigned webChannel object. +*/ + +/*! + \qmlproperty WebEngineProfile WebEngineView::profile + \since QtWebEngine 1.1 + + The current profile used for the view. + + \sa WebEngineProfile +*/ + +/*! + \qmlproperty WebEngineSettings WebEngineView::settings + \readonly + \since QtWebEngine 1.1 + + Settings used by this view. + + \sa WebEngineSettings +*/ + + +/*! + \qmlproperty list<WebEngineScript> WebEngineView::userScripts + \readonly + + List of script objects attached to the view. +*/ + +/*! + \qmlproperty real WebEngineView::zoomFactor + \since QtWebEngine 1.1 + + Zoom factor for the view. Valid values are within the range from \c{0.25} + to \c{5.0}. The default factor is \c{1.0}. */ /*! @@ -198,10 +232,9 @@ is the base url, then an image referenced with the relative url, \c diagram.png, should be at \c{http://www.example.com/documents/diagram.png}. - \sa WebEngineView::url + \sa url */ - /*! \qmlmethod void WebEngineView::runJavaScript(string script, variant callback) \brief Runs the specified \a script in the content of the web view. @@ -255,13 +288,16 @@ */ /*! - \qmlmethod void WebEngineView::grantFeaturePermission(url securityOrigin, WebEngineView::Feature feature, bool granted) + \qmlmethod void WebEngineView::grantFeaturePermission(url securityOrigin, Feature feature, bool granted) + \since QtWebEngine 1.1 - Sets the permission for the web site identified by \a securityOrigin to use \a feature. + Sets or unsets the permission, depending on \a granted, for the web site + identified by \a securityOrigin to use \a feature. \sa featurePermissionRequested() */ + /*! \qmlmethod void WebEngineView::fullScreenCancelled() \since QtWebEngine 1.1 @@ -283,13 +319,13 @@ } \endcode - \sa WebEngineView::isFullScreen, WebEngineView::fullScreenRequested() + \sa isFullScreen, fullScreenRequested() */ /*! - \qmlsignal void WebEngineView::featurePermissionRequested(url securityOrigin, WebEngineView::Feature feature) + \qmlsignal WebEngineView::featurePermissionRequested(url securityOrigin, Feature feature) - This is signal is emitted when the web site identified by \a securityOrigin requests + This signal is emitted when the web site identified by \a securityOrigin requests to make use of the resource or device identified by \a feature. \sa grantFeaturePermission() @@ -331,11 +367,12 @@ \l{WebEngineView::ErrorDomain} for the full list. \endtable - \sa WebEngineView::loading + \sa loading */ /*! \qmlsignal WebEngineView::certificateError(error) + \since QtWebEngine 1.1 This signal is emitted when an invalid certificate error is raised while loading a given request. @@ -380,6 +417,7 @@ /*! \qmlsignal WebEngineView::newViewRequested(request) + \since QtWebEngine 1.1 This signal is emitted when a page load is requested to happen in a separate WebEngineView. This can either be because the current page requested it explicitly @@ -395,11 +433,11 @@ The corresponding handler is onNewViewRequested. - \sa WebEngineNewViewRequest, WebEngineView::NewViewDestination, {WebEngine Quick Nano Browser} + \sa WebEngineNewViewRequest, NewViewDestination, {WebEngine Quick Nano Browser} */ /*! - \qmlsignal WebEngineView::fullScreenRequested(request) + \qmlsignal WebEngineView::fullScreenRequested(WebEngineFullScreenRequest request) \since QtWebEngine 1.1 This signal is emitted when the web page requests fullscreen mode through the @@ -407,7 +445,7 @@ The corresponding handler is onFullScreenRequested. - \sa WebEngineFullScreenRequest, WebEngineView::isFullScreen + \sa WebEngineFullScreenRequest, isFullScreen */ /*! @@ -415,7 +453,7 @@ This enumeration details various high-level error types. - \value NoErrorDomain + \value WebEngineView::NoErrorDomain \value WebEngineView::InternalErrorDomain Content fails to be interpreted by Qt WebEngine. \value WebEngineView::ConnectionErrorDomain @@ -509,7 +547,7 @@ \value FindCaseSensitively By default findText() works case insensitive. Specifying this option changes the behavior to a case sensitive find operation. - \sa WebEngineView::findText() + \sa findText() */ /*! @@ -523,7 +561,6 @@ \value MediaAudioVideoCapture Both Audio and Video capture devices. \sa featurePermissionRequested(), grantFeaturePermission() - */ /*! @@ -532,9 +569,9 @@ \inqmlmodule QtWebEngine 1.1 \since QtWebEngine 1.1 - \brief A utility class for the WebEngineView::fullScreenRequested signal. + \brief A utility class for the WebEngineView::fullScreenRequested() signal. - \sa WebEngineView::fullScreenRequested + \sa WebEngineView::fullScreenRequested() */ /*! @@ -544,7 +581,7 @@ Returns \c{true} if the application should toggle fullscreen mode on, \c{false} otherwise. - \sa WebEngineFullScreenRequest::accept() + \sa accept() */ /*! @@ -552,7 +589,7 @@ \since QtWebEngine 1.1 Call this method to accept the fullscreen request. It sets the WebEngineView::isFullScreen - property to be equal to WebEngineFullScreenRequest::toggleOn. + property to be equal to toggleOn. \code ApplicationWindow { @@ -569,5 +606,5 @@ } \endcode - \sa WebEngineFullScreenRequest::toggleOn() + \sa toggleOn */ diff --git a/src/webengine/plugin/experimental/plugin.cpp b/src/webengine/plugin/experimental/plugin.cpp index 507286e2f7244cfdf4ab576377dbd0fe4f6a61b2..f9525e65675c5194b829a3def4ffd047270a0506 100644 --- a/src/webengine/plugin/experimental/plugin.cpp +++ b/src/webengine/plugin/experimental/plugin.cpp @@ -63,9 +63,9 @@ public: qmlRegisterExtendedType<QQuickWebEngineView, QQuickWebEngineViewExperimentalExtension>(uri, 1, 0, "WebEngineView"); qmlRegisterUncreatableType<QQuickWebEngineViewExperimental>(uri, 1, 0, "WebEngineViewExperimental", - QObject::tr("Cannot create a separate instance of WebEngineViewExperimental")); + tr("Cannot create a separate instance of WebEngineViewExperimental")); qmlRegisterUncreatableType<QQuickWebEngineViewport>(uri, 1, 0, "WebEngineViewport", - QObject::tr("Cannot create a separate instance of WebEngineViewport")); + tr("Cannot create a separate instance of WebEngineViewport")); // Use the latest revision of QQuickWebEngineView when importing QtWebEngine.experimental 1.0 qmlRegisterRevision<QQuickWebEngineView, LATEST_WEBENGINEVIEW_REVISION>(uri, 1, 0); diff --git a/src/webengine/plugin/plugin.cpp b/src/webengine/plugin/plugin.cpp index cb8950019eaf80d6a3c39e8d9843cc6b59fd668a..c42eb63d527a2f95ffd5e527f5531c257721fb07 100644 --- a/src/webengine/plugin/plugin.cpp +++ b/src/webengine/plugin/plugin.cpp @@ -65,27 +65,27 @@ public: Q_ASSERT(QLatin1String(uri) == QLatin1String("QtWebEngine")); qmlRegisterType<QQuickWebEngineView>(uri, 1, 0, "WebEngineView"); - qmlRegisterUncreatableType<QQuickWebEngineLoadRequest>(uri, 1, 0, "WebEngineLoadRequest", QObject::tr("Cannot create separate instance of WebEngineLoadRequest")); - qmlRegisterUncreatableType<QQuickWebEngineNavigationRequest>(uri, 1, 0, "WebEngineNavigationRequest", QObject::tr("Cannot create separate instance of WebEngineNavigationRequest")); + qmlRegisterUncreatableType<QQuickWebEngineLoadRequest>(uri, 1, 0, "WebEngineLoadRequest", tr("Cannot create separate instance of WebEngineLoadRequest")); + qmlRegisterUncreatableType<QQuickWebEngineNavigationRequest>(uri, 1, 0, "WebEngineNavigationRequest", tr("Cannot create separate instance of WebEngineNavigationRequest")); qmlRegisterType<QQuickWebEngineView, 1>(uri, 1, 1, "WebEngineView"); qmlRegisterType<QQuickWebEngineView, 2>(uri, 1, 2, "WebEngineView"); qmlRegisterType<QQuickWebEngineProfile>(uri, 1, 1, "WebEngineProfile"); qmlRegisterType<QQuickWebEngineProfile, 1>(uri, 1, 2, "WebEngineProfile"); qmlRegisterType<QQuickWebEngineScript>(uri, 1, 1, "WebEngineScript"); - qmlRegisterUncreatableType<QQuickWebEngineCertificateError>(uri, 1, 1, "WebEngineCertificateError", QObject::tr("Cannot create separate instance of WebEngineCertificateError")); + qmlRegisterUncreatableType<QQuickWebEngineCertificateError>(uri, 1, 1, "WebEngineCertificateError", tr("Cannot create separate instance of WebEngineCertificateError")); qmlRegisterUncreatableType<QQuickWebEngineDownloadItem>(uri, 1, 1, "WebEngineDownloadItem", - QObject::tr("Cannot create a separate instance of WebEngineDownloadItem")); - qmlRegisterUncreatableType<QQuickWebEngineNewViewRequest>(uri, 1, 1, "WebEngineNewViewRequest", QObject::tr("Cannot create separate instance of WebEngineNewViewRequest")); - qmlRegisterUncreatableType<QQuickWebEngineSettings>(uri, 1, 1, "WebEngineSettings", QObject::tr("Cannot create a separate instance of WebEngineSettings")); - qmlRegisterUncreatableType<QQuickWebEngineSettings, 1>(uri, 1, 2, "WebEngineSettings", QObject::tr("Cannot create a separate instance of WebEngineSettings")); + tr("Cannot create a separate instance of WebEngineDownloadItem")); + qmlRegisterUncreatableType<QQuickWebEngineNewViewRequest>(uri, 1, 1, "WebEngineNewViewRequest", tr("Cannot create separate instance of WebEngineNewViewRequest")); + qmlRegisterUncreatableType<QQuickWebEngineSettings>(uri, 1, 1, "WebEngineSettings", tr("Cannot create a separate instance of WebEngineSettings")); + qmlRegisterUncreatableType<QQuickWebEngineSettings, 1>(uri, 1, 2, "WebEngineSettings", tr("Cannot create a separate instance of WebEngineSettings")); qmlRegisterSingletonType<QQuickWebEngineSingleton>(uri, 1, 1, "WebEngine", webEngineSingletonProvider); qmlRegisterUncreatableType<QQuickWebEngineHistory>(uri, 1, 1, "NavigationHistory", - QObject::tr("Cannot create a separate instance of NavigationHistory")); + tr("Cannot create a separate instance of NavigationHistory")); qmlRegisterUncreatableType<QQuickWebEngineHistoryListModel>(uri, 1, 1, "NavigationHistoryListModel", - QObject::tr("Cannot create a separate instance of NavigationHistory")); + tr("Cannot create a separate instance of NavigationHistory")); qmlRegisterUncreatableType<QQuickWebEngineFullScreenRequest>(uri, 1, 1, "FullScreenRequest", - QObject::tr("Cannot create a separate instance of FullScreenRequest")); + tr("Cannot create a separate instance of FullScreenRequest")); // For now (1.x import), the latest revision matches the minor version of the import. qmlRegisterRevision<QQuickWebEngineView, LATEST_WEBENGINEVIEW_REVISION>(uri, 1, LATEST_WEBENGINEVIEW_REVISION); diff --git a/src/webengine/plugin/plugins.qmltypes b/src/webengine/plugin/plugins.qmltypes index cebf986d202c1563272f6a62fbdeb0ee7aa6bbf4..9dcded7b0f110dfa357a8a3f7ce977886eca64e3 100644 --- a/src/webengine/plugin/plugins.qmltypes +++ b/src/webengine/plugin/plugins.qmltypes @@ -1,12 +1,529 @@ -import QtQuick.tooling 1.1 +import QtQuick.tooling 1.2 // This file describes the plugin-supplied types contained in the library. // It is used for QML tooling purposes only. // // This file was auto-generated by: -// 'qmlplugindump -noinstantiate -nonrelocatable QtWebEngine 1.0' +// 'qmlplugindump -nonrelocatable QtWebEngine 1.1' Module { + dependencies: [] + Component { + name: "QAbstractItemModel" + prototype: "QObject" + Enum { + name: "LayoutChangeHint" + values: { + "NoLayoutChangeHint": 0, + "VerticalSortHint": 1, + "HorizontalSortHint": 2 + } + } + Signal { + name: "dataChanged" + Parameter { name: "topLeft"; type: "QModelIndex" } + Parameter { name: "bottomRight"; type: "QModelIndex" } + Parameter { name: "roles"; type: "QVector<int>" } + } + Signal { + name: "dataChanged" + Parameter { name: "topLeft"; type: "QModelIndex" } + Parameter { name: "bottomRight"; type: "QModelIndex" } + } + Signal { + name: "headerDataChanged" + Parameter { name: "orientation"; type: "Qt::Orientation" } + Parameter { name: "first"; type: "int" } + Parameter { name: "last"; type: "int" } + } + Signal { + name: "layoutChanged" + Parameter { name: "parents"; type: "QList<QPersistentModelIndex>" } + Parameter { name: "hint"; type: "QAbstractItemModel::LayoutChangeHint" } + } + Signal { + name: "layoutChanged" + Parameter { name: "parents"; type: "QList<QPersistentModelIndex>" } + } + Signal { name: "layoutChanged" } + Signal { + name: "layoutAboutToBeChanged" + Parameter { name: "parents"; type: "QList<QPersistentModelIndex>" } + Parameter { name: "hint"; type: "QAbstractItemModel::LayoutChangeHint" } + } + Signal { + name: "layoutAboutToBeChanged" + Parameter { name: "parents"; type: "QList<QPersistentModelIndex>" } + } + Signal { name: "layoutAboutToBeChanged" } + Signal { + name: "rowsAboutToBeInserted" + Parameter { name: "parent"; type: "QModelIndex" } + Parameter { name: "first"; type: "int" } + Parameter { name: "last"; type: "int" } + } + Signal { + name: "rowsInserted" + Parameter { name: "parent"; type: "QModelIndex" } + Parameter { name: "first"; type: "int" } + Parameter { name: "last"; type: "int" } + } + Signal { + name: "rowsAboutToBeRemoved" + Parameter { name: "parent"; type: "QModelIndex" } + Parameter { name: "first"; type: "int" } + Parameter { name: "last"; type: "int" } + } + Signal { + name: "rowsRemoved" + Parameter { name: "parent"; type: "QModelIndex" } + Parameter { name: "first"; type: "int" } + Parameter { name: "last"; type: "int" } + } + Signal { + name: "columnsAboutToBeInserted" + Parameter { name: "parent"; type: "QModelIndex" } + Parameter { name: "first"; type: "int" } + Parameter { name: "last"; type: "int" } + } + Signal { + name: "columnsInserted" + Parameter { name: "parent"; type: "QModelIndex" } + Parameter { name: "first"; type: "int" } + Parameter { name: "last"; type: "int" } + } + Signal { + name: "columnsAboutToBeRemoved" + Parameter { name: "parent"; type: "QModelIndex" } + Parameter { name: "first"; type: "int" } + Parameter { name: "last"; type: "int" } + } + Signal { + name: "columnsRemoved" + Parameter { name: "parent"; type: "QModelIndex" } + Parameter { name: "first"; type: "int" } + Parameter { name: "last"; type: "int" } + } + Signal { name: "modelAboutToBeReset" } + Signal { name: "modelReset" } + Signal { + name: "rowsAboutToBeMoved" + Parameter { name: "sourceParent"; type: "QModelIndex" } + Parameter { name: "sourceStart"; type: "int" } + Parameter { name: "sourceEnd"; type: "int" } + Parameter { name: "destinationParent"; type: "QModelIndex" } + Parameter { name: "destinationRow"; type: "int" } + } + Signal { + name: "rowsMoved" + Parameter { name: "parent"; type: "QModelIndex" } + Parameter { name: "start"; type: "int" } + Parameter { name: "end"; type: "int" } + Parameter { name: "destination"; type: "QModelIndex" } + Parameter { name: "row"; type: "int" } + } + Signal { + name: "columnsAboutToBeMoved" + Parameter { name: "sourceParent"; type: "QModelIndex" } + Parameter { name: "sourceStart"; type: "int" } + Parameter { name: "sourceEnd"; type: "int" } + Parameter { name: "destinationParent"; type: "QModelIndex" } + Parameter { name: "destinationColumn"; type: "int" } + } + Signal { + name: "columnsMoved" + Parameter { name: "parent"; type: "QModelIndex" } + Parameter { name: "start"; type: "int" } + Parameter { name: "end"; type: "int" } + Parameter { name: "destination"; type: "QModelIndex" } + Parameter { name: "column"; type: "int" } + } + Method { name: "submit"; type: "bool" } + Method { name: "revert" } + Method { + name: "hasIndex" + type: "bool" + Parameter { name: "row"; type: "int" } + Parameter { name: "column"; type: "int" } + Parameter { name: "parent"; type: "QModelIndex" } + } + Method { + name: "hasIndex" + type: "bool" + Parameter { name: "row"; type: "int" } + Parameter { name: "column"; type: "int" } + } + Method { + name: "index" + type: "QModelIndex" + Parameter { name: "row"; type: "int" } + Parameter { name: "column"; type: "int" } + Parameter { name: "parent"; type: "QModelIndex" } + } + Method { + name: "index" + type: "QModelIndex" + Parameter { name: "row"; type: "int" } + Parameter { name: "column"; type: "int" } + } + Method { + name: "parent" + type: "QModelIndex" + Parameter { name: "child"; type: "QModelIndex" } + } + Method { + name: "sibling" + type: "QModelIndex" + Parameter { name: "row"; type: "int" } + Parameter { name: "column"; type: "int" } + Parameter { name: "idx"; type: "QModelIndex" } + } + Method { + name: "rowCount" + type: "int" + Parameter { name: "parent"; type: "QModelIndex" } + } + Method { name: "rowCount"; type: "int" } + Method { + name: "columnCount" + type: "int" + Parameter { name: "parent"; type: "QModelIndex" } + } + Method { name: "columnCount"; type: "int" } + Method { + name: "hasChildren" + type: "bool" + Parameter { name: "parent"; type: "QModelIndex" } + } + Method { name: "hasChildren"; type: "bool" } + Method { + name: "data" + type: "QVariant" + Parameter { name: "index"; type: "QModelIndex" } + Parameter { name: "role"; type: "int" } + } + Method { + name: "data" + type: "QVariant" + Parameter { name: "index"; type: "QModelIndex" } + } + Method { + name: "setData" + type: "bool" + Parameter { name: "index"; type: "QModelIndex" } + Parameter { name: "value"; type: "QVariant" } + Parameter { name: "role"; type: "int" } + } + Method { + name: "setData" + type: "bool" + Parameter { name: "index"; type: "QModelIndex" } + Parameter { name: "value"; type: "QVariant" } + } + Method { + name: "headerData" + type: "QVariant" + Parameter { name: "section"; type: "int" } + Parameter { name: "orientation"; type: "Qt::Orientation" } + Parameter { name: "role"; type: "int" } + } + Method { + name: "headerData" + type: "QVariant" + Parameter { name: "section"; type: "int" } + Parameter { name: "orientation"; type: "Qt::Orientation" } + } + Method { + name: "fetchMore" + Parameter { name: "parent"; type: "QModelIndex" } + } + Method { + name: "canFetchMore" + type: "bool" + Parameter { name: "parent"; type: "QModelIndex" } + } + Method { + name: "flags" + type: "Qt::ItemFlags" + Parameter { name: "index"; type: "QModelIndex" } + } + Method { + name: "match" + type: "QModelIndexList" + Parameter { name: "start"; type: "QModelIndex" } + Parameter { name: "role"; type: "int" } + Parameter { name: "value"; type: "QVariant" } + Parameter { name: "hits"; type: "int" } + Parameter { name: "flags"; type: "Qt::MatchFlags" } + } + Method { + name: "match" + type: "QModelIndexList" + Parameter { name: "start"; type: "QModelIndex" } + Parameter { name: "role"; type: "int" } + Parameter { name: "value"; type: "QVariant" } + Parameter { name: "hits"; type: "int" } + } + Method { + name: "match" + type: "QModelIndexList" + Parameter { name: "start"; type: "QModelIndex" } + Parameter { name: "role"; type: "int" } + Parameter { name: "value"; type: "QVariant" } + } + } + Component { name: "QAbstractListModel"; prototype: "QAbstractItemModel" } + Component { + name: "QQuickItem" + defaultProperty: "data" + prototype: "QObject" + Enum { + name: "TransformOrigin" + values: { + "TopLeft": 0, + "Top": 1, + "TopRight": 2, + "Left": 3, + "Center": 4, + "Right": 5, + "BottomLeft": 6, + "Bottom": 7, + "BottomRight": 8 + } + } + Property { name: "parent"; type: "QQuickItem"; isPointer: true } + Property { name: "data"; type: "QObject"; isList: true; isReadonly: true } + Property { name: "resources"; type: "QObject"; isList: true; isReadonly: true } + Property { name: "children"; type: "QQuickItem"; isList: true; isReadonly: true } + Property { name: "x"; type: "double" } + Property { name: "y"; type: "double" } + Property { name: "z"; type: "double" } + Property { name: "width"; type: "double" } + Property { name: "height"; type: "double" } + Property { name: "opacity"; type: "double" } + Property { name: "enabled"; type: "bool" } + Property { name: "visible"; type: "bool" } + Property { name: "visibleChildren"; type: "QQuickItem"; isList: true; isReadonly: true } + Property { name: "states"; type: "QQuickState"; isList: true; isReadonly: true } + Property { name: "transitions"; type: "QQuickTransition"; isList: true; isReadonly: true } + Property { name: "state"; type: "string" } + Property { name: "childrenRect"; type: "QRectF"; isReadonly: true } + Property { name: "anchors"; type: "QQuickAnchors"; isReadonly: true; isPointer: true } + Property { name: "left"; type: "QQuickAnchorLine"; isReadonly: true } + Property { name: "right"; type: "QQuickAnchorLine"; isReadonly: true } + Property { name: "horizontalCenter"; type: "QQuickAnchorLine"; isReadonly: true } + Property { name: "top"; type: "QQuickAnchorLine"; isReadonly: true } + Property { name: "bottom"; type: "QQuickAnchorLine"; isReadonly: true } + Property { name: "verticalCenter"; type: "QQuickAnchorLine"; isReadonly: true } + Property { name: "baseline"; type: "QQuickAnchorLine"; isReadonly: true } + Property { name: "baselineOffset"; type: "double" } + Property { name: "clip"; type: "bool" } + Property { name: "focus"; type: "bool" } + Property { name: "activeFocus"; type: "bool"; isReadonly: true } + Property { name: "activeFocusOnTab"; revision: 1; type: "bool" } + Property { name: "rotation"; type: "double" } + Property { name: "scale"; type: "double" } + Property { name: "transformOrigin"; type: "TransformOrigin" } + Property { name: "transformOriginPoint"; type: "QPointF"; isReadonly: true } + Property { name: "transform"; type: "QQuickTransform"; isList: true; isReadonly: true } + Property { name: "smooth"; type: "bool" } + Property { name: "antialiasing"; type: "bool" } + Property { name: "implicitWidth"; type: "double" } + Property { name: "implicitHeight"; type: "double" } + Property { name: "layer"; type: "QQuickItemLayer"; isReadonly: true; isPointer: true } + Signal { + name: "childrenRectChanged" + Parameter { type: "QRectF" } + } + Signal { + name: "baselineOffsetChanged" + Parameter { type: "double" } + } + Signal { + name: "stateChanged" + Parameter { type: "string" } + } + Signal { + name: "focusChanged" + Parameter { type: "bool" } + } + Signal { + name: "activeFocusChanged" + Parameter { type: "bool" } + } + Signal { + name: "activeFocusOnTabChanged" + revision: 1 + Parameter { type: "bool" } + } + Signal { + name: "parentChanged" + Parameter { type: "QQuickItem"; isPointer: true } + } + Signal { + name: "transformOriginChanged" + Parameter { type: "TransformOrigin" } + } + Signal { + name: "smoothChanged" + Parameter { type: "bool" } + } + Signal { + name: "antialiasingChanged" + Parameter { type: "bool" } + } + Signal { + name: "clipChanged" + Parameter { type: "bool" } + } + Signal { + name: "windowChanged" + revision: 1 + Parameter { name: "window"; type: "QQuickWindow"; isPointer: true } + } + Method { name: "update" } + Method { + name: "grabToImage" + revision: 2 + type: "bool" + Parameter { name: "callback"; type: "QJSValue" } + Parameter { name: "targetSize"; type: "QSize" } + } + Method { + name: "grabToImage" + revision: 2 + type: "bool" + Parameter { name: "callback"; type: "QJSValue" } + } + Method { + name: "contains" + type: "bool" + Parameter { name: "point"; type: "QPointF" } + } + Method { + name: "mapFromItem" + Parameter { type: "QQmlV4Function"; isPointer: true } + } + Method { + name: "mapToItem" + Parameter { type: "QQmlV4Function"; isPointer: true } + } + Method { name: "forceActiveFocus" } + Method { + name: "forceActiveFocus" + Parameter { name: "reason"; type: "Qt::FocusReason" } + } + Method { + name: "nextItemInFocusChain" + revision: 1 + type: "QQuickItem*" + Parameter { name: "forward"; type: "bool" } + } + Method { name: "nextItemInFocusChain"; revision: 1; type: "QQuickItem*" } + Method { + name: "childAt" + type: "QQuickItem*" + Parameter { name: "x"; type: "double" } + Parameter { name: "y"; type: "double" } + } + } + Component { + name: "QQuickWebEngineCertificateError" + prototype: "QObject" + exports: ["QtWebEngine/WebEngineCertificateError 1.1"] + isCreatable: false + exportMetaObjectRevisions: [0] + Enum { + name: "Error" + values: { + "SslPinnedKeyNotInCertificateChain": -150, + "CertificateCommonNameInvalid": -200, + "CertificateDateInvalid": -201, + "CertificateAuthorityInvalid": -202, + "CertificateContainsErrors": -203, + "CertificateNoRevocationMechanism": -204, + "CertificateUnableToCheckRevocation": -205, + "CertificateRevoked": -206, + "CertificateInvalid": -207, + "CertificateWeakSignatureAlgorithm": -208, + "CertificateNonUniqueName": -210, + "CertificateWeakKey": -211, + "CertificateNameConstraintViolation": -212 + } + } + Property { name: "url"; type: "QUrl"; isReadonly: true } + Property { name: "error"; type: "Error"; isReadonly: true } + Property { name: "description"; type: "string"; isReadonly: true } + Property { name: "overridable"; type: "bool"; isReadonly: true } + Method { name: "defer" } + Method { name: "ignoreCertificateError" } + Method { name: "rejectCertificate" } + } + Component { + name: "QQuickWebEngineDownloadItem" + prototype: "QObject" + exports: ["QtWebEngine/WebEngineDownloadItem 1.1"] + isCreatable: false + exportMetaObjectRevisions: [0] + Enum { + name: "DownloadState" + values: { + "DownloadRequested": 0, + "DownloadInProgress": 1, + "DownloadCompleted": 2, + "DownloadCancelled": 3, + "DownloadInterrupted": 4 + } + } + Property { name: "id"; type: "uint"; isReadonly: true } + Property { name: "state"; type: "DownloadState"; isReadonly: true } + Property { name: "totalBytes"; type: "qlonglong"; isReadonly: true } + Property { name: "receivedBytes"; type: "qlonglong"; isReadonly: true } + Property { name: "path"; type: "string" } + Method { name: "accept" } + Method { name: "cancel" } + } + Component { + name: "QQuickWebEngineFullScreenRequest" + exports: ["QtWebEngine/FullScreenRequest 1.1"] + isCreatable: false + exportMetaObjectRevisions: [0] + Property { name: "toggleOn"; type: "bool"; isReadonly: true } + Method { name: "accept" } + } + Component { + name: "QQuickWebEngineHistory" + defaultProperty: "data" + prototype: "QQuickItem" + exports: ["QtWebEngine/NavigationHistory 1.1"] + isCreatable: false + exportMetaObjectRevisions: [0] + Property { + name: "items" + type: "QQuickWebEngineHistoryListModel" + isReadonly: true + isPointer: true + } + Property { + name: "backItems" + type: "QQuickWebEngineHistoryListModel" + isReadonly: true + isPointer: true + } + Property { + name: "forwardItems" + type: "QQuickWebEngineHistoryListModel" + isReadonly: true + isPointer: true + } + } + Component { + name: "QQuickWebEngineHistoryListModel" + prototype: "QAbstractListModel" + exports: ["QtWebEngine/NavigationHistoryListModel 1.1"] + isCreatable: false + exportMetaObjectRevisions: [0] + } Component { name: "QQuickWebEngineLoadRequest" prototype: "QObject" @@ -37,7 +554,7 @@ Module { Component { name: "QQuickWebEngineNewViewRequest" prototype: "QObject" - exports: ["QtWebEngine/WebEngineNewViewRequest 1.0"] + exports: ["QtWebEngine/WebEngineNewViewRequest 1.1"] isCreatable: false exportMetaObjectRevisions: [0] Property { @@ -51,12 +568,164 @@ Module { Parameter { name: "view"; type: "QQuickWebEngineView"; isPointer: true } } } + Component { + name: "QQuickWebEngineProfile" + prototype: "QObject" + exports: ["QtWebEngine/WebEngineProfile 1.1"] + exportMetaObjectRevisions: [0] + Enum { + name: "HttpCacheType" + values: { + "MemoryHttpCache": 0, + "DiskHttpCache": 1 + } + } + Enum { + name: "PersistentCookiesPolicy" + values: { + "NoPersistentCookies": 0, + "AllowPersistentCookies": 1, + "ForcePersistentCookies": 2 + } + } + Property { name: "storageName"; type: "string" } + Property { name: "offTheRecord"; type: "bool" } + Property { name: "persistentStoragePath"; type: "string" } + Property { name: "cachePath"; type: "string" } + Property { name: "httpUserAgent"; type: "string" } + Property { name: "httpCacheType"; type: "HttpCacheType" } + Property { name: "persistentCookiesPolicy"; type: "PersistentCookiesPolicy" } + Property { name: "httpCacheMaximumSize"; type: "int" } + Signal { + name: "downloadRequested" + Parameter { name: "download"; type: "QQuickWebEngineDownloadItem"; isPointer: true } + } + Signal { + name: "downloadFinished" + Parameter { name: "download"; type: "QQuickWebEngineDownloadItem"; isPointer: true } + } + } + Component { + name: "QQuickWebEngineScript" + prototype: "QObject" + exports: ["QtWebEngine/WebEngineScript 1.1"] + exportMetaObjectRevisions: [0] + Enum { + name: "InjectionPoint" + values: { + "Deferred": 0, + "DocumentReady": 1, + "DocumentCreation": 2 + } + } + Enum { + name: "ScriptWorldId" + values: { + "MainWorld": 0, + "ApplicationWorld": 1, + "UserWorld": 2 + } + } + Property { name: "name"; type: "string" } + Property { name: "sourceUrl"; type: "QUrl" } + Property { name: "sourceCode"; type: "string" } + Property { name: "injectionPoint"; type: "InjectionPoint" } + Property { name: "worldId"; type: "ScriptWorldId" } + Property { name: "runOnSubframes"; type: "bool" } + Signal { + name: "nameChanged" + Parameter { name: "arg"; type: "string" } + } + Signal { + name: "sourceUrlChanged" + Parameter { name: "arg"; type: "QUrl" } + } + Signal { + name: "sourceCodeChanged" + Parameter { name: "arg"; type: "string" } + } + Signal { + name: "injectionPointChanged" + Parameter { name: "arg"; type: "InjectionPoint" } + } + Signal { + name: "worldIdChanged" + Parameter { name: "arg"; type: "ScriptWorldId" } + } + Signal { + name: "runOnSubframesChanged" + Parameter { name: "arg"; type: "bool" } + } + Method { + name: "setName" + Parameter { name: "arg"; type: "string" } + } + Method { + name: "setSourceUrl" + Parameter { name: "arg"; type: "QUrl" } + } + Method { + name: "setSourceCode" + Parameter { name: "arg"; type: "string" } + } + Method { + name: "setInjectionPoint" + Parameter { name: "arg"; type: "InjectionPoint" } + } + Method { + name: "setWorldId" + Parameter { name: "arg"; type: "ScriptWorldId" } + } + Method { + name: "setRunOnSubframes" + Parameter { name: "arg"; type: "bool" } + } + Method { name: "toString"; type: "string" } + } + Component { + name: "QQuickWebEngineSettings" + prototype: "QObject" + exports: ["QtWebEngine/WebEngineSettings 1.1"] + isCreatable: false + exportMetaObjectRevisions: [0] + Property { name: "autoLoadImages"; type: "bool" } + Property { name: "javascriptEnabled"; type: "bool" } + Property { name: "javascriptCanOpenWindows"; type: "bool" } + Property { name: "javascriptCanAccessClipboard"; type: "bool" } + Property { name: "linksIncludedInFocusChain"; type: "bool" } + Property { name: "localStorageEnabled"; type: "bool" } + Property { name: "localContentCanAccessRemoteUrls"; type: "bool" } + Property { name: "spatialNavigationEnabled"; type: "bool" } + Property { name: "localContentCanAccessFileUrls"; type: "bool" } + Property { name: "hyperlinkAuditingEnabled"; type: "bool" } + Property { name: "errorPageEnabled"; type: "bool" } + Property { name: "defaultTextEncoding"; type: "string" } + } + Component { + name: "QQuickWebEngineSingleton" + prototype: "QObject" + exports: ["QtWebEngine/WebEngine 1.1"] + isCreatable: false + isSingleton: true + exportMetaObjectRevisions: [0] + Property { name: "settings"; type: "QQuickWebEngineSettings"; isReadonly: true; isPointer: true } + Property { + name: "defaultProfile" + revision: 1 + type: "QQuickWebEngineProfile" + isReadonly: true + isPointer: true + } + } Component { name: "QQuickWebEngineView" defaultProperty: "data" prototype: "QQuickItem" - exports: ["QtWebEngine/WebEngineView 1.0"] - exportMetaObjectRevisions: [0] + exports: [ + "QtWebEngine/WebEngineView 1.0", + "QtWebEngine/WebEngineView 1.1" + ] + exportMetaObjectRevisions: [0, 1] Enum { name: "NavigationRequestAction" values: { @@ -101,7 +770,17 @@ Module { values: { "NewViewInWindow": 0, "NewViewInTab": 1, - "NewViewInDialog": 2 + "NewViewInDialog": 2, + "NewViewInBackgroundTab": 3 + } + } + Enum { + name: "Feature" + values: { + "MediaAudioCapture": 0, + "MediaVideoCapture": 1, + "MediaAudioVideoCapture": 2, + "Geolocation": 3 } } Enum { @@ -112,6 +791,13 @@ Module { "ErrorMessageLevel": 2 } } + Enum { + name: "FindFlags" + values: { + "FindBackward": 1, + "FindCaseSensitively": 2 + } + } Property { name: "url"; type: "QUrl" } Property { name: "icon"; type: "QUrl"; isReadonly: true } Property { name: "loading"; type: "bool"; isReadonly: true } @@ -119,6 +805,31 @@ Module { Property { name: "title"; type: "string"; isReadonly: true } Property { name: "canGoBack"; type: "bool"; isReadonly: true } Property { name: "canGoForward"; type: "bool"; isReadonly: true } + Property { name: "isFullScreen"; revision: 1; type: "bool"; isReadonly: true } + Property { name: "zoomFactor"; revision: 1; type: "double" } + Property { name: "profile"; revision: 1; type: "QQuickWebEngineProfile"; isPointer: true } + Property { + name: "settings" + revision: 1 + type: "QQuickWebEngineSettings" + isReadonly: true + isPointer: true + } + Property { + name: "navigationHistory" + revision: 1 + type: "QQuickWebEngineHistory" + isReadonly: true + isPointer: true + } + Property { name: "webChannel"; revision: 1; type: "QQmlWebChannel"; isPointer: true } + Property { + name: "userScripts" + revision: 1 + type: "QQuickWebEngineScript" + isList: true + isReadonly: true + } Signal { name: "loadingChanged" Parameter { name: "loadRequest"; type: "QQuickWebEngineLoadRequest"; isPointer: true } @@ -138,6 +849,35 @@ Module { Parameter { name: "lineNumber"; type: "int" } Parameter { name: "sourceID"; type: "string" } } + Signal { + name: "certificateError" + revision: 1 + Parameter { name: "error"; type: "QQuickWebEngineCertificateError"; isPointer: true } + } + Signal { + name: "fullScreenRequested" + revision: 1 + Parameter { name: "request"; type: "QQuickWebEngineFullScreenRequest" } + } + Signal { name: "isFullScreenChanged"; revision: 1 } + Signal { + name: "featurePermissionRequested" + revision: 1 + Parameter { name: "securityOrigin"; type: "QUrl" } + Parameter { name: "feature"; type: "Feature" } + } + Signal { + name: "newViewRequested" + revision: 1 + Parameter { name: "request"; type: "QQuickWebEngineNewViewRequest"; isPointer: true } + } + Signal { + name: "zoomFactorChanged" + revision: 1 + Parameter { name: "arg"; type: "double" } + } + Signal { name: "profileChanged"; revision: 1 } + Signal { name: "webChannelChanged"; revision: 1 } Method { name: "runJavaScript" Parameter { type: "string" } @@ -158,7 +898,39 @@ Module { } Method { name: "goBack" } Method { name: "goForward" } + Method { + name: "goBackOrForward" + revision: 1 + Parameter { name: "index"; type: "int" } + } Method { name: "reload" } + Method { name: "reloadAndBypassCache"; revision: 1 } Method { name: "stop" } + Method { + name: "findText" + revision: 1 + Parameter { name: "subString"; type: "string" } + Parameter { name: "options"; type: "FindFlags" } + Parameter { name: "callback"; type: "QJSValue" } + } + Method { + name: "findText" + revision: 1 + Parameter { name: "subString"; type: "string" } + Parameter { name: "options"; type: "FindFlags" } + } + Method { + name: "findText" + revision: 1 + Parameter { name: "subString"; type: "string" } + } + Method { name: "fullScreenCancelled"; revision: 1 } + Method { + name: "grantFeaturePermission" + revision: 1 + Parameter { name: "securityOrigin"; type: "QUrl" } + Parameter { type: "Feature" } + Parameter { name: "granted"; type: "bool" } + } } } diff --git a/src/webengine/plugin/testsupport/plugin.cpp b/src/webengine/plugin/testsupport/plugin.cpp index 60e56062c497ae10d5c9b4aeccea882fcf7efd74..28001db54febc57073412fefd8814df1417bf0cd 100644 --- a/src/webengine/plugin/testsupport/plugin.cpp +++ b/src/webengine/plugin/testsupport/plugin.cpp @@ -1,7 +1,7 @@ /**************************************************************************** ** -** Copyright (C) 2015 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ ** ** This file is part of the QtWebEngine module of the Qt Toolkit. ** @@ -10,15 +10,15 @@ ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 3 as published by the Free Software ** Foundation and appearing in the file LICENSE.LGPLv3 included in the -** packaging of this file. Please review the following information to +** packaging of this file. Please review the following information to ** ensure the GNU Lesser General Public License version 3 requirements ** will be met: https://www.gnu.org/licenses/lgpl.html. ** @@ -26,7 +26,7 @@ ** Alternatively, this file may be used under the terms of the GNU ** General Public License version 2.0 or later as published by the Free ** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information to +** the packaging of this file. Please review the following information to ** ensure the GNU General Public License version 2.0 requirements will be ** met: http://www.gnu.org/licenses/gpl-2.0.html. ** @@ -54,7 +54,7 @@ public: qmlRegisterType<QQuickWebEngineTestSupport>(uri, 1, 0, "WebEngineTestSupport"); qmlRegisterUncreatableType<QQuickWebEngineErrorPage>(uri, 1, 0, "WebEngineErrorPage", - QObject::tr("Cannot create a separate instance of WebEngineErrorPage")); + tr("Cannot create a separate instance of WebEngineErrorPage")); } }; diff --git a/src/webengine/ui/AuthenticationDialog.qml b/src/webengine/ui/AuthenticationDialog.qml new file mode 100644 index 0000000000000000000000000000000000000000..46e2e3151e1fc456323344d90e30d64ca4ffb4ab --- /dev/null +++ b/src/webengine/ui/AuthenticationDialog.qml @@ -0,0 +1,105 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the QtWebEngine module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// FIXME: authentication missing in Qt Quick Dialogs atm. Make our own for now. +import QtQuick.Controls 1.4 +import QtQuick.Layouts 1.0 +import QtQuick 2.5 + +ApplicationWindow { + signal accepted(string user, string password); + signal rejected; + property alias text: message.text; + + width: 350 + height: 100 + flags: Qt.Dialog + + title: "Authentication Required" + + function open() { + show(); + } + + ColumnLayout { + anchors.fill: parent; + anchors.margins: 4; + Text { + id: message; + Layout.fillWidth: true; + } + RowLayout { + Label { + text: "Username:" + } + TextField { + id: userField; + Layout.fillWidth: true; + } + } + RowLayout { + Label { + text: "Password:" + } + TextField { + id: passwordField; + Layout.fillWidth: true; + echoMode: TextInput.Password; + } + } + RowLayout { + Layout.alignment: Qt.AlignRight + spacing: 8; + Button { + text: "Log In" + onClicked: { + accepted(userField.text, passwordField.text); + close(); + destroy(); + } + } + Button { + text: "Cancel" + onClicked: { + rejected(); + close(); + destroy(); + } + } + } + } + +} diff --git a/src/webengine/ui/Menu.qml b/src/webengine/ui/Menu.qml index e6fec297f4faf77989d4c080cc6e49ef4c5a719e..6ecf650e889a4a55eee189dc52f5a289b7403653 100644 --- a/src/webengine/ui/Menu.qml +++ b/src/webengine/ui/Menu.qml @@ -38,8 +38,17 @@ import QtQuick 2.5 import QtQuick.Controls 1.4 as Controls Controls.Menu { + id: menu signal done() // Use private API for now - onAboutToHide: done(); + onAboutToHide: doneTimer.start(); + + // WORKAROUND On Mac the Menu may be destroyed before the MenuItem + // is actually triggered (see qtbase commit 08cc9b9991ae9ab51) + Timer { + id: doneTimer + interval: 100 + onTriggered: menu.done() + } } diff --git a/src/webengine/ui/MessageBubble.qml b/src/webengine/ui/MessageBubble.qml index 17cf5b79780d502b128302e5910f7a7748eb37f3..2f5d6376693ff1d887d1ab7a490fcde5581710a9 100644 --- a/src/webengine/ui/MessageBubble.qml +++ b/src/webengine/ui/MessageBubble.qml @@ -1,7 +1,7 @@ /**************************************************************************** ** -** Copyright (C) 2015 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ ** ** This file is part of the QtWebEngine module of the Qt Toolkit. ** @@ -10,15 +10,15 @@ ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 3 as published by the Free Software ** Foundation and appearing in the file LICENSE.LGPLv3 included in the -** packaging of this file. Please review the following information to +** packaging of this file. Please review the following information to ** ensure the GNU Lesser General Public License version 3 requirements ** will be met: https://www.gnu.org/licenses/lgpl.html. ** @@ -26,7 +26,7 @@ ** Alternatively, this file may be used under the terms of the GNU ** General Public License version 2.0 or later as published by the Free ** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information to +** the packaging of this file. Please review the following information to ** ensure the GNU General Public License version 2.0 requirements will be ** met: http://www.gnu.org/licenses/gpl-2.0.html. ** diff --git a/src/webengine/ui/ui.pro b/src/webengine/ui/ui.pro index fdf7a85bc3d24e3b5c8ca5387c7f61eb1c6cd98a..28ea691b25a2960b961a7383f6725bd67e0815b4 100644 --- a/src/webengine/ui/ui.pro +++ b/src/webengine/ui/ui.pro @@ -1,6 +1,8 @@ TARGETPATH = QtWebEngine/UIDelegates QML_FILES += \ + # Authentication Dialog + AuthenticationDialog.qml \ # JS Dialogs AlertDialog.qml \ ConfirmDialog.qml \ diff --git a/src/webengine/ui_delegates_manager.cpp b/src/webengine/ui_delegates_manager.cpp index bacf48419a2aca61169c22a4f0041b902efd9076..5a5c261b41125c3d9f51ef57eae42ee4fe70452b 100644 --- a/src/webengine/ui_delegates_manager.cpp +++ b/src/webengine/ui_delegates_manager.cpp @@ -37,6 +37,7 @@ #include "ui_delegates_manager.h" #include "api/qquickwebengineview_p.h" +#include "authentication_dialog_controller.h" #include "file_picker_controller.h" #include "javascript_dialog_controller.h" @@ -248,15 +249,15 @@ void UIDelegatesManager::showDialog(QSharedPointer<JavaScriptDialogController> d switch (dialogController->type()) { case WebContentsAdapterClient::AlertDialog: dialogComponentType = AlertDialog; - title = QObject::tr("Javascript Alert - %1").arg(m_view->url().toString()); + title = QCoreApplication::translate("UIDelegatesManager", "Javascript Alert - %1").arg(m_view->url().toString()); break; case WebContentsAdapterClient::ConfirmDialog: dialogComponentType = ConfirmDialog; - title = QObject::tr("Javascript Confirm - %1").arg(m_view->url().toString()); + title = QCoreApplication::translate("UIDelegatesManager", "Javascript Confirm - %1").arg(m_view->url().toString()); break; case WebContentsAdapterClient::PromptDialog: dialogComponentType = PromptDialog; - title = QObject::tr("Javascript Prompt - %1").arg(m_view->url().toString()); + title = QCoreApplication::translate("UIDelegatesManager", "Javascript Prompt - %1").arg(m_view->url().toString()); break; case WebContentsAdapterClient::InternalAuthorizationDialog: dialogComponentType = ConfirmDialog; @@ -317,6 +318,46 @@ void UIDelegatesManager::showDialog(QSharedPointer<JavaScriptDialogController> d QMetaObject::invokeMethod(dialog, "open"); } +void UIDelegatesManager::showDialog(QSharedPointer<AuthenticationDialogController> dialogController) +{ + Q_ASSERT(!dialogController.isNull()); + + if (!ensureComponentLoaded(AuthenticationDialog)) { + // Let the controller know it couldn't be loaded + qWarning("Failed to load authentication dialog, rejecting."); + dialogController->reject(); + return; + } + + QQmlContext *context = qmlContext(m_view); + QObject *authenticationDialog = authenticationDialogComponent->beginCreate(context); + authenticationDialog->setParent(m_view); + + QString introMessage; + if (dialogController->isProxy()) { + introMessage = QObject::tr("Connect to proxy \"%1\" using:"); + introMessage = introMessage.arg(dialogController->host().toHtmlEscaped()); + } else { + introMessage = QObject::tr("Enter username and password for \"%1\" at %2"); + introMessage = introMessage.arg(dialogController->realm()).arg(dialogController->url().toString().toHtmlEscaped()); + } + QQmlProperty textProp(authenticationDialog, QStringLiteral("text")); + textProp.write(introMessage); + + QQmlProperty acceptSignal(authenticationDialog, QStringLiteral("onAccepted")); + QQmlProperty rejectSignal(authenticationDialog, QStringLiteral("onRejected")); + CHECK_QML_SIGNAL_PROPERTY(acceptSignal, authenticationDialogComponent->url()); + CHECK_QML_SIGNAL_PROPERTY(rejectSignal, authenticationDialogComponent->url()); + + static int acceptIndex = dialogController->metaObject()->indexOfSlot("accept(QString,QString)"); + QObject::connect(authenticationDialog, acceptSignal.method(), dialogController.data(), dialogController->metaObject()->method(acceptIndex)); + static int rejectIndex = dialogController->metaObject()->indexOfSlot("reject()"); + QObject::connect(authenticationDialog, rejectSignal.method(), dialogController.data(), dialogController->metaObject()->method(rejectIndex)); + + authenticationDialogComponent->completeCreate(); + QMetaObject::invokeMethod(authenticationDialog, "open"); +} + void UIDelegatesManager::showFilePicker(FilePickerController *controller) { diff --git a/src/webengine/ui_delegates_manager.h b/src/webengine/ui_delegates_manager.h index 37cbb85dfe3b4f17b437b83a1d7858adc4b5aeea..2a86b2803becc144925cbeeb4f89f6bbf56a8308 100644 --- a/src/webengine/ui_delegates_manager.h +++ b/src/webengine/ui_delegates_manager.h @@ -55,7 +55,8 @@ F(ConfirmDialog, confirmDialog) SEPARATOR \ F(PromptDialog, promptDialog) SEPARATOR \ F(FilePicker, filePicker) SEPARATOR \ - F(MessageBubble, messageBubble) SEPARATOR + F(MessageBubble, messageBubble) SEPARATOR \ + F(AuthenticationDialog, authenticationDialog) SEPARATOR #define COMMA_SEPARATOR , #define SEMICOLON_SEPARATOR ; @@ -72,6 +73,7 @@ class QQuickWebEngineView; QT_END_NAMESPACE namespace QtWebEngineCore { +class AuthenticationDialogController; class JavaScriptDialogController; class FilePickerController; @@ -102,6 +104,7 @@ public: QObject *addMenu(QObject *parentMenu, const QString &title, const QPoint &pos = QPoint()); QQmlContext *creationContextForComponent(QQmlComponent *); void showDialog(QSharedPointer<JavaScriptDialogController>); + void showDialog(QSharedPointer<AuthenticationDialogController>); void showFilePicker(FilePickerController *controller); void showMessageBubble(const QRect &anchor, const QString &mainText, const QString &subText); void hideMessageBubble(); diff --git a/src/webenginewidgets/api/qwebenginecertificateerror.cpp b/src/webenginewidgets/api/qwebenginecertificateerror.cpp index 3535b3a9ce367ff95de6d68d8e570380943948e4..f35175c672a78d20b0e3a3f99669fa2d5c3f0d36 100644 --- a/src/webenginewidgets/api/qwebenginecertificateerror.cpp +++ b/src/webenginewidgets/api/qwebenginecertificateerror.cpp @@ -41,10 +41,10 @@ QT_BEGIN_NAMESPACE /*! \class QWebEngineCertificateError \brief The QWebEngineCertificateError class provides information about a certificate error. - + \since 5.4 \inmodule QtWebEngineWidgets - QWebEngineCertificateError holds known information about a certificate error to be used to determine whether to allow it or not, and to be reported to the user. + Provides information about a certificate error. */ class QWebEngineCertificateErrorPrivate { @@ -82,7 +82,8 @@ QWebEngineCertificateError::~QWebEngineCertificateError() This enum describes the type of certificate error encountered. - \value SslPinnedKeyNotInCertificateChain The certificate did not match the built-in public key pins for the host name. + \value SslPinnedKeyNotInCertificateChain The certificate did not match the built-in public keys + pinned for the host name. \value CertificateCommonNameInvalid The certificate's common name did not match the host name. \value CertificateDateInvalid The certificate is not valid at the current date and time. \value CertificateAuthorityInvalid The certificate is not signed by a trusted authority. diff --git a/src/webenginewidgets/api/qwebenginedownloaditem.cpp b/src/webenginewidgets/api/qwebenginedownloaditem.cpp index 7df044e66d55c2c9911e4f838053b18fbc5b96ea..6c9413280f8954cec5c0f3b4bd0a2127806d2363 100644 --- a/src/webenginewidgets/api/qwebenginedownloaditem.cpp +++ b/src/webenginewidgets/api/qwebenginedownloaditem.cpp @@ -153,7 +153,7 @@ void QWebEngineDownloadItem::cancel() } /*! - Returns the download item's id. + Returns the download item's ID. */ quint32 QWebEngineDownloadItem::id() const @@ -190,13 +190,14 @@ quint32 QWebEngineDownloadItem::id() const /*! \enum QWebEngineDownloadItem::DownloadState - This enum describes the state in which the download is in. + This enum describes the state of the download: - \value DownloadRequested The download has been requested, but has not been accepted yet. - \value DownloadInProgress The download is in progress. - \value DownloadCompleted The download completed successfully. - \value DownloadCancelled The download has been cancelled. - \value DownloadInterrupted The download has been interrupted (by the server or because of lost connectivity). + \value DownloadRequested Download has been requested, but has not been accepted yet. + \value DownloadInProgress Download is in progress. + \value DownloadCompleted Download completed successfully. + \value DownloadCancelled Download has been cancelled. + \value DownloadInterrupted Download has been interrupted (by the server or because of lost + connectivity). */ /*! @@ -212,9 +213,9 @@ QWebEngineDownloadItem::DownloadState QWebEngineDownloadItem::state() const } /*! - Returns the download's total size in bytes. + Returns the the total amount of data to download in bytes. - -1 means the size is unknown. + \c -1 means the size is unknown. */ qint64 QWebEngineDownloadItem::totalBytes() const @@ -224,9 +225,9 @@ qint64 QWebEngineDownloadItem::totalBytes() const } /*! - Returns the download's bytes that have been received so far. + Returns the amount of data in bytes that has been downloaded so far. - -1 means the size is unknown. + \c -1 means the size is unknown. */ qint64 QWebEngineDownloadItem::receivedBytes() const @@ -236,7 +237,7 @@ qint64 QWebEngineDownloadItem::receivedBytes() const } /*! - Returns the download's origin url. + Returns the download's origin URL. */ QUrl QWebEngineDownloadItem::url() const @@ -246,7 +247,7 @@ QUrl QWebEngineDownloadItem::url() const } /*! - Returns the download's full target path where it is being downloaded to. + Returns the full target path where data is being downloaded to. The path includes the file name. The default suggested path is the standard download location and file name is deduced not to overwrite already existing files. @@ -259,11 +260,11 @@ QString QWebEngineDownloadItem::path() const } /*! - Sets the download's full target path, where the file should be downloaded to. + Sets the full target path to download the file to. The \a path should also include the file name. The download path can only be set in response to the QWebEngineProfile::downloadRequested() signal before the download is accepted. - Past that point this function has no effect on the download item's state. + Past that point, this function has no effect on the download item's state. */ void QWebEngineDownloadItem::setPath(QString path) { diff --git a/src/webenginewidgets/api/qwebenginedownloaditem.h b/src/webenginewidgets/api/qwebenginedownloaditem.h index 1428ad4c35f5886ac9bc0e6dba63df4d64e4c44f..05e0f8765f3f8e0288d839e540c256f95766f44f 100644 --- a/src/webenginewidgets/api/qwebenginedownloaditem.h +++ b/src/webenginewidgets/api/qwebenginedownloaditem.h @@ -76,7 +76,7 @@ public Q_SLOTS: Q_SIGNALS: void finished(); - void stateChanged(DownloadState state); + void stateChanged(QWebEngineDownloadItem::DownloadState state); void downloadProgress(qint64 bytesReceived, qint64 bytesTotal); private: diff --git a/src/webenginewidgets/api/qwebenginedownloaditem_p.h b/src/webenginewidgets/api/qwebenginedownloaditem_p.h index 40c7c6b49d6c330bfc7a36a4338e32a55da85829..87dc4114ac3d6553f0d5454c71017189c9ff77c2 100644 --- a/src/webenginewidgets/api/qwebenginedownloaditem_p.h +++ b/src/webenginewidgets/api/qwebenginedownloaditem_p.h @@ -37,6 +37,17 @@ #ifndef QWEBENGINEDOWNLOADITEM_P_H #define QWEBENGINEDOWNLOADITEM_P_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include "qtwebenginewidgetsglobal.h" #include "qwebenginedownloaditem_p.h" diff --git a/src/webenginewidgets/api/qwebenginehistory.cpp b/src/webenginewidgets/api/qwebenginehistory.cpp index b04c81147be106cc5a3a5858f903cb41cf1a6552..9aed2aca90aafa4f73a526530afb10d77ec3d9ad 100644 --- a/src/webenginewidgets/api/qwebenginehistory.cpp +++ b/src/webenginewidgets/api/qwebenginehistory.cpp @@ -92,6 +92,11 @@ QDateTime QWebEngineHistoryItem::lastVisited() const return d->page ? d->page->webContents()->getNavigationEntryTimestamp(d->index) : QDateTime(); } +/*! + Returns the URL of the icon associated with the history item. + + \sa url(), originalUrl(), title() +*/ QUrl QWebEngineHistoryItem::iconUrl() const { Q_D(const QWebEngineHistoryItem); diff --git a/src/webenginewidgets/api/qwebenginehistory_p.h b/src/webenginewidgets/api/qwebenginehistory_p.h index a3c773c5e9bf3d0ef483a0a0520dd6098c4b1aa8..e45023177ff3ec2e48cc7fb1599f65088edc5356 100644 --- a/src/webenginewidgets/api/qwebenginehistory_p.h +++ b/src/webenginewidgets/api/qwebenginehistory_p.h @@ -37,6 +37,17 @@ #ifndef QWEBENGINEHISTORY_P_H #define QWEBENGINEHISTORY_P_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include <QtCore/qshareddata.h> QT_BEGIN_NAMESPACE diff --git a/src/webenginewidgets/api/qwebenginepage.cpp b/src/webenginewidgets/api/qwebenginepage.cpp index e7d4e60e50a82246c13d0e29b2d44be1a73fa143..677f67cbe97fbd61528774311fd59eaff66b5e31 100644 --- a/src/webenginewidgets/api/qwebenginepage.cpp +++ b/src/webenginewidgets/api/qwebenginepage.cpp @@ -23,6 +23,7 @@ #include "qwebenginepage.h" #include "qwebenginepage_p.h" +#include "authentication_dialog_controller.h" #include "browser_context_adapter.h" #include "certificate_error_controller.h" #include "file_picker_controller.h" @@ -88,6 +89,7 @@ QWebEnginePagePrivate::QWebEnginePagePrivate(QWebEngineProfile *_profile) , isLoading(false) , scriptCollection(new QWebEngineScriptCollectionPrivate(browserContextAdapter()->userScriptController(), adapter.data())) , m_backgroundColor(Qt::white) + , m_fullscreenRequested(false) { memset(actions, 0, sizeof(actions)); } @@ -248,18 +250,24 @@ void QWebEnginePagePrivate::passOnFocus(bool reverse) view->focusNextPrevChild(!reverse); } -void QWebEnginePagePrivate::authenticationRequired(const QUrl &requestUrl, const QString &realm, bool isProxy, const QString &challengingHost, QString *outUser, QString *outPassword) +void QWebEnginePagePrivate::authenticationRequired(QSharedPointer<AuthenticationDialogController> controller) { Q_Q(QWebEnginePage); QAuthenticator networkAuth; - networkAuth.setRealm(realm); + networkAuth.setRealm(controller->realm()); - if (isProxy) - Q_EMIT q->proxyAuthenticationRequired(requestUrl, &networkAuth, challengingHost); + if (controller->isProxy()) + Q_EMIT q->proxyAuthenticationRequired(controller->url(), &networkAuth, controller->host()); else - Q_EMIT q->authenticationRequired(requestUrl, &networkAuth); - *outUser = networkAuth.user(); - *outPassword = networkAuth.password(); + Q_EMIT q->authenticationRequired(controller->url(), &networkAuth); + + // Authentication has been cancelled + if (networkAuth.isNull()) { + controller->reject(); + return; + } + + controller->accept(networkAuth.user(), networkAuth.password()); } void QWebEnginePagePrivate::runMediaAccessPermissionRequest(const QUrl &securityOrigin, WebContentsAdapterClient::MediaRequestFlags requestFlags) @@ -374,10 +382,44 @@ QWebEnginePage::QWebEnginePage(QObject* parent) } /*! - Constructs an empty QWebEnginePage in the QWebEngineProfile \a profile with parent \a parent. + \enum QWebEnginePage::RenderProcessTerminationStatus + + This enum describes the status with which the render process terminated: + + \value NormalTerminationStatus + The render process terminated normally. + \value AbnormalTerminationStatus + The render process terminated with with a non-zero exit status. + \value CrashedTerminationStatus + The render process crashed, for example because of a segmentation fault. + \value KilledTerminationStatus + The render process was killed, for example by \c SIGKILL or task manager kill. +*/ + +/*! + \fn QWebEnginePage::renderProcessTerminated(RenderProcessTerminationStatus terminationStatus, int exitCode) + + This signal is emitted when the render process is terminated with a non-zero exit status. + \a terminationStatus is the termination status of the process and \a exitCode is the status code + with which the process terminated. +*/ + +/*! + \fn QWebEnginePage::fullScreenRequested(bool fullScreen) + + This signal is emitted when the web page issues the request to enter or exit fullscreen mode. + If \a fullScreen is \c true, the page wants to enter the mode and if it is \c false, the page + wants to exit the mode. + + \sa isFullScreen(), QWebEngineSettings::FullScreenSupportEnabled +*/ + +/*! + Constructs an empty web engine page in the web engine profile \a profile with the parent + \a parent. - If the profile is not the default profile the caller must ensure the profile is alive for as - long as the page is. + If the profile is not the default profile, the caller must ensure that the profile stays alive + for as long as the page does. \since 5.5 */ @@ -409,12 +451,12 @@ QWebEngineSettings *QWebEnginePage::settings() const } /*! - * Returns a pointer to the web channel instance used by this page, or a null pointer if none was set. - * This channel is automatically using the internal QtWebEngine transport mechanism over Chromium IPC, - * and exposed in the javascript context of this page as \c qt.webChannelTransport + * Returns a pointer to the web channel instance used by this page or a null pointer if none was set. + * This channel automatically uses the internal web engine transport mechanism over Chromium IPC + * that is exposed in the JavaScript context of this page as \c qt.webChannelTransport. * * \since 5.5 - * \sa {QtWebChannel::QWebChannel}{QWebChannel} + * \sa QWebChannel */ QWebChannel *QWebEnginePage::webChannel() const { @@ -423,14 +465,14 @@ QWebChannel *QWebEnginePage::webChannel() const } /*! - * Sets the web channel instance to be used by this page and connects it to QtWebEngine's transport - * using Chromium IPC messages. That transport is exposed in the javascript context of this page as + * Sets the web channel instance to be used by this page to \a channel and connects it to + * web engine's transport using Chromium IPC messages. The transport is exposed in the JavaScript + * context of this page as * \c qt.webChannelTransport, which should be used when using the \l{Qt WebChannel JavaScript API}. * - * \note The page does not take ownership of the \a channel object. + * \note The page does not take ownership of the channel object. * * \since 5.5 - * \param channel */ void QWebEnginePage::setWebChannel(QWebChannel *channel) @@ -441,12 +483,12 @@ void QWebEnginePage::setWebChannel(QWebChannel *channel) /*! \property QWebEnginePage::backgroundColor - \brief the page's background color, behing the document's body. + \brief the page's background color behind the document's body. \since 5.6 - You can set it to Qt::transparent or to a translucent - color to see through the document, or you can set this color to match your - web content in an hybrid app to prevent the white flashes that may appear + You can set the background color to Qt::transparent or to a translucent + color to see through the document, or you can set it to match your + web content in a hybrid application to prevent the white flashes that may appear during loading. The default value is white. @@ -478,7 +520,7 @@ QWidget *QWebEnginePage::view() const } /*! - Returns the QWebEngineProfile the page belongs to. + Returns the web engine profile the page belongs to. \since 5.5 */ QWebEngineProfile *QWebEnginePage::profile() const @@ -562,7 +604,7 @@ QAction *QWebEnginePage::action(WebAction action) const text = tr("Copy Link URL"); break; case DownloadLinkToDisk: - text = tr("Save Link..."); + text = tr("Save Link"); break; case CopyImageToClipboard: text = tr("Copy Image"); @@ -589,7 +631,13 @@ QAction *QWebEnginePage::action(WebAction action) const text = tr("Toggle Mute"); break; case DownloadMediaToDisk: - text = tr("Download Media"); + text = tr("Save Media"); + break; + case InspectElement: + text = tr("Inspect Element"); + break; + case ExitFullScreen: + text = tr("Exit Full Screen Mode"); break; default: break; @@ -755,6 +803,12 @@ void QWebEnginePage::triggerAction(WebAction action, bool) d->adapter->executeMediaPlayerActionAt(d->m_menuData.pos, WebContentsAdapter::MediaPlayerMute, enable); } break; + case InspectElement: + d->adapter->inspectElementAt(d->m_menuData.pos); + break; + case ExitFullScreen: + d->adapter->exitFullScreen(); + break; default: Q_UNREACHABLE(); } @@ -820,6 +874,18 @@ void QWebEnginePagePrivate::navigationRequested(int navigationType, const QUrl & navigationRequestAction = accepted ? WebContentsAdapterClient::AcceptRequest : WebContentsAdapterClient::IgnoreRequest; } +void QWebEnginePagePrivate::requestFullScreen(bool fullScreen) +{ + Q_Q(QWebEnginePage); + m_fullscreenRequested = fullScreen; + Q_EMIT q->fullScreenRequested(fullScreen); +} + +bool QWebEnginePagePrivate::isFullScreen() const +{ + return m_fullscreenRequested && q_ptr->isFullScreen(); +} + void QWebEnginePagePrivate::javascriptDialog(QSharedPointer<JavaScriptDialogController> controller) { Q_Q(QWebEnginePage); @@ -889,6 +955,14 @@ void QWebEnginePagePrivate::moveValidationMessage(const QRect &anchor) #endif } +void QWebEnginePagePrivate::renderProcessTerminated(RenderProcessTerminationStatus terminationStatus, + int exitCode) +{ + Q_Q(QWebEnginePage); + Q_EMIT q->renderProcessTerminated(static_cast<QWebEnginePage::RenderProcessTerminationStatus>( + terminationStatus), exitCode); +} + QMenu *QWebEnginePage::createStandardContextMenu() { Q_D(QWebEnginePage); @@ -950,6 +1024,12 @@ QMenu *QWebEnginePage::createStandardContextMenu() menu->addAction(QWebEnginePage::action(CopyImageToClipboard)); } + if (d->adapter->hasInspector()) + menu->addAction(QWebEnginePage::action(InspectElement)); + + if (d->isFullScreen()) + menu->addAction(QWebEnginePage::action(ExitFullScreen)); + return menu; } @@ -1201,6 +1281,15 @@ bool QWebEnginePage::acceptNavigationRequest(const QUrl &url, NavigationType typ return true; } +/*! + Returns \c true if the web view is in fullscreen mode, \c false otherwise. +*/ +bool QWebEnginePage::isFullScreen() +{ + Q_D(const QWebEnginePage); + return d->view ? d->view->isFullScreen() : false; +} + QT_END_NAMESPACE #include "moc_qwebenginepage.cpp" diff --git a/src/webenginewidgets/api/qwebenginepage.h b/src/webenginewidgets/api/qwebenginepage.h index 471fd72905fe41f4b17394d6bc7d0f049c410cf8..90fa62f97d57b50e7a43ab8e157c482e08756e1c 100644 --- a/src/webenginewidgets/api/qwebenginepage.h +++ b/src/webenginewidgets/api/qwebenginepage.h @@ -106,6 +106,9 @@ public: ToggleMediaMute, DownloadMediaToDisk, + InspectElement, + ExitFullScreen, + WebActionCount }; @@ -162,6 +165,14 @@ public: ErrorMessageLevel }; + // must match WebContentsAdapterClient::RenderProcessTerminationStatus + enum RenderProcessTerminationStatus { + NormalTerminationStatus = 0, + AbnormalTerminationStatus, + CrashedTerminationStatus, + KilledTerminationStatus + }; + explicit QWebEnginePage(QObject *parent = 0); QWebEnginePage(QWebEngineProfile *profile, QObject *parent = 0); ~QWebEnginePage(); @@ -234,6 +245,7 @@ Q_SIGNALS: void linkHovered(const QString &url); void selectionChanged(); + void fullScreenRequested(bool fullScreen); void geometryChangeRequested(const QRect& geom); void windowCloseRequested(); @@ -243,6 +255,8 @@ Q_SIGNALS: void authenticationRequired(const QUrl &requestUrl, QAuthenticator *authenticator); void proxyAuthenticationRequired(const QUrl &requestUrl, QAuthenticator *authenticator, const QString &proxyHost); + void renderProcessTerminated(RenderProcessTerminationStatus terminationStatus, int exitCode); + // Ex-QWebFrame signals void titleChanged(const QString &title); void urlChanged(const QUrl &url); @@ -258,8 +272,9 @@ protected: virtual void javaScriptConsoleMessage(JavaScriptConsoleMessageLevel level, const QString& message, int lineNumber, const QString& sourceID); virtual bool certificateError(const QWebEngineCertificateError &certificateError); virtual bool acceptNavigationRequest(const QUrl &url, NavigationType type, bool isMainFrame); - + virtual bool isFullScreen(); private: + Q_DISABLE_COPY(QWebEnginePage) Q_DECLARE_PRIVATE(QWebEnginePage) QScopedPointer<QWebEnginePagePrivate> d_ptr; #ifndef QT_NO_ACTION diff --git a/src/webenginewidgets/api/qwebenginepage_p.h b/src/webenginewidgets/api/qwebenginepage_p.h index e1561c3acb04eedbac0b8ccbd4648df6b3e94db6..8d9bc25177a06e04729bbc8db93d48e527c25467 100644 --- a/src/webenginewidgets/api/qwebenginepage_p.h +++ b/src/webenginewidgets/api/qwebenginepage_p.h @@ -37,6 +37,17 @@ #ifndef QWEBENGINEPAGE_P_H #define QWEBENGINEPAGE_P_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include "qwebenginepage.h" #include "qwebenginecallback_p.h" @@ -86,8 +97,8 @@ public: virtual void close() Q_DECL_OVERRIDE; virtual bool contextMenuRequested(const QtWebEngineCore::WebEngineContextMenuData &data) Q_DECL_OVERRIDE; virtual void navigationRequested(int navigationType, const QUrl &url, int &navigationRequestAction, bool isMainFrame) Q_DECL_OVERRIDE; - virtual void requestFullScreen(bool) Q_DECL_OVERRIDE { } - virtual bool isFullScreen() const Q_DECL_OVERRIDE { return false; } + virtual void requestFullScreen(bool) Q_DECL_OVERRIDE; + virtual bool isFullScreen() const Q_DECL_OVERRIDE; virtual void javascriptDialog(QSharedPointer<QtWebEngineCore::JavaScriptDialogController>) Q_DECL_OVERRIDE; virtual void runFileChooser(QtWebEngineCore::FilePickerController *controller) Q_DECL_OVERRIDE; virtual void didRunJavaScript(quint64 requestId, const QVariant& result) Q_DECL_OVERRIDE; @@ -96,7 +107,7 @@ public: virtual void didFindText(quint64 requestId, int matchCount) Q_DECL_OVERRIDE; virtual void passOnFocus(bool reverse) Q_DECL_OVERRIDE; virtual void javaScriptConsoleMessage(JavaScriptConsoleMessageLevel level, const QString& message, int lineNumber, const QString& sourceID) Q_DECL_OVERRIDE; - virtual void authenticationRequired(const QUrl &requestUrl, const QString &realm, bool isProxy, const QString &challengingHost, QString *outUser, QString *outPassword) Q_DECL_OVERRIDE; + virtual void authenticationRequired(QSharedPointer<QtWebEngineCore::AuthenticationDialogController>) Q_DECL_OVERRIDE; virtual void runMediaAccessPermissionRequest(const QUrl &securityOrigin, MediaRequestFlags requestFlags) Q_DECL_OVERRIDE; virtual void runGeolocationPermissionRequest(const QUrl &securityOrigin) Q_DECL_OVERRIDE; virtual void runMouseLockPermissionRequest(const QUrl &securityOrigin) Q_DECL_OVERRIDE; @@ -108,6 +119,8 @@ public: virtual void showValidationMessage(const QRect &anchor, const QString &mainText, const QString &subText) Q_DECL_OVERRIDE; virtual void hideValidationMessage() Q_DECL_OVERRIDE; virtual void moveValidationMessage(const QRect &anchor) Q_DECL_OVERRIDE; + virtual void renderProcessTerminated(RenderProcessTerminationStatus terminationStatus, + int exitCode) Q_DECL_OVERRIDE; virtual QtWebEngineCore::BrowserContextAdapter *browserContextAdapter() Q_DECL_OVERRIDE; @@ -128,6 +141,7 @@ public: bool isLoading; QWebEngineScriptCollection scriptCollection; QColor m_backgroundColor; + bool m_fullscreenRequested; mutable QtWebEngineCore::CallbackDirectory m_callbacks; mutable QAction *actions[QWebEnginePage::WebActionCount]; diff --git a/src/webenginewidgets/api/qwebengineprofile.cpp b/src/webenginewidgets/api/qwebengineprofile.cpp index 29010b0ddd9cffdc255c7c9442cfebb68655e2d6..323659827825179e376eaa69652ba8affd77f51f 100644 --- a/src/webenginewidgets/api/qwebengineprofile.cpp +++ b/src/webenginewidgets/api/qwebengineprofile.cpp @@ -42,7 +42,7 @@ #include "qwebenginepage.h" #include "qwebengineprofile_p.h" #include "qwebenginesettings.h" -#include "qwebengineurlschemehandler_p_p.h" +#include "qwebengineurlschemehandler_p.h" #include "qwebenginescriptcollection_p.h" #include "browser_context_adapter.h" @@ -60,30 +60,37 @@ using QtWebEngineCore::BrowserContextAdapter; \inmodule QtWebEngineWidgets - QWebEngineProfile contains settings and history shared by all QWebEnginePages that belong - to the profile. + QWebEngineProfile contains settings, scripts, and the list of visited links shared by all + web engine pages that belong to the profile. As such, profiles can be used to isolate pages + from each other. A typical use case is a dedicated profile for a 'private browsing' mode. - A default profile is built-in that all web pages not specifically created with another profile - belongs to. + The default profile is a built-in profile that all web pages not specifically created with + another profile belong to. */ /*! \enum QWebEngineProfile::HttpCacheType - This enum describes the HTTP cache types QtWebEngine can be configured to use. + This enum describes the HTTP cache type: - \value MemoryHttpCache Use a in-memory cache. This is the only setting possible if off-the-record is set or no cache path is available. + \value MemoryHttpCache Use an in-memory cache. This is the only setting possible if + \c off-the-record is set or no cache path is available. \value DiskHttpCache Use a disk cache. This is the default. */ /*! \enum QWebEngineProfile::PersistentCookiesPolicy - This enum describes policy for cookie persistency. + This enum describes policy for cookie persistency: - \value NoPersistentCookies Both session and persistent cookies are stored in memory. This is the only setting possible if off-the-record is set or no persistent data path is available. - \value AllowPersistentCookies Cookies marked persistent are save and restored from disk, session cookies are only stored to disk for crash recovery. This is the default setting. - \value ForcePersistentCookies Both session and persistent cookies are save and restored from disk. + \value NoPersistentCookies + Both session and persistent cookies are stored in memory. This is the only setting + possible if \c off-the-record is set or no persistent data path is available. + \value AllowPersistentCookies + Cookies marked persistent are saved to and restored from disk, whereas session cookies + are only stored to disk for crash recovery. This is the default setting. + \value ForcePersistentCookies + Both session and persistent cookies are saved to and restored from disk. */ /*! @@ -93,12 +100,11 @@ using QtWebEngineCore::BrowserContextAdapter; This signal is emitted whenever a download has been triggered. The \a download argument holds the state of the download. - The \a download either has to be explicitly accepted with - QWebEngineDownloadItem::accept(), else the download will be + The download has to be explicitly accepted with QWebEngineDownloadItem::accept() or it will be cancelled by default. - The download item is parented by the profile, but if not accepted + The download item is parented by the profile. If it is not accepted, it will be deleted immediately after the signal emission. - This signal can not be used with a queued connection. + This signal cannot be used with a queued connection. \sa QWebEngineDownloadItem */ @@ -184,10 +190,10 @@ void QWebEngineProfilePrivate::downloadUpdated(const DownloadItemInfo &info) } /*! - Constructs a new off-the-record profile. + Constructs a new off-the-record profile with the parent \a parent. An off-the-record profile leaves no record on the local machine, and has no persistent data or cache. - Thus, the HTTP cache can only be in memory and the cookies only be non-persistent, trying to change + Thus, the HTTP cache can only be in memory and the cookies can only be non-persistent. Trying to change these settings will have no effect. \sa isOffTheRecord() @@ -200,7 +206,7 @@ QWebEngineProfile::QWebEngineProfile(QObject *parent) } /*! - Constructs a new profile with storage name \a storageName. + Constructs a new profile with the storage name \a storageName and parent \a parent. The storage name must be unique. @@ -243,7 +249,7 @@ QString QWebEngineProfile::storageName() const } /*! - Returns true if this is an off-the-record profile that leaves no record on the computer. + Returns \c true if this is an off-the-record profile that leaves no record on the computer. This will force cookies and HTTP cache to be in memory, but also force all other normally persistent data to be stored in memory. @@ -257,9 +263,10 @@ bool QWebEngineProfile::isOffTheRecord() const /*! Returns the path used to store persistent data for the browser and web content. - Persistent data includes persistent cookies, HTML5 local storage and visited links. + Persistent data includes persistent cookies, HTML5 local storage, and visited links. - By default this is below QStandardPaths::writableLocation(QStandardPaths::DataLocation) in a storage name specific directory. + By default, this is below QStandardPaths::writableLocation() in a storage name specific + directory. \sa setPersistentStoragePath(), storageName(), QStandardPaths::writableLocation() */ @@ -272,7 +279,7 @@ QString QWebEngineProfile::persistentStoragePath() const /*! Overrides the default path used to store persistent web engine data. - If set to the null string, the default path is restored. + If \a path is set to the null string, the default path is restored. \sa persistentStoragePath() */ @@ -285,7 +292,8 @@ void QWebEngineProfile::setPersistentStoragePath(const QString &path) /*! Returns the path used for caches. - By default this is below QStandardPaths::writableLocation(QStandardPaths::CacheLocation) in a storage name specific directory. + By default, this is below QStandardPaths::writableLocation() in a storage name specific + directory. \sa setCachePath(), storageName(), QStandardPaths::writableLocation() */ @@ -296,7 +304,7 @@ QString QWebEngineProfile::cachePath() const } /*! - Overrides the default path used for disk caches. + Overrides the default path used for disk caches, setting it to \a path. If set to the null string, the default path is restored. @@ -309,7 +317,7 @@ void QWebEngineProfile::setCachePath(const QString &path) } /*! - Returns the user-agent string send with HTTP to identify the browser. + Returns the user-agent string sent with HTTP to identify the browser. \sa setHttpUserAgent() */ @@ -333,7 +341,7 @@ void QWebEngineProfile::setHttpUserAgent(const QString &userAgent) /*! Returns the type of HTTP cache used. - If the profile is off-the-record MemoryHttpCache is returned. + If the profile is off-the-record, MemoryHttpCache is returned. \sa setHttpCacheType(), cachePath() */ @@ -355,7 +363,7 @@ void QWebEngineProfile::setHttpCacheType(QWebEngineProfile::HttpCacheType httpCa } /*! - Sets the value of the Accept-Language HTTP request-header field. + Sets the value of the Accept-Language HTTP request-header field to \a httpAcceptLanguage. \since 5.6 */ @@ -379,7 +387,7 @@ QString QWebEngineProfile::httpAcceptLanguage() const /*! Returns the current policy for persistent cookies. - If the profile is off-the-record NoPersistentCookies is returned. + If the profile is off-the-record, NoPersistentCookies is returned. \sa setPersistentCookiesPolicy() */ @@ -401,9 +409,9 @@ void QWebEngineProfile::setPersistentCookiesPolicy(QWebEngineProfile::Persistent } /*! - Returns the maximum size of the HTTP size. + Returns the maximum size of the HTTP cache in bytes. - Will return 0 if the size is automatically controlled by QtWebEngine. + Will return \c 0 if the size is automatically controlled by QtWebEngine. \sa setHttpCacheMaximumSize(), httpCacheType() */ @@ -414,9 +422,9 @@ int QWebEngineProfile::httpCacheMaximumSize() const } /*! - Sets the maximum size of the HTTP cache to \a maxSize. + Sets the maximum size of the HTTP cache to \a maxSize bytes. - Setting it to 0 means the size will be controlled automatically by QtWebEngine. + Setting it to \c 0 means the size will be controlled automatically by QtWebEngine. \sa httpCacheMaximumSize(), setHttpCacheType() */ @@ -426,18 +434,38 @@ void QWebEngineProfile::setHttpCacheMaximumSize(int maxSize) d->browserContext()->setHttpCacheMaxSize(maxSize); } +/*! + Returns the cookie store client singleton, if one has been set. +*/ + QWebEngineCookieStoreClient* QWebEngineProfile::cookieStoreClient() { Q_D(QWebEngineProfile); return d->browserContext()->cookieStoreClient(); } +/*! + Registers a cookie store client singleton \a client to access Chromium's cookies. + + The profile does not take ownership of the pointer. + + \sa QWebEngineCookieStoreClient +*/ + void QWebEngineProfile::setCookieStoreClient(QWebEngineCookieStoreClient *client) { Q_D(QWebEngineProfile); d->browserContext()->setCookieStoreClient(client); } +/*! + Registers a request interceptor singleton \a interceptor to intercept URL requests. + + The profile does not take ownership of the pointer. + + \sa QWebEngineUrlRequestInfo +*/ + void QWebEngineProfile::setRequestInterceptor(QWebEngineUrlRequestInterceptor *interceptor) { Q_D(QWebEngineProfile); @@ -467,7 +495,7 @@ void QWebEngineProfile::clearVisitedLinks(const QList<QUrl> &urls) } /*! - Returns true if \a url is considered a visited link by this profile. + Returns \c true if \a url is considered a visited link by this profile. */ bool QWebEngineProfile::visitedLinksContainsUrl(const QUrl &url) const { @@ -509,10 +537,16 @@ QWebEngineSettings *QWebEngineProfile::settings() const return d->settings(); } -QWebEngineUrlSchemeHandler *QWebEngineProfilePrivate::urlSchemeHandler(const QByteArray &protocol) +/*! + \since 5.6 + + Returns the custom URL scheme handler register for the URL scheme \a scheme. +*/ +const QWebEngineUrlSchemeHandler *QWebEngineProfile::urlSchemeHandler(const QByteArray &scheme) const { - if (m_urlSchemeHandlers.contains(protocol)) - return m_urlSchemeHandlers.value(protocol); + const Q_D(QWebEngineProfile); + if (d->m_urlSchemeHandlers.contains(scheme)) + return d->m_urlSchemeHandlers.value(scheme); return 0; } @@ -526,8 +560,14 @@ static bool checkInternalScheme(const QByteArray &scheme) return internalSchemes.contains(scheme); } -void QWebEngineProfilePrivate::installUrlSchemeHandler(QWebEngineUrlSchemeHandler *handler) +/*! + \since 5.6 + + Installs the custom URL scheme handler \a handler in the profile. +*/ +void QWebEngineProfile::installUrlSchemeHandler(QWebEngineUrlSchemeHandler *handler) { + Q_D(QWebEngineProfile); Q_ASSERT(handler); QByteArray scheme = handler->scheme(); if (checkInternalScheme(scheme)) { @@ -535,29 +575,51 @@ void QWebEngineProfilePrivate::installUrlSchemeHandler(QWebEngineUrlSchemeHandle return; } - if (m_urlSchemeHandlers.contains(scheme)) { + if (d->m_urlSchemeHandlers.contains(scheme)) { qWarning() << "URL scheme handler already installed for the scheme: " << scheme; return; } - m_urlSchemeHandlers.insert(scheme, handler); - browserContext()->customUrlSchemeHandlers().append(handler->d_func()); - browserContext()->updateCustomUrlSchemeHandlers(); + d->m_urlSchemeHandlers.insert(scheme, handler); + d->browserContext()->customUrlSchemeHandlers().append(handler->d_func()); + d->browserContext()->updateCustomUrlSchemeHandlers(); + connect(handler, SIGNAL(destroyed(QObject*)), this, SLOT(destroyedUrlSchemeHandler(QObject*))); } -void QWebEngineProfilePrivate::removeUrlSchemeHandler(QWebEngineUrlSchemeHandler *handler) +/*! + \since 5.6 + + Removes the custom URL scheme handler \a handler from the profile +*/ +void QWebEngineProfile::removeUrlSchemeHandler(QWebEngineUrlSchemeHandler *handler) { - int count = m_urlSchemeHandlers.remove(handler->scheme()); + Q_D(QWebEngineProfile); + Q_ASSERT(handler); + if (!handler) + return; + int count = d->m_urlSchemeHandlers.remove(handler->scheme()); if (!count) return; - browserContext()->customUrlSchemeHandlers().removeOne(handler->d_func()); - browserContext()->updateCustomUrlSchemeHandlers(); + disconnect(handler, SIGNAL(destroyed(QObject*)), this, SLOT(destroyedUrlSchemeHandler(QObject*))); + d->browserContext()->removeCustomUrlSchemeHandler(handler->d_func()); + d->browserContext()->updateCustomUrlSchemeHandlers(); +} + +/*! + \since 5.6 + + Removes all custom URL scheme handlers installed in the profile. +*/ +void QWebEngineProfile::clearUrlSchemeHandlers() +{ + Q_D(QWebEngineProfile); + d->m_urlSchemeHandlers.clear(); + d->browserContext()->customUrlSchemeHandlers().clear(); + d->browserContext()->updateCustomUrlSchemeHandlers(); } -void QWebEngineProfilePrivate::clearUrlSchemeHandlers() +void QWebEngineProfile::destroyedUrlSchemeHandler(QObject *obj) { - m_urlSchemeHandlers.clear(); - browserContext()->customUrlSchemeHandlers().clear(); - browserContext()->updateCustomUrlSchemeHandlers(); + removeUrlSchemeHandler(qobject_cast<QWebEngineUrlSchemeHandler*>(obj)); } QT_END_NAMESPACE diff --git a/src/webenginewidgets/api/qwebengineprofile.h b/src/webenginewidgets/api/qwebengineprofile.h index 06e11eeca830bd00814e4f4d09305f781f98704a..5532f12ee8eeadcba9b6ea279af0557f4516eaf8 100644 --- a/src/webenginewidgets/api/qwebengineprofile.h +++ b/src/webenginewidgets/api/qwebengineprofile.h @@ -55,6 +55,7 @@ class QWebEngineProfilePrivate; class QWebEngineSettings; class QWebEngineScriptCollection; class QWebEngineUrlRequestInterceptor; +class QWebEngineUrlSchemeHandler; class QWEBENGINEWIDGETS_EXPORT QWebEngineProfile : public QObject { Q_OBJECT @@ -109,12 +110,21 @@ public: QWebEngineSettings *settings() const; QWebEngineScriptCollection *scripts() const; + const QWebEngineUrlSchemeHandler *urlSchemeHandler(const QByteArray &) const; + void installUrlSchemeHandler(QWebEngineUrlSchemeHandler *); + void removeUrlSchemeHandler(QWebEngineUrlSchemeHandler *); + void clearUrlSchemeHandlers(); + static QWebEngineProfile *defaultProfile(); Q_SIGNALS: void downloadRequested(QWebEngineDownloadItem *download); +private Q_SLOTS: + void destroyedUrlSchemeHandler(QObject *obj); + private: + Q_DISABLE_COPY(QWebEngineProfile) Q_DECLARE_PRIVATE(QWebEngineProfile) QWebEngineProfile(QWebEngineProfilePrivate *, QObject *parent = 0); diff --git a/src/webenginewidgets/api/qwebengineprofile_p.h b/src/webenginewidgets/api/qwebengineprofile_p.h index 55941580dfbe8da02b76db4607131b43efe40176..8ba64c43849c4e30f0fbd36411e5ea4f4d4bc668 100644 --- a/src/webenginewidgets/api/qwebengineprofile_p.h +++ b/src/webenginewidgets/api/qwebengineprofile_p.h @@ -37,6 +37,17 @@ #ifndef QWEBENGINEPROFILE_P_H #define QWEBENGINEPROFILE_P_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include "browser_context_adapter_client.h" #include "qwebengineprofile.h" #include "qwebengineurlschemehandler_p.h" @@ -68,18 +79,13 @@ public: void downloadRequested(DownloadItemInfo &info) Q_DECL_OVERRIDE; void downloadUpdated(const DownloadItemInfo &info) Q_DECL_OVERRIDE; - QWebEngineUrlSchemeHandler *urlSchemeHandler(const QByteArray &); - void installUrlSchemeHandler(QWebEngineUrlSchemeHandler *); - void removeUrlSchemeHandler(QWebEngineUrlSchemeHandler *); - void clearUrlSchemeHandlers(); - private: QWebEngineProfile *q_ptr; QWebEngineSettings *m_settings; QScopedPointer<QWebEngineScriptCollection> m_scriptCollection; QExplicitlySharedDataPointer<QtWebEngineCore::BrowserContextAdapter> m_browserContextRef; QMap<quint32, QPointer<QWebEngineDownloadItem> > m_ongoingDownloads; - QMap<QByteArray, QPointer<QWebEngineUrlSchemeHandler> > m_urlSchemeHandlers; + QMap<QByteArray, QWebEngineUrlSchemeHandler *> m_urlSchemeHandlers; }; QT_END_NAMESPACE diff --git a/src/webenginewidgets/api/qwebenginescript.cpp b/src/webenginewidgets/api/qwebenginescript.cpp index e834c5067ae928819fa18b8a92dfcec858d745cf..1bd56604db4485fee66d54de507319219eda670f 100644 --- a/src/webenginewidgets/api/qwebenginescript.cpp +++ b/src/webenginewidgets/api/qwebenginescript.cpp @@ -46,26 +46,28 @@ using QtWebEngineCore::UserScript; \inmodule QtWebEngineWidgets \since 5.5 \brief The QWebEngineScript class encapsulates a JavaScript program. - \preliminary - QWebEngineScript allows the programatic injection of so called "user scripts" in the - javascript engine at different points, determined by injectionPoint(), during the loading of web contents. - Scripts can be executed either in the main javascript world, along with the rest of the JavaScript coming - from the web contents, or in their own isolated world. While the DOM of the page can be accessed from any world, - JavaScript variables a function defined in one world are not accessible from a different one. - ScriptWorldId provides some predefined ids for this purpose. + QWebEngineScript enables the programmatic injection of so called \e {user scripts} in the + JavaScript engine at different points, determined by injectionPoint(), during the loading of web + contents. + + Scripts can be executed either in the main JavaScript \e world, along with the rest of the + JavaScript coming from the web contents, or in their own isolated world. While the DOM of the + page can be accessed from any world, JavaScript variables of a function defined in one world are + not accessible from a different one. ScriptWorldId provides some predefined IDs for this + purpose. */ /*! \enum QWebEngineScript::InjectionPoint - This enum describes the timing for when the script injection should happen. + This enum describes the timing of the script injection: \value DocumentCreation The script will be executed as soon as the document is created. This is not suitable for any DOM operation. - \value DocumentReady The script will run as soon as the DOM is ready. This is equivalent to the DOMContentLoaded - event firing in JavaScript. + \value DocumentReady The script will run as soon as the DOM is ready. This is equivalent to the + \c DOMContentLoaded event firing in JavaScript. \value Deferred The script will run when the page load finishes, or 500ms after the document is ready, whichever comes first. @@ -73,20 +75,30 @@ using QtWebEngineCore::UserScript; /*! \enum QWebEngineScript::ScriptWorldId - This enum provides pre defined world ids for isolating user scripts into different worlds. + This enum provides pre-defined world IDs for isolating user scripts into different worlds: \value MainWorld The world used by the page's web contents. It can be useful in order to expose custom functionality to web contents in certain scenarios. \value ApplicationWorld The default isolated world used for application level functionality implemented in JavaScript. \value UserWorld The first isolated world to be used by scripts set by users if the application is not making use - of more worlds. As a rule of thumbs, if that functionality is exposed to the application users, each individual script + of more worlds. As a rule of thumb, if that functionality is exposed to the application users, each individual script should probably get its own isolated world. */ /*! - * \brief QWebEngineScript::QWebEngineScript - * + \fn QWebEngineScript::operator!=(const QWebEngineScript &other) const + + Returns \c true if the script is not equal to \a other, otherwise returns \c false. +*/ + +/*! + \fn QWebEngineScript::swap(QWebEngineScript &other) + + Swaps the contents of the script with the contents of \a other. +*/ + +/*! * Constructs a null script. */ @@ -94,34 +106,42 @@ QWebEngineScript::QWebEngineScript() : d(new UserScript) { } + /*! - * \brief QWebEngineScript::isNull - * \return \c true is the script is null, \c false otherwise. + * Constructs a user script using the contents of \a other. */ - QWebEngineScript::QWebEngineScript(const QWebEngineScript &other) : d(other.d) { } +/*! + Destroys a script. +*/ QWebEngineScript::~QWebEngineScript() { } +/*! + Assigns \a other to the script. +*/ QWebEngineScript &QWebEngineScript::operator=(const QWebEngineScript &other) { d = other.d; return *this; } +/*! + Returns \c true is the script is null; otherwise returns \c false. +*/ bool QWebEngineScript::isNull() const { return d->isNull(); } /*! - * \brief QWebEngineScript::name - * \return The name of the script. Can be useful to retrieve a given script from a QWebEngineScriptCollection. + * Returns the name of the script. Can be useful to retrieve a particular script from a + * QWebEngineScriptCollection. * * \sa QWebEngineScriptCollection::findScript(), QWebEngineScriptCollection::findScripts() */ @@ -132,9 +152,6 @@ QString QWebEngineScript::name() const } /*! - * \brief QWebEngineScript::setName - * \param scriptName - * * Sets the script name to \a scriptName. */ void QWebEngineScript::setName(const QString &scriptName) @@ -145,8 +162,7 @@ void QWebEngineScript::setName(const QString &scriptName) } /*! - * \brief QWebEngineScript::sourceCode - * \return the source of the script. + Returns the source of the script. */ QString QWebEngineScript::sourceCode() const { @@ -154,8 +170,6 @@ QString QWebEngineScript::sourceCode() const } /*! - * \brief QWebEngineScript::setSourceCode - * \param scriptSource * Sets the script source to \a scriptSource. */ void QWebEngineScript::setSourceCode(const QString &scriptSource) @@ -170,8 +184,7 @@ ASSERT_ENUMS_MATCH(QWebEngineScript::DocumentReady, UserScript::DocumentLoadFini ASSERT_ENUMS_MATCH(QWebEngineScript::DocumentCreation, UserScript::DocumentElementCreation) /*! - * \brief QWebEngineScript::injectionPoint - * \return the point in the loading process at which the script will be executed. + * Returns the point in the loading process at which the script will be executed. * The default value is QWebEngineScript::Deferred. * * \sa setInjectionPoint @@ -181,9 +194,7 @@ QWebEngineScript::InjectionPoint QWebEngineScript::injectionPoint() const return static_cast<QWebEngineScript::InjectionPoint>(d->injectionPoint()); } /*! - * \brief QWebEngineScript::setInjectionPoint - * \param p - * Sets the point at which to execute the script to be \p. + * Sets the point at which to execute the script to be \a p. * * \sa QWebEngineScript::InjectionPoint */ @@ -195,8 +206,7 @@ void QWebEngineScript::setInjectionPoint(QWebEngineScript::InjectionPoint p) } /*! - * \brief QWebEngineScript::worldId - * \return the world id defining which world the script is executed in. + Returns the world ID defining which world the script is executed in. */ quint32 QWebEngineScript::worldId() const { @@ -204,9 +214,7 @@ quint32 QWebEngineScript::worldId() const } /*! - * \brief QWebEngineScript::setWorldId - * \param id - * Sets the world id of the isolated world to use when running this script. + Sets the world ID of the isolated world to \a id when running this script. */ void QWebEngineScript::setWorldId(quint32 id) { @@ -216,8 +224,8 @@ void QWebEngineScript::setWorldId(quint32 id) } /*! - * \brief QWebEngineScript::runsOnSubFrames - * \return \c true if the script is executed on every frame in the page, \c false if it is only ran for the main frame. + Returns \c true if the script is executed on every frame in the page, or \c false if it is only + ran for the main frame. */ bool QWebEngineScript::runsOnSubFrames() const { @@ -225,9 +233,7 @@ bool QWebEngineScript::runsOnSubFrames() const } /*! - * \brief QWebEngineScript::setRunsOnSubFrames - * \param on - * Sets whether or not the script is executed on sub frames in addition to the main frame. + * Executes the script on sub frames in addition to the main frame if \a on returns \c true. */ void QWebEngineScript::setRunsOnSubFrames(bool on) { @@ -237,9 +243,7 @@ void QWebEngineScript::setRunsOnSubFrames(bool on) } /*! - * \brief QWebEngineScript::operator == - * \param other - * \return \c true if this QWebEngineScript is equal to \a other, otherwise returns \c false. + Returns \c true if the script is equal to \a other, otherwise returns \c false. */ bool QWebEngineScript::operator==(const QWebEngineScript &other) const { diff --git a/src/webenginewidgets/api/qwebenginescriptcollection.cpp b/src/webenginewidgets/api/qwebenginescriptcollection.cpp index 21cb0d05e162dd880cf9bc087e12423117ebb2b6..80a7f9b6ea2126dfe0d607182bd9ebe46cd8b39c 100644 --- a/src/webenginewidgets/api/qwebenginescriptcollection.cpp +++ b/src/webenginewidgets/api/qwebenginescriptcollection.cpp @@ -49,18 +49,32 @@ using QtWebEngineCore::UserScript; */ +/*! + \fn QWebEngineScriptCollection::isEmpty() const + + Returns \c true if the collection is empty; otherwise returns \c false. +*/ + +/*! + \fn QWebEngineScriptCollection::size() const + + Returns the number of elements in the collection. +*/ + QWebEngineScriptCollection::QWebEngineScriptCollection(QWebEngineScriptCollectionPrivate *collectionPrivate) :d(collectionPrivate) { } +/*! + Destroys the collection. +*/ QWebEngineScriptCollection::~QWebEngineScriptCollection() { } /*! - * \brief QWebEngineScriptCollection::count - * \return the number of elements in the collection. + Returns the number of elements in the collection. */ int QWebEngineScriptCollection::count() const @@ -69,9 +83,8 @@ int QWebEngineScriptCollection::count() const } /*! - * \brief QWebEngineScriptCollection::contains - * \param value - * \return \c true if the collection contains an occurrence of \a value; otherwise returns false. + Returns \c true if the collection contains an occurrence of \a value; otherwise returns + \c false. */ bool QWebEngineScriptCollection::contains(const QWebEngineScript &value) const @@ -80,11 +93,10 @@ bool QWebEngineScriptCollection::contains(const QWebEngineScript &value) const } /*! - * \brief QWebEngineScriptCollection::findScript - * \param name - * \return the first script found in collection the name property of which is \a name, or a null QWebEngineScript if none was found. - * \note the order in which the script collection is traversed is undefined, which means this should be used when the unicity is - * guaranteed at the application level. + * Returns the first script found in the collection with the name \a name, or a null + * QWebEngineScript if none was found. + * \note The order in which the script collection is traversed is undefined, which means this should + * be used when the unicity is guaranteed at the application level. * \sa findScripts() */ @@ -94,9 +106,8 @@ QWebEngineScript QWebEngineScriptCollection::findScript(const QString &name) con } /*! - * \brief QWebEngineScriptCollection::findScripts - * \param name - * \return the list of scripts in the collection the name property of which is \a name, or an empty list if none was found. + Returns the list of scripts in the collection with the name \a name, or an empty list if none + was found. */ QList<QWebEngineScript> QWebEngineScriptCollection::findScripts(const QString &name) const @@ -104,20 +115,14 @@ QList<QWebEngineScript> QWebEngineScriptCollection::findScripts(const QString &n return d->toList(name); } /*! - * \brief QWebEngineScriptCollection::insert - * \param s - * - * Inserts script \c s into the collection. + Inserts the script \a s into the collection. */ void QWebEngineScriptCollection::insert(const QWebEngineScript &s) { d->insert(s); } /*! - * \brief QWebEngineScriptCollection::insert - * \param list - * - * Inserts scripts \c list into the collection. + Inserts scripts from the list \a list into the collection. */ void QWebEngineScriptCollection::insert(const QList<QWebEngineScript> &list) { @@ -127,10 +132,10 @@ void QWebEngineScriptCollection::insert(const QList<QWebEngineScript> &list) } /*! - * \brief QWebEngineScriptCollection::remove - * \param script - * Removes \a script from the collection, if it is present. - * \return \c true if the script was found and successfully removed from the collection, \c false otherwise. + Removes \a script from the collection. + + Returns \c true if the script was found and successfully removed from the collection; otherwise + returns \c false. */ bool QWebEngineScriptCollection::remove(const QWebEngineScript &script) { @@ -138,7 +143,6 @@ bool QWebEngineScriptCollection::remove(const QWebEngineScript &script) } /*! - * \brief QWebEngineScriptCollection::clear * Removes all scripts from this collection. */ void QWebEngineScriptCollection::clear() @@ -147,8 +151,7 @@ void QWebEngineScriptCollection::clear() } /*! - * \brief QWebEngineScriptCollection::toList - * \return a QList with the values of the scripts used in this collection. + Returns a list with the values of the scripts used in this collection. */ QList<QWebEngineScript> QWebEngineScriptCollection::toList() const { diff --git a/src/webenginewidgets/api/qwebenginescriptcollection_p.h b/src/webenginewidgets/api/qwebenginescriptcollection_p.h index 76267c70c3f9f19439903c8e6cf4d2da9031a4da..cc6e884457a504770ae05d0fc84e6950b135ce83 100644 --- a/src/webenginewidgets/api/qwebenginescriptcollection_p.h +++ b/src/webenginewidgets/api/qwebenginescriptcollection_p.h @@ -37,6 +37,17 @@ #ifndef QWEBENGINESCRIPTCOLLECTION_P_H #define QWEBENGINESCRIPTCOLLECTION_P_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include "qtwebenginewidgetsglobal.h" #include "qwebenginescript.h" diff --git a/src/webenginewidgets/api/qwebenginesettings.cpp b/src/webenginewidgets/api/qwebenginesettings.cpp index aaa93ab9f65dcf4fe9943ca77f0612675441d3bc..430d64185907664ebe8aa221b85a1ed746fdff66 100644 --- a/src/webenginewidgets/api/qwebenginesettings.cpp +++ b/src/webenginewidgets/api/qwebenginesettings.cpp @@ -74,6 +74,8 @@ static WebEngineSettings::Attribute toWebEngineAttribute(QWebEngineSettings::Web return WebEngineSettings::ErrorPageEnabled; case QWebEngineSettings::PluginsEnabled: return WebEngineSettings::PluginsEnabled; + case QWebEngineSettings::FullScreenSupportEnabled: + return WebEngineSettings::FullScreenSupportEnabled; default: return WebEngineSettings::UnsupportedInCoreSettings; } @@ -97,6 +99,11 @@ QWebEngineSettings *QWebEngineSettings::globalSettings() } #endif +/*! + Returns the default settings for the web engine page. + + \sa globalSettings() +*/ QWebEngineSettings *QWebEngineSettings::defaultSettings() { return QWebEngineProfile::defaultProfile()->settings(); diff --git a/src/webenginewidgets/api/qwebenginesettings.h b/src/webenginewidgets/api/qwebenginesettings.h index 50a93e393e8e9141092d6bcc23188fdf5d7f1d31..327fd447ba4d7f0ae42c1108f309ac957a3df84a 100644 --- a/src/webenginewidgets/api/qwebenginesettings.h +++ b/src/webenginewidgets/api/qwebenginesettings.h @@ -59,7 +59,8 @@ public: HyperlinkAuditingEnabled, ScrollAnimatorEnabled, ErrorPageEnabled, - PluginsEnabled + PluginsEnabled, + FullScreenSupportEnabled }; enum FontSize { diff --git a/src/webenginewidgets/api/qwebengineview.cpp b/src/webenginewidgets/api/qwebengineview.cpp index a4a8dd76085a64992de840fa741576a3c0062349..ddd1e4cbfd688a95f99149b5add041594c5ede65 100644 --- a/src/webenginewidgets/api/qwebengineview.cpp +++ b/src/webenginewidgets/api/qwebengineview.cpp @@ -86,6 +86,7 @@ void QWebEngineViewPrivate::bind(QWebEngineView *view, QWebEnginePage *page) QObject::connect(page, &QWebEnginePage::loadProgress, view, &QWebEngineView::loadProgress); QObject::connect(page, &QWebEnginePage::loadFinished, view, &QWebEngineView::loadFinished); QObject::connect(page, &QWebEnginePage::selectionChanged, view, &QWebEngineView::selectionChanged); + QObject::connect(page, &QWebEnginePage::renderProcessTerminated, view, &QWebEngineView::renderProcessTerminated); } } diff --git a/src/webenginewidgets/api/qwebengineview.h b/src/webenginewidgets/api/qwebengineview.h index 6b37dbf393651bc578f38cf37616a9c2fc55a92e..ae38e6c5c79de19fa08f07e16928e4a5bcf947f1 100644 --- a/src/webenginewidgets/api/qwebengineview.h +++ b/src/webenginewidgets/api/qwebengineview.h @@ -113,6 +113,8 @@ Q_SIGNALS: void selectionChanged(); void urlChanged(const QUrl&); void iconUrlChanged(const QUrl&); + void renderProcessTerminated(QWebEnginePage::RenderProcessTerminationStatus terminationStatus, + int exitCode); protected: virtual QWebEngineView *createWindow(QWebEnginePage::WebWindowType type); @@ -120,6 +122,7 @@ protected: virtual bool event(QEvent*) Q_DECL_OVERRIDE; private: + Q_DISABLE_COPY(QWebEngineView) Q_DECLARE_PRIVATE(QWebEngineView) QScopedPointer<QWebEngineViewPrivate> d_ptr; diff --git a/src/webenginewidgets/api/qwebengineview_p.h b/src/webenginewidgets/api/qwebengineview_p.h index b69a27ac229c9f64d330c4c8c270f41f0d25cfd3..af8bc70ac8a6333daa232538bf80572016f452d1 100644 --- a/src/webenginewidgets/api/qwebengineview_p.h +++ b/src/webenginewidgets/api/qwebengineview_p.h @@ -37,6 +37,17 @@ #ifndef QWEBENGINEVIEW_P_H #define QWEBENGINEVIEW_P_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include <QtWebEngineWidgets/qwebengineview.h> #include <QtWidgets/qaccessiblewidget.h> diff --git a/src/webenginewidgets/doc/qtwebenginewidgets.qdocconf b/src/webenginewidgets/doc/qtwebenginewidgets.qdocconf index ad1e46f1cb8bb6ac60c4e547b3f03e65d286646a..7b48b7a14176de7a4579b5134f16df33b3bd3121 100644 --- a/src/webenginewidgets/doc/qtwebenginewidgets.qdocconf +++ b/src/webenginewidgets/doc/qtwebenginewidgets.qdocconf @@ -29,11 +29,15 @@ qhp.QtWebEngineWidgets.subprojects.examples.sortPages = true tagfile = ../../../doc/qtwebenginewidgets/qtwebenginewidgets.tags -depends += qtwebengine qtcore qtnetwork qtgui qtwidgets qtwebkit qtdoc +depends += qtwebengine qtcore qtnetwork qtgui qtwidgets qtwebkit qtdoc qtwebchannel headerdirs += ../api -sourcedirs += ../api -exampledirs += ../../../examples/webenginewidgets . +sourcedirs += ../api src + +exampledirs += ../../../examples/webenginewidgets \ + snippets navigation.landingpage = "Qt WebEngine Widgets" navigation.cppclassespage = "Qt WebEngine Widgets C++ Classes" + +Cpp.ignoretokens += QWEBENGINEWIDGETS_EXPORT diff --git a/src/webenginewidgets/doc/src/qtwebenginewidgets-examples.qdoc b/src/webenginewidgets/doc/src/qtwebenginewidgets-examples.qdoc new file mode 100644 index 0000000000000000000000000000000000000000..eff22be26baaacfdc20f0c238d143cac3a8f3615 --- /dev/null +++ b/src/webenginewidgets/doc/src/qtwebenginewidgets-examples.qdoc @@ -0,0 +1,38 @@ +/* + Copyright (C) 2015 The Qt Company Ltd. + Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY + EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +/*! + \group webengine-widgetexamples + \title Qt WebEngine Widgets Examples + \brief Examples demonstrating the Qt WebEngine Widgets usage + \ingroup all-examples + + Qt provides an integrated Web browser component based on Chromium, the popular + open source browser engine. + + These examples and demonstrations show a range of different uses for Qt WebEngine, + from displaying Web pages within a Qt user interface to an implementation of + a basic function Web browser. +*/ diff --git a/src/webenginewidgets/doc/src/qtwebenginewidgets.qdoc b/src/webenginewidgets/doc/src/qtwebenginewidgets-index.qdoc similarity index 50% rename from src/webenginewidgets/doc/src/qtwebenginewidgets.qdoc rename to src/webenginewidgets/doc/src/qtwebenginewidgets-index.qdoc index ed1f1a7738ca8cf51fe1ab517e79ef3acb27e798..77596a3705b9576a97de3c7b1e0a4ae4976ffe29 100644 --- a/src/webenginewidgets/doc/src/qtwebenginewidgets.qdoc +++ b/src/webenginewidgets/doc/src/qtwebenginewidgets-index.qdoc @@ -25,95 +25,30 @@ ** ****************************************************************************/ -/*! - \module QtWebEngineWidgets - \title Qt WebEngine Widgets C++ Classes - \brief Provides a web browser engine as well as C++ classes to render and - interact with web content - - To include the definitions of the module's classes, use the - following directive: - - \snippet snippets/qtwebengine_build_snippet.qdoc 1 - - To link against the module, add this line to your \l qmake \c - .pro file: - - \snippet snippets/qtwebengine_build_snippet.qdoc 0 -*/ - /*! \page qtwebenginewidgets-index.html \title Qt WebEngine Widgets \ingroup modules - \brief The Qt WebEngine Widgets module provides a web browser engine as well as - C++ classes to render and interact with web content. - - Qt WebEngine Widgets provides a Web browser engine that makes it easy to embed - content from the World Wide Web into your Qt application. - - Qt WebEngine Widgets provides facilities for rendering of HyperText Markup - Language version 5 (HTML5), Extensible HyperText Markup Language (XHTML) and Scalable - Vector Graphics (SVG) documents, styled using Cascading Style Sheets (CSS) - and scripted with JavaScript. - - In addition to providing pure rendering features, HTML documents can be - made fully editable to the user through the use of the \c{contenteditable} - attribute on HTML elements. - - Qt WebEngine is based on the Chromium project. More information about - Chromium itself can be found on the \l{http://www.chromium.org} - {Chromium Project} Web site. - - \section1 Should I use Qt WebEngine or Qt WebKit? - - Qt WebEngine supercedes the \l{Qt WebKit Widgets}{Qt WebKit} module, which - was based on the WebKit project, but isn't actively synchronized with the - upstream WebKit code since Qt 5.2. - - Chromium provides its own network and painting engines and is developed - tightly together with its dependent modules, thus Qt WebEngine provides - better and more reliable support for the latest HTML5 specification. - For this reason Qt WebEngine is however heavier than Qt WebKit and doesn't - give direct access to the network stack and the HTML document through C++ APIs. - - For new code we suggest using Qt WebEngine, but it makes sense to continue - using Qt WebKit for applications that are in need of a deeper C++ API than - having better and up-to-date support for HTML, CSS and JavaScript features. + \brief Provides a web browser engine as well as C++ classes to render web content and interact + with it. - For tips on how to change a Qt WebKit application to use Qt WebEngine, see - \l{Porting from Qt WebKit to Qt WebEngine} - - \section1 Including In Your Project + \section1 Getting Started To include the definitions of the module's classes, use the following directive: - \snippet snippets/qtwebengine_build_snippet.qdoc 1 - - To link against the module, add this line to your \l qmake \c - .pro file: - - \snippet snippets/qtwebengine_build_snippet.qdoc 0 - - \section1 Architecture - - Use the QWebEngineView class to display web pages in the simplest way. - Because it's a widget, you can embed QWebEngineView into your forms and use - its convenience functions to download and display web sites. + \snippet qtwebengine_build_snippet.qdoc 1 - \snippet snippets/simple/main.cpp Using QWebEngineView + To link against the module, add this line to your qmake project file: - An instance of QWebEngineView has one QWebEnginePage. QWebEnginePage - provides access to the page's navigation history, ability to run JavaScript - code in the context of the page's main frame, and enables customization of - handlers for specific events like showing custom authentication dialogs. + \snippet qtwebengine_build_snippet.qdoc 0 - \section1 Reference Documentation + \section1 Articles and Guides \list - \li \l {Qt WebEngine Widgets C++ Classes} + \li \l{Qt WebEngine Overview} + \li \l{Porting from Qt WebKit to Qt WebEngine} \endlist \section1 Examples @@ -122,7 +57,14 @@ \li \l {Qt WebEngine Widgets Examples} \endlist + \section1 API Reference + + \list + \li \l {Qt WebEngine Widgets C++ Classes} + \endlist + \section1 License Information + This is a snapshot of the integration of Chromium into Qt. Qt Commercial Edition licensees that wish to distribute applications that @@ -166,17 +108,3 @@ \endlegalese */ - -/*! - \group webengine-widgetexamples - \title Qt WebEngine Widgets Examples - \brief Examples demonstrating the Qt WebEngine Widgets usage - \ingroup all-examples - - Qt provides an integrated Web browser component based on Chromium, the popular - open source browser engine. - - These examples and demonstrations show a range of different uses for Qt WebEngine, - from displaying Web pages within a Qt user interface to an implementation of - a basic function Web browser. -*/ diff --git a/src/webenginewidgets/doc/src/qtwebenginewidgets-module.qdoc b/src/webenginewidgets/doc/src/qtwebenginewidgets-module.qdoc new file mode 100644 index 0000000000000000000000000000000000000000..6373389f3c6fedbb696af78894dca5e15187c772 --- /dev/null +++ b/src/webenginewidgets/doc/src/qtwebenginewidgets-module.qdoc @@ -0,0 +1,43 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: http://www.gnu.org/copyleft/fdl.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \module QtWebEngineWidgets + \title Qt WebEngine Widgets C++ Classes + \brief Provides a web browser engine as well as C++ classes to render and + interact with web content + \ingroup qtwebengine-modules + + To include the definitions of the module's classes, use the + following directive: + + \snippet qtwebengine_build_snippet.qdoc 1 + + To link against the module, add the following to your qmake project file: + + \snippet qtwebengine_build_snippet.qdoc 0 +*/ diff --git a/src/webenginewidgets/doc/src/qwebenginehistory_lgpl.qdoc b/src/webenginewidgets/doc/src/qwebenginehistory_lgpl.qdoc index 08690e5049335e3554ca6093b3069c2181050189..5e3ebecb1b29bf96fc65c99ac8e3ca617434d1db 100644 --- a/src/webenginewidgets/doc/src/qwebenginehistory_lgpl.qdoc +++ b/src/webenginewidgets/doc/src/qwebenginehistory_lgpl.qdoc @@ -24,23 +24,12 @@ /*! \class QWebEngineHistoryItem - \brief The QWebEngineHistoryItem class represents one item in the history of a QWebEnginePage - + \brief The QWebEngineHistoryItem class represents one item in the history of a web engine page. + \since 5.4 \inmodule QtWebEngineWidgets - Each QWebEngineHistoryItem instance represents an entry in the history stack of a Web page, - containing information about the page, its location, and when it was last visited. - - The following table shows the properties of the page held by the history item, and - the functions used to access them. - - \table - \header \li Function \li Description - \row \li title() \li The page title. - \row \li url() \li The location of the page. - \row \li originalUrl() \li The URL used to access the page. - \row \li lastVisited() \li The date and time of the user's last visit to the page. - \endtable + Each web engine history item represents an entry in the history stack of a web page, + containing information about the page, its location, and the time when it was last visited. \sa QWebEngineHistory, QWebEnginePage::history() */ @@ -87,7 +76,7 @@ /*! \fn QDateTime QWebEngineHistoryItem::lastVisited() const - Returns the date and time that the page associated with the item was last visited. + Returns the date and time when the page associated with the item was last visited. \sa title(), url() */ @@ -99,13 +88,12 @@ /*! \class QWebEngineHistory - \brief The QWebEngineHistory class represents the history of a QWebEnginePage - + \brief The QWebEngineHistory class represents the history of a web engine page. + \since 5.4 \inmodule QtWebEngineWidgets - Each QWebEnginePage instance contains a history of visited pages that can be accessed - by QWebEnginePage::history(). QWebEngineHistory represents this history and makes it possible - to navigate it. + Each web engine page contains a history of visited pages that can be accessed + by QWebEnginePage::history(). The history uses the concept of a \e{current item}, dividing the pages visited into those that can be visited by navigating \e back and \e forward using the @@ -161,23 +149,23 @@ /*! \fn bool QWebEngineHistory::canGoBack() const - Returns true if there is an item preceding the current item in the history; - otherwise returns false. + Returns \c true if there is an item preceding the current item in the history; + otherwise returns \c false. \sa canGoForward() */ /*! \fn bool QWebEngineHistory::canGoForward() const - Returns true if we have an item to go forward to; otherwise returns false. + Returns \c true if we have an item to go forward to; otherwise returns \c false. \sa canGoBack() */ /*! \fn void QWebEngineHistory::back() - Set the current item to be the previous item in the history and goes to the - corresponding page; i.e., goes back one history item. + Sets the current item to be the previous item in the history and goes to the + corresponding page; that is, goes back one history item. \sa forward(), goToItem() */ @@ -185,7 +173,7 @@ /*! \fn void QWebEngineHistory::forward() Sets the current item to be the next item in the history and goes to the - corresponding page; i.e., goes forward one history item. + corresponding page; that is, goes forward one history item. \sa back(), goToItem() */ @@ -231,9 +219,7 @@ \fn QDataStream& operator<<(QDataStream& stream, const QWebEngineHistory& history) \relates QWebEngineHistory - \brief The operator<< function streams a history into a data stream. - - It saves the \a history into the specified \a stream. + Saves the web engine history \a history into \a stream. */ @@ -241,7 +227,5 @@ \fn QDataStream& operator>>(QDataStream& stream, QWebEngineHistory& history) \relates QWebEngineHistory - \brief The operator>> function loads a history from a data stream. - - Loads a QWebEngineHistory from the specified \a stream into the given \a history. + Loads the web engine history from \a stream into \a history. */ diff --git a/src/webenginewidgets/doc/src/qwebenginepage_lgpl.qdoc b/src/webenginewidgets/doc/src/qwebenginepage_lgpl.qdoc index 29e5d60ce4033afa1bc2b8e44412cc4bfc8f8b3a..794cb56d262ed0627f59129c450724ac601bde13 100644 --- a/src/webenginewidgets/doc/src/qwebenginepage_lgpl.qdoc +++ b/src/webenginewidgets/doc/src/qwebenginepage_lgpl.qdoc @@ -27,11 +27,11 @@ /*! \class QWebEnginePage \brief The QWebEnginePage class provides an object to view and edit web documents. - + \since 5.4 \inmodule QtWebEngineWidgets - QWebEnginePage holds a main frame responsible for web content, the history - of navigated links and actions. + A web engine page holds a main frame responsible for web content, the history + of navigated links, and actions. QWebEnginePage's API is very similar to QWebEngineView, as you are still provided with common functions like action() (known as @@ -39,7 +39,7 @@ and findText(). A page can be loaded using load() or setUrl(). Alternatively, if you have - the HTML content readily available, you can use setHtml() instead. + the HTML content readily available, you can use setHtml(). The QWebEnginePage class also offers methods to retrieve both the URL currently loaded by its main frame (see url()) as well as the URL originally requested @@ -50,17 +50,16 @@ The title of an HTML page can be accessed with the title() property. Additionally, a page may also specify an icon, which can be accessed - using the icon() property. If the title or the icon changes, the - corresponding titleChanged() and iconChanged() signals will be emitted. + using the iconUrl() property. If the title or the icon changes, the + corresponding titleChanged() and iconUrlChanged() signals will be emitted. The zoomFactor() property can be used to change the overall size of the content displayed in the page. - The loadStarted() signal is emitted when the page begins to load.The - loadProgress() signal, on the other hand, is emitted whenever an element - of the web page completes loading, such as an embedded image, a script, - etc. Finally, the loadFinished() signal is emitted when the page contents - are loaded completely, independent of script execution or page rendering. - Its argument, either true or false, indicates whether or not the load + The loadStarted() signal is emitted when the page begins to load, whereas the loadProgress() + signal is emitted whenever an element of the web page completes loading, such as an embedded + image or a script. The loadFinished() signal is emitted when the page contents + have been loaded completely, independent of script execution or page rendering. + Its argument, either \c true or \c false, indicates whether or not the load operation succeeded. */ @@ -95,7 +94,7 @@ \value Paste Paste content from the clipboard. \value Undo Undo the last editing action. \value Redo Redo the last editing action. - \value SelectAll Selects all content. + \value SelectAll Select all content. \value PasteAndMatchStyle Paste content from the clipboard with current style. \value OpenLinkInThisWindow Open the current link in the current window. (Added in Qt 5.6) @@ -106,14 +105,21 @@ \value CopyImageToClipboard Copy the clicked image to the clipboard. (Added in Qt 5.6) \value CopyImageUrlToClipboard Copy the clicked image's URL to the clipboard. (Added in Qt 5.6) \value CopyMediaUrlToClipboard Copy the hovered audio or video's URL to the clipboard. (Added in Qt 5.6) - \value ToggleMediaControls Toggles between showing and hiding the controls for the hovered audio or video element. (Added in Qt 5.6) - \value ToggleMediaLoop Toggles whether the hovered audio or video should loop on completetion or not. (Added in Qt 5.6) - \value ToggleMediaPlayPause Toggles the play/pause state of the hovered audio or video element. (Added in Qt 5.6) - \value ToggleMediaMute Mutes or unmutes the hovered audio or video element. (Added in Qt 5.6) + \value ToggleMediaControls Toggle between showing and hiding the controls for the hovered audio + or video element. (Added in Qt 5.6) + \value ToggleMediaLoop Toggle whether the hovered audio or video should loop on completetion or + not. (Added in Qt 5.6) + \value ToggleMediaPlayPause Toggle the play/pause state of the hovered audio or video element. + (Added in Qt 5.6) + \value ToggleMediaMute Mute or unmute the hovered audio or video element. (Added in Qt 5.6) \value DownloadLinkToDisk Download the current link to the disk. (Added in Qt 5.6) \value DownloadImageToDisk Download the highlighted image to the disk. (Added in Qt 5.6) \value DownloadMediaToDisk Download the hovered audio or video to the disk. (Added in Qt 5.6) + \value InspectElement Trigger any attached Web Inspector to inspect the highlighed element. + (Added in Qt 5.6) + \value ExitFullScreen Exit the fullscreen mode. (Added in Qt 5.6) + \omitvalue WebActionCount */ @@ -121,31 +127,37 @@ /*! \enum QWebEnginePage::WebWindowType - This enum describes the types of window that can be created by the createWindow() function. + This enum describes the types of window that can be created by the createWindow() function: - \value WebBrowserWindow The page should be opened in a complete web browser window. - \value WebBrowserTab The page should be opened as a web browser tab. - \value WebDialog The page should be opened in a window without decoration. + \value WebBrowserWindow + A complete web browser window. + \value WebBrowserTab + A web browser tab. + \value WebDialog + A window without decoration. */ /*! \enum QWebEnginePage::JavaScriptConsoleMessageLevel - This enum describes the different severity levels a JavaScript console message can have. + This enum describes the different severity levels a JavaScript console message can have: \value InfoMessageLevel The message is purely informative and can safely be ignored. - \value WarningMessageLevel The message informs about unexpected behaviors or errors that may need attention. + \value WarningMessageLevel The message informs about unexpected behavior or errors that may + need attention. \value ErrorMessageLevel The message indicates there has been an error. */ /*! \enum QWebEnginePage::FileSelectionMode - This enum indicates whether the implementation of the chooseFiles function should - return only one file or may return multiple files. + This enum indicates whether the implementation of the chooseFiles() function should + return only one file or may return multiple files: - \value FileSelectOpen The implementation should return only one file name. - \value FileSelectOpenMultiple The implementation may return multiple file names. + \value FileSelectOpen + Return only one file name. + \value FileSelectOpenMultiple + Return multiple file names. \sa chooseFiles() */ @@ -153,7 +165,7 @@ /*! \enum QWebEnginePage::PermissionPolicy - This enum describes the permission policies that the user may set for data or device access. + This enum describes the permission policies that the user may set for data or device access: \value PermissionUnknown It is unknown whether the user grants or denies permission. \value PermissionGrantedByUser The user has granted permission. @@ -165,12 +177,12 @@ /*! \enum QWebEnginePage::NavigationType - This enum describes the type of a navigation request. + This enum describes the type of a navigation request: \value NavigationTypeLinkClicked The navigation request resulted from a clicked link. - \value NavigationTypeTyped The navigation request resulted from an explicitly loaded url. + \value NavigationTypeTyped The navigation request resulted from an explicitly loaded URL. \value NavigationTypeFormSubmitted The navigation request resulted from a form submission. - \value NavigationTypeBackForward The navigation request resulted from a back/forward action. + \value NavigationTypeBackForward The navigation request resulted from a back or forward action. \value NavigationTypeReload The navigation request resulted from a reload action. \value NavigationTypeOther The navigation request was triggered by other means not covered by the above. @@ -180,12 +192,20 @@ /*! \enum QWebEnginePage::Feature - This enum describes the platform feature access categories that the user may be asked to grant or deny access to. - - \value Geolocation Access to location hardware or service - \value MediaAudioCapture Audio capture devices such a microphones - \value MediaVideoCapture Video devices, e.g. cameras - \value MediaAudioVideoCapture Both Audio and Video capture devices. + This enum describes the platform feature access categories that the user may be asked to grant + or deny access to: + + \value Geolocation + Location hardware or service. + \value MediaAudioCapture + Audio capture devices, such as microphones. + \value MediaVideoCapture + Video devices, such as cameras. + \value MediaAudioVideoCapture + Both audio and video capture devices. + \value MouseLock + Mouse locking, which locks the mouse pointer to the web view and is typically used in + games. \sa featurePermissionRequested(), featurePermissionRequestCanceled(), setFeaturePermission(), PermissionPolicy @@ -193,7 +213,7 @@ /*! \fn QWebEnginePage::QWebEnginePage(QObject *parent) - Constructs an empty QWebEnginePage with parent \a parent. + Constructs an empty QWebEnginePage with the parent \a parent. */ /*! @@ -222,19 +242,21 @@ /*! \fn QMenu *QWebEnginePage::createStandardContextMenu() - This function creates the standard context menu which is shown when + Creates the standard context menu which is shown when the user clicks on the web page with the right mouse button. It is - called from the default contextMenuEvent() handler. The popup menu's + called from the default \l{QWidget::}{contextMenuEvent()} handler. The popup menu's ownership is transferred to the caller. */ /*! \fn void QWebEnginePage::javaScriptConsoleMessage(JavaScriptConsoleMessageLevel level, const QString& message, int lineNumber, const QString& sourceID) - This function is called whenever a JavaScript program tries to print a \a message to the web browser's console. + This function is called when a JavaScript program tries to print the \a message to the web + browser's console. - For example in case of evaluation errors the source URL may be provided in \a sourceID as well as the \a lineNumber. + For example, in case of evaluation errors the source URL may be provided in \a sourceID as well + as the \a lineNumber. - \a level indicates the severity of the event that triggered the message, i.e. if it + \a level indicates the severity of the event that triggered the message. That is, whether it was triggered by an error or a less severe event. The default implementation prints nothing. @@ -242,25 +264,27 @@ /*! \fn bool acceptNavigationRequest(const QUrl &url, NavigationType type, bool isMainFrame) - This function is called whenever there is a request to navigate to a specified \a url by means of the specified navigation type \atype. - The \a isMainFrame argument marks if the request corresponds to the main frame, or a sub frame. - If the request is accepted Chromium will continue to load the page, else the request will be ignored. - The default implementation accepts the navigation request. + This function is called upon receiving a request to navigate to the specified \a url by means of + the specified navigation type \a type. \a isMainFrame indicates whether the request corresponds + to the main frame or a sub frame. If the function returns \c true, the navigation request is + accepted and Chromium continues to load the page. Otherwise, the request is ignored. The default + implementation accepts the navigation request. */ /*! \fn void QWebEnginePage::javaScriptAlert(const QUrl &securityOrigin, const QString& msg) - This function is called whenever a JavaScript program running in a frame affiliated with \a securityOrigin calls the alert() function with - the message \a msg. + This function is called whenever a JavaScript program running in a frame affiliated with + \a securityOrigin calls the \c alert() function with the message \a msg. The default implementation shows the message, \a msg, with QMessageBox::information. */ /*! \fn bool QWebEnginePage::javaScriptConfirm(const QUrl &securityOrigin, const QString& msg) - This function is called whenever a JavaScript program running in a frame affiliated with \a securityOrigin calls the confirm() function - with the message, \a msg. Returns true if the user confirms the message; otherwise returns false. + This function is called whenever a JavaScript program running in a frame affiliated with + \a securityOrigin calls the \c confirm() function with the message \a msg. Returns \c true + if the user confirms the message; otherwise returns \c false. The default implementation executes the query using QMessageBox::information with QMessageBox::Ok and QMessageBox::Cancel buttons. */ @@ -270,36 +294,38 @@ This function is called whenever a JavaScript program running in a frame affiliated with \a securityOrigin tries to prompt the user for input. The program may provide an optional message, \a msg, as well as a default value for the input in \a defaultValue. - If the prompt was cancelled by the user the implementation should return false; otherwise the - result should be written to \a result and true should be returned. If the prompt was not cancelled by the - user, the implementation should return true and the result string must not be null. + If the prompt was cancelled by the user, the implementation should return \c false; otherwise the + result should be written to \a result and \c true should be returned. If the prompt was not + cancelled by the user, the implementation should return \c true and the result string must not + be null. The default implementation uses QInputDialog::getText(). */ /*! \fn QWebEnginePage *QWebEnginePage::createWindow(WebWindowType type) - This function is called whenever the WebEngine wants to create a new window of the given \a type, for example when a JavaScript program requests to open a document in a new window. + This function is called to create a new window of the specified \a type. For example, when a + JavaScript program requests to open a document in a new window. If the new window can be created, the new window's QWebEnginePage is returned; otherwise a null pointer is returned. If the view associated with the web page is a QWebEngineView object, then the default implementation forwards - the request to QWebEngineView's createWindow() function; otherwise it returns a null pointer. + the request to QWebEngineView::createWindow(); otherwise it returns a null pointer. \note In the cases when the window creation is being triggered by JavaScript, apart from - reimplementing this method application must also set the JavaScriptCanOpenWindows attribute - of QWebEngineSettings to true in order for it to get called. + reimplementing this method the application must also set + QWebEngineSettings::JavascriptCanOpenWindows to \c true in order for the method to get called. \sa QWebEngineView::createWindow() */ /*! - \fn void QWebEnginePage::triggerAction(WebAction action, bool) + \fn void QWebEnginePage::triggerAction(WebAction action, bool checked = false) This function can be called to trigger the specified \a action. It is also called by Qt WebEngine if the user triggers the action, for example through a context menu item. - If \a action is a checkable action then \a checked specified whether the action + If \a action is a checkable action, then \a checked specifies whether the action is toggled or not. \sa action() @@ -347,11 +373,11 @@ To clear the selection, just pass an empty string. - The \a resultCallback must take a boolean parameter. It will be called with a value of true if the \a subString - was found; otherwise the callback value will be false. + The \a resultCallback must take a boolean parameter. It will be called with a value of \c true + if the \a subString was found; otherwise the callback value will be \c false. For example: - \snippet snippets/qtwebengine_qwebenginepage_snippet.cpp 0 + \snippet qtwebengine_qwebenginepage_snippet.cpp 0 */ /*! @@ -367,7 +393,8 @@ The \a certificateError parameter contains information about the certificate and details of the error. - Return true to ignore the error and complete the request, otherwise return false to stop loading the request. + Return \c true to ignore the error and complete the request. Return \c false to stop loading + the request. \sa QWebEngineCertificateError */ @@ -375,9 +402,9 @@ /*! \fn QString QWebEnginePage::chooseFiles(FileSelectionMode mode, const QStringList& oldFiles, const QStringList& acceptedMimeTypes) This function is called when the web content requests a file name, for example - as a result of the user clicking on a "file upload" button in a HTML form. + as a result of the user clicking on a file upload button in an HTML form. - \a mode indicates whether only one file or multiples files are expected to be returned. + \a mode indicates whether only one file or multiple files are expected to be returned. A suggested filename may be provided as the first entry of \a oldFiles. \a acceptedMimeTypes is ignored by the default implementation, but might be used by overrides. @@ -415,7 +442,7 @@ \fn void QWebEnginePage::selectionChanged() This signal is emitted whenever the selection changes, either interactively - or programmatically (e.g. by calling triggerAction() with a selection action). + or programmatically. For example, by calling triggerAction() with a selection action. \sa selectedText() */ @@ -487,7 +514,7 @@ /*! \property QWebEnginePage::url - \brief the url of the frame currently viewed + \brief the URL of the frame currently viewed Setting this property clears the view and loads the URL. @@ -498,16 +525,16 @@ /*! \property QWebEnginePage::iconUrl - \brief the url of the icon associated with the frame currently viewed. + \brief the URL of the icon associated with the frame currently viewed. \sa iconUrlChanged() */ /*! \property QWebEnginePage::requestedUrl + \brief the URL requested to be loaded by the frame currently viewed - The URL requested to loaded by the frame currently viewed. The URL may differ from - the one returned by url() if a DNS resolution or a redirection occurs. + The URL may differ from the one returned by url() if a DNS resolution or a redirection occurs. \sa url(), setUrl() */ @@ -516,7 +543,7 @@ \fn void QWebEnginePage::load(const QUrl &url) Loads \a url into this frame. - \note The view remains the same until enough data has arrived to display the new \a url. + \note The view remains the same until enough data has arrived to display the new URL. \sa setUrl(), setHtml(), setContent() */ @@ -532,16 +559,16 @@ for example due to being blocked by a modal JavaScript alert dialog, this method will return as soon as possible after the timeout and any subsequent \a html will be loaded asynchronously. - When using this method WebEngie assumes that external resources such as JavaScript programs or style - sheets are encoded in UTF-8 unless otherwise specified. For example, the encoding of an external + When using this method, the web engine assumes that external resources, such as JavaScript programs or style + sheets, are encoded in UTF-8 unless otherwise specified. For example, the encoding of an external script can be specified through the charset attribute of the HTML script tag. It is also possible - for the encoding to be specified by web server. + for the encoding to be specified by the web server. This is a convenience function equivalent to setContent(html, "text/html", baseUrl). \note This method will not affect session or global history for the frame. - \warning This function works only for HTML, for other mime types (i.e. XHTML, SVG) + \warning This function works only for HTML, for other mime types (such as XHTML and SVG) setContent() should be used instead. \sa toHtml(), setContent(), load() @@ -550,7 +577,7 @@ /*! \fn void QWebEnginePage::setContent(const QByteArray &data, const QString &mimeType, const QUrl &baseUrl) Sets the content of this page's main frame to the specified content \a data. If the \a mimeType argument - is empty it is currently assumed that the content is HTML but in future versions we may introduce + is empty, it is currently assumed that the content is HTML but in future versions we may introduce auto-detection. External objects referenced in the content are located relative to \a baseUrl. @@ -586,6 +613,10 @@ Sets the permission for the web site identified by \a securityOrigin to use \a feature to \a policy. + \note Call this method on the featurePermissionRequested() signal, as it is + meant to serve pending feature requests only. Setting feature permissions + ahead of a request has no effect. + \sa featurePermissionRequested(), featurePermissionRequestCanceled() */ diff --git a/src/webenginewidgets/doc/src/qwebenginesettings_lgpl.qdoc b/src/webenginewidgets/doc/src/qwebenginesettings_lgpl.qdoc index 82410a50f882f1ea4b15b19642046581f481eb67..3dc23e037af9e90f7cf57312c7943cf0beb8156d 100644 --- a/src/webenginewidgets/doc/src/qwebenginesettings_lgpl.qdoc +++ b/src/webenginewidgets/doc/src/qwebenginesettings_lgpl.qdoc @@ -28,13 +28,15 @@ Any setting changed on the default object is automatically applied to all QWebEnginePage instances where the particular setting is not overridden already. + + \sa defaultSettings() */ /*! \class QWebEngineSettings - \since QtWebEngine 1.0 + \since 5.4 \brief The QWebEngineSettings class provides an object to store the settings used - by QWebEnginePage + by QWebEnginePage. \inmodule QtWebEngineWidgets @@ -44,10 +46,9 @@ globalSettings(). QWebEngineSettings allows configuration of browser properties, such as font sizes and - families, the location of a custom style sheet, and generic attributes like - JavaScript and plugins. Individual attributes are set using the setAttribute() - function. The \l{QWebEngineSettings::WebAttribute}{WebAttribute} enum further describes - each attribute. + families, the location of a custom style sheet, and generic attributes, such as JavaScript + support. Individual attributes are set using the setAttribute() function. The + \l{QWebEngineSettings::WebAttribute}{WebAttribute} enum further describes each attribute. \sa QWebEnginePage::settings(), QWebEngineView::settings() */ @@ -70,11 +71,11 @@ /*! \enum QWebEngineSettings::FontSize - This enum describes the font sizes configurable through QWebEngineSettings. + This enum describes the font sizes configurable through QWebEngineSettings: \value MinimumFontSize The hard minimum font size. \value MinimumLogicalFontSize The minimum logical font size that is applied - when zooming out with QWebEngineFrame::setTextSizeMultiplier(). + when zooming out. \value DefaultFontSize The default font size for regular text. \value DefaultFixedFontSize The default font size for fixed-pitch text. */ @@ -82,40 +83,46 @@ /*! \enum QWebEngineSettings::WebAttribute - This enum describes various attributes that are configurable through QWebEngineSettings. - - \value AutoLoadImages Specifies whether images are automatically loaded in - web pages. This is enabled by default. - \value JavascriptEnabled Enables or disables the running of JavaScript - programs. This is enabled by default - \value JavascriptCanOpenWindows Specifies whether JavaScript programs - can open new windows. This is enabled by default. - \value JavascriptCanAccessClipboard Specifies whether JavaScript programs - can read or write to the clipboard. This is disabled by default. - \value LinksIncludedInFocusChain Specifies whether hyperlinks should be - included in the keyboard focus chain. This is enabled by default. - \value LocalStorageEnabled Specifies whether support for the HTML 5 - local storage feature is enabled or not. This is enabled by default. - \value LocalContentCanAccessRemoteUrls Specifies whether locally loaded documents are - allowed to access remote urls. This is disabled by default. For more information - about security origins and local vs. remote content see QWebEngineSecurityOrigin. - \value XSSAuditingEnabled Specifies whether load requests should be monitored for cross-site - scripting attempts. Suspicious scripts will be blocked and reported in the inspector's - JavaScript console. Enabling this feature might have an impact on performance - and it is disabled by default. - \value SpatialNavigationEnabled Enables or disables the Spatial Navigation - feature, which consists in the ability to navigate between focusable - elements in a Web page, such as hyperlinks and form controls, by using - Left, Right, Up and Down arrow keys. For example, if a user presses the - Right key, heuristics determine whether there is an element they might be - trying to reach towards the right and which element they probably want. - This is disabled by default. - \value LocalContentCanAccessFileUrls Specifies whether locally loaded documents are - allowed to access other local urls. This is enabled by default. For more information - about security origins and local vs. remote content see QWebEngineSecurityOrigin. - \value HyperlinkAuditingEnabled This setting enables support for the ping attribute for hyperlinks. It is disabled by default. - \value ScrollAnimatorEnabled This setting enables animated scrolling. It is disabled by default. - \value ErrorPageEnabled This setting enables built-in error pages of Chromium. It is enabled by default. + This enum type specifies settings for web pages: + + \value AutoLoadImages + Automatically loads images on web pages. Enabled by default. + \value JavascriptEnabled + Enables the running of JavaScript programs. Enabled by default. + \value JavascriptCanOpenWindows + Allows JavaScript programs to open new windows. Enabled by default. + \value JavascriptCanAccessClipboard + Allows JavaScript programs to read from and write to the clipboard. Disabled by + default. + \value LinksIncludedInFocusChain + Includes hyperlinks in the keyboard focus chain. Enabled by default. + \value LocalStorageEnabled + Enables support for the HTML 5 local storage feature. Enabled by default. + \value LocalContentCanAccessRemoteUrls + Allows locally loaded documents to access remote URLs. Disabled by default. + \value XSSAuditingEnabled + Monitors load requests for cross-site scripting attempts. Suspicious scripts are blocked + and reported in the inspector's JavaScript console. Disabled by default, because it + might negatively affect performance. + \value SpatialNavigationEnabled + Enables the Spatial Navigation feature, which means the ability to navigate between + focusable elements, such as hyperlinks and form controls, on a web page by using the + Left, Right, Up and Down arrow keys. For example, if a user presses the + Right key, heuristics determine whether there is an element they might be + trying to reach towards the right and which element they probably want. + Disabled by default. + \value LocalContentCanAccessFileUrls + Allows locally loaded documents to access other local URLs. Enabled by default. + \value HyperlinkAuditingEnabled + Enables support for the \c ping attribute for hyperlinks. Disabled by default. + \value ScrollAnimatorEnabled + Enables animated scrolling. Disabled by default. + \value ErrorPageEnabled + Enables displaying the built-in error pages of Chromium. Enabled by default. + \value PluginsEnabled + Enables support for Pepper plugins, such as the Flash player. Disabled by default. + \value FullScreenSupportEnabled + Enables fullscreen support in an application. Disabled by default. */ /*! @@ -140,9 +147,9 @@ \fn void QWebEngineSettings::setDefaultTextEncoding(const QString& encoding) Specifies the default text encoding system. - The \a encoding, must be a string describing an encoding such as "utf-8", - "iso-8859-1", etc. If left empty a default value will be used. For a more - extensive list of encoding names see \l{QTextCodec} + The value of \a encoding must be a string describing an encoding such as "utf-8" or + "iso-8859-1". If left empty, a default value will be used. For a more + extensive list of encoding names see \l{QTextCodec}. \sa defaultTextEncoding() */ @@ -184,7 +191,7 @@ /*! \fn bool QWebEngineSettings::testAttribute(WebAttribute attribute) const - Returns true if \a attribute is enabled; otherwise returns false. + Returns \c true if \a attribute is enabled; otherwise returns \c false. */ /*! diff --git a/src/webenginewidgets/doc/src/qwebengineview_lgpl.qdoc b/src/webenginewidgets/doc/src/qwebengineview_lgpl.qdoc index d1b390580c4944f22c95720bc484c99a080398e1..76878e07749e9a969665a4b965b9ef741381e5a6 100644 --- a/src/webenginewidgets/doc/src/qwebengineview_lgpl.qdoc +++ b/src/webenginewidgets/doc/src/qwebengineview_lgpl.qdoc @@ -28,6 +28,7 @@ \class QWebEngineView \brief The QWebEngineView class provides a widget that is used to view and edit web documents. + \since 5.4 \ingroup advanced \inmodule QtWebEngineWidgets @@ -40,7 +41,7 @@ Qt widgets, the show() function must be invoked in order to display QWebEngineView. The snippet below illustrates this: - \snippet snippets/simple/main.cpp Using QWebEngineView + \snippet simple/main.cpp Using QWebEngineView Alternatively, setUrl() can also be used to load a web site. If you have the HTML content readily available, you can use setHtml() instead. @@ -58,8 +59,8 @@ The title of an HTML document can be accessed with the title() property. Additionally, a web site may also specify an icon, which can be accessed - using the icon() property. If the title or the icon changes, the corresponding - titleChanged() and iconChanged() signals will be emitted. The + using the iconUrl() property. If the title or the icon changes, the corresponding + titleChanged() and iconUrlChanged() signals will be emitted. The textSizeMultiplier() property can be used to change the overall size of the text displayed in the web view. @@ -169,7 +170,7 @@ It is equivalent to - \snippet snippets/qtwebengine_qwebengineview_snippet.cpp 0 + \snippet qtwebengine_qwebengineview_snippet.cpp 0 */ /*! @@ -230,7 +231,7 @@ The following example triggers the copy action and therefore copies any selected text to the clipboard. - \snippet snippets/qtwebengine_qwebengineview_snippet.cpp 2 + \snippet qtwebengine_qwebengineview_snippet.cpp 2 \sa pageAction() */ @@ -267,7 +268,7 @@ It is equivalent to - \snippet snippets/qtwebengine_qwebengineview_snippet.cpp 3 + \snippet qtwebengine_qwebengineview_snippet.cpp 3 \sa reload(), pageAction(), loadFinished() */ @@ -279,7 +280,7 @@ It is equivalent to - \snippet snippets/qtwebengine_qwebengineview_snippet.cpp 4 + \snippet qtwebengine_qwebengineview_snippet.cpp 4 \sa forward(), pageAction() */ @@ -291,7 +292,7 @@ It is equivalent to - \snippet snippets/qtwebengine_qwebengineview_snippet.cpp 5 + \snippet qtwebengine_qwebengineview_snippet.cpp 5 \sa back(), pageAction() */ @@ -385,7 +386,7 @@ It is equivalent to - \snippet snippets/qtwebengine_qwebengineview_snippet.cpp 6 + \snippet qtwebengine_qwebengineview_snippet.cpp 6 \sa QWebEngineSettings::globalSettings() */ diff --git a/src/webenginewidgets/ui/messagebubblewidget.cpp b/src/webenginewidgets/ui/messagebubblewidget.cpp index 3465f421848ad4846efc08d3f71f8fe320807dd3..490e2a8f8af2c60ce40dc3807080262aad0027ce 100644 --- a/src/webenginewidgets/ui/messagebubblewidget.cpp +++ b/src/webenginewidgets/ui/messagebubblewidget.cpp @@ -1,7 +1,7 @@ /**************************************************************************** ** -** Copyright (C) 2015 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ ** ** This file is part of the QtWebEngine module of the Qt Toolkit. ** @@ -10,15 +10,15 @@ ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 3 as published by the Free Software ** Foundation and appearing in the file LICENSE.LGPLv3 included in the -** packaging of this file. Please review the following information to +** packaging of this file. Please review the following information to ** ensure the GNU Lesser General Public License version 3 requirements ** will be met: https://www.gnu.org/licenses/lgpl.html. ** @@ -26,7 +26,7 @@ ** Alternatively, this file may be used under the terms of the GNU ** General Public License version 2.0 or later as published by the Free ** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information to +** the packaging of this file. Please review the following information to ** ensure the GNU General Public License version 2.0 requirements will be ** met: http://www.gnu.org/licenses/gpl-2.0.html. ** diff --git a/src/webenginewidgets/ui/messagebubblewidget_p.h b/src/webenginewidgets/ui/messagebubblewidget_p.h index 7b7a9e309efa528c9a968710cb33e9dcf39a136d..28ccf1b133d08e0cffef78b6d3c5ddc2153ee812 100644 --- a/src/webenginewidgets/ui/messagebubblewidget_p.h +++ b/src/webenginewidgets/ui/messagebubblewidget_p.h @@ -1,7 +1,7 @@ /**************************************************************************** ** -** Copyright (C) 2015 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ ** ** This file is part of the QtWebEngine module of the Qt Toolkit. ** @@ -10,15 +10,15 @@ ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 3 as published by the Free Software ** Foundation and appearing in the file LICENSE.LGPLv3 included in the -** packaging of this file. Please review the following information to +** packaging of this file. Please review the following information to ** ensure the GNU Lesser General Public License version 3 requirements ** will be met: https://www.gnu.org/licenses/lgpl.html. ** @@ -26,7 +26,7 @@ ** Alternatively, this file may be used under the terms of the GNU ** General Public License version 2.0 or later as published by the Free ** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information to +** the packaging of this file. Please review the following information to ** ensure the GNU General Public License version 2.0 requirements will be ** met: http://www.gnu.org/licenses/gpl-2.0.html. ** @@ -37,6 +37,17 @@ #ifndef MESSAGEBUBBLEWIDGET_P_H #define MESSAGEBUBBLEWIDGET_P_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include <QWidget> #include <QPainterPath> diff --git a/src/webenginewidgets/webenginewidgets.pro b/src/webenginewidgets/webenginewidgets.pro index 0d92767c1bd54ca2e0e2335b2f5391630b00cee6..c321855632b311a0b9565f62aa4148e5aaf019f5 100644 --- a/src/webenginewidgets/webenginewidgets.pro +++ b/src/webenginewidgets/webenginewidgets.pro @@ -20,8 +20,6 @@ SOURCES = \ api/qwebenginescript.cpp \ api/qwebenginescriptcollection.cpp \ api/qwebenginesettings.cpp \ - api/qwebengineurlrequestjob.cpp \ - api/qwebengineurlschemehandler.cpp \ api/qwebengineview.cpp \ render_widget_host_view_qt_delegate_widget.cpp @@ -38,9 +36,6 @@ HEADERS = \ api/qwebenginescriptcollection.h \ api/qwebenginescriptcollection_p.h \ api/qwebenginesettings.h \ - api/qwebengineurlrequestjob_p.h \ - api/qwebengineurlschemehandler_p.h \ - api/qwebengineurlschemehandler_p_p.h \ api/qwebengineview.h \ api/qwebengineview_p.h \ render_widget_host_view_qt_delegate_widget.h diff --git a/tests/auto/core/qwebenginecookiestoreclient/qwebenginecookiestoreclient.pro b/tests/auto/core/qwebenginecookiestoreclient/qwebenginecookiestoreclient.pro index ff6c4962896e4c056799ef1640cb1560781caa5b..e99c7f4938cb1510eefefaefce31663c097f0542 100644 --- a/tests/auto/core/qwebenginecookiestoreclient/qwebenginecookiestoreclient.pro +++ b/tests/auto/core/qwebenginecookiestoreclient/qwebenginecookiestoreclient.pro @@ -1,2 +1 @@ include(../tests.pri) -exists($${TARGET}.qrc):RESOURCES += $${TARGET}.qrc diff --git a/tests/auto/core/qwebengineurlrequestinterceptor/qwebengineurlrequestinterceptor.pro b/tests/auto/core/qwebengineurlrequestinterceptor/qwebengineurlrequestinterceptor.pro index ff6c4962896e4c056799ef1640cb1560781caa5b..e99c7f4938cb1510eefefaefce31663c097f0542 100644 --- a/tests/auto/core/qwebengineurlrequestinterceptor/qwebengineurlrequestinterceptor.pro +++ b/tests/auto/core/qwebengineurlrequestinterceptor/qwebengineurlrequestinterceptor.pro @@ -1,2 +1 @@ include(../tests.pri) -exists($${TARGET}.qrc):RESOURCES += $${TARGET}.qrc diff --git a/tests/auto/core/qwebengineurlrequestinterceptor/tst_qwebengineurlrequestinterceptor.cpp b/tests/auto/core/qwebengineurlrequestinterceptor/tst_qwebengineurlrequestinterceptor.cpp index b0ef9a1baea488b78a2a77a8699f4fdbf2f50f01..a2f9e0c37dfcb2727bcc78b61bd3f6e8e21f1015 100644 --- a/tests/auto/core/qwebengineurlrequestinterceptor/tst_qwebengineurlrequestinterceptor.cpp +++ b/tests/auto/core/qwebengineurlrequestinterceptor/tst_qwebengineurlrequestinterceptor.cpp @@ -44,6 +44,7 @@ #include <QtWebEngineCore/qwebengineurlrequestinterceptor.h> #include <QtWebEngineWidgets/qwebenginepage.h> #include <QtWebEngineWidgets/qwebengineprofile.h> +#include <QtWebEngineWidgets/qwebenginesettings.h> #include <QtWebEngineWidgets/qwebengineview.h> class tst_QWebEngineUrlRequestInterceptor : public QObject @@ -62,6 +63,9 @@ private Q_SLOTS: void initTestCase(); void cleanupTestCase(); void interceptRequest(); + void ipv6HostEncoding(); + void requestedUrl(); + void setUrlSameUrl(); }; tst_QWebEngineUrlRequestInterceptor::tst_QWebEngineUrlRequestInterceptor() @@ -88,7 +92,7 @@ void tst_QWebEngineUrlRequestInterceptor::cleanupTestCase() { } -class TestRequestInterceptor: public QWebEngineUrlRequestInterceptor +class TestRequestInterceptor : public QWebEngineUrlRequestInterceptor { public: QList<QUrl> observedUrls; @@ -96,11 +100,11 @@ public: bool interceptRequest(QWebEngineUrlRequestInfo &info) override { - info.blockRequest(info.method() != QByteArrayLiteral("GET")); - if (info.url().toString().endsWith(QLatin1String("__placeholder__"))) - info.redirectTo(QUrl("qrc:///resources/content.html")); + info.block(info.requestMethod() != QByteArrayLiteral("GET")); + if (info.requestUrl().toString().endsWith(QLatin1String("__placeholder__"))) + info.redirect(QUrl("qrc:///resources/content.html")); - observedUrls.append(info.url()); + observedUrls.append(info.requestUrl()); return shouldIntercept; } TestRequestInterceptor(bool intercept) @@ -151,5 +155,103 @@ void tst_QWebEngineUrlRequestInterceptor::interceptRequest() QCOMPARE(observer.observedUrls.count(), 1); } +class LocalhostContentProvider : public QWebEngineUrlRequestInterceptor +{ +public: + LocalhostContentProvider() { } + + bool interceptRequest(QWebEngineUrlRequestInfo &info) override + { + requestedUrls.append(info.requestUrl()); + info.redirect(QUrl("data:text/html,<p>hello")); + return true; + } + + QList<QUrl> requestedUrls; +}; + +void tst_QWebEngineUrlRequestInterceptor::ipv6HostEncoding() +{ + QWebEngineView view; + QWebEnginePage *page = view.page(); + LocalhostContentProvider contentProvider; + QSignalSpy spyLoadFinished(page, SIGNAL(loadFinished(bool))); + + page->profile()->setRequestInterceptor(&contentProvider); + + page->setHtml("<p>Hi", QUrl::fromEncoded("http://[::1]/index.html")); + QTRY_COMPARE(spyLoadFinished.count(), 1); + QCOMPARE(contentProvider.requestedUrls.count(), 0); + + evaluateJavaScriptSync(page, "var r = new XMLHttpRequest();" + "r.open('GET', 'http://[::1]/test.xml', false);" + "r.send(null);" + ); + + QCOMPARE(contentProvider.requestedUrls.count(), 1); + QCOMPARE(contentProvider.requestedUrls.at(0), QUrl::fromEncoded("http://[::1]/test.xml")); +} + +void tst_QWebEngineUrlRequestInterceptor::requestedUrl() +{ + QWebEnginePage page; + page.settings()->setAttribute(QWebEngineSettings::ErrorPageEnabled, false); + + QSignalSpy spy(&page, SIGNAL(loadFinished(bool))); + TestRequestInterceptor interceptor(/* intercept */ true); + page.profile()->setRequestInterceptor(&interceptor); + + page.setUrl(QUrl("qrc:///resources/__placeholder__")); + waitForSignal(&page, SIGNAL(loadFinished(bool))); + QCOMPARE(spy.count(), 1); + QCOMPARE(interceptor.observedUrls.at(0), QUrl("qrc:///resources/content.html")); + QCOMPARE(page.requestedUrl(), QUrl("qrc:///resources/__placeholder__")); + QCOMPARE(page.url(), QUrl("qrc:///resources/content.html")); + + page.setUrl(QUrl("qrc:/non-existent.html")); + waitForSignal(&page, SIGNAL(loadFinished(bool))); + QCOMPARE(spy.count(), 2); + QCOMPARE(interceptor.observedUrls.at(2), QUrl("qrc:/non-existent.html")); + QCOMPARE(page.requestedUrl(), QUrl("qrc:///resources/__placeholder__")); + QCOMPARE(page.url(), QUrl("qrc:///resources/content.html")); + + page.setUrl(QUrl("http://abcdef.abcdef")); + waitForSignal(&page, SIGNAL(loadFinished(bool))); + QCOMPARE(spy.count(), 3); + QCOMPARE(interceptor.observedUrls.at(3), QUrl("http://abcdef.abcdef/")); + QCOMPARE(page.requestedUrl(), QUrl("qrc:///resources/__placeholder__")); + QCOMPARE(page.url(), QUrl("qrc:///resources/content.html")); +} + +void tst_QWebEngineUrlRequestInterceptor::setUrlSameUrl() +{ + QWebEnginePage page; + TestRequestInterceptor interceptor(/* intercept */ true); + page.profile()->setRequestInterceptor(&interceptor); + + QSignalSpy spy(&page, SIGNAL(loadFinished(bool))); + + page.setUrl(QUrl("qrc:///resources/__placeholder__")); + waitForSignal(&page, SIGNAL(loadFinished(bool))); + QCOMPARE(page.url(), QUrl("qrc:///resources/content.html")); + QCOMPARE(spy.count(), 1); + + page.setUrl(QUrl("qrc:///resources/__placeholder__")); + waitForSignal(&page, SIGNAL(loadFinished(bool))); + QCOMPARE(page.url(), QUrl("qrc:///resources/content.html")); + QCOMPARE(spy.count(), 2); + + // Now a case without redirect. + page.setUrl(QUrl("qrc:///resources/content.html")); + waitForSignal(&page, SIGNAL(loadFinished(bool))); + QCOMPARE(page.url(), QUrl("qrc:///resources/content.html")); + QCOMPARE(spy.count(), 3); + + page.setUrl(QUrl("qrc:///resources/__placeholder__")); + waitForSignal(&page, SIGNAL(loadFinished(bool))); + QCOMPARE(page.url(), QUrl("qrc:///resources/content.html")); + QCOMPARE(spy.count(), 4); +} + QTEST_MAIN(tst_QWebEngineUrlRequestInterceptor) #include "tst_qwebengineurlrequestinterceptor.moc" diff --git a/tests/auto/core/tests.pri b/tests/auto/core/tests.pri index 7046487dbaeb8a44e7accf7aaabe5acdfe3ac069..cd6ef8615e9cdd55a4370e345906873c8ccc66bd 100644 --- a/tests/auto/core/tests.pri +++ b/tests/auto/core/tests.pri @@ -11,8 +11,7 @@ TARGET = tst_$$TARGET SOURCES += $${TARGET}.cpp INCLUDEPATH += $$PWD +exists($$_PRO_FILE_PWD_/$${TARGET}.qrc): RESOURCES += $${TARGET}.qrc + QT += testlib network webenginewidgets widgets osx: CONFIG -= app_bundle - -# This define is used by some tests to look up resources in the source tree -DEFINES += TESTS_SOURCE_DIR=\\\"$$PWD/\\\" diff --git a/tests/auto/quick/publicapi/tst_publicapi.cpp b/tests/auto/quick/publicapi/tst_publicapi.cpp index eb925b178162bac4e19058fdb84c492c9523f24c..8f0c2f6ecbb77393b5dfdc4914b4e03b69e00f97 100644 --- a/tests/auto/quick/publicapi/tst_publicapi.cpp +++ b/tests/auto/quick/publicapi/tst_publicapi.cpp @@ -169,6 +169,7 @@ static QStringList expectedAPI = QStringList() << "QQuickWebEngineView.zoomFactor --> double" << "QQuickWebEngineView.zoomFactorChanged(double) --> void" << "QQuickWebEngineView.profile --> QQuickWebEngineProfile*" + << "QQuickWebEngineView.profileChanged() --> void" << "QQuickWebEngineView.navigationHistory --> QQuickWebEngineHistory*" << "QQuickWebEngineView.newViewRequested(QQuickWebEngineNewViewRequest*) --> void" << "QQuickWebEngineView.userScripts --> QQmlListProperty<QQuickWebEngineScript>" diff --git a/tests/auto/quick/qmltests/data/download.zip b/tests/auto/quick/qmltests/data/download.zip new file mode 100644 index 0000000000000000000000000000000000000000..b5456351a55155613539615accece9ee030b7d44 Binary files /dev/null and b/tests/auto/quick/qmltests/data/download.zip differ diff --git a/tests/auto/quick/qmltests/data/geolocation.html b/tests/auto/quick/qmltests/data/geolocation.html new file mode 100644 index 0000000000000000000000000000000000000000..c095a6b9ed8d802e14ee2a01dccee2dd335a6eb5 --- /dev/null +++ b/tests/auto/quick/qmltests/data/geolocation.html @@ -0,0 +1,26 @@ +<html> +<head> +<title>Geolocation Permission API Test</title> +<script> + +function successHandler(location) { + var message = document.getElementById("message"); + message.innerHTML = "Latitude: " + location.coords.latitude + + "<br>Longitude: " + location.coords.longitude; + +} + +function errorHandler(error) { + console.error(error.message); +} + +<!-- One shot example --> +navigator.geolocation.getCurrentPosition(successHandler, errorHandler); + +</script> +</head> +<body> +<div id="message">Location unknown</div> +</body> +</html> + diff --git a/tests/auto/quick/qmltests/data/tst_download.qml b/tests/auto/quick/qmltests/data/tst_download.qml new file mode 100644 index 0000000000000000000000000000000000000000..ffd7041e318abde5fffe8f6980b5bf1c5f9881bf --- /dev/null +++ b/tests/auto/quick/qmltests/data/tst_download.qml @@ -0,0 +1,139 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the QtWebEngine module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** As a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtTest 1.0 +import QtWebEngine 1.1 + +TestWebEngineView { + id: webEngineView + width: 200 + height: 200 + profile: testDownloadProfile + + property int totalBytes: 0 + property int receivedBytes: 0 + property bool cancelDownload: false + property var downloadState: [] + + SignalSpy { + id: downLoadRequestedSpy + target: testDownloadProfile + signalName: "downloadRequested" + } + + SignalSpy { + id: downloadFinishedSpy + target: testDownloadProfile + signalName: "downloadFinished" + } + + WebEngineProfile { + id: testDownloadProfile + + onDownloadRequested: { + downloadState.push(download.state) + if (cancelDownload) { + download.cancel() + downloadState.push(download.state) + } else { + totalBytes = download.totalBytes + download.path = "testfile.zip" + download.accept() + downloadState.push(download.state) + } + } + onDownloadFinished: { + downloadState.push(download.state) + receivedBytes = download.receivedBytes; + } + } + + TestCase { + name: "WebEngineViewDownload" + + function init() { + downLoadRequestedSpy.clear() + downloadFinishedSpy.clear() + totalBytes = 0 + receivedBytes = 0 + cancelDownload = false + downloadState = [] + } + + function test_downloadRequest() { + compare(downLoadRequestedSpy.count, 0) + webEngineView.url = Qt.resolvedUrl("download.zip") + downLoadRequestedSpy.wait() + compare(downLoadRequestedSpy.count, 1) + compare(downloadState[0], WebEngineDownloadItem.DownloadRequested) + } + + function test_totalFileLength() { + compare(downLoadRequestedSpy.count, 0) + webEngineView.url = Qt.resolvedUrl("download.zip") + downLoadRequestedSpy.wait() + compare(downLoadRequestedSpy.count, 1) + compare(totalBytes, 325) + } + + function test_downloadSucceeded() { + compare(downLoadRequestedSpy.count, 0) + webEngineView.url = Qt.resolvedUrl("download.zip") + downLoadRequestedSpy.wait() + compare(downLoadRequestedSpy.count, 1) + compare(downloadState[1], WebEngineDownloadItem.DownloadInProgress) + downloadFinishedSpy.wait() + compare(totalBytes, receivedBytes) + compare(downloadState[2], WebEngineDownloadItem.DownloadCompleted) + } + + function test_downloadCancelled() { + compare(downLoadRequestedSpy.count, 0) + cancelDownload = true + webEngineView.url = Qt.resolvedUrl("download.zip") + downLoadRequestedSpy.wait() + compare(downLoadRequestedSpy.count, 1) + compare(downloadFinishedSpy.count, 1) + compare(downloadState[2], WebEngineDownloadItem.DownloadCancelled) + } + } +} diff --git a/tests/auto/quick/qmltests/data/tst_geopermission.qml b/tests/auto/quick/qmltests/data/tst_geopermission.qml new file mode 100644 index 0000000000000000000000000000000000000000..acb561825442b346caec078bbe4f60450aba0054 --- /dev/null +++ b/tests/auto/quick/qmltests/data/tst_geopermission.qml @@ -0,0 +1,105 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the QtWebEngine module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** As a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.2 +import QtTest 1.0 +import QtWebEngine 1.1 + +TestWebEngineView { + id: webEngineView + width: 200 + height: 200 + + property bool deniedGeolocation: false + property bool geoPermissionRequested: false + property string consoleErrorMessage: "" + + SignalSpy { + id: featurePermissionSpy + target: webEngineView + signalName: "featurePermissionRequested" + } + + onFeaturePermissionRequested: { + if (feature === WebEngineView.Geolocation) { + geoPermissionRequested = true + if (deniedGeolocation) { + webEngineView.grantFeaturePermission(securityOrigin, feature, false) + } + else { + webEngineView.grantFeaturePermission(securityOrigin, feature, true) + } + } + } + + onJavaScriptConsoleMessage: { + if (level === WebEngineView.ErrorMessageLevel) + consoleErrorMessage = message + } + + TestCase { + name: "WebViewGeopermission" + when: windowShown + + function init() { + deniedGeolocation = false + consoleErrorMessage = "" + featurePermissionSpy.clear() + } + + function test_geoPermissionRequest() { + compare(featurePermissionSpy.count, 0) + webEngineView.url = Qt.resolvedUrl("geolocation.html") + featurePermissionSpy.wait() + verify(geoPermissionRequested) + compare(featurePermissionSpy.count, 1) + if (consoleErrorMessage) // Print the error message if it fails to get user's location + fail(consoleErrorMessage) + } + + function test_deniedGeolocationByUser() { + deniedGeolocation = true + webEngineView.url = Qt.resolvedUrl("geolocation.html") + featurePermissionSpy.wait() + compare(consoleErrorMessage, "User denied Geolocation") + } + } +} diff --git a/tests/auto/quick/qmltests/qmltests.pro b/tests/auto/quick/qmltests/qmltests.pro index 6776c1aa6cdeedc8217c6723c264dca931242004..01517af47b9d8c66e964657ed007dcb62e622315 100644 --- a/tests/auto/quick/qmltests/qmltests.pro +++ b/tests/auto/quick/qmltests/qmltests.pro @@ -10,12 +10,14 @@ OTHER_FILES += \ $$PWD/data/append-document-title.js \ $$PWD/data/big-user-script.js \ $$PWD/data/change-document-title.js \ + $$PWD/data/download.zip \ $$PWD/data/confirm.html \ $$PWD/data/directoryupload.html \ $$PWD/data/favicon.html \ $$PWD/data/favicon.png \ $$PWD/data/favicon2.html \ $$PWD/data/forms.html \ + $$PWD/data/geolocation.html \ $$PWD/data/javascript.html \ $$PWD/data/link.html \ $$PWD/data/prompt.html \ @@ -30,9 +32,11 @@ OTHER_FILES += \ $$PWD/data/keyboardModifierMapping.html \ $$PWD/data/titleupdate.js \ $$PWD/data/tst_desktopBehaviorLoadHtml.qml \ + $$PWD/data/tst_download.qml \ $$PWD/data/tst_favIconLoad.qml \ $$PWD/data/tst_filePicker.qml \ $$PWD/data/tst_formValidation.qml \ + $$PWD/data/tst_geopermission.qml \ $$PWD/data/tst_javaScriptDialogs.qml \ $$PWD/data/tst_linkHovered.qml \ $$PWD/data/tst_loadFail.qml \ diff --git a/tests/auto/widgets/qwebengineaccessibility/qwebengineaccessibility.pro b/tests/auto/widgets/qwebengineaccessibility/qwebengineaccessibility.pro index ff6c4962896e4c056799ef1640cb1560781caa5b..e99c7f4938cb1510eefefaefce31663c097f0542 100644 --- a/tests/auto/widgets/qwebengineaccessibility/qwebengineaccessibility.pro +++ b/tests/auto/widgets/qwebengineaccessibility/qwebengineaccessibility.pro @@ -1,2 +1 @@ include(../tests.pri) -exists($${TARGET}.qrc):RESOURCES += $${TARGET}.qrc diff --git a/tests/auto/widgets/qwebengineframe/qwebengineframe.pro b/tests/auto/widgets/qwebengineframe/qwebengineframe.pro deleted file mode 100644 index ff6c4962896e4c056799ef1640cb1560781caa5b..0000000000000000000000000000000000000000 --- a/tests/auto/widgets/qwebengineframe/qwebengineframe.pro +++ /dev/null @@ -1,2 +0,0 @@ -include(../tests.pri) -exists($${TARGET}.qrc):RESOURCES += $${TARGET}.qrc diff --git a/tests/auto/widgets/qwebengineframe/tst_qwebengineframe.cpp b/tests/auto/widgets/qwebengineframe/tst_qwebengineframe.cpp deleted file mode 100644 index 00e1b1123aeb2f5ecbb653dc65770354eb9278af..0000000000000000000000000000000000000000 --- a/tests/auto/widgets/qwebengineframe/tst_qwebengineframe.cpp +++ /dev/null @@ -1,1654 +0,0 @@ -/* - Copyright (C) 2008,2009 Nokia Corporation and/or its subsidiary(-ies) - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - - -#include <QtTest/QtTest> - -#include <qwebenginepage.h> -#include <qwebengineview.h> -#include <qwebenginehistory.h> -#include <QAbstractItemView> -#include <QApplication> -#include <QComboBox> -#include <QPaintEngine> -#include <QPicture> -#include <QRegExp> -#include <QNetworkRequest> -#include <QNetworkReply> -#include <QTextCodec> -#include <QWebEngineSettings> -#ifndef QT_NO_OPENSSL -#include <qsslerror.h> -#endif -#include "../util.h" - -class tst_QWebEngineFrame : public QObject -{ - Q_OBJECT - -public: - bool eventFilter(QObject* watched, QEvent* event); - -public Q_SLOTS: - void initTestCase(); - void init(); - void cleanup(); - -private Q_SLOTS: - void horizontalScrollAfterBack(); - void symmetricUrl(); - void progressSignal(); - void urlChange(); - void requestedUrl(); - void requestedUrlAfterSetAndLoadFailures(); - void javaScriptWindowObjectCleared_data(); - void javaScriptWindowObjectCleared(); - void javaScriptWindowObjectClearedOnEvaluate(); - void asyncAndDelete(); - void earlyToHtml(); - void setHtml(); - void setHtmlWithImageResource(); - void setHtmlWithStylesheetResource(); - void setHtmlWithBaseURL(); - void setHtmlWithJSAlert(); - void ipv6HostEncoding(); - void metaData(); -#if !defined(QT_NO_COMBOBOX) - void popupFocus(); -#endif - void inputFieldFocus(); - void hitTestContent(); - void baseUrl_data(); - void baseUrl(); - void hasSetFocus(); - void renderGeometry(); - void renderHints(); - void scrollPosition(); - void scrollToAnchor(); - void scrollbarsOff(); - void evaluateWillCauseRepaint(); - void setContent_data(); - void setContent(); - void setCacheLoadControlAttribute(); - void setUrlWithPendingLoads(); - void setUrlToEmpty(); - void setUrlToInvalid(); - void setUrlHistory(); - void setUrlUsingStateObject(); - void setUrlSameUrl(); - void setUrlThenLoads_data(); - void setUrlThenLoads(); - void loadFinishedAfterNotFoundError(); - void loadInSignalHandlers_data(); - void loadInSignalHandlers(); - -private: - QWebEngineView* m_view; - QWebEnginePage* m_page; - QWebEngineView* m_inputFieldsTestView; - int m_inputFieldTestPaintCount; -}; - -bool tst_QWebEngineFrame::eventFilter(QObject* watched, QEvent* event) -{ - // used on the inputFieldFocus test - if (watched == m_inputFieldsTestView) { - if (event->type() == QEvent::Paint) - m_inputFieldTestPaintCount++; - } - return QObject::eventFilter(watched, event); -} - -void tst_QWebEngineFrame::initTestCase() -{ -} - -void tst_QWebEngineFrame::init() -{ - m_view = new QWebEngineView(); - m_page = m_view->page(); - m_page->settings()->setAttribute(QWebEngineSettings::ErrorPageEnabled, false); -} - -void tst_QWebEngineFrame::cleanup() -{ - delete m_view; -} - -void tst_QWebEngineFrame::symmetricUrl() -{ - QWebEngineView view; - QSignalSpy loadFinishedSpy(view.page(), SIGNAL(loadFinished(bool))); - - QVERIFY(view.url().isEmpty()); - - QCOMPARE(view.history()->count(), 0); - - QUrl dataUrl("data:text/html,<h1>Test"); - - view.setUrl(dataUrl); - QCOMPARE(view.url(), dataUrl); - QCOMPARE(view.history()->count(), 0); - - // loading is _not_ immediate, so the text isn't set just yet. - QVERIFY(toPlainTextSync(view.page()).isEmpty()); - - QTRY_COMPARE(loadFinishedSpy.count(), 1); - - QCOMPARE(view.history()->count(), 1); - QCOMPARE(toPlainTextSync(view.page()), QString("Test")); - - QUrl dataUrl2("data:text/html,<h1>Test2"); - QUrl dataUrl3("data:text/html,<h1>Test3"); - - view.setUrl(dataUrl2); - view.setUrl(dataUrl3); - - QCOMPARE(view.url(), dataUrl3); - - QTRY_VERIFY(loadFinishedSpy.count() >= 2); - QTRY_COMPARE(loadFinishedSpy.count(), 3); - - QCOMPARE(view.history()->count(), 2); - - QCOMPARE(toPlainTextSync(view.page()), QString("Test3")); -} - -void tst_QWebEngineFrame::progressSignal() -{ - QSignalSpy progressSpy(m_view, SIGNAL(loadProgress(int))); - - QUrl dataUrl("data:text/html,<h1>Test"); - m_view->setUrl(dataUrl); - - ::waitForSignal(m_view, SIGNAL(loadFinished(bool))); - - QVERIFY(progressSpy.size() >= 2); - int previousValue = -1; - for (QSignalSpy::ConstIterator it = progressSpy.begin(); it < progressSpy.end(); ++it) { - int current = (*it).first().toInt(); - QVERIFY(current > previousValue); - previousValue = current; - } - - // But we always end at 100% - QCOMPARE(progressSpy.last().first().toInt(), 100); -} - -void tst_QWebEngineFrame::urlChange() -{ - QSignalSpy urlSpy(m_page, SIGNAL(urlChanged(QUrl))); - - QUrl dataUrl("data:text/html,<h1>Test"); - m_view->setUrl(dataUrl); - - ::waitForSignal(m_page, SIGNAL(urlChanged(QUrl))); - - QCOMPARE(urlSpy.size(), 1); - - QUrl dataUrl2("data:text/html,<html><head><title>title</title></head><body><h1>Test</body></html>"); - m_view->setUrl(dataUrl2); - - ::waitForSignal(m_page, SIGNAL(urlChanged(QUrl))); - - QCOMPARE(urlSpy.size(), 2); -} - -class FakeReply : public QNetworkReply { - Q_OBJECT - -public: - static const QUrl urlFor404ErrorWithoutContents; - - FakeReply(const QNetworkRequest& request, QObject* parent = 0) - : QNetworkReply(parent) - { - setOperation(QNetworkAccessManager::GetOperation); - setRequest(request); - setUrl(request.url()); - if (request.url() == QUrl("qrc:/test1.html")) { - setHeader(QNetworkRequest::LocationHeader, QString("qrc:/test2.html")); - setAttribute(QNetworkRequest::RedirectionTargetAttribute, QUrl("qrc:/test2.html")); - QTimer::singleShot(0, this, SLOT(continueRedirect())); - } -#ifndef QT_NO_OPENSSL - else if (request.url() == QUrl("qrc:/fake-ssl-error.html")) { - setError(QNetworkReply::SslHandshakeFailedError, tr("Fake error!")); - QTimer::singleShot(0, this, SLOT(continueError())); - } -#endif - else if (request.url().host() == QLatin1String("abcdef.abcdef")) { - setError(QNetworkReply::HostNotFoundError, tr("Invalid URL")); - QTimer::singleShot(0, this, SLOT(continueError())); - } else if (request.url() == FakeReply::urlFor404ErrorWithoutContents) { - setError(QNetworkReply::ContentNotFoundError, "Not found"); - setAttribute(QNetworkRequest::HttpStatusCodeAttribute, 404); - QTimer::singleShot(0, this, SLOT(continueError())); - } - - open(QIODevice::ReadOnly); - } - ~FakeReply() - { - close(); - } - virtual void abort() {} - virtual void close() {} - -protected: - qint64 readData(char*, qint64) - { - return 0; - } - -private Q_SLOTS: - void continueRedirect() - { - emit metaDataChanged(); - emit finished(); - } - - void continueError() - { - emit error(this->error()); - emit finished(); - } -}; - -const QUrl FakeReply::urlFor404ErrorWithoutContents = QUrl("http://this.will/return-http-404-error-without-contents.html"); - -class FakeNetworkManager : public QNetworkAccessManager { - Q_OBJECT - -public: - FakeNetworkManager(QObject* parent) : QNetworkAccessManager(parent) { } - -protected: - virtual QNetworkReply* createRequest(Operation op, const QNetworkRequest& request, QIODevice* outgoingData) - { - QString url = request.url().toString(); - if (op == QNetworkAccessManager::GetOperation) { -#ifndef QT_NO_OPENSSL - if (url == "qrc:/fake-ssl-error.html") { - FakeReply* reply = new FakeReply(request, this); - QList<QSslError> errors; - emit sslErrors(reply, errors << QSslError(QSslError::UnspecifiedError)); - return reply; - } -#endif - if (url == "qrc:/test1.html" || url == "http://abcdef.abcdef/" || request.url() == FakeReply::urlFor404ErrorWithoutContents) - return new FakeReply(request, this); - } - - return QNetworkAccessManager::createRequest(op, request, outgoingData); - } -}; - -void tst_QWebEngineFrame::requestedUrl() -{ -#if !defined(QWEBENGINEPAGE_SETNETWORKACCESSMANAGER) - QSKIP("QWEBENGINEPAGE_SETNETWORKACCESSMANAGER"); -#else - QWebEnginePage page; - - // in few seconds, the image should be completely loaded - QSignalSpy spy(&page, SIGNAL(loadFinished(bool))); - FakeNetworkManager* networkManager = new FakeNetworkManager(&page); - page.setNetworkAccessManager(networkManager); - - page.setUrl(QUrl("qrc:/test1.html")); - waitForSignal(&page, SIGNAL(loadFinished(bool)), 200); - QCOMPARE(spy.count(), 1); - QCOMPARE(page.requestedUrl(), QUrl("qrc:/test1.html")); - QCOMPARE(page.url(), QUrl("qrc:/test2.html")); - - page.setUrl(QUrl("qrc:/non-existent.html")); - waitForSignal(&page, SIGNAL(loadFinished(bool)), 200); - QCOMPARE(spy.count(), 2); - QCOMPARE(page.requestedUrl(), QUrl("qrc:/non-existent.html")); - QCOMPARE(page.url(), QUrl("qrc:/non-existent.html")); - - page.setUrl(QUrl("http://abcdef.abcdef")); - waitForSignal(&page, SIGNAL(loadFinished(bool)), 200); - QCOMPARE(spy.count(), 3); - QCOMPARE(page.requestedUrl(), QUrl("http://abcdef.abcdef/")); - QCOMPARE(page.url(), QUrl("http://abcdef.abcdef/")); - -#ifndef QT_NO_OPENSSL - qRegisterMetaType<QList<QSslError> >("QList<QSslError>"); - qRegisterMetaType<QNetworkReply* >("QNetworkReply*"); - - QSignalSpy spy2(page.networkAccessManager(), SIGNAL(sslErrors(QNetworkReply*,QList<QSslError>))); - page.setUrl(QUrl("qrc:/fake-ssl-error.html")); - waitForSignal(&page, SIGNAL(loadFinished(bool)), 200); - QCOMPARE(spy2.count(), 1); - QCOMPARE(page.requestedUrl(), QUrl("qrc:/fake-ssl-error.html")); - QCOMPARE(page.url(), QUrl("qrc:/fake-ssl-error.html")); -#endif -#endif -} - -void tst_QWebEngineFrame::requestedUrlAfterSetAndLoadFailures() -{ - QWebEnginePage page; - page.settings()->setAttribute(QWebEngineSettings::ErrorPageEnabled, false); - QSignalSpy spy(&page, SIGNAL(loadFinished(bool))); - - const QUrl first("http://abcdef.abcdef/"); - page.setUrl(first); - ::waitForSignal(&page, SIGNAL(loadFinished(bool))); - QCOMPARE(spy.count(), 1); - QCOMPARE(page.url(), first); - QCOMPARE(page.requestedUrl(), first); - QVERIFY(!spy.at(0).first().toBool()); - - const QUrl second("http://abcdef.abcdef/another_page.html"); - QVERIFY(first != second); - - page.load(second); - ::waitForSignal(&page, SIGNAL(loadFinished(bool))); - QCOMPARE(spy.count(), 2); - QCOMPARE(page.url(), first); - QCOMPARE(page.requestedUrl(), second); - QVERIFY(!spy.at(1).first().toBool()); -} - -void tst_QWebEngineFrame::javaScriptWindowObjectCleared_data() -{ - QTest::addColumn<QString>("html"); - QTest::addColumn<int>("signalCount"); - QTest::newRow("with <script>") << "<html><body><script>i=0</script><p>hello world</p></body></html>" << 1; - // NOTE: Empty scripts no longer cause this signal to be emitted. - QTest::newRow("with empty <script>") << "<html><body><script></script><p>hello world</p></body></html>" << 0; - QTest::newRow("without <script>") << "<html><body><p>hello world</p></body></html>" << 0; -} - -void tst_QWebEngineFrame::javaScriptWindowObjectCleared() -{ -#if !defined(QWEBENGINEPAGE_JAVASCRIPTWINDOWOBJECTCLEARED) - QSKIP("QWEBENGINEPAGE_JAVASCRIPTWINDOWOBJECTCLEARED"); -#else - QWebEnginePage page; - QSignalSpy spy(&page, SIGNAL(javaScriptWindowObjectCleared())); - QFETCH(QString, html); - page.setHtml(html); - - QFETCH(int, signalCount); - QCOMPARE(spy.count(), signalCount); -#endif -} - -void tst_QWebEngineFrame::javaScriptWindowObjectClearedOnEvaluate() -{ -#if !defined(QWEBENGINEPAGE_EVALUATEJAVASCRIPT) - QSKIP("QWEBENGINEPAGE_EVALUATEJAVASCRIPT"); -#else - QWebEnginePage page; - QSignalSpy spy(&page, SIGNAL(javaScriptWindowObjectCleared())); - page.setHtml("<html></html>"); - QCOMPARE(spy.count(), 0); - page.evaluateJavaScript("var a = 'a';"); - QCOMPARE(spy.count(), 1); - // no new clear for a new script: - page.evaluateJavaScript("var a = 1;"); - QCOMPARE(spy.count(), 1); -#endif -} - -void tst_QWebEngineFrame::asyncAndDelete() -{ - QWebEnginePage *page = new QWebEnginePage; - CallbackSpy<QString> plainTextSpy; - CallbackSpy<QString> htmlSpy; - page->toPlainText(plainTextSpy.ref()); - page->toHtml(htmlSpy.ref()); - - delete page; - // Pending callbacks should be called with an empty value in the page's destructor. - QCOMPARE(plainTextSpy.waitForResult(), QString()); - QVERIFY(plainTextSpy.wasCalled()); - QCOMPARE(htmlSpy.waitForResult(), QString()); - QVERIFY(htmlSpy.wasCalled()); -} - -void tst_QWebEngineFrame::earlyToHtml() -{ - QString html("<html><head></head><body></body></html>"); - QCOMPARE(toHtmlSync(m_view->page()), html); -} - -void tst_QWebEngineFrame::setHtml() -{ - QString html("<html><head></head><body><p>hello world</p></body></html>"); - QSignalSpy spy(m_view->page(), SIGNAL(loadFinished(bool))); - m_view->page()->setHtml(html); - QVERIFY(spy.wait()); - QCOMPARE(toHtmlSync(m_view->page()), html); -} - -void tst_QWebEngineFrame::setHtmlWithImageResource() -{ - // By default, only security origins of local files can load local resources. - // So we should specify baseUrl to be a local file in order to get a proper origin and load the local image. - - QLatin1String html("<html><body><p>hello world</p><img src='qrc:/image.png'/></body></html>"); - QWebEnginePage page; - - page.setHtml(html, QUrl(QLatin1String("file:///path/to/file"))); - waitForSignal(&page, SIGNAL(loadFinished(bool)), 200); - - QCOMPARE(evaluateJavaScriptSync(&page, "document.images.length").toInt(), 1); - QCOMPARE(evaluateJavaScriptSync(&page, "document.images[0].width").toInt(), 128); - QCOMPARE(evaluateJavaScriptSync(&page, "document.images[0].height").toInt(), 128); - - // Now we test the opposite: without a baseUrl as a local file, we cannot request local resources. - - page.setHtml(html); - waitForSignal(&page, SIGNAL(loadFinished(bool)), 200); - QCOMPARE(evaluateJavaScriptSync(&page, "document.images.length").toInt(), 1); - QEXPECT_FAIL("", "https://bugs.webkit.org/show_bug.cgi?id=118659", Continue); - QCOMPARE(evaluateJavaScriptSync(&page, "document.images[0].width").toInt(), 0); - QEXPECT_FAIL("", "https://bugs.webkit.org/show_bug.cgi?id=118659", Continue); - QCOMPARE(evaluateJavaScriptSync(&page, "document.images[0].height").toInt(), 0); -} - -void tst_QWebEngineFrame::setHtmlWithStylesheetResource() -{ -#if !defined(QWEBENGINEELEMENT) - QSKIP("QWEBENGINEELEMENT"); -#else - // By default, only security origins of local files can load local resources. - // So we should specify baseUrl to be a local file in order to be able to download the local stylesheet. - - const char* htmlData = - "<html>" - "<head>" - "<link rel='stylesheet' href='qrc:/style.css' type='text/css' />" - "</head>" - "<body>" - "<p id='idP'>some text</p>" - "</body>" - "</html>"; - QLatin1String html(htmlData); - QWebEnginePage page; - QWebEngineElement webElement; - - page.setHtml(html, QUrl(QLatin1String("qrc:///file"))); - waitForSignal(&page, SIGNAL(loadFinished(bool)), 200); - webElement = page.documentElement().findFirst("p"); - QCOMPARE(webElement.styleProperty("color", QWebEngineElement::CascadedStyle), QLatin1String("red")); - - // Now we test the opposite: without a baseUrl as a local file, we cannot request local resources. - - page.setHtml(html, QUrl(QLatin1String("http://www.example.com/"))); - waitForSignal(&page, SIGNAL(loadFinished(bool)), 200); - webElement = page.documentElement().findFirst("p"); - QEXPECT_FAIL("", "https://bugs.webkit.org/show_bug.cgi?id=118659", Continue); - QCOMPARE(webElement.styleProperty("color", QWebEngineElement::CascadedStyle), QString()); -#endif -} - -void tst_QWebEngineFrame::setHtmlWithBaseURL() -{ - // This tests if baseUrl is indeed affecting the relative paths from resources. - // As we are using a local file as baseUrl, its security origin should be able to load local resources. - - if (!QDir(TESTS_SOURCE_DIR).exists()) - W_QSKIP(QString("This test requires access to resources found in '%1'").arg(TESTS_SOURCE_DIR).toLatin1().constData(), SkipAll); - - QDir::setCurrent(TESTS_SOURCE_DIR); - - QString html("<html><body><p>hello world</p><img src='resources/image2.png'/></body></html>"); - - QWebEnginePage page; - - // in few seconds, the image should be completey loaded - QSignalSpy spy(&page, SIGNAL(loadFinished(bool))); - - page.setHtml(html, QUrl::fromLocalFile(TESTS_SOURCE_DIR)); - waitForSignal(&page, SIGNAL(loadFinished(bool)), 200); - QCOMPARE(spy.count(), 1); - - QCOMPARE(evaluateJavaScriptSync(&page, "document.images.length").toInt(), 1); - QCOMPARE(evaluateJavaScriptSync(&page, "document.images[0].width").toInt(), 128); - QCOMPARE(evaluateJavaScriptSync(&page, "document.images[0].height").toInt(), 128); - - // no history item has to be added. - QCOMPARE(m_view->page()->history()->count(), 0); -} - -class MyPage : public QWebEnginePage -{ -public: - MyPage() : QWebEnginePage(), alerts(0) {} - int alerts; - -protected: - virtual void javaScriptAlert(const QUrl &securityOrigin, const QString &msg) - { - alerts++; - QCOMPARE(securityOrigin, QUrl(QStringLiteral("http://test.origin.com/"))); - QCOMPARE(msg, QString("foo")); - } -}; - -void tst_QWebEngineFrame::setHtmlWithJSAlert() -{ - QString html("<html><head></head><body><script>alert('foo');</script><p>hello world</p></body></html>"); - MyPage page; - page.setHtml(html, QUrl(QStringLiteral("http://test.origin.com/path#fragment"))); - waitForSignal(&page, SIGNAL(loadFinished(bool))); - QCOMPARE(page.alerts, 1); - QCOMPARE(toHtmlSync(&page), html); -} - -class TestNetworkManager : public QNetworkAccessManager -{ -public: - TestNetworkManager(QObject* parent) : QNetworkAccessManager(parent) {} - - QList<QUrl> requestedUrls; - -protected: - virtual QNetworkReply* createRequest(Operation op, const QNetworkRequest &request, QIODevice* outgoingData) { - requestedUrls.append(request.url()); - QNetworkRequest redirectedRequest = request; - redirectedRequest.setUrl(QUrl("data:text/html,<p>hello")); - return QNetworkAccessManager::createRequest(op, redirectedRequest, outgoingData); - } -}; - -void tst_QWebEngineFrame::ipv6HostEncoding() -{ -#if !defined(QWEBENGINEPAGE_EVALUATEJAVASCRIPT) - QSKIP("QWEBENGINEPAGE_EVALUATEJAVASCRIPT"); -#else - TestNetworkManager* networkManager = new TestNetworkManager(m_page); - m_page->setNetworkAccessManager(networkManager); - networkManager->requestedUrls.clear(); - - QUrl baseUrl = QUrl::fromEncoded("http://[::1]/index.html"); - m_view->setHtml("<p>Hi", baseUrl); - m_view->page()->evaluateJavaScript("var r = new XMLHttpRequest();" - "r.open('GET', 'http://[::1]/test.xml', false);" - "r.send(null);" - ); - QCOMPARE(networkManager->requestedUrls.count(), 1); - QCOMPARE(networkManager->requestedUrls.at(0), QUrl::fromEncoded("http://[::1]/test.xml")); -#endif -} - -void tst_QWebEngineFrame::metaData() -{ -#if !defined(QWEBENGINEPAGE_METADATA) - QSKIP("QWEBENGINEPAGE_METADATA"); -#else - m_view->setHtml("<html>" - " <head>" - " <meta name=\"description\" content=\"Test description\">" - " <meta name=\"keywords\" content=\"HTML, JavaScript, Css\">" - " </head>" - "</html>"); - - QMultiMap<QString, QString> metaData = m_view->page()->metaData(); - - QCOMPARE(metaData.count(), 2); - - QCOMPARE(metaData.value("description"), QString("Test description")); - QCOMPARE(metaData.value("keywords"), QString("HTML, JavaScript, Css")); - QCOMPARE(metaData.value("nonexistent"), QString()); - - m_view->setHtml("<html>" - " <head>" - " <meta name=\"samekey\" content=\"FirstValue\">" - " <meta name=\"samekey\" content=\"SecondValue\">" - " </head>" - "</html>"); - - metaData = m_view->page()->metaData(); - - QCOMPARE(metaData.count(), 2); - - QStringList values = metaData.values("samekey"); - QCOMPARE(values.count(), 2); - - QVERIFY(values.contains("FirstValue")); - QVERIFY(values.contains("SecondValue")); - - QCOMPARE(metaData.value("nonexistent"), QString()); -#endif -} - -#if !defined(QT_NO_COMBOBOX) -void tst_QWebEngineFrame::popupFocus() -{ -#if !defined(QWEBENGINEELEMENT) - QSKIP("QWEBENGINEELEMENT"); -#else - QWebEngineView view; - view.setHtml("<html>" - " <body>" - " <select name=\"select\">" - " <option>1</option>" - " <option>2</option>" - " </select>" - " <input type=\"text\"> </input>" - " <textarea name=\"text_area\" rows=\"3\" cols=\"40\">" - "This test checks whether showing and hiding a popup" - "takes the focus away from the webpage." - " </textarea>" - " </body>" - "</html>"); - view.resize(400, 100); - // Call setFocus before show to work around http://bugreports.qt.nokia.com/browse/QTBUG-14762 - view.setFocus(); - view.show(); - QTest::qWaitForWindowExposed(&view); - view.activateWindow(); - QTRY_VERIFY(view.hasFocus()); - - // open the popup by clicking. check if focus is on the popup - const QWebEngineElement webCombo = view.page()->documentElement().findFirst(QLatin1String("select[name=select]")); - QTest::mouseClick(&view, Qt::LeftButton, 0, webCombo.geometry().center()); - - QComboBox* combo = view.findChild<QComboBox*>(); - QVERIFY(combo != 0); - QTRY_VERIFY(!view.hasFocus() && combo->view()->hasFocus()); // Focus should be on the popup - - // hide the popup and check if focus is on the page - combo->hidePopup(); - QTRY_VERIFY(view.hasFocus()); // Focus should be back on the WebView -#endif -} -#endif - -void tst_QWebEngineFrame::inputFieldFocus() -{ -#if !defined(QWEBENGINEELEMENT) - QSKIP("QWEBENGINEELEMENT"); -#else - QWebEngineView view; - view.setHtml("<html><body><input type=\"text\"></input></body></html>"); - view.resize(400, 100); - view.show(); - QTest::qWaitForWindowExposed(&view); - view.activateWindow(); - view.setFocus(); - QTRY_VERIFY(view.hasFocus()); - - // double the flashing time, should at least blink once already - int delay = qApp->cursorFlashTime() * 2; - - // focus the lineedit and check if it blinks - bool autoSipEnabled = qApp->autoSipEnabled(); - qApp->setAutoSipEnabled(false); - const QWebEngineElement inputElement = view.page()->documentElement().findFirst(QLatin1String("input[type=text]")); - QTest::mouseClick(&view, Qt::LeftButton, 0, inputElement.geometry().center()); - m_inputFieldsTestView = &view; - view.installEventFilter( this ); - QTest::qWait(delay); - QVERIFY2(m_inputFieldTestPaintCount >= 3, - "The input field should have a blinking caret"); - qApp->setAutoSipEnabled(autoSipEnabled); -#endif -} - -void tst_QWebEngineFrame::hitTestContent() -{ -#if !defined(QWEBENGINEELEMENT) - QSKIP("QWEBENGINEELEMENT"); -#else - QString html("<html><body><p>A paragraph</p><br/><br/><br/><a href=\"about:blank\" target=\"_foo\" id=\"link\">link text</a></body></html>"); - - QWebEnginePage page; - page.setHtml(html); - page.setViewportSize(QSize(200, 0)); //no height so link is not visible - const QWebEngineElement linkElement = page.documentElement().findFirst(QLatin1String("a#link")); - QWebEngineHitTestResult result = page.hitTestContent(linkElement.geometry().center()); - QCOMPARE(result.linkText(), QString("link text")); - QWebEngineElement link = result.linkElement(); - QCOMPARE(link.attribute("target"), QString("_foo")); -#endif -} - -void tst_QWebEngineFrame::baseUrl_data() -{ - QTest::addColumn<QString>("html"); - QTest::addColumn<QUrl>("loadUrl"); - QTest::addColumn<QUrl>("url"); - QTest::addColumn<QUrl>("baseUrl"); - - QTest::newRow("null") << QString() << QUrl() - << QUrl("about:blank") << QUrl("about:blank"); - - QTest::newRow("foo") << QString() << QUrl("http://foobar.baz/") - << QUrl("http://foobar.baz/") << QUrl("http://foobar.baz/"); - - QString html = "<html>" - "<head>" - "<base href=\"http://foobaz.bar/\" />" - "</head>" - "</html>"; - QTest::newRow("customBaseUrl") << html << QUrl("http://foobar.baz/") - << QUrl("http://foobar.baz/") << QUrl("http://foobaz.bar/"); -} - -void tst_QWebEngineFrame::baseUrl() -{ - QFETCH(QString, html); - QFETCH(QUrl, loadUrl); - QFETCH(QUrl, url); - QFETCH(QUrl, baseUrl); - - QSignalSpy loadSpy(m_page, SIGNAL(loadFinished(bool))); - m_page->setHtml(html, loadUrl); - QTRY_COMPARE(loadSpy.count(), 1); - QCOMPARE(m_page->url(), url); - QEXPECT_FAIL("null", "Slight change: We now translate QUrl() to about:blank for the virtual url, but not for the baseUrl", Continue); - QCOMPARE(baseUrlSync(m_page), baseUrl); -} - -void tst_QWebEngineFrame::hasSetFocus() -{ -#if !defined(QWEBENGINEFRAME) - QSKIP("QWEBENGINEFRAME"); -#else - QString html("<html><body><p>top</p>" \ - "<iframe width='80%' height='30%'/>" \ - "</body></html>"); - - QSignalSpy loadSpy(m_page, SIGNAL(loadFinished(bool))); - m_page->setHtml(html); - - waitForSignal(m_page, SIGNAL(loadFinished(bool)), 200); - QCOMPARE(loadSpy.size(), 1); - - QList<QWebEngineFrame*> children = m_page->childFrames(); - QWebEngineFrame* frame = children.at(0); - QString innerHtml("<html><body><p>another iframe</p>" \ - "<iframe width='80%' height='30%'/>" \ - "</body></html>"); - frame->setHtml(innerHtml); - - waitForSignal(frame, SIGNAL(loadFinished(bool)), 200); - QCOMPARE(loadSpy.size(), 2); - - m_page->setFocus(); - QTRY_VERIFY(m_page->hasFocus()); - - for (int i = 0; i < children.size(); ++i) { - children.at(i)->setFocus(); - QTRY_VERIFY(children.at(i)->hasFocus()); - QVERIFY(!m_page->hasFocus()); - } - - m_page->setFocus(); - QTRY_VERIFY(m_page->hasFocus()); -#endif -} - -void tst_QWebEngineFrame::renderGeometry() -{ -#if !defined(QWEBENGINEFRAME) - QSKIP("QWEBENGINEFRAME"); -#else - QString html("<html>" \ - "<head><style>" \ - "body, iframe { margin: 0px; border: none; }" \ - "</style></head>" \ - "<body><iframe width='100px' height='100px'/></body>" \ - "</html>"); - - QWebEnginePage page; - page.setHtml(html); - - QList<QWebEngineFrame*> frames = page.childFrames(); - QWebEngineFrame *frame = frames.at(0); - QString innerHtml("<body style='margin: 0px;'><img src='qrc:/image.png'/></body>"); - - // By default, only security origins of local files can load local resources. - // So we should specify baseUrl to be a local file in order to get a proper origin. - frame->setHtml(innerHtml, QUrl("file:///path/to/file")); - waitForSignal(frame, SIGNAL(loadFinished(bool)), 200); - - QPicture picture; - - QSize size = page.contentsSize(); - page.setViewportSize(size); - - // render contents layer only (the iframe is smaller than the image, so it will have scrollbars) - QPainter painter1(&picture); - frame->render(&painter1, QWebEngineFrame::ContentsLayer); - painter1.end(); - - QCOMPARE(size.width(), picture.boundingRect().width() + frame->scrollBarGeometry(Qt::Vertical).width()); - QCOMPARE(size.height(), picture.boundingRect().height() + frame->scrollBarGeometry(Qt::Horizontal).height()); - - // render everything, should be the size of the iframe - QPainter painter2(&picture); - frame->render(&painter2, QWebEngineFrame::AllLayers); - painter2.end(); - - QCOMPARE(size.width(), picture.boundingRect().width()); // width: 100px - QCOMPARE(size.height(), picture.boundingRect().height()); // height: 100px -#endif -} - - -class DummyPaintEngine: public QPaintEngine { -public: - - DummyPaintEngine() - : QPaintEngine(QPaintEngine::AllFeatures) - , renderHints(0) - { - } - - bool begin(QPaintDevice*) - { - setActive(true); - return true; - } - - bool end() - { - setActive(false); - return false; - } - - void updateState(const QPaintEngineState& state) - { - renderHints = state.renderHints(); - } - - void drawPath(const QPainterPath&) { } - void drawPixmap(const QRectF&, const QPixmap&, const QRectF&) { } - - QPaintEngine::Type type() const - { - return static_cast<QPaintEngine::Type>(QPaintEngine::User + 2); - } - - QPainter::RenderHints renderHints; -}; - -class DummyPaintDevice: public QPaintDevice { -public: - DummyPaintDevice() - : QPaintDevice() - , m_engine(new DummyPaintEngine) - { - } - - ~DummyPaintDevice() - { - delete m_engine; - } - - QPaintEngine* paintEngine() const - { - return m_engine; - } - - QPainter::RenderHints renderHints() const - { - return m_engine->renderHints; - } - -protected: - int metric(PaintDeviceMetric metric) const; - -private: - DummyPaintEngine* m_engine; - friend class DummyPaintEngine; -}; - - -int DummyPaintDevice::metric(PaintDeviceMetric metric) const -{ - switch (metric) { - case PdmWidth: - return 400; - break; - - case PdmHeight: - return 200; - break; - - case PdmNumColors: - return INT_MAX; - break; - - case PdmDepth: - return 32; - break; - - default: - break; - } - return 0; -} - -void tst_QWebEngineFrame::renderHints() -{ -#if !defined(QWEBENGINEPAGE_RENDER) - QSKIP("QWEBENGINEPAGE_RENDER"); -#else - QString html("<html><body><p>Hello, world!</p></body></html>"); - - QWebEnginePage page; - page.setHtml(html); - page.setViewportSize(page.contentsSize()); - - // We will call frame->render and trap the paint engine state changes - // to ensure that GraphicsContext does not clobber the render hints. - DummyPaintDevice buffer; - QPainter painter(&buffer); - - painter.setRenderHint(QPainter::TextAntialiasing, false); - page.render(&painter); - QVERIFY(!(buffer.renderHints() & QPainter::TextAntialiasing)); - QVERIFY(!(buffer.renderHints() & QPainter::SmoothPixmapTransform)); - QVERIFY(!(buffer.renderHints() & QPainter::HighQualityAntialiasing)); - - painter.setRenderHint(QPainter::TextAntialiasing, true); - page.render(&painter); - QVERIFY(buffer.renderHints() & QPainter::TextAntialiasing); - QVERIFY(!(buffer.renderHints() & QPainter::SmoothPixmapTransform)); - QVERIFY(!(buffer.renderHints() & QPainter::HighQualityAntialiasing)); - - painter.setRenderHint(QPainter::SmoothPixmapTransform, true); - page.render(&painter); - QVERIFY(buffer.renderHints() & QPainter::TextAntialiasing); - QVERIFY(buffer.renderHints() & QPainter::SmoothPixmapTransform); - QVERIFY(!(buffer.renderHints() & QPainter::HighQualityAntialiasing)); - - painter.setRenderHint(QPainter::HighQualityAntialiasing, true); - page.render(&painter); - QVERIFY(buffer.renderHints() & QPainter::TextAntialiasing); - QVERIFY(buffer.renderHints() & QPainter::SmoothPixmapTransform); - QVERIFY(buffer.renderHints() & QPainter::HighQualityAntialiasing); -#endif -} - -void tst_QWebEngineFrame::scrollPosition() -{ -#if !defined(QWEBENGINEPAGE_EVALUATEJAVASCRIPT) - QSKIP("QWEBENGINEPAGE_EVALUATEJAVASCRIPT"); -#else - // enlarged image in a small viewport, to provoke the scrollbars to appear - QString html("<html><body><img src='qrc:/image.png' height=500 width=500/></body></html>"); - - QWebEnginePage page; - page.setViewportSize(QSize(200, 200)); - - page.setHtml(html); - page.setScrollBarPolicy(Qt::Vertical, Qt::ScrollBarAlwaysOff); - page.setScrollBarPolicy(Qt::Horizontal, Qt::ScrollBarAlwaysOff); - - // try to set the scroll offset programmatically - page.setScrollPosition(QPoint(23, 29)); - QCOMPARE(page.scrollPosition().x(), 23); - QCOMPARE(page.scrollPosition().y(), 29); - - int x = page.evaluateJavaScript("window.scrollX").toInt(); - int y = page.evaluateJavaScript("window.scrollY").toInt(); - QCOMPARE(x, 23); - QCOMPARE(y, 29); -#endif -} - -void tst_QWebEngineFrame::scrollToAnchor() -{ -#if !defined(QWEBENGINEELEMENT) - QSKIP("QWEBENGINEELEMENT"); -#else - QWebEnginePage page; - page.setViewportSize(QSize(480, 800)); - - QString html("<html><body><p style=\"margin-bottom: 1500px;\">Hello.</p>" - "<p><a id=\"foo\">This</a> is an anchor</p>" - "<p style=\"margin-bottom: 1500px;\"><a id=\"bar\">This</a> is another anchor</p>" - "</body></html>"); - page.setHtml(html); - page.setScrollPosition(QPoint(0, 0)); - QCOMPARE(page.scrollPosition().x(), 0); - QCOMPARE(page.scrollPosition().y(), 0); - - QWebEngineElement fooAnchor = page.findFirstElement("a[id=foo]"); - - page.scrollToAnchor("foo"); - QCOMPARE(page.scrollPosition().y(), fooAnchor.geometry().top()); - - page.scrollToAnchor("bar"); - page.scrollToAnchor("foo"); - QCOMPARE(page.scrollPosition().y(), fooAnchor.geometry().top()); - - page.scrollToAnchor("top"); - QCOMPARE(page.scrollPosition().y(), 0); - - page.scrollToAnchor("bar"); - page.scrollToAnchor("notexist"); - QVERIFY(page.scrollPosition().y() != 0); -#endif -} - - -void tst_QWebEngineFrame::scrollbarsOff() -{ -#if !defined(QWEBENGINEPAGE_EVALUATEJAVASCRIPT) - QSKIP("QWEBENGINEPAGE_EVALUATEJAVASCRIPT"); -#else - QWebEngineView view; - QWebEngineFrame* mainFrame = view.page(); - - mainFrame->setScrollBarPolicy(Qt::Vertical, Qt::ScrollBarAlwaysOff); - mainFrame->setScrollBarPolicy(Qt::Horizontal, Qt::ScrollBarAlwaysOff); - - QString html("<script>" \ - " function checkScrollbar() {" \ - " if (innerWidth === document.documentElement.offsetWidth)" \ - " document.getElementById('span1').innerText = 'SUCCESS';" \ - " else" \ - " document.getElementById('span1').innerText = 'FAIL';" \ - " }" \ - "</script>" \ - "<body>" \ - " <div style='margin-top:1000px ; margin-left:1000px'>" \ - " <a id='offscreen' href='a'>End</a>" \ - " </div>" \ - "<span id='span1'></span>" \ - "</body>"); - - - QSignalSpy loadSpy(&view, SIGNAL(loadFinished(bool))); - view.setHtml(html); - ::waitForSignal(&view, SIGNAL(loadFinished(bool)), 200); - QCOMPARE(loadSpy.count(), 1); - - mainFrame->evaluateJavaScript("checkScrollbar();"); - QCOMPARE(mainFrame->documentElement().findAll("span").at(0).toPlainText(), QString("SUCCESS")); -#endif -} - -void tst_QWebEngineFrame::horizontalScrollAfterBack() -{ -#if !defined(QWEBENGINESETTINGS) - QSKIP("QWEBENGINESETTINGS"); -#else - QWebEngineView view; - QSignalSpy loadSpy(view.page(), SIGNAL(loadFinished(bool))); - - view.page()->settings()->setMaximumPagesInCache(2); - view.page()->setScrollBarPolicy(Qt::Vertical, Qt::ScrollBarAsNeeded); - view.page()->setScrollBarPolicy(Qt::Horizontal, Qt::ScrollBarAsNeeded); - - view.load(QUrl("qrc:/testiframe2.html")); - view.resize(200, 200); - QTRY_COMPARE(loadSpy.count(), 1); - QTRY_VERIFY((view.page()->scrollBarGeometry(Qt::Horizontal)).height()); - - view.load(QUrl("qrc:/testiframe.html")); - QTRY_COMPARE(loadSpy.count(), 2); - - view.page()->triggerAction(QWebEnginePage::Back); - QTRY_COMPARE(loadSpy.count(), 3); - QTRY_VERIFY((view.page()->scrollBarGeometry(Qt::Horizontal)).height()); -#endif -} - -void tst_QWebEngineFrame::evaluateWillCauseRepaint() -{ -#if !defined(QWEBENGINEPAGE_EVALUATEJAVASCRIPT) - QSKIP("QWEBENGINEPAGE_EVALUATEJAVASCRIPT"); -#else - QWebEngineView view; - QString html("<html><body>top<div id=\"junk\" style=\"display: block;\">" - "junk</div>bottom</body></html>"); - view.setHtml(html); - view.show(); - - QTest::qWaitForWindowExposed(&view); - view.page()->evaluateJavaScript( - "document.getElementById('junk').style.display = 'none';"); - - ::waitForSignal(view.page(), SIGNAL(repaintRequested(QRect))); -#endif -} - -void tst_QWebEngineFrame::setContent_data() -{ - QTest::addColumn<QString>("mimeType"); - QTest::addColumn<QByteArray>("testContents"); - QTest::addColumn<QString>("expected"); - - QString str = QString::fromUtf8("ὕαλον ϕαγεῖν δύναμαι· τοῦτο οὔ με βλάπτει"); - QTest::newRow("UTF-8 plain text") << "text/plain; charset=utf-8" << str.toUtf8() << str; - - QTextCodec *utf16 = QTextCodec::codecForName("UTF-16"); - if (utf16) - QTest::newRow("UTF-16 plain text") << "text/plain; charset=utf-16" << utf16->fromUnicode(str) << str; - - str = QString::fromUtf8("Une chaîne de caractères à sa façon."); - QTest::newRow("latin-1 plain text") << "text/plain; charset=iso-8859-1" << str.toLatin1() << str; - - -} - -void tst_QWebEngineFrame::setContent() -{ - QFETCH(QString, mimeType); - QFETCH(QByteArray, testContents); - QFETCH(QString, expected); - QSignalSpy loadSpy(m_page, SIGNAL(loadFinished(bool))); - m_view->setContent(testContents, mimeType); - QVERIFY(loadSpy.wait()); - QCOMPARE(toPlainTextSync(m_view->page()), expected); -} - -class CacheNetworkAccessManager : public QNetworkAccessManager { -public: - CacheNetworkAccessManager(QObject* parent = 0) - : QNetworkAccessManager(parent) - , m_lastCacheLoad(QNetworkRequest::PreferNetwork) - { - } - - virtual QNetworkReply* createRequest(Operation, const QNetworkRequest& request, QIODevice*) - { - QVariant cacheLoad = request.attribute(QNetworkRequest::CacheLoadControlAttribute); - if (cacheLoad.isValid()) - m_lastCacheLoad = static_cast<QNetworkRequest::CacheLoadControl>(cacheLoad.toUInt()); - else - m_lastCacheLoad = QNetworkRequest::PreferNetwork; // default value - return new FakeReply(request, this); - } - - QNetworkRequest::CacheLoadControl lastCacheLoad() const - { - return m_lastCacheLoad; - } - -private: - QNetworkRequest::CacheLoadControl m_lastCacheLoad; -}; - -void tst_QWebEngineFrame::setCacheLoadControlAttribute() -{ -#if !defined(QWEBENGINEPAGE_SETNETWORKACCESSMANAGER) - QSKIP("QWEBENGINEPAGE_SETNETWORKACCESSMANAGER"); -#else - QWebEnginePage page; - CacheNetworkAccessManager* manager = new CacheNetworkAccessManager(&page); - page.setNetworkAccessManager(manager); - - QNetworkRequest request(QUrl("http://abcdef.abcdef/")); - - request.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::AlwaysCache); - page.load(request); - QCOMPARE(manager->lastCacheLoad(), QNetworkRequest::AlwaysCache); - - request.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferCache); - page.load(request); - QCOMPARE(manager->lastCacheLoad(), QNetworkRequest::PreferCache); - - request.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::AlwaysNetwork); - page.load(request); - QCOMPARE(manager->lastCacheLoad(), QNetworkRequest::AlwaysNetwork); - - request.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferNetwork); - page.load(request); - QCOMPARE(manager->lastCacheLoad(), QNetworkRequest::PreferNetwork); -#endif -} - -void tst_QWebEngineFrame::setUrlWithPendingLoads() -{ - QWebEnginePage page; - page.setHtml("<img src='dummy:'/>"); - page.setUrl(QUrl("about:blank")); -} - -void tst_QWebEngineFrame::setUrlToEmpty() -{ - int expectedLoadFinishedCount = 0; - const QUrl aboutBlank("about:blank"); - const QUrl url("qrc:/test2.html"); - - QWebEnginePage page; - QCOMPARE(page.url(), QUrl()); - QCOMPARE(page.requestedUrl(), QUrl()); - QCOMPARE(baseUrlSync(&page), QUrl()); - - QSignalSpy spy(&page, SIGNAL(loadFinished(bool))); - - // Set existing url - page.setUrl(url); - expectedLoadFinishedCount++; - ::waitForSignal(&page, SIGNAL(loadFinished(bool))); - - QCOMPARE(spy.count(), expectedLoadFinishedCount); - QCOMPARE(page.url(), url); - QCOMPARE(page.requestedUrl(), url); - QCOMPARE(baseUrlSync(&page), url); - - // Set empty url - page.setUrl(QUrl()); - expectedLoadFinishedCount++; - - QTRY_COMPARE(spy.count(), expectedLoadFinishedCount); - QCOMPARE(page.url(), aboutBlank); - QCOMPARE(page.requestedUrl(), QUrl()); - QCOMPARE(baseUrlSync(&page), aboutBlank); - - // Set existing url - page.setUrl(url); - expectedLoadFinishedCount++; - - QTRY_COMPARE(spy.count(), expectedLoadFinishedCount); - QCOMPARE(page.url(), url); - QCOMPARE(page.requestedUrl(), url); - QCOMPARE(baseUrlSync(&page), url); - - // Load empty url - page.load(QUrl()); - expectedLoadFinishedCount++; - - QTRY_COMPARE(spy.count(), expectedLoadFinishedCount); - QCOMPARE(page.url(), aboutBlank); - QCOMPARE(page.requestedUrl(), QUrl()); - QCOMPARE(baseUrlSync(&page), aboutBlank); -} - -void tst_QWebEngineFrame::setUrlToInvalid() -{ - QEXPECT_FAIL("", "Unsupported: QtWebEngine doesn't adjust invalid URLs.", Abort); - QVERIFY(false); - - QWebEnginePage page; - - const QUrl invalidUrl("http:/example.com"); - QVERIFY(!invalidUrl.isEmpty()); - QVERIFY(invalidUrl != QUrl()); - - // QWebEngineFrame will do its best to accept the URL, possible converting it to a valid equivalent URL. - const QUrl validUrl("http://example.com/"); - page.setUrl(invalidUrl); - QCOMPARE(page.url(), validUrl); - QCOMPARE(page.requestedUrl(), validUrl); - QCOMPARE(baseUrlSync(&page), validUrl); - - // QUrls equivalent to QUrl() will be treated as such. - const QUrl aboutBlank("about:blank"); - const QUrl anotherInvalidUrl("1http://bugs.webkit.org"); - QVERIFY(!anotherInvalidUrl.isEmpty()); // and they are not necessarily empty. - QVERIFY(!anotherInvalidUrl.isValid()); - QCOMPARE(anotherInvalidUrl.toEncoded(), QUrl().toEncoded()); - - page.setUrl(anotherInvalidUrl); - QCOMPARE(page.url(), aboutBlank); - QCOMPARE(page.requestedUrl().toEncoded(), anotherInvalidUrl.toEncoded()); - QCOMPARE(baseUrlSync(&page), aboutBlank); -} - -static QStringList collectHistoryUrls(QWebEngineHistory *history) -{ - QStringList urls; - foreach (const QWebEngineHistoryItem &i, history->items()) - urls << i.url().toString(); - return urls; -} - -void tst_QWebEngineFrame::setUrlHistory() -{ - const QUrl aboutBlank("about:blank"); - QUrl url; - int expectedLoadFinishedCount = 0; - QSignalSpy spy(m_page, SIGNAL(loadFinished(bool))); - - QCOMPARE(m_page->history()->count(), 0); - - m_page->setUrl(QUrl()); - expectedLoadFinishedCount++; - QTRY_COMPARE(spy.count(), expectedLoadFinishedCount); - QCOMPARE(m_page->url(), aboutBlank); - QCOMPARE(m_page->requestedUrl(), QUrl()); - // Chromium stores navigation entry for every successful loads. The load of the empty page is committed and stored as about:blank. - QCOMPARE(collectHistoryUrls(m_page->history()), QStringList() << aboutBlank.toString()); - - url = QUrl("http://non.existent/"); - m_page->setUrl(url); - expectedLoadFinishedCount++; - QTRY_COMPARE(spy.count(), expectedLoadFinishedCount); - // When error page is disabled in case of LoadFail the entry of the unavailable page is not stored. - // We expect the url of the previously loaded page here. - QCOMPARE(m_page->url(), aboutBlank); - QCOMPARE(m_page->requestedUrl(), QUrl()); - // Since the entry of the unavailable page is not stored it will not available in the history. - QCOMPARE(collectHistoryUrls(m_page->history()), QStringList() << aboutBlank.toString()); - - url = QUrl("qrc:/test1.html"); - m_page->setUrl(url); - expectedLoadFinishedCount++; - QTRY_COMPARE(spy.count(), expectedLoadFinishedCount); - QCOMPARE(m_page->url(), url); - QCOMPARE(m_page->requestedUrl(), url); - QCOMPARE(collectHistoryUrls(m_page->history()), QStringList() << aboutBlank.toString() << QStringLiteral("qrc:/test1.html")); - - m_page->setUrl(QUrl()); - expectedLoadFinishedCount++; - QTRY_COMPARE(spy.count(), expectedLoadFinishedCount); - QCOMPARE(m_page->url(), aboutBlank); - QCOMPARE(m_page->requestedUrl(), QUrl()); - // Chromium stores navigation entry for every successful loads. The load of the empty page is committed and stored as about:blank. - QCOMPARE(collectHistoryUrls(m_page->history()), QStringList() - << aboutBlank.toString() - << QStringLiteral("qrc:/test1.html") - << aboutBlank.toString()); - - url = QUrl("qrc:/test1.html"); - m_page->setUrl(url); - expectedLoadFinishedCount++; - QTRY_COMPARE(spy.count(), expectedLoadFinishedCount); - QCOMPARE(m_page->url(), url); - QCOMPARE(m_page->requestedUrl(), url); - // The history count DOES change since the about:blank is in the list. - QCOMPARE(collectHistoryUrls(m_page->history()), QStringList() - << aboutBlank.toString() - << QStringLiteral("qrc:/test1.html") - << aboutBlank.toString() - << QStringLiteral("qrc:/test1.html")); - - url = QUrl("qrc:/test2.html"); - m_page->setUrl(url); - expectedLoadFinishedCount++; - QTRY_COMPARE(spy.count(), expectedLoadFinishedCount); - QCOMPARE(m_page->url(), url); - QCOMPARE(m_page->requestedUrl(), url); - QCOMPARE(collectHistoryUrls(m_page->history()), QStringList() - << aboutBlank.toString() - << QStringLiteral("qrc:/test1.html") - << aboutBlank.toString() - << QStringLiteral("qrc:/test1.html") - << QStringLiteral("qrc:/test2.html")); -} - -void tst_QWebEngineFrame::setUrlUsingStateObject() -{ - const QUrl aboutBlank("about:blank"); - QUrl url; - QSignalSpy urlChangedSpy(m_page, SIGNAL(urlChanged(QUrl))); - int expectedUrlChangeCount = 0; - - QCOMPARE(m_page->history()->count(), 0); - - url = QUrl("qrc:/test1.html"); - m_page->setUrl(url); - waitForSignal(m_page, SIGNAL(loadFinished(bool))); - expectedUrlChangeCount++; - QCOMPARE(urlChangedSpy.count(), expectedUrlChangeCount); - QCOMPARE(m_page->url(), url); - QCOMPARE(m_page->history()->count(), 1); - - evaluateJavaScriptSync(m_page, "window.history.pushState(null, 'push', 'navigate/to/here')"); - expectedUrlChangeCount++; - QCOMPARE(urlChangedSpy.count(), expectedUrlChangeCount); - QCOMPARE(m_page->url(), QUrl("qrc:/navigate/to/here")); - QCOMPARE(m_page->history()->count(), 2); - QVERIFY(m_page->history()->canGoBack()); - - evaluateJavaScriptSync(m_page, "window.history.replaceState(null, 'replace', 'another/location')"); - expectedUrlChangeCount++; - QCOMPARE(urlChangedSpy.count(), expectedUrlChangeCount); - QCOMPARE(m_page->url(), QUrl("qrc:/navigate/to/another/location")); - QCOMPARE(m_page->history()->count(), 2); - QVERIFY(!m_page->history()->canGoForward()); - QVERIFY(m_page->history()->canGoBack()); - - evaluateJavaScriptSync(m_page, "window.history.back()"); - QTest::qWait(100); - expectedUrlChangeCount++; - QCOMPARE(urlChangedSpy.count(), expectedUrlChangeCount); - QCOMPARE(m_page->url(), QUrl("qrc:/test1.html")); - QVERIFY(m_page->history()->canGoForward()); - QVERIFY(!m_page->history()->canGoBack()); -} - -void tst_QWebEngineFrame::setUrlSameUrl() -{ -#if !defined(QWEBENGINEPAGE_SETNETWORKACCESSMANAGER) - QSKIP("QWEBENGINEPAGE_SETNETWORKACCESSMANAGER"); -#else - const QUrl url1("qrc:/test1.html"); - const QUrl url2("qrc:/test2.html"); - - QWebEnginePage page; - FakeNetworkManager* networkManager = new FakeNetworkManager(&page); - page.setNetworkAccessManager(networkManager); - - QSignalSpy spy(&page, SIGNAL(loadFinished(bool))); - - page.setUrl(url1); - waitForSignal(&page, SIGNAL(loadFinished(bool))); - QVERIFY(page.url() != url1); // Nota bene: our QNAM redirects url1 to url2 - QCOMPARE(page.url(), url2); - QCOMPARE(spy.count(), 1); - - page.setUrl(url1); - waitForSignal(&page, SIGNAL(loadFinished(bool))); - QVERIFY(page.url() != url1); - QCOMPARE(page.url(), url2); - QCOMPARE(spy.count(), 2); - - // Now a case without redirect. The existing behavior we have for setUrl() - // is more like a "clear(); load()", so the page will be loaded again, even - // if urlToBeLoaded == url(). This test should be changed if we want to - // make setUrl() early return in this case. - page.setUrl(url2); - waitForSignal(&page, SIGNAL(loadFinished(bool))); - QCOMPARE(page.url(), url2); - QCOMPARE(spy.count(), 3); - - page.setUrl(url1); - waitForSignal(&page, SIGNAL(loadFinished(bool))); - QCOMPARE(page.url(), url2); - QCOMPARE(spy.count(), 4); -#endif -} - -static inline QUrl extractBaseUrl(const QUrl& url) -{ - return url.resolved(QUrl()); -} - -void tst_QWebEngineFrame::setUrlThenLoads_data() -{ - QTest::addColumn<QUrl>("url"); - QTest::addColumn<QUrl>("baseUrl"); - - QTest::newRow("resource file") << QUrl("qrc:/test1.html") << extractBaseUrl(QUrl("qrc:/test1.html")); - QTest::newRow("base specified in HTML") << QUrl("data:text/html,<head><base href=\"http://different.base/\"></head>") << QUrl("http://different.base/"); -} - -void tst_QWebEngineFrame::setUrlThenLoads() -{ - QFETCH(QUrl, url); - QFETCH(QUrl, baseUrl); - QSignalSpy urlChangedSpy(m_page, SIGNAL(urlChanged(QUrl))); - QSignalSpy startedSpy(m_page, SIGNAL(loadStarted())); - QSignalSpy finishedSpy(m_page, SIGNAL(loadFinished(bool))); - - m_page->setUrl(url); - QTRY_COMPARE(startedSpy.count(), 1); - QTRY_COMPARE(urlChangedSpy.count(), 1); - QTRY_COMPARE(finishedSpy.count(), 1); - QVERIFY(finishedSpy.at(0).first().toBool()); - QCOMPARE(m_page->url(), url); - QCOMPARE(m_page->requestedUrl(), url); - QCOMPARE(baseUrlSync(m_page), baseUrl); - - const QUrl urlToLoad1("qrc:/test2.html"); - const QUrl urlToLoad2("qrc:/test1.html"); - - // Just after first load. URL didn't changed yet. - m_page->load(urlToLoad1); - QCOMPARE(m_page->url(), url); - QCOMPARE(m_page->requestedUrl(), urlToLoad1); - // baseUrlSync spins an event loop and this sometimes return the next result. - // QCOMPARE(baseUrlSync(m_page), baseUrl); - QTRY_COMPARE(startedSpy.count(), 2); - - // After first URL changed. - QTRY_COMPARE(urlChangedSpy.count(), 2); - QTRY_COMPARE(finishedSpy.count(), 2); - QVERIFY(finishedSpy.at(1).first().toBool()); - QCOMPARE(m_page->url(), urlToLoad1); - QCOMPARE(m_page->requestedUrl(), urlToLoad1); - QCOMPARE(baseUrlSync(m_page), extractBaseUrl(urlToLoad1)); - - // Just after second load. URL didn't changed yet. - m_page->load(urlToLoad2); - QCOMPARE(m_page->url(), urlToLoad1); - QCOMPARE(m_page->requestedUrl(), urlToLoad2); - QCOMPARE(baseUrlSync(m_page), extractBaseUrl(urlToLoad1)); - QTRY_COMPARE(startedSpy.count(), 3); - - // After second URL changed. - QTRY_COMPARE(urlChangedSpy.count(), 3); - QTRY_COMPARE(finishedSpy.count(), 3); - QVERIFY(finishedSpy.at(2).first().toBool()); - QCOMPARE(m_page->url(), urlToLoad2); - QCOMPARE(m_page->requestedUrl(), urlToLoad2); - QCOMPARE(baseUrlSync(m_page), extractBaseUrl(urlToLoad2)); -} - -void tst_QWebEngineFrame::loadFinishedAfterNotFoundError() -{ -#if !defined(QWEBENGINEPAGE_SETNETWORKACCESSMANAGER) - QSKIP("QWEBENGINEPAGE_SETNETWORKACCESSMANAGER"); -#else - QWebEnginePage page; - - QSignalSpy spy(&page, SIGNAL(loadFinished(bool))); - FakeNetworkManager* networkManager = new FakeNetworkManager(&page); - page.setNetworkAccessManager(networkManager); - - page.setUrl(FakeReply::urlFor404ErrorWithoutContents); - QTRY_COMPARE(spy.count(), 1); - const bool wasLoadOk = spy.at(0).at(0).toBool(); - QVERIFY(!wasLoadOk); -#endif -} - -class URLSetter : public QObject { - Q_OBJECT - -public: - enum Signal { - LoadStarted, - LoadFinished, - ProvisionalLoad - }; - - enum Type { - UseLoad, - UseSetUrl - }; - - URLSetter(QWebEnginePage*, Signal, Type, const QUrl&); - -public Q_SLOTS: - void execute(); - -Q_SIGNALS: - void finished(); - -private: - QWebEnginePage* m_page; - QUrl m_url; - Type m_type; -}; - -Q_DECLARE_METATYPE(URLSetter::Signal) -Q_DECLARE_METATYPE(URLSetter::Type) - -URLSetter::URLSetter(QWebEnginePage* page, Signal signal, URLSetter::Type type, const QUrl& url) - : m_page(page), m_url(url), m_type(type) -{ - if (signal == LoadStarted) - connect(m_page, SIGNAL(loadStarted()), SLOT(execute())); - else if (signal == LoadFinished) - connect(m_page, SIGNAL(loadFinished(bool)), SLOT(execute())); - else - connect(m_page, SIGNAL(provisionalLoad()), SLOT(execute())); -} - -void URLSetter::execute() -{ - // We track only the first emission. - m_page->disconnect(this); - if (m_type == URLSetter::UseLoad) - m_page->load(m_url); - else - m_page->setUrl(m_url); - connect(m_page, SIGNAL(loadFinished(bool)), SIGNAL(finished())); -} - -void tst_QWebEngineFrame::loadInSignalHandlers_data() -{ - QSKIP("FIXME: This crashes in content::WebContentsImpl::NavigateToEntry because of reentrancy. Should we require QueuedConnections or do it ourselves to support this?"); - - QTest::addColumn<URLSetter::Type>("type"); - QTest::addColumn<URLSetter::Signal>("signal"); - QTest::addColumn<QUrl>("url"); - - const QUrl validUrl("qrc:/test2.html"); - const QUrl invalidUrl("qrc:/invalid"); - - QTest::newRow("call load() in loadStarted() after valid url") << URLSetter::UseLoad << URLSetter::LoadStarted << validUrl; - QTest::newRow("call load() in loadStarted() after invalid url") << URLSetter::UseLoad << URLSetter::LoadStarted << invalidUrl; - QTest::newRow("call load() in loadFinished() after valid url") << URLSetter::UseLoad << URLSetter::LoadFinished << validUrl; - QTest::newRow("call load() in loadFinished() after invalid url") << URLSetter::UseLoad << URLSetter::LoadFinished << invalidUrl; - QTest::newRow("call load() in provisionalLoad() after valid url") << URLSetter::UseLoad << URLSetter::ProvisionalLoad << validUrl; - QTest::newRow("call load() in provisionalLoad() after invalid url") << URLSetter::UseLoad << URLSetter::ProvisionalLoad << invalidUrl; - - QTest::newRow("call setUrl() in loadStarted() after valid url") << URLSetter::UseSetUrl << URLSetter::LoadStarted << validUrl; - QTest::newRow("call setUrl() in loadStarted() after invalid url") << URLSetter::UseSetUrl << URLSetter::LoadStarted << invalidUrl; - QTest::newRow("call setUrl() in loadFinished() after valid url") << URLSetter::UseSetUrl << URLSetter::LoadFinished << validUrl; - QTest::newRow("call setUrl() in loadFinished() after invalid url") << URLSetter::UseSetUrl << URLSetter::LoadFinished << invalidUrl; - QTest::newRow("call setUrl() in provisionalLoad() after valid url") << URLSetter::UseSetUrl << URLSetter::ProvisionalLoad << validUrl; - QTest::newRow("call setUrl() in provisionalLoad() after invalid url") << URLSetter::UseSetUrl << URLSetter::ProvisionalLoad << invalidUrl; -} - -void tst_QWebEngineFrame::loadInSignalHandlers() -{ - QFETCH(URLSetter::Type, type); - QFETCH(URLSetter::Signal, signal); - QFETCH(QUrl, url); - - const QUrl urlForSetter("qrc:/test1.html"); - URLSetter setter(m_page, signal, type, urlForSetter); - - m_page->load(url); - waitForSignal(&setter, SIGNAL(finished()), 200); - QCOMPARE(m_page->url(), urlForSetter); -} - -QTEST_MAIN(tst_QWebEngineFrame) -#include "tst_qwebengineframe.moc" diff --git a/tests/auto/widgets/qwebengineframe/tst_qwebengineframe.qrc b/tests/auto/widgets/qwebengineframe/tst_qwebengineframe.qrc deleted file mode 100644 index 2a7d0b9c2825ff8505aa61ad8753fc561d621ecb..0000000000000000000000000000000000000000 --- a/tests/auto/widgets/qwebengineframe/tst_qwebengineframe.qrc +++ /dev/null @@ -1,10 +0,0 @@ -<!DOCTYPE RCC><RCC version="1.0"> -<qresource prefix="/"> -<file alias="image.png">resources/image.png</file> -<file alias="style.css">resources/style.css</file> -<file alias="test1.html">resources/test1.html</file> -<file alias="test2.html">resources/test2.html</file> -<file alias="testiframe.html">resources/testiframe.html</file> -<file alias="testiframe2.html">resources/testiframe2.html</file> -</qresource> -</RCC> diff --git a/tests/auto/widgets/qwebenginehistory/qwebenginehistory.pro b/tests/auto/widgets/qwebenginehistory/qwebenginehistory.pro index ff6c4962896e4c056799ef1640cb1560781caa5b..e99c7f4938cb1510eefefaefce31663c097f0542 100644 --- a/tests/auto/widgets/qwebenginehistory/qwebenginehistory.pro +++ b/tests/auto/widgets/qwebenginehistory/qwebenginehistory.pro @@ -1,2 +1 @@ include(../tests.pri) -exists($${TARGET}.qrc):RESOURCES += $${TARGET}.qrc diff --git a/tests/auto/widgets/qwebenginehistoryinterface/qwebenginehistoryinterface.pro b/tests/auto/widgets/qwebenginehistoryinterface/qwebenginehistoryinterface.pro index ff6c4962896e4c056799ef1640cb1560781caa5b..e99c7f4938cb1510eefefaefce31663c097f0542 100644 --- a/tests/auto/widgets/qwebenginehistoryinterface/qwebenginehistoryinterface.pro +++ b/tests/auto/widgets/qwebenginehistoryinterface/qwebenginehistoryinterface.pro @@ -1,2 +1 @@ include(../tests.pri) -exists($${TARGET}.qrc):RESOURCES += $${TARGET}.qrc diff --git a/tests/auto/widgets/qwebengineinspector/qwebengineinspector.pro b/tests/auto/widgets/qwebengineinspector/qwebengineinspector.pro index ff6c4962896e4c056799ef1640cb1560781caa5b..e99c7f4938cb1510eefefaefce31663c097f0542 100644 --- a/tests/auto/widgets/qwebengineinspector/qwebengineinspector.pro +++ b/tests/auto/widgets/qwebengineinspector/qwebengineinspector.pro @@ -1,2 +1 @@ include(../tests.pri) -exists($${TARGET}.qrc):RESOURCES += $${TARGET}.qrc diff --git a/tests/auto/widgets/qwebenginepage/qwebenginepage.pro b/tests/auto/widgets/qwebenginepage/qwebenginepage.pro index e56bbe8f7aaf2d1c917c99c459c7634c9c56c184..70786e70f9c8b49d8b3d96a457df627f2b3cc04f 100644 --- a/tests/auto/widgets/qwebenginepage/qwebenginepage.pro +++ b/tests/auto/widgets/qwebenginepage/qwebenginepage.pro @@ -1,3 +1,2 @@ include(../tests.pri) -exists($${TARGET}.qrc):RESOURCES += $${TARGET}.qrc QT *= core-private gui-private diff --git a/tests/auto/widgets/qwebenginepage/resources/fullscreen.html b/tests/auto/widgets/qwebenginepage/resources/fullscreen.html new file mode 100644 index 0000000000000000000000000000000000000000..84771ca85ffd2626944ab1b7301b637cf0c4d8f9 --- /dev/null +++ b/tests/auto/widgets/qwebenginepage/resources/fullscreen.html @@ -0,0 +1,10 @@ +<html> +<body onkeypress='onKeyPress()'> +<a>This is test content</a> +<script> +function onKeyPress() { + document.documentElement.webkitRequestFullScreen(); +} +</script> +</body> +</html> diff --git a/tests/auto/widgets/qwebengineframe/resources/image.png b/tests/auto/widgets/qwebenginepage/resources/image.png similarity index 100% rename from tests/auto/widgets/qwebengineframe/resources/image.png rename to tests/auto/widgets/qwebenginepage/resources/image.png diff --git a/tests/auto/widgets/qwebengineframe/resources/style.css b/tests/auto/widgets/qwebenginepage/resources/style.css similarity index 100% rename from tests/auto/widgets/qwebengineframe/resources/style.css rename to tests/auto/widgets/qwebenginepage/resources/style.css diff --git a/tests/auto/widgets/qwebengineframe/resources/test1.html b/tests/auto/widgets/qwebenginepage/resources/test1.html similarity index 100% rename from tests/auto/widgets/qwebengineframe/resources/test1.html rename to tests/auto/widgets/qwebenginepage/resources/test1.html diff --git a/tests/auto/widgets/qwebengineframe/resources/test2.html b/tests/auto/widgets/qwebenginepage/resources/test2.html similarity index 100% rename from tests/auto/widgets/qwebengineframe/resources/test2.html rename to tests/auto/widgets/qwebenginepage/resources/test2.html diff --git a/tests/auto/widgets/qwebengineframe/resources/testiframe.html b/tests/auto/widgets/qwebenginepage/resources/testiframe.html similarity index 100% rename from tests/auto/widgets/qwebengineframe/resources/testiframe.html rename to tests/auto/widgets/qwebenginepage/resources/testiframe.html diff --git a/tests/auto/widgets/qwebengineframe/resources/testiframe2.html b/tests/auto/widgets/qwebenginepage/resources/testiframe2.html similarity index 100% rename from tests/auto/widgets/qwebengineframe/resources/testiframe2.html rename to tests/auto/widgets/qwebenginepage/resources/testiframe2.html diff --git a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp index 9562871b38437bc29b75cd6b9165f1e56d65b853..6e3976766c7cba6ddc00989a0c0afc33f54d8056 100644 --- a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp +++ b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp @@ -27,6 +27,7 @@ #include <QMainWindow> #include <QMenu> #include <QMimeDatabase> +#include <QPaintEngine> #include <QPushButton> #include <QStateMachine> #include <QStyle> @@ -95,6 +96,8 @@ public: tst_QWebEnginePage(); virtual ~tst_QWebEnginePage(); + bool eventFilter(QObject *watched, QEvent *event); + public Q_SLOTS: void init(); void cleanup(); @@ -108,6 +111,7 @@ private Q_SLOTS: void contextMenuPopulatedOnce(); void acceptNavigationRequest(); void acceptNavigationRequestNavigationType(); + void geolocationRequestJS_data(); void geolocationRequestJS(); void loadFinished(); void actionStates(); @@ -132,7 +136,6 @@ private Q_SLOTS: void textSelection(); void textEditing(); void backActionUpdate(); - void frameAt(); void protectBindingsRuntimeObjectsFromCollector(); void localURLSchemes(); void testOptionalJSObjects(); @@ -145,8 +148,6 @@ private Q_SLOTS: void inputMethodsTextFormat(); void defaultTextEncoding(); void errorPageExtension(); - void errorPageExtensionInIFrames(); - void errorPageExtensionInFrameset(); void errorPageExtensionLoadFinished(); void userAgentApplicationName(); void userAgentNewlineStripping(); @@ -166,9 +167,6 @@ private Q_SLOTS: void unacceleratedWebGLScreenshotWithoutView(); #endif - void originatingObjectInNetworkRequests(); - void networkReplyParentDidntChange(); - void destroyQNAMBeforeAbortDoesntCrash(); void testJSPrompt(); void testStopScheduledPageRefresh(); void findText(); @@ -192,10 +190,57 @@ private Q_SLOTS: #endif void runJavaScript(); + void fullScreenRequested(); + + + // Tests from tst_QWebEngineFrame + void horizontalScrollAfterBack(); + void symmetricUrl(); + void progressSignal(); + void urlChange(); + void requestedUrlAfterSetAndLoadFailures(); + void javaScriptWindowObjectCleared_data(); + void javaScriptWindowObjectCleared(); + void javaScriptWindowObjectClearedOnEvaluate(); + void asyncAndDelete(); + void earlyToHtml(); + void setHtml(); + void setHtmlWithImageResource(); + void setHtmlWithStylesheetResource(); + void setHtmlWithBaseURL(); + void setHtmlWithJSAlert(); + void metaData(); +#if !defined(QT_NO_COMBOBOX) + void popupFocus(); +#endif + void inputFieldFocus(); + void hitTestContent(); + void baseUrl_data(); + void baseUrl(); + void renderHints(); + void scrollPosition(); + void scrollToAnchor(); + void scrollbarsOff(); + void evaluateWillCauseRepaint(); + void setContent_data(); + void setContent(); + void setCacheLoadControlAttribute(); + void setUrlWithPendingLoads(); + void setUrlToEmpty(); + void setUrlToInvalid(); + void setUrlHistory(); + void setUrlUsingStateObject(); + void setUrlThenLoads_data(); + void setUrlThenLoads(); + void loadFinishedAfterNotFoundError(); + void loadInSignalHandlers_data(); + void loadInSignalHandlers(); private: QWebEngineView* m_view; QWebEnginePage* m_page; + QWebEngineView* m_inputFieldsTestView; + int m_inputFieldTestPaintCount; QString tmpDirPath() const { static QString tmpd = QDir::tempPath() + "/tst_qwebenginepage-" @@ -212,10 +257,21 @@ tst_QWebEnginePage::~tst_QWebEnginePage() { } +bool tst_QWebEnginePage::eventFilter(QObject* watched, QEvent* event) +{ + // used on the inputFieldFocus test + if (watched == m_inputFieldsTestView) { + if (event->type() == QEvent::Paint) + m_inputFieldTestPaintCount++; + } + return QObject::eventFilter(watched, event); +} + void tst_QWebEnginePage::init() { m_view = new QWebEngineView(); m_page = m_view->page(); + m_page->settings()->setAttribute(QWebEngineSettings::ErrorPageEnabled, false); } void tst_QWebEnginePage::cleanup() @@ -278,7 +334,6 @@ void tst_QWebEnginePage::acceptNavigationRequest() m_view->setPage(0); } -#if defined(QWEBENGINEPAGE_SETFEATUREPERMISSION) class JSTestPage : public QWebEnginePage { Q_OBJECT @@ -291,12 +346,12 @@ public: return true; } public Q_SLOTS: - void requestPermission(QWebEngineFrame* frame, QWebEnginePage::Feature feature) + void requestPermission(const QUrl &origin, QWebEnginePage::Feature feature) { if (m_allowGeolocation) - setFeaturePermission(frame, feature, PermissionGrantedByUser); + setFeaturePermission(origin, feature, PermissionGrantedByUser); else - setFeaturePermission(frame, feature, PermissionDeniedByUser); + setFeaturePermission(origin, feature, PermissionDeniedByUser); } public: @@ -308,7 +363,6 @@ public: private: bool m_allowGeolocation; }; -#endif // [Qt] tst_QWebEnginePage::infiniteLoopJS() timeouts with DFG JIT // https://bugs.webkit.org/show_bug.cgi?id=79040 @@ -323,40 +377,38 @@ void tst_QWebEnginePage::infiniteLoopJS() } */ -void tst_QWebEnginePage::geolocationRequestJS() +void tst_QWebEnginePage::geolocationRequestJS_data() { -#if !defined(QWEBENGINEPAGE_SETFEATUREPERMISSION) - QSKIP("QWEBENGINEPAGE_SETFEATUREPERMISSION"); -#else - JSTestPage* newPage = new JSTestPage(m_view); + QTest::addColumn<bool>("allowed"); + QTest::addColumn<int>("errorCode"); + QTest::newRow("allowed") << true << 0; + QTest::newRow("not allowed") << false << 1; +} +void tst_QWebEnginePage::geolocationRequestJS() +{ + QFETCH(bool, allowed); + QFETCH(int, errorCode); + QWebEngineView *view = new QWebEngineView; + JSTestPage *newPage = new JSTestPage(view); + newPage->setView(view); + newPage->setGeolocationPermission(allowed); + + connect(newPage, SIGNAL(featurePermissionRequested(const QUrl&, QWebEnginePage::Feature)), + newPage, SLOT(requestPermission(const QUrl&, QWebEnginePage::Feature))); + + QSignalSpy spyLoadFinished(newPage, SIGNAL(loadFinished(bool))); + newPage->setHtml(QString("<html><body>test</body></html>"), QUrl()); + QTRY_COMPARE(spyLoadFinished.count(), 1); if (evaluateJavaScriptSync(newPage, QLatin1String("!navigator.geolocation")).toBool()) { - delete newPage; + delete view; W_QSKIP("Geolocation is not supported.", SkipSingle); } - connect(newPage, SIGNAL(featurePermissionRequested(QWebEngineFrame*, QWebEnginePage::Feature)), - newPage, SLOT(requestPermission(QWebEngineFrame*, QWebEnginePage::Feature))); - - newPage->setGeolocationPermission(false); - m_view->setPage(newPage); - m_view->setHtml(QString("<html><body>test</body></html>"), QUrl()); - evaluateJavaScriptSync(m_view->page(), "var errorCode = 0; function error(err) { errorCode = err.code; } function success(pos) { } navigator.geolocation.getCurrentPosition(success, error)"); - QTest::qWait(2000); - QVariant empty = evaluateJavaScriptSync(m_view->page(), "errorCode"); - - QEXPECT_FAIL("", "https://bugs.webkit.org/show_bug.cgi?id=102235", Continue); - QVERIFY(empty.type() == QVariant::Double && empty.toInt() != 0); - - newPage->setGeolocationPermission(true); - evaluateJavaScriptSync(m_view->page(), "errorCode = 0; navigator.geolocation.getCurrentPosition(success, error);"); - empty = evaluateJavaScriptSync(m_view->page(), "errorCode"); + evaluateJavaScriptSync(newPage, "var errorCode = 0; function error(err) { errorCode = err.code; } function success(pos) { } navigator.geolocation.getCurrentPosition(success, error)"); - //http://dev.w3.org/geo/api/spec-source.html#position - //PositionError: const unsigned short PERMISSION_DENIED = 1; - QVERIFY(empty.type() == QVariant::Double && empty.toInt() != 1); - delete newPage; -#endif + QTRY_COMPARE(evaluateJavaScriptSync(newPage, "errorCode").toInt(), errorCode); + delete view; } void tst_QWebEnginePage::loadFinished() @@ -1176,6 +1228,10 @@ public: int isSelectionCollapsed() { return evaluateJavaScriptSync(this, "window.getSelection().getRangeAt(0).collapsed").toBool(); } + bool hasSelection() + { + return !selectedText().isEmpty(); + } }; void tst_QWebEnginePage::cursorMovements() @@ -1380,17 +1436,19 @@ void tst_QWebEnginePage::cursorMovements() void tst_QWebEnginePage::textSelection() { -#if !defined(QWEBENGINEPAGE_EVALUATEJAVASCRIPT) - QSKIP("QWEBENGINEPAGE_EVALUATEJAVASCRIPT"); -#else - CursorTrackedPage* page = new CursorTrackedPage; + QWebEngineView *view = new QWebEngineView; + CursorTrackedPage *page = new CursorTrackedPage; QString content("<html><body><p id=one>The quick brown fox</p>" \ "<p id=two>jumps over the lazy dog</p>" \ "<p>May the source<br/>be with you!</p></body></html>"); + page->setView(view); + QSignalSpy loadSpy(view, SIGNAL(loadFinished(bool))); page->setHtml(content); + QTRY_COMPARE(loadSpy.count(), 1); // these actions must exist QVERIFY(page->action(QWebEnginePage::SelectAll) != 0); +#if defined(QWEBENGINEPAGE_SELECTACTIONS) QVERIFY(page->action(QWebEnginePage::SelectNextChar) != 0); QVERIFY(page->action(QWebEnginePage::SelectPreviousChar) != 0); QVERIFY(page->action(QWebEnginePage::SelectNextWord) != 0); @@ -1418,6 +1476,7 @@ void tst_QWebEnginePage::textSelection() QCOMPARE(page->action(QWebEnginePage::SelectEndOfBlock)->isEnabled(), false); QCOMPARE(page->action(QWebEnginePage::SelectStartOfDocument)->isEnabled(), false); QCOMPARE(page->action(QWebEnginePage::SelectEndOfDocument)->isEnabled(), false); +#endif // ..but SelectAll is awalys enabled QCOMPARE(page->action(QWebEnginePage::SelectAll)->isEnabled(), true); @@ -1432,13 +1491,15 @@ void tst_QWebEnginePage::textSelection() "getSelection().addRange(range);"; evaluateJavaScriptSync(page, selectScript); QCOMPARE(page->selectedText().trimmed(), QString::fromLatin1("The quick brown fox")); +#if defined(QWEBENGINEPAGE_SELECTEDHTML) QRegExp regExp(" style=\".*\""); regExp.setMinimal(true); QCOMPARE(page->selectedHtml().trimmed().replace(regExp, ""), QString::fromLatin1("<p id=\"one\">The quick brown fox</p>")); - +#endif // Make sure hasSelection returns true, since there is selected text now... QCOMPARE(page->hasSelection(), true); +#if defined(QWEBENGINEPAGE_SELECTACTIONS) // here the actions are enabled after a selection has been created QCOMPARE(page->action(QWebEnginePage::SelectNextChar)->isEnabled(), true); QCOMPARE(page->action(QWebEnginePage::SelectPreviousChar)->isEnabled(), true); @@ -1474,9 +1535,10 @@ void tst_QWebEnginePage::textSelection() QCOMPARE(page->action(QWebEnginePage::SelectEndOfBlock)->isEnabled(), true); QCOMPARE(page->action(QWebEnginePage::SelectStartOfDocument)->isEnabled(), true); QCOMPARE(page->action(QWebEnginePage::SelectEndOfDocument)->isEnabled(), true); +#endif delete page; -#endif + delete view; } void tst_QWebEnginePage::textEditing() @@ -1621,39 +1683,6 @@ void tst_QWebEnginePage::backActionUpdate() QVERIFY(action->isEnabled()); } -#if defined(QWEBENGINEFRAME) -void frameAtHelper(QWebEnginePage* webPage, QWebEngineFrame* webFrame, QPoint framePosition) -{ - if (!webFrame) - return; - - framePosition += QPoint(webFrame->pos()); - QList<QWebEngineFrame*> children = webFrame->childFrames(); - for (int i = 0; i < children.size(); ++i) { - if (children.at(i)->childFrames().size() > 0) - frameAtHelper(webPage, children.at(i), framePosition); - - QRect frameRect(children.at(i)->pos() + framePosition, children.at(i)->geometry().size()); - QVERIFY(children.at(i) == webPage->frameAt(frameRect.topLeft())); - } -} -#endif - -void tst_QWebEnginePage::frameAt() -{ -#if !defined(QWEBENGINEFRAME) - QSKIP("QWEBENGINEFRAME"); -#else - QWebEngineView webView; - QWebEnginePage* webPage = webView.page(); - QSignalSpy loadSpy(webPage, SIGNAL(loadFinished(bool))); - QUrl url = QUrl("qrc:///resources/iframe.html"); - webPage->load(url); - QTRY_COMPARE(loadSpy.count(), 1); - frameAtHelper(webPage, webPage->mainFrame(), webPage->mainFrame()->pos()); -#endif -} - void tst_QWebEnginePage::inputMethods_data() { QTest::addColumn<QString>("viewType"); @@ -2726,47 +2755,6 @@ void tst_QWebEnginePage::errorPageExtension() #endif } -void tst_QWebEnginePage::errorPageExtensionInIFrames() -{ -#if !defined(QWEBENGINEFRAME) - QSKIP("QWEBENGINEFRAME"); -#else - ErrorPage page; - m_view->setPage(&page); - - m_view->page()->load(QUrl( - "data:text/html," - "<h1>h1</h1>" - "<iframe src='data:text/html,<p/>p'></iframe>" - "<iframe src='http://non.existent/url'></iframe>")); - QSignalSpy spyLoadFinished(m_view, SIGNAL(loadFinished(bool))); - QTRY_COMPARE(spyLoadFinished.count(), 1); - - QCOMPARE(page.mainFrame()->childFrames()[1]->toPlainText(), QString("error")); - - m_view->setPage(0); -#endif -} - -void tst_QWebEnginePage::errorPageExtensionInFrameset() -{ -#if !defined(QWEBENGINEFRAME) - QSKIP("QWEBENGINEFRAME"); -#else - ErrorPage page; - m_view->setPage(&page); - - m_view->load(QUrl("qrc:///resources/index.html")); - - QSignalSpy spyLoadFinished(m_view, SIGNAL(loadFinished(bool))); - QTRY_COMPARE(spyLoadFinished.count(), 1); - QCOMPARE(page.mainFrame()->childFrames().count(), 2); - QCOMPARE(page.mainFrame()->childFrames()[1]->toPlainText(), QString("error")); - - m_view->setPage(0); -#endif -} - void tst_QWebEnginePage::errorPageExtensionLoadFinished() { #if !defined(QWEBENGINEPAGE_ERRORPAGEEXTENSION) @@ -2951,65 +2939,6 @@ void tst_QWebEnginePage::unacceleratedWebGLScreenshotWithoutView() } #endif -void tst_QWebEnginePage::originatingObjectInNetworkRequests() -{ -#if !defined(QWEBENGINEFRAME) - QSKIP("QWEBENGINEFRAME"); -#else - TestNetworkManager* networkManager = new TestNetworkManager(m_page); - m_page->setNetworkAccessManager(networkManager); - networkManager->requests.clear(); - - m_view->setHtml(QString("<frameset cols=\"25%,75%\"><frame src=\"data:text/html," - "<head><meta http-equiv='refresh' content='1'></head>foo \">" - "<frame src=\"data:text/html,bar\"></frameset>"), QUrl()); - QVERIFY(::waitForSignal(m_view, SIGNAL(loadFinished(bool)))); - - QCOMPARE(networkManager->requests.count(), 2); - - QList<QWebEngineFrame*> childFrames = m_page->mainFrame()->childFrames(); - QEXPECT_FAIL("", "https://bugs.webkit.org/show_bug.cgi?id=118660", Continue); - QCOMPARE(childFrames.count(), 2); - - for (int i = 0; i < 2; ++i) - QVERIFY(qobject_cast<QWebEngineFrame*>(networkManager->requests.at(i).originatingObject()) == childFrames.at(i)); -#endif -} - -void tst_QWebEnginePage::networkReplyParentDidntChange() -{ -#if !defined(QWEBENGINEPAGE_SETNETWORKACCESSMANAGER) - QSKIP("QWEBENGINEPAGE_SETNETWORKACCESSMANAGER"); -#else - TestNetworkManager* networkManager = new TestNetworkManager(m_page); - m_page->setNetworkAccessManager(networkManager); - networkManager->requests.clear(); - - // Trigger a load and check that pending QNetworkReplies haven't been reparented before returning to the event loop. - m_view->load(QUrl("qrc:///resources/content.html")); - - QVERIFY(networkManager->requests.count() > 0); - QVERIFY(networkManager->findChildren<QNetworkReply*>().size() > 0); -#endif -} - -void tst_QWebEnginePage::destroyQNAMBeforeAbortDoesntCrash() -{ -#if !defined(QWEBENGINEPAGE_SETNETWORKACCESSMANAGER) - QSKIP("QWEBENGINEPAGE_SETNETWORKACCESSMANAGER"); -#else - QNetworkAccessManager* networkManager = new QNetworkAccessManager; - m_page->setNetworkAccessManager(networkManager); - - m_view->load(QUrl("qrc:///resources/content.html")); - delete networkManager; - // This simulates what PingLoader does with its QNetworkReply when it times out. - // PingLoader isn't attached to a QWebEnginePage and can be kept alive - // for 60000 seconds (~16.7 hours) to then cancel its ResourceHandle. - m_view->stop(); -#endif -} - /** * Test fixups for https://bugs.webkit.org/show_bug.cgi?id=30914 * @@ -3109,13 +3038,16 @@ void tst_QWebEnginePage::testStopScheduledPageRefresh() void tst_QWebEnginePage::findText() { - m_view->setHtml(QString("<html><head></head><body><div>foo bar</div></body></html>")); -#if defined(QWEBENGINEPAGE_TRIGGERACTION_SELECTALL) + QSignalSpy loadSpy(m_page, SIGNAL(loadFinished(bool))); + m_page->setHtml(QString("<html><head></head><body><div>foo bar</div></body></html>")); + QTRY_COMPARE(loadSpy.count(), 1); m_page->triggerAction(QWebEnginePage::SelectAll); - QVERIFY(!m_page->selectedText().isEmpty()); + QTRY_COMPARE(m_page->hasSelection(), true); +#if defined(QWEBENGINEPAGE_SELECTEDHTML) QVERIFY(!m_page->selectedHtml().isEmpty()); #endif m_page->findText(""); + QEXPECT_FAIL("", "Unsupported: findText only highlights and doesn't update the selection.", Continue); QVERIFY(m_page->selectedText().isEmpty()); #if defined(QWEBENGINEPAGE_SELECTEDHTML) QVERIFY(m_page->selectedHtml().isEmpty()); @@ -3129,6 +3061,7 @@ void tst_QWebEnginePage::findText() QVERIFY(m_page->selectedHtml().contains(subString)); #endif m_page->findText(""); + QEXPECT_FAIL("", "Unsupported: findText only highlights and doesn't update the selection.", Continue); QVERIFY(m_page->selectedText().isEmpty()); #if defined(QWEBENGINEPAGE_SELECTEDHTML) QVERIFY(m_page->selectedHtml().isEmpty()); @@ -3674,41 +3607,115 @@ void tst_QWebEnginePage::cssMediaTypePageSetting() #endif } -class JavaScriptCallback +class JavaScriptCallbackBase +{ +public: + JavaScriptCallbackBase() + { + if (watcher) + QMetaObject::invokeMethod(watcher, "add"); + } + + void operator() (const QVariant &result) + { + check(result); + if (watcher) + QMetaObject::invokeMethod(watcher, "notify"); + } + +protected: + virtual void check(const QVariant &result) = 0; + +private: + friend class JavaScriptCallbackWatcher; + static QPointer<QObject> watcher; +}; + +QPointer<QObject> JavaScriptCallbackBase::watcher = 0; + +class JavaScriptCallback : public JavaScriptCallbackBase { public: JavaScriptCallback() { } JavaScriptCallback(const QVariant& _expected) : expected(_expected) { } - virtual void operator() (const QVariant& result) { + + void check(const QVariant& result) Q_DECL_OVERRIDE + { QVERIFY(result.isValid()); QCOMPARE(result, expected); } + private: QVariant expected; }; -class JavaScriptCallbackNull +class JavaScriptCallbackNull : public JavaScriptCallbackBase { public: - virtual void operator() (const QVariant& result) { + void check(const QVariant& result) Q_DECL_OVERRIDE + { QVERIFY(result.isNull()); // FIXME: Returned null values are currently invalid QVariants. // QVERIFY(result.isValid()); } }; -class JavaScriptCallbackUndefined +class JavaScriptCallbackUndefined : public JavaScriptCallbackBase { public: - virtual void operator() (const QVariant& result) { + void check(const QVariant& result) Q_DECL_OVERRIDE + { QVERIFY(result.isNull()); QVERIFY(!result.isValid()); } }; +class JavaScriptCallbackWatcher : public QObject +{ + Q_OBJECT +public: + JavaScriptCallbackWatcher() + { + Q_ASSERT(!JavaScriptCallbackBase::watcher); + JavaScriptCallbackBase::watcher = this; + } + + Q_INVOKABLE void add() + { + available++; + } + + Q_INVOKABLE void notify() + { + called++; + if (called == available) + emit allCalled(); + } + + bool wait(int maxSeconds = 30) + { + if (called == available) + return true; + + QTestEventLoop loop; + connect(this, SIGNAL(allCalled()), &loop, SLOT(exitLoop())); + loop.enterLoop(maxSeconds); + return !loop.timeout(); + } + +signals: + void allCalled(); + +private: + int available = 0; + int called = 0; +}; + + void tst_QWebEnginePage::runJavaScript() { TestPage page; + JavaScriptCallbackWatcher watcher; JavaScriptCallback callbackBool(QVariant(false)); page.runJavaScript("false", QWebEngineCallback<const QVariant&>(callbackBool)); @@ -3734,10 +3741,1373 @@ void tst_QWebEnginePage::runJavaScript() JavaScriptCallbackNull callbackNull; page.runJavaScript("null", QWebEngineCallback<const QVariant&>(callbackNull)); - JavaScriptCallbackNull callbackUndefined; + JavaScriptCallbackUndefined callbackUndefined; page.runJavaScript("undefined", QWebEngineCallback<const QVariant&>(callbackUndefined)); + QVERIFY(watcher.wait()); +} + +class FullScreenPage : public QWebEnginePage { + Q_OBJECT +public: + FullScreenPage(QObject* parent = 0) + : QWebEnginePage(parent) + , m_isFullScreen(true) + { } + + void setIsFullScreen(bool b) { m_isFullScreen = b; } + +protected: + bool isFullScreen() override + { + return m_isFullScreen; + } + bool m_isFullScreen; +}; + +void tst_QWebEnginePage::fullScreenRequested() +{ + JavaScriptCallbackWatcher watcher; + FullScreenPage* page = new FullScreenPage; + QWebEngineView* view = new QWebEngineView; + view->setPage(page); + view->show(); + + page->settings()->setAttribute(QWebEngineSettings::FullScreenSupportEnabled, true); + + QSignalSpy loadSpy(view, SIGNAL(loadFinished(bool))); + page->load(QUrl("qrc:///resources/fullscreen.html")); + QTRY_COMPARE(loadSpy.count(), 1); + + page->runJavaScript("document.webkitFullscreenEnabled", JavaScriptCallback(true)); + page->runJavaScript("document.webkitIsFullScreen", JavaScriptCallback(false)); + QVERIFY(watcher.wait()); + + // FullscreenRequest must be a user gesture + QTest::keyPress(qApp->focusWindow(), Qt::Key_Space); QTest::qWait(100); + page->runJavaScript("document.webkitIsFullScreen", JavaScriptCallback(true)); + page->runJavaScript("document.webkitExitFullscreen()", JavaScriptCallbackUndefined()); + QVERIFY(watcher.wait()); + page->setIsFullScreen(false); + page->runJavaScript("document.webkitFullscreenEnabled", JavaScriptCallback(true)); + QTest::keyPress(qApp->focusWindow(), Qt::Key_Space); + QVERIFY(watcher.wait()); + page->runJavaScript("document.webkitIsFullScreen", JavaScriptCallback(false)); + QVERIFY(watcher.wait()); + + delete view; + delete page; +} + +void tst_QWebEnginePage::symmetricUrl() +{ + QWebEngineView view; + QSignalSpy loadFinishedSpy(view.page(), SIGNAL(loadFinished(bool))); + + QVERIFY(view.url().isEmpty()); + + QCOMPARE(view.history()->count(), 0); + + QUrl dataUrl("data:text/html,<h1>Test"); + + view.setUrl(dataUrl); + QCOMPARE(view.url(), dataUrl); + QCOMPARE(view.history()->count(), 0); + + // loading is _not_ immediate, so the text isn't set just yet. + QVERIFY(toPlainTextSync(view.page()).isEmpty()); + + QTRY_COMPARE(loadFinishedSpy.count(), 1); + + QCOMPARE(view.history()->count(), 1); + QCOMPARE(toPlainTextSync(view.page()), QString("Test")); + + QUrl dataUrl2("data:text/html,<h1>Test2"); + QUrl dataUrl3("data:text/html,<h1>Test3"); + + view.setUrl(dataUrl2); + view.setUrl(dataUrl3); + + QCOMPARE(view.url(), dataUrl3); + + QTRY_VERIFY(loadFinishedSpy.count() >= 2); + QTRY_COMPARE(loadFinishedSpy.count(), 3); + + QCOMPARE(view.history()->count(), 2); + + QCOMPARE(toPlainTextSync(view.page()), QString("Test3")); +} + +void tst_QWebEnginePage::progressSignal() +{ + QSignalSpy progressSpy(m_view, SIGNAL(loadProgress(int))); + + QUrl dataUrl("data:text/html,<h1>Test"); + m_view->setUrl(dataUrl); + + ::waitForSignal(m_view, SIGNAL(loadFinished(bool))); + + QVERIFY(progressSpy.size() >= 2); + int previousValue = -1; + for (QSignalSpy::ConstIterator it = progressSpy.begin(); it < progressSpy.end(); ++it) { + int current = (*it).first().toInt(); + QVERIFY(current >= previousValue); + previousValue = current; + } + + // But we always end at 100% + QCOMPARE(progressSpy.last().first().toInt(), 100); +} + +void tst_QWebEnginePage::urlChange() +{ + QSignalSpy urlSpy(m_page, SIGNAL(urlChanged(QUrl))); + + QUrl dataUrl("data:text/html,<h1>Test"); + m_view->setUrl(dataUrl); + + ::waitForSignal(m_page, SIGNAL(urlChanged(QUrl))); + + QCOMPARE(urlSpy.size(), 1); + + QUrl dataUrl2("data:text/html,<html><head><title>title</title></head><body><h1>Test</body></html>"); + m_view->setUrl(dataUrl2); + + ::waitForSignal(m_page, SIGNAL(urlChanged(QUrl))); + + QCOMPARE(urlSpy.size(), 2); +} + +class FakeReply : public QNetworkReply { + Q_OBJECT + +public: + static const QUrl urlFor404ErrorWithoutContents; + + FakeReply(const QNetworkRequest& request, QObject* parent = 0) + : QNetworkReply(parent) + { + setOperation(QNetworkAccessManager::GetOperation); + setRequest(request); + setUrl(request.url()); + if (request.url() == QUrl("qrc:/test1.html")) { + setHeader(QNetworkRequest::LocationHeader, QString("qrc:/test2.html")); + setAttribute(QNetworkRequest::RedirectionTargetAttribute, QUrl("qrc:/test2.html")); + QTimer::singleShot(0, this, SLOT(continueRedirect())); + } +#ifndef QT_NO_OPENSSL + else if (request.url() == QUrl("qrc:/fake-ssl-error.html")) { + setError(QNetworkReply::SslHandshakeFailedError, tr("Fake error!")); + QTimer::singleShot(0, this, SLOT(continueError())); + } +#endif + else if (request.url().host() == QLatin1String("abcdef.abcdef")) { + setError(QNetworkReply::HostNotFoundError, tr("Invalid URL")); + QTimer::singleShot(0, this, SLOT(continueError())); + } else if (request.url() == FakeReply::urlFor404ErrorWithoutContents) { + setError(QNetworkReply::ContentNotFoundError, "Not found"); + setAttribute(QNetworkRequest::HttpStatusCodeAttribute, 404); + QTimer::singleShot(0, this, SLOT(continueError())); + } + + open(QIODevice::ReadOnly); + } + ~FakeReply() + { + close(); + } + virtual void abort() {} + virtual void close() {} + +protected: + qint64 readData(char*, qint64) + { + return 0; + } + +private Q_SLOTS: + void continueRedirect() + { + emit metaDataChanged(); + emit finished(); + } + + void continueError() + { + emit error(this->error()); + emit finished(); + } +}; + +const QUrl FakeReply::urlFor404ErrorWithoutContents = QUrl("http://this.will/return-http-404-error-without-contents.html"); + +class FakeNetworkManager : public QNetworkAccessManager { + Q_OBJECT + +public: + FakeNetworkManager(QObject* parent) : QNetworkAccessManager(parent) { } + +protected: + virtual QNetworkReply* createRequest(Operation op, const QNetworkRequest& request, QIODevice* outgoingData) + { + QString url = request.url().toString(); + if (op == QNetworkAccessManager::GetOperation) { +#ifndef QT_NO_OPENSSL + if (url == "qrc:/fake-ssl-error.html") { + FakeReply* reply = new FakeReply(request, this); + QList<QSslError> errors; + emit sslErrors(reply, errors << QSslError(QSslError::UnspecifiedError)); + return reply; + } +#endif + if (url == "qrc:/test1.html" || url == "http://abcdef.abcdef/" || request.url() == FakeReply::urlFor404ErrorWithoutContents) + return new FakeReply(request, this); + } + + return QNetworkAccessManager::createRequest(op, request, outgoingData); + } +}; + +void tst_QWebEnginePage::requestedUrlAfterSetAndLoadFailures() +{ + QWebEnginePage page; + page.settings()->setAttribute(QWebEngineSettings::ErrorPageEnabled, false); + QSignalSpy spy(&page, SIGNAL(loadFinished(bool))); + + const QUrl first("http://abcdef.abcdef/"); + page.setUrl(first); + ::waitForSignal(&page, SIGNAL(loadFinished(bool))); + QCOMPARE(spy.count(), 1); + QCOMPARE(page.url(), first); + QCOMPARE(page.requestedUrl(), first); + QVERIFY(!spy.at(0).first().toBool()); + + const QUrl second("http://abcdef.abcdef/another_page.html"); + QVERIFY(first != second); + + page.load(second); + ::waitForSignal(&page, SIGNAL(loadFinished(bool))); + QCOMPARE(spy.count(), 2); + QCOMPARE(page.url(), first); + QCOMPARE(page.requestedUrl(), second); + QVERIFY(!spy.at(1).first().toBool()); +} + +void tst_QWebEnginePage::javaScriptWindowObjectCleared_data() +{ + QTest::addColumn<QString>("html"); + QTest::addColumn<int>("signalCount"); + QTest::newRow("with <script>") << "<html><body><script>i=0</script><p>hello world</p></body></html>" << 1; + // NOTE: Empty scripts no longer cause this signal to be emitted. + QTest::newRow("with empty <script>") << "<html><body><script></script><p>hello world</p></body></html>" << 0; + QTest::newRow("without <script>") << "<html><body><p>hello world</p></body></html>" << 0; +} + +void tst_QWebEnginePage::javaScriptWindowObjectCleared() +{ +#if !defined(QWEBENGINEPAGE_JAVASCRIPTWINDOWOBJECTCLEARED) + QSKIP("QWEBENGINEPAGE_JAVASCRIPTWINDOWOBJECTCLEARED"); +#else + QWebEnginePage page; + QSignalSpy spy(&page, SIGNAL(javaScriptWindowObjectCleared())); + QFETCH(QString, html); + page.setHtml(html); + + QFETCH(int, signalCount); + QCOMPARE(spy.count(), signalCount); +#endif +} + +void tst_QWebEnginePage::javaScriptWindowObjectClearedOnEvaluate() +{ +#if !defined(QWEBENGINEPAGE_EVALUATEJAVASCRIPT) + QSKIP("QWEBENGINEPAGE_EVALUATEJAVASCRIPT"); +#else + QWebEnginePage page; + QSignalSpy spy(&page, SIGNAL(javaScriptWindowObjectCleared())); + page.setHtml("<html></html>"); + QCOMPARE(spy.count(), 0); + page.evaluateJavaScript("var a = 'a';"); + QCOMPARE(spy.count(), 1); + // no new clear for a new script: + page.evaluateJavaScript("var a = 1;"); + QCOMPARE(spy.count(), 1); +#endif +} + +void tst_QWebEnginePage::asyncAndDelete() +{ + QWebEnginePage *page = new QWebEnginePage; + CallbackSpy<QString> plainTextSpy; + CallbackSpy<QString> htmlSpy; + page->toPlainText(plainTextSpy.ref()); + page->toHtml(htmlSpy.ref()); + + delete page; + // Pending callbacks should be called with an empty value in the page's destructor. + QCOMPARE(plainTextSpy.waitForResult(), QString()); + QVERIFY(plainTextSpy.wasCalled()); + QCOMPARE(htmlSpy.waitForResult(), QString()); + QVERIFY(htmlSpy.wasCalled()); +} + +void tst_QWebEnginePage::earlyToHtml() +{ + QString html("<html><head></head><body></body></html>"); + QCOMPARE(toHtmlSync(m_view->page()), html); +} + +void tst_QWebEnginePage::setHtml() +{ + QString html("<html><head></head><body><p>hello world</p></body></html>"); + QSignalSpy spy(m_view->page(), SIGNAL(loadFinished(bool))); + m_view->page()->setHtml(html); + QVERIFY(spy.wait()); + QCOMPARE(toHtmlSync(m_view->page()), html); +} + +void tst_QWebEnginePage::setHtmlWithImageResource() +{ + // By default, only security origins of local files can load local resources. + // So we should specify baseUrl to be a local file in order to get a proper origin and load the local image. + + QLatin1String html("<html><body><p>hello world</p><img src='qrc:/resources/image.png'/></body></html>"); + QWebEnginePage page; + + page.setHtml(html, QUrl(QLatin1String("file:///path/to/file"))); + waitForSignal(&page, SIGNAL(loadFinished(bool)), 200); + + QCOMPARE(evaluateJavaScriptSync(&page, "document.images.length").toInt(), 1); + QCOMPARE(evaluateJavaScriptSync(&page, "document.images[0].width").toInt(), 128); + QCOMPARE(evaluateJavaScriptSync(&page, "document.images[0].height").toInt(), 128); + + // Now we test the opposite: without a baseUrl as a local file, we cannot request local resources. + + page.setHtml(html); + waitForSignal(&page, SIGNAL(loadFinished(bool)), 200); + QCOMPARE(evaluateJavaScriptSync(&page, "document.images.length").toInt(), 1); + QEXPECT_FAIL("", "https://bugs.webkit.org/show_bug.cgi?id=118659", Continue); + QCOMPARE(evaluateJavaScriptSync(&page, "document.images[0].width").toInt(), 0); + QEXPECT_FAIL("", "https://bugs.webkit.org/show_bug.cgi?id=118659", Continue); + QCOMPARE(evaluateJavaScriptSync(&page, "document.images[0].height").toInt(), 0); +} + +void tst_QWebEnginePage::setHtmlWithStylesheetResource() +{ +#if !defined(QWEBENGINEELEMENT) + QSKIP("QWEBENGINEELEMENT"); +#else + // By default, only security origins of local files can load local resources. + // So we should specify baseUrl to be a local file in order to be able to download the local stylesheet. + + const char* htmlData = + "<html>" + "<head>" + "<link rel='stylesheet' href='qrc:/style.css' type='text/css' />" + "</head>" + "<body>" + "<p id='idP'>some text</p>" + "</body>" + "</html>"; + QLatin1String html(htmlData); + QWebEnginePage page; + QWebEngineElement webElement; + + page.setHtml(html, QUrl(QLatin1String("qrc:///file"))); + waitForSignal(&page, SIGNAL(loadFinished(bool)), 200); + webElement = page.documentElement().findFirst("p"); + QCOMPARE(webElement.styleProperty("color", QWebEngineElement::CascadedStyle), QLatin1String("red")); + + // Now we test the opposite: without a baseUrl as a local file, we cannot request local resources. + + page.setHtml(html, QUrl(QLatin1String("http://www.example.com/"))); + waitForSignal(&page, SIGNAL(loadFinished(bool)), 200); + webElement = page.documentElement().findFirst("p"); + QEXPECT_FAIL("", "https://bugs.webkit.org/show_bug.cgi?id=118659", Continue); + QCOMPARE(webElement.styleProperty("color", QWebEngineElement::CascadedStyle), QString()); +#endif +} + +void tst_QWebEnginePage::setHtmlWithBaseURL() +{ + // This tests if baseUrl is indeed affecting the relative paths from resources. + // As we are using a local file as baseUrl, its security origin should be able to load local resources. + + if (!QDir(TESTS_SOURCE_DIR).exists()) + W_QSKIP(QString("This test requires access to resources found in '%1'").arg(TESTS_SOURCE_DIR).toLatin1().constData(), SkipAll); + + QDir::setCurrent(TESTS_SOURCE_DIR); + + QString html("<html><body><p>hello world</p><img src='resources/image2.png'/></body></html>"); + + QWebEnginePage page; + + // in few seconds, the image should be completey loaded + QSignalSpy spy(&page, SIGNAL(loadFinished(bool))); + + page.setHtml(html, QUrl::fromLocalFile(TESTS_SOURCE_DIR)); + waitForSignal(&page, SIGNAL(loadFinished(bool)), 200); + QCOMPARE(spy.count(), 1); + + QCOMPARE(evaluateJavaScriptSync(&page, "document.images.length").toInt(), 1); + QCOMPARE(evaluateJavaScriptSync(&page, "document.images[0].width").toInt(), 128); + QCOMPARE(evaluateJavaScriptSync(&page, "document.images[0].height").toInt(), 128); + + // no history item has to be added. + QCOMPARE(m_view->page()->history()->count(), 0); +} + +class MyPage : public QWebEnginePage +{ +public: + MyPage() : QWebEnginePage(), alerts(0) {} + int alerts; + +protected: + virtual void javaScriptAlert(const QUrl &securityOrigin, const QString &msg) + { + alerts++; + QCOMPARE(securityOrigin, QUrl(QStringLiteral("http://test.origin.com/"))); + QCOMPARE(msg, QString("foo")); + } +}; + +void tst_QWebEnginePage::setHtmlWithJSAlert() +{ + QString html("<html><head></head><body><script>alert('foo');</script><p>hello world</p></body></html>"); + MyPage page; + page.setHtml(html, QUrl(QStringLiteral("http://test.origin.com/path#fragment"))); + waitForSignal(&page, SIGNAL(loadFinished(bool))); + QCOMPARE(page.alerts, 1); + QCOMPARE(toHtmlSync(&page), html); +} + +void tst_QWebEnginePage::metaData() +{ +#if !defined(QWEBENGINEPAGE_METADATA) + QSKIP("QWEBENGINEPAGE_METADATA"); +#else + m_view->setHtml("<html>" + " <head>" + " <meta name=\"description\" content=\"Test description\">" + " <meta name=\"keywords\" content=\"HTML, JavaScript, Css\">" + " </head>" + "</html>"); + + QMultiMap<QString, QString> metaData = m_view->page()->metaData(); + + QCOMPARE(metaData.count(), 2); + + QCOMPARE(metaData.value("description"), QString("Test description")); + QCOMPARE(metaData.value("keywords"), QString("HTML, JavaScript, Css")); + QCOMPARE(metaData.value("nonexistent"), QString()); + + m_view->setHtml("<html>" + " <head>" + " <meta name=\"samekey\" content=\"FirstValue\">" + " <meta name=\"samekey\" content=\"SecondValue\">" + " </head>" + "</html>"); + + metaData = m_view->page()->metaData(); + + QCOMPARE(metaData.count(), 2); + + QStringList values = metaData.values("samekey"); + QCOMPARE(values.count(), 2); + + QVERIFY(values.contains("FirstValue")); + QVERIFY(values.contains("SecondValue")); + + QCOMPARE(metaData.value("nonexistent"), QString()); +#endif +} + +#if !defined(QT_NO_COMBOBOX) +void tst_QWebEnginePage::popupFocus() +{ +#if !defined(QWEBENGINEELEMENT) + QSKIP("QWEBENGINEELEMENT"); +#else + QWebEngineView view; + view.setHtml("<html>" + " <body>" + " <select name=\"select\">" + " <option>1</option>" + " <option>2</option>" + " </select>" + " <input type=\"text\"> </input>" + " <textarea name=\"text_area\" rows=\"3\" cols=\"40\">" + "This test checks whether showing and hiding a popup" + "takes the focus away from the webpage." + " </textarea>" + " </body>" + "</html>"); + view.resize(400, 100); + // Call setFocus before show to work around http://bugreports.qt.nokia.com/browse/QTBUG-14762 + view.setFocus(); + view.show(); + QTest::qWaitForWindowExposed(&view); + view.activateWindow(); + QTRY_VERIFY(view.hasFocus()); + + // open the popup by clicking. check if focus is on the popup + const QWebEngineElement webCombo = view.page()->documentElement().findFirst(QLatin1String("select[name=select]")); + QTest::mouseClick(&view, Qt::LeftButton, 0, webCombo.geometry().center()); + + QComboBox* combo = view.findChild<QComboBox*>(); + QVERIFY(combo != 0); + QTRY_VERIFY(!view.hasFocus() && combo->view()->hasFocus()); // Focus should be on the popup + + // hide the popup and check if focus is on the page + combo->hidePopup(); + QTRY_VERIFY(view.hasFocus()); // Focus should be back on the WebView +#endif +} +#endif + +void tst_QWebEnginePage::inputFieldFocus() +{ +#if !defined(QWEBENGINEELEMENT) + QSKIP("QWEBENGINEELEMENT"); +#else + QWebEngineView view; + view.setHtml("<html><body><input type=\"text\"></input></body></html>"); + view.resize(400, 100); + view.show(); + QTest::qWaitForWindowExposed(&view); + view.activateWindow(); + view.setFocus(); + QTRY_VERIFY(view.hasFocus()); + + // double the flashing time, should at least blink once already + int delay = qApp->cursorFlashTime() * 2; + + // focus the lineedit and check if it blinks + bool autoSipEnabled = qApp->autoSipEnabled(); + qApp->setAutoSipEnabled(false); + const QWebEngineElement inputElement = view.page()->documentElement().findFirst(QLatin1String("input[type=text]")); + QTest::mouseClick(&view, Qt::LeftButton, 0, inputElement.geometry().center()); + m_inputFieldsTestView = &view; + view.installEventFilter( this ); + QTest::qWait(delay); + QVERIFY2(m_inputFieldTestPaintCount >= 3, + "The input field should have a blinking caret"); + qApp->setAutoSipEnabled(autoSipEnabled); +#endif +} + +void tst_QWebEnginePage::hitTestContent() +{ +#if !defined(QWEBENGINEELEMENT) + QSKIP("QWEBENGINEELEMENT"); +#else + QString html("<html><body><p>A paragraph</p><br/><br/><br/><a href=\"about:blank\" target=\"_foo\" id=\"link\">link text</a></body></html>"); + + QWebEnginePage page; + page.setHtml(html); + page.setViewportSize(QSize(200, 0)); //no height so link is not visible + const QWebEngineElement linkElement = page.documentElement().findFirst(QLatin1String("a#link")); + QWebEngineHitTestResult result = page.hitTestContent(linkElement.geometry().center()); + QCOMPARE(result.linkText(), QString("link text")); + QWebEngineElement link = result.linkElement(); + QCOMPARE(link.attribute("target"), QString("_foo")); +#endif +} + +void tst_QWebEnginePage::baseUrl_data() +{ + QTest::addColumn<QString>("html"); + QTest::addColumn<QUrl>("loadUrl"); + QTest::addColumn<QUrl>("url"); + QTest::addColumn<QUrl>("baseUrl"); + + QTest::newRow("null") << QString() << QUrl() + << QUrl("about:blank") << QUrl("about:blank"); + + QTest::newRow("foo") << QString() << QUrl("http://foobar.baz/") + << QUrl("http://foobar.baz/") << QUrl("http://foobar.baz/"); + + QString html = "<html>" + "<head>" + "<base href=\"http://foobaz.bar/\" />" + "</head>" + "</html>"; + QTest::newRow("customBaseUrl") << html << QUrl("http://foobar.baz/") + << QUrl("http://foobar.baz/") << QUrl("http://foobaz.bar/"); +} + +void tst_QWebEnginePage::baseUrl() +{ + QFETCH(QString, html); + QFETCH(QUrl, loadUrl); + QFETCH(QUrl, url); + QFETCH(QUrl, baseUrl); + + QSignalSpy loadSpy(m_page, SIGNAL(loadFinished(bool))); + m_page->setHtml(html, loadUrl); + QTRY_COMPARE(loadSpy.count(), 1); + QCOMPARE(m_page->url(), url); + QEXPECT_FAIL("null", "Slight change: We now translate QUrl() to about:blank for the virtual url, but not for the baseUrl", Continue); + QCOMPARE(baseUrlSync(m_page), baseUrl); +} + +class DummyPaintEngine: public QPaintEngine { +public: + + DummyPaintEngine() + : QPaintEngine(QPaintEngine::AllFeatures) + , renderHints(0) + { + } + + bool begin(QPaintDevice*) + { + setActive(true); + return true; + } + + bool end() + { + setActive(false); + return false; + } + + void updateState(const QPaintEngineState& state) + { + renderHints = state.renderHints(); + } + + void drawPath(const QPainterPath&) { } + void drawPixmap(const QRectF&, const QPixmap&, const QRectF&) { } + + QPaintEngine::Type type() const + { + return static_cast<QPaintEngine::Type>(QPaintEngine::User + 2); + } + + QPainter::RenderHints renderHints; +}; + +class DummyPaintDevice: public QPaintDevice { +public: + DummyPaintDevice() + : QPaintDevice() + , m_engine(new DummyPaintEngine) + { + } + + ~DummyPaintDevice() + { + delete m_engine; + } + + QPaintEngine* paintEngine() const + { + return m_engine; + } + + QPainter::RenderHints renderHints() const + { + return m_engine->renderHints; + } + +protected: + int metric(PaintDeviceMetric metric) const; + +private: + DummyPaintEngine* m_engine; + friend class DummyPaintEngine; +}; + + +int DummyPaintDevice::metric(PaintDeviceMetric metric) const +{ + switch (metric) { + case PdmWidth: + return 400; + break; + + case PdmHeight: + return 200; + break; + + case PdmNumColors: + return INT_MAX; + break; + + case PdmDepth: + return 32; + break; + + default: + break; + } + return 0; +} + +void tst_QWebEnginePage::renderHints() +{ +#if !defined(QWEBENGINEPAGE_RENDER) + QSKIP("QWEBENGINEPAGE_RENDER"); +#else + QString html("<html><body><p>Hello, world!</p></body></html>"); + + QWebEnginePage page; + page.setHtml(html); + page.setViewportSize(page.contentsSize()); + + // We will call frame->render and trap the paint engine state changes + // to ensure that GraphicsContext does not clobber the render hints. + DummyPaintDevice buffer; + QPainter painter(&buffer); + + painter.setRenderHint(QPainter::TextAntialiasing, false); + page.render(&painter); + QVERIFY(!(buffer.renderHints() & QPainter::TextAntialiasing)); + QVERIFY(!(buffer.renderHints() & QPainter::SmoothPixmapTransform)); + QVERIFY(!(buffer.renderHints() & QPainter::HighQualityAntialiasing)); + + painter.setRenderHint(QPainter::TextAntialiasing, true); + page.render(&painter); + QVERIFY(buffer.renderHints() & QPainter::TextAntialiasing); + QVERIFY(!(buffer.renderHints() & QPainter::SmoothPixmapTransform)); + QVERIFY(!(buffer.renderHints() & QPainter::HighQualityAntialiasing)); + + painter.setRenderHint(QPainter::SmoothPixmapTransform, true); + page.render(&painter); + QVERIFY(buffer.renderHints() & QPainter::TextAntialiasing); + QVERIFY(buffer.renderHints() & QPainter::SmoothPixmapTransform); + QVERIFY(!(buffer.renderHints() & QPainter::HighQualityAntialiasing)); + + painter.setRenderHint(QPainter::HighQualityAntialiasing, true); + page.render(&painter); + QVERIFY(buffer.renderHints() & QPainter::TextAntialiasing); + QVERIFY(buffer.renderHints() & QPainter::SmoothPixmapTransform); + QVERIFY(buffer.renderHints() & QPainter::HighQualityAntialiasing); +#endif +} + +void tst_QWebEnginePage::scrollPosition() +{ +#if !defined(QWEBENGINEPAGE_EVALUATEJAVASCRIPT) + QSKIP("QWEBENGINEPAGE_EVALUATEJAVASCRIPT"); +#else + // enlarged image in a small viewport, to provoke the scrollbars to appear + QString html("<html><body><img src='qrc:/image.png' height=500 width=500/></body></html>"); + + QWebEnginePage page; + page.setViewportSize(QSize(200, 200)); + + page.setHtml(html); + page.setScrollBarPolicy(Qt::Vertical, Qt::ScrollBarAlwaysOff); + page.setScrollBarPolicy(Qt::Horizontal, Qt::ScrollBarAlwaysOff); + + // try to set the scroll offset programmatically + page.setScrollPosition(QPoint(23, 29)); + QCOMPARE(page.scrollPosition().x(), 23); + QCOMPARE(page.scrollPosition().y(), 29); + + int x = page.evaluateJavaScript("window.scrollX").toInt(); + int y = page.evaluateJavaScript("window.scrollY").toInt(); + QCOMPARE(x, 23); + QCOMPARE(y, 29); +#endif +} + +void tst_QWebEnginePage::scrollToAnchor() +{ +#if !defined(QWEBENGINEELEMENT) + QSKIP("QWEBENGINEELEMENT"); +#else + QWebEnginePage page; + page.setViewportSize(QSize(480, 800)); + + QString html("<html><body><p style=\"margin-bottom: 1500px;\">Hello.</p>" + "<p><a id=\"foo\">This</a> is an anchor</p>" + "<p style=\"margin-bottom: 1500px;\"><a id=\"bar\">This</a> is another anchor</p>" + "</body></html>"); + page.setHtml(html); + page.setScrollPosition(QPoint(0, 0)); + QCOMPARE(page.scrollPosition().x(), 0); + QCOMPARE(page.scrollPosition().y(), 0); + + QWebEngineElement fooAnchor = page.findFirstElement("a[id=foo]"); + + page.scrollToAnchor("foo"); + QCOMPARE(page.scrollPosition().y(), fooAnchor.geometry().top()); + + page.scrollToAnchor("bar"); + page.scrollToAnchor("foo"); + QCOMPARE(page.scrollPosition().y(), fooAnchor.geometry().top()); + + page.scrollToAnchor("top"); + QCOMPARE(page.scrollPosition().y(), 0); + + page.scrollToAnchor("bar"); + page.scrollToAnchor("notexist"); + QVERIFY(page.scrollPosition().y() != 0); +#endif +} + + +void tst_QWebEnginePage::scrollbarsOff() +{ +#if !defined(QWEBENGINEPAGE_EVALUATEJAVASCRIPT) + QSKIP("QWEBENGINEPAGE_EVALUATEJAVASCRIPT"); +#else + QWebEngineView view; + QWebEngineFrame* mainFrame = view.page(); + + mainFrame->setScrollBarPolicy(Qt::Vertical, Qt::ScrollBarAlwaysOff); + mainFrame->setScrollBarPolicy(Qt::Horizontal, Qt::ScrollBarAlwaysOff); + + QString html("<script>" \ + " function checkScrollbar() {" \ + " if (innerWidth === document.documentElement.offsetWidth)" \ + " document.getElementById('span1').innerText = 'SUCCESS';" \ + " else" \ + " document.getElementById('span1').innerText = 'FAIL';" \ + " }" \ + "</script>" \ + "<body>" \ + " <div style='margin-top:1000px ; margin-left:1000px'>" \ + " <a id='offscreen' href='a'>End</a>" \ + " </div>" \ + "<span id='span1'></span>" \ + "</body>"); + + + QSignalSpy loadSpy(&view, SIGNAL(loadFinished(bool))); + view.setHtml(html); + ::waitForSignal(&view, SIGNAL(loadFinished(bool)), 200); + QCOMPARE(loadSpy.count(), 1); + + mainFrame->evaluateJavaScript("checkScrollbar();"); + QCOMPARE(mainFrame->documentElement().findAll("span").at(0).toPlainText(), QString("SUCCESS")); +#endif +} + +void tst_QWebEnginePage::horizontalScrollAfterBack() +{ +#if !defined(QWEBENGINESETTINGS) + QSKIP("QWEBENGINESETTINGS"); +#else + QWebEngineView view; + QSignalSpy loadSpy(view.page(), SIGNAL(loadFinished(bool))); + + view.page()->settings()->setMaximumPagesInCache(2); + view.page()->setScrollBarPolicy(Qt::Vertical, Qt::ScrollBarAsNeeded); + view.page()->setScrollBarPolicy(Qt::Horizontal, Qt::ScrollBarAsNeeded); + + view.load(QUrl("qrc:/resources/testiframe2.html")); + view.resize(200, 200); + QTRY_COMPARE(loadSpy.count(), 1); + QTRY_VERIFY((view.page()->scrollBarGeometry(Qt::Horizontal)).height()); + + view.load(QUrl("qrc:/resources/testiframe.html")); + QTRY_COMPARE(loadSpy.count(), 2); + + view.page()->triggerAction(QWebEnginePage::Back); + QTRY_COMPARE(loadSpy.count(), 3); + QTRY_VERIFY((view.page()->scrollBarGeometry(Qt::Horizontal)).height()); +#endif +} + +void tst_QWebEnginePage::evaluateWillCauseRepaint() +{ +#if !defined(QWEBENGINEPAGE_EVALUATEJAVASCRIPT) + QSKIP("QWEBENGINEPAGE_EVALUATEJAVASCRIPT"); +#else + QWebEngineView view; + QString html("<html><body>top<div id=\"junk\" style=\"display: block;\">" + "junk</div>bottom</body></html>"); + view.setHtml(html); + view.show(); + + QTest::qWaitForWindowExposed(&view); + view.page()->evaluateJavaScript( + "document.getElementById('junk').style.display = 'none';"); + + ::waitForSignal(view.page(), SIGNAL(repaintRequested(QRect))); +#endif +} + +void tst_QWebEnginePage::setContent_data() +{ + QTest::addColumn<QString>("mimeType"); + QTest::addColumn<QByteArray>("testContents"); + QTest::addColumn<QString>("expected"); + + QString str = QString::fromUtf8("ὕαλον ϕαγεῖν δύναμαι· τοῦτο οὔ με βλάπτει"); + QTest::newRow("UTF-8 plain text") << "text/plain; charset=utf-8" << str.toUtf8() << str; + + QTextCodec *utf16 = QTextCodec::codecForName("UTF-16"); + if (utf16) + QTest::newRow("UTF-16 plain text") << "text/plain; charset=utf-16" << utf16->fromUnicode(str) << str; + + str = QString::fromUtf8("Une chaîne de caractères à sa façon."); + QTest::newRow("latin-1 plain text") << "text/plain; charset=iso-8859-1" << str.toLatin1() << str; + + +} + +void tst_QWebEnginePage::setContent() +{ + QFETCH(QString, mimeType); + QFETCH(QByteArray, testContents); + QFETCH(QString, expected); + QSignalSpy loadSpy(m_page, SIGNAL(loadFinished(bool))); + m_view->setContent(testContents, mimeType); + QVERIFY(loadSpy.wait()); + QCOMPARE(toPlainTextSync(m_view->page()), expected); +} + +class CacheNetworkAccessManager : public QNetworkAccessManager { +public: + CacheNetworkAccessManager(QObject* parent = 0) + : QNetworkAccessManager(parent) + , m_lastCacheLoad(QNetworkRequest::PreferNetwork) + { + } + + virtual QNetworkReply* createRequest(Operation, const QNetworkRequest& request, QIODevice*) + { + QVariant cacheLoad = request.attribute(QNetworkRequest::CacheLoadControlAttribute); + if (cacheLoad.isValid()) + m_lastCacheLoad = static_cast<QNetworkRequest::CacheLoadControl>(cacheLoad.toUInt()); + else + m_lastCacheLoad = QNetworkRequest::PreferNetwork; // default value + return new FakeReply(request, this); + } + + QNetworkRequest::CacheLoadControl lastCacheLoad() const + { + return m_lastCacheLoad; + } + +private: + QNetworkRequest::CacheLoadControl m_lastCacheLoad; +}; + +void tst_QWebEnginePage::setCacheLoadControlAttribute() +{ +#if !defined(QWEBENGINEPAGE_SETNETWORKACCESSMANAGER) + QSKIP("QWEBENGINEPAGE_SETNETWORKACCESSMANAGER"); +#else + QWebEnginePage page; + CacheNetworkAccessManager* manager = new CacheNetworkAccessManager(&page); + page.setNetworkAccessManager(manager); + + QNetworkRequest request(QUrl("http://abcdef.abcdef/")); + + request.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::AlwaysCache); + page.load(request); + QCOMPARE(manager->lastCacheLoad(), QNetworkRequest::AlwaysCache); + + request.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferCache); + page.load(request); + QCOMPARE(manager->lastCacheLoad(), QNetworkRequest::PreferCache); + + request.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::AlwaysNetwork); + page.load(request); + QCOMPARE(manager->lastCacheLoad(), QNetworkRequest::AlwaysNetwork); + + request.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferNetwork); + page.load(request); + QCOMPARE(manager->lastCacheLoad(), QNetworkRequest::PreferNetwork); +#endif +} + +void tst_QWebEnginePage::setUrlWithPendingLoads() +{ + QWebEnginePage page; + page.setHtml("<img src='dummy:'/>"); + page.setUrl(QUrl("about:blank")); +} + +void tst_QWebEnginePage::setUrlToEmpty() +{ + QSKIP("FIXME: [0908/090526:FATAL:navigation_controller_impl.cc(927)] Check failed: active_entry->site_instance() == rfh->GetSiteInstance()."); + + int expectedLoadFinishedCount = 0; + const QUrl aboutBlank("about:blank"); + const QUrl url("qrc:/resources/test2.html"); + + QWebEnginePage page; + QCOMPARE(page.url(), QUrl()); + QCOMPARE(page.requestedUrl(), QUrl()); + QCOMPARE(baseUrlSync(&page), QUrl()); + + QSignalSpy spy(&page, SIGNAL(loadFinished(bool))); + + // Set existing url + page.setUrl(url); + expectedLoadFinishedCount++; + ::waitForSignal(&page, SIGNAL(loadFinished(bool))); + + QCOMPARE(spy.count(), expectedLoadFinishedCount); + QCOMPARE(page.url(), url); + QCOMPARE(page.requestedUrl(), url); + QCOMPARE(baseUrlSync(&page), url); + + // Set empty url + page.setUrl(QUrl()); + expectedLoadFinishedCount++; + + QTRY_COMPARE(spy.count(), expectedLoadFinishedCount); + QCOMPARE(page.url(), aboutBlank); + QCOMPARE(page.requestedUrl(), QUrl()); + QCOMPARE(baseUrlSync(&page), aboutBlank); + + // Set existing url + page.setUrl(url); + expectedLoadFinishedCount++; + + QTRY_COMPARE(spy.count(), expectedLoadFinishedCount); + QCOMPARE(page.url(), url); + QCOMPARE(page.requestedUrl(), url); + QCOMPARE(baseUrlSync(&page), url); + + // Load empty url + page.load(QUrl()); + expectedLoadFinishedCount++; + + QTRY_COMPARE(spy.count(), expectedLoadFinishedCount); + QCOMPARE(page.url(), aboutBlank); + QCOMPARE(page.requestedUrl(), QUrl()); + QCOMPARE(baseUrlSync(&page), aboutBlank); +} + +void tst_QWebEnginePage::setUrlToInvalid() +{ + QEXPECT_FAIL("", "Unsupported: QtWebEngine doesn't adjust invalid URLs.", Abort); + QVERIFY(false); + + QWebEnginePage page; + + const QUrl invalidUrl("http:/example.com"); + QVERIFY(!invalidUrl.isEmpty()); + QVERIFY(invalidUrl != QUrl()); + + // QWebEnginePage will do its best to accept the URL, possible converting it to a valid equivalent URL. + const QUrl validUrl("http://example.com/"); + page.setUrl(invalidUrl); + QCOMPARE(page.url(), validUrl); + QCOMPARE(page.requestedUrl(), validUrl); + QCOMPARE(baseUrlSync(&page), validUrl); + + // QUrls equivalent to QUrl() will be treated as such. + const QUrl aboutBlank("about:blank"); + const QUrl anotherInvalidUrl("1http://bugs.webkit.org"); + QVERIFY(!anotherInvalidUrl.isEmpty()); // and they are not necessarily empty. + QVERIFY(!anotherInvalidUrl.isValid()); + QCOMPARE(anotherInvalidUrl.toEncoded(), QUrl().toEncoded()); + + page.setUrl(anotherInvalidUrl); + QCOMPARE(page.url(), aboutBlank); + QCOMPARE(page.requestedUrl().toEncoded(), anotherInvalidUrl.toEncoded()); + QCOMPARE(baseUrlSync(&page), aboutBlank); +} + +static QStringList collectHistoryUrls(QWebEngineHistory *history) +{ + QStringList urls; + foreach (const QWebEngineHistoryItem &i, history->items()) + urls << i.url().toString(); + return urls; +} + +void tst_QWebEnginePage::setUrlHistory() +{ + QSKIP("FIXME: [0908/090526:FATAL:navigation_controller_impl.cc(927)] Check failed: active_entry->site_instance() == rfh->GetSiteInstance()."); + + const QUrl aboutBlank("about:blank"); + QUrl url; + int expectedLoadFinishedCount = 0; + QSignalSpy spy(m_page, SIGNAL(loadFinished(bool))); + + QCOMPARE(m_page->history()->count(), 0); + + m_page->setUrl(QUrl()); + expectedLoadFinishedCount++; + QTRY_COMPARE(spy.count(), expectedLoadFinishedCount); + QCOMPARE(m_page->url(), aboutBlank); + QCOMPARE(m_page->requestedUrl(), QUrl()); + // Chromium stores navigation entry for every successful loads. The load of the empty page is committed and stored as about:blank. + QCOMPARE(collectHistoryUrls(m_page->history()), QStringList() << aboutBlank.toString()); + + url = QUrl("http://non.existent/"); + m_page->setUrl(url); + expectedLoadFinishedCount++; + QTRY_COMPARE(spy.count(), expectedLoadFinishedCount); + // When error page is disabled in case of LoadFail the entry of the unavailable page is not stored. + // We expect the url of the previously loaded page here. + QCOMPARE(m_page->url(), aboutBlank); + QCOMPARE(m_page->requestedUrl(), QUrl()); + // Since the entry of the unavailable page is not stored it will not available in the history. + QCOMPARE(collectHistoryUrls(m_page->history()), QStringList() << aboutBlank.toString()); + + url = QUrl("qrc:/resources/test1.html"); + m_page->setUrl(url); + expectedLoadFinishedCount++; + QTRY_COMPARE(spy.count(), expectedLoadFinishedCount); + QCOMPARE(m_page->url(), url); + QCOMPARE(m_page->requestedUrl(), url); + QCOMPARE(collectHistoryUrls(m_page->history()), QStringList() << aboutBlank.toString() << QStringLiteral("qrc:/resources/test1.html")); + + m_page->setUrl(QUrl()); + expectedLoadFinishedCount++; + QTRY_COMPARE(spy.count(), expectedLoadFinishedCount); + QCOMPARE(m_page->url(), aboutBlank); + QCOMPARE(m_page->requestedUrl(), QUrl()); + // Chromium stores navigation entry for every successful loads. The load of the empty page is committed and stored as about:blank. + QCOMPARE(collectHistoryUrls(m_page->history()), QStringList() + << aboutBlank.toString() + << QStringLiteral("qrc:/resources/test1.html") + << aboutBlank.toString()); + + url = QUrl("qrc:/resources/test1.html"); + m_page->setUrl(url); + expectedLoadFinishedCount++; + QTRY_COMPARE(spy.count(), expectedLoadFinishedCount); + QCOMPARE(m_page->url(), url); + QCOMPARE(m_page->requestedUrl(), url); + // The history count DOES change since the about:blank is in the list. + QCOMPARE(collectHistoryUrls(m_page->history()), QStringList() + << aboutBlank.toString() + << QStringLiteral("qrc:/resources/test1.html") + << aboutBlank.toString() + << QStringLiteral("qrc:/resources/test1.html")); + + url = QUrl("qrc:/resources/test2.html"); + m_page->setUrl(url); + expectedLoadFinishedCount++; + QTRY_COMPARE(spy.count(), expectedLoadFinishedCount); + QCOMPARE(m_page->url(), url); + QCOMPARE(m_page->requestedUrl(), url); + QCOMPARE(collectHistoryUrls(m_page->history()), QStringList() + << aboutBlank.toString() + << QStringLiteral("qrc:/resources/test1.html") + << aboutBlank.toString() + << QStringLiteral("qrc:/resources/test1.html") + << QStringLiteral("qrc:/resources/test2.html")); +} + +void tst_QWebEnginePage::setUrlUsingStateObject() +{ + const QUrl aboutBlank("about:blank"); + QUrl url; + QSignalSpy urlChangedSpy(m_page, SIGNAL(urlChanged(QUrl))); + int expectedUrlChangeCount = 0; + + QCOMPARE(m_page->history()->count(), 0); + + url = QUrl("qrc:/resources/test1.html"); + m_page->setUrl(url); + waitForSignal(m_page, SIGNAL(loadFinished(bool))); + expectedUrlChangeCount++; + QCOMPARE(urlChangedSpy.count(), expectedUrlChangeCount); + QCOMPARE(m_page->url(), url); + QCOMPARE(m_page->history()->count(), 1); + + evaluateJavaScriptSync(m_page, "window.history.pushState(null, 'push', 'navigate/to/here')"); + expectedUrlChangeCount++; + QCOMPARE(urlChangedSpy.count(), expectedUrlChangeCount); + QCOMPARE(m_page->url(), QUrl("qrc:/resources/navigate/to/here")); + QCOMPARE(m_page->history()->count(), 2); + QVERIFY(m_page->history()->canGoBack()); + + evaluateJavaScriptSync(m_page, "window.history.replaceState(null, 'replace', 'another/location')"); + expectedUrlChangeCount++; + QCOMPARE(urlChangedSpy.count(), expectedUrlChangeCount); + QCOMPARE(m_page->url(), QUrl("qrc:/resources/navigate/to/another/location")); + QCOMPARE(m_page->history()->count(), 2); + QVERIFY(!m_page->history()->canGoForward()); + QVERIFY(m_page->history()->canGoBack()); + + evaluateJavaScriptSync(m_page, "window.history.back()"); + QTest::qWait(100); + expectedUrlChangeCount++; + QCOMPARE(urlChangedSpy.count(), expectedUrlChangeCount); + QCOMPARE(m_page->url(), QUrl("qrc:/resources/test1.html")); + QVERIFY(m_page->history()->canGoForward()); + QVERIFY(!m_page->history()->canGoBack()); +} + +static inline QUrl extractBaseUrl(const QUrl& url) +{ + return url.resolved(QUrl()); +} + +void tst_QWebEnginePage::setUrlThenLoads_data() +{ + QTest::addColumn<QUrl>("url"); + QTest::addColumn<QUrl>("baseUrl"); + + QTest::newRow("resource file") << QUrl("qrc:/resources/test1.html") << extractBaseUrl(QUrl("qrc:/resources/test1.html")); + QTest::newRow("base specified in HTML") << QUrl("data:text/html,<head><base href=\"http://different.base/\"></head>") << QUrl("http://different.base/"); +} + +void tst_QWebEnginePage::setUrlThenLoads() +{ + QFETCH(QUrl, url); + QFETCH(QUrl, baseUrl); + QSignalSpy urlChangedSpy(m_page, SIGNAL(urlChanged(QUrl))); + QSignalSpy startedSpy(m_page, SIGNAL(loadStarted())); + QSignalSpy finishedSpy(m_page, SIGNAL(loadFinished(bool))); + + m_page->setUrl(url); + QTRY_COMPARE(startedSpy.count(), 1); + QTRY_COMPARE(urlChangedSpy.count(), 1); + QTRY_COMPARE(finishedSpy.count(), 1); + QVERIFY(finishedSpy.at(0).first().toBool()); + QCOMPARE(m_page->url(), url); + QCOMPARE(m_page->requestedUrl(), url); + QCOMPARE(baseUrlSync(m_page), baseUrl); + + const QUrl urlToLoad1("qrc:/resources/test2.html"); + const QUrl urlToLoad2("qrc:/resources/test1.html"); + + // Just after first load. URL didn't changed yet. + m_page->load(urlToLoad1); + QCOMPARE(m_page->url(), url); + QCOMPARE(m_page->requestedUrl(), urlToLoad1); + // baseUrlSync spins an event loop and this sometimes return the next result. + // QCOMPARE(baseUrlSync(m_page), baseUrl); + QTRY_COMPARE(startedSpy.count(), 2); + + // After first URL changed. + QTRY_COMPARE(urlChangedSpy.count(), 2); + QTRY_COMPARE(finishedSpy.count(), 2); + QVERIFY(finishedSpy.at(1).first().toBool()); + QCOMPARE(m_page->url(), urlToLoad1); + QCOMPARE(m_page->requestedUrl(), urlToLoad1); + QCOMPARE(baseUrlSync(m_page), extractBaseUrl(urlToLoad1)); + + // Just after second load. URL didn't changed yet. + m_page->load(urlToLoad2); + QCOMPARE(m_page->url(), urlToLoad1); + QCOMPARE(m_page->requestedUrl(), urlToLoad2); + QCOMPARE(baseUrlSync(m_page), extractBaseUrl(urlToLoad1)); + QTRY_COMPARE(startedSpy.count(), 3); + + // After second URL changed. + QTRY_COMPARE(urlChangedSpy.count(), 3); + QTRY_COMPARE(finishedSpy.count(), 3); + QVERIFY(finishedSpy.at(2).first().toBool()); + QCOMPARE(m_page->url(), urlToLoad2); + QCOMPARE(m_page->requestedUrl(), urlToLoad2); + QCOMPARE(baseUrlSync(m_page), extractBaseUrl(urlToLoad2)); +} + +void tst_QWebEnginePage::loadFinishedAfterNotFoundError() +{ + QWebEnginePage page; + QSignalSpy spy(&page, SIGNAL(loadFinished(bool))); + + page.settings()->setAttribute(QWebEngineSettings::ErrorPageEnabled, false); + page.setUrl(QUrl("http://non.existent/url")); + QTRY_COMPARE(spy.count(), 1); + + page.settings()->setAttribute(QWebEngineSettings::ErrorPageEnabled, true); + page.setUrl(QUrl("http://another.non.existent/url")); + QTRY_COMPARE(spy.count(), 2); +} + +class URLSetter : public QObject { + Q_OBJECT + +public: + enum Signal { + LoadStarted, + LoadFinished, + ProvisionalLoad + }; + + enum Type { + UseLoad, + UseSetUrl + }; + + URLSetter(QWebEnginePage*, Signal, Type, const QUrl&); + +public Q_SLOTS: + void execute(); + +Q_SIGNALS: + void finished(); + +private: + QWebEnginePage* m_page; + QUrl m_url; + Type m_type; +}; + +Q_DECLARE_METATYPE(URLSetter::Signal) +Q_DECLARE_METATYPE(URLSetter::Type) + +URLSetter::URLSetter(QWebEnginePage* page, Signal signal, URLSetter::Type type, const QUrl& url) + : m_page(page), m_url(url), m_type(type) +{ + if (signal == LoadStarted) + connect(m_page, SIGNAL(loadStarted()), SLOT(execute())); + else if (signal == LoadFinished) + connect(m_page, SIGNAL(loadFinished(bool)), SLOT(execute())); + else + connect(m_page, SIGNAL(provisionalLoad()), SLOT(execute())); +} + +void URLSetter::execute() +{ + // We track only the first emission. + m_page->disconnect(this); + if (m_type == URLSetter::UseLoad) + m_page->load(m_url); + else + m_page->setUrl(m_url); + connect(m_page, SIGNAL(loadFinished(bool)), SIGNAL(finished())); +} + +void tst_QWebEnginePage::loadInSignalHandlers_data() +{ + QSKIP("FIXME: This crashes in content::WebContentsImpl::NavigateToEntry because of reentrancy. Should we require QueuedConnections or do it ourselves to support this?"); + + QTest::addColumn<URLSetter::Type>("type"); + QTest::addColumn<URLSetter::Signal>("signal"); + QTest::addColumn<QUrl>("url"); + + const QUrl validUrl("qrc:/resources/test2.html"); + const QUrl invalidUrl("qrc:/invalid"); + + QTest::newRow("call load() in loadStarted() after valid url") << URLSetter::UseLoad << URLSetter::LoadStarted << validUrl; + QTest::newRow("call load() in loadStarted() after invalid url") << URLSetter::UseLoad << URLSetter::LoadStarted << invalidUrl; + QTest::newRow("call load() in loadFinished() after valid url") << URLSetter::UseLoad << URLSetter::LoadFinished << validUrl; + QTest::newRow("call load() in loadFinished() after invalid url") << URLSetter::UseLoad << URLSetter::LoadFinished << invalidUrl; + QTest::newRow("call load() in provisionalLoad() after valid url") << URLSetter::UseLoad << URLSetter::ProvisionalLoad << validUrl; + QTest::newRow("call load() in provisionalLoad() after invalid url") << URLSetter::UseLoad << URLSetter::ProvisionalLoad << invalidUrl; + + QTest::newRow("call setUrl() in loadStarted() after valid url") << URLSetter::UseSetUrl << URLSetter::LoadStarted << validUrl; + QTest::newRow("call setUrl() in loadStarted() after invalid url") << URLSetter::UseSetUrl << URLSetter::LoadStarted << invalidUrl; + QTest::newRow("call setUrl() in loadFinished() after valid url") << URLSetter::UseSetUrl << URLSetter::LoadFinished << validUrl; + QTest::newRow("call setUrl() in loadFinished() after invalid url") << URLSetter::UseSetUrl << URLSetter::LoadFinished << invalidUrl; + QTest::newRow("call setUrl() in provisionalLoad() after valid url") << URLSetter::UseSetUrl << URLSetter::ProvisionalLoad << validUrl; + QTest::newRow("call setUrl() in provisionalLoad() after invalid url") << URLSetter::UseSetUrl << URLSetter::ProvisionalLoad << invalidUrl; +} + +void tst_QWebEnginePage::loadInSignalHandlers() +{ + QFETCH(URLSetter::Type, type); + QFETCH(URLSetter::Signal, signal); + QFETCH(QUrl, url); + + const QUrl urlForSetter("qrc:/resources/test1.html"); + URLSetter setter(m_page, signal, type, urlForSetter); + + m_page->load(url); + waitForSignal(&setter, SIGNAL(finished()), 200); + QCOMPARE(m_page->url(), urlForSetter); } QTEST_MAIN(tst_QWebEnginePage) diff --git a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.qrc b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.qrc index 994d71b430e5631be40f49e2eb765e8cb6833395..c7bffd5bb58f87ec3a15ae1cb662c4d19d740fc3 100644 --- a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.qrc +++ b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.qrc @@ -1,5 +1,6 @@ <!DOCTYPE RCC><RCC version="1.0"> <qresource> + <file>resources/content.html</file> <file>resources/index.html</file> <file>resources/frame_a.html</file> <file>resources/frame_c.html</file> @@ -7,8 +8,14 @@ <file>resources/iframe2.html</file> <file>resources/iframe3.html</file> <file>resources/framedindex.html</file> - <file>resources/content.html</file> + <file>resources/fullscreen.html</file> <file>resources/script.html</file> <file>resources/user.css</file> + <file>resources/image.png</file> + <file>resources/style.css</file> + <file>resources/test1.html</file> + <file>resources/test2.html</file> + <file>resources/testiframe.html</file> + <file>resources/testiframe2.html</file> </qresource> </RCC> diff --git a/tests/auto/widgets/qwebenginescript/qwebenginescript.pro b/tests/auto/widgets/qwebenginescript/qwebenginescript.pro index ff6c4962896e4c056799ef1640cb1560781caa5b..e99c7f4938cb1510eefefaefce31663c097f0542 100644 --- a/tests/auto/widgets/qwebenginescript/qwebenginescript.pro +++ b/tests/auto/widgets/qwebenginescript/qwebenginescript.pro @@ -1,2 +1 @@ include(../tests.pri) -exists($${TARGET}.qrc):RESOURCES += $${TARGET}.qrc diff --git a/tests/auto/widgets/qwebengineview/qwebengineview.pro b/tests/auto/widgets/qwebengineview/qwebengineview.pro index ff6c4962896e4c056799ef1640cb1560781caa5b..e99c7f4938cb1510eefefaefce31663c097f0542 100644 --- a/tests/auto/widgets/qwebengineview/qwebengineview.pro +++ b/tests/auto/widgets/qwebengineview/qwebengineview.pro @@ -1,2 +1 @@ include(../tests.pri) -exists($${TARGET}.qrc):RESOURCES += $${TARGET}.qrc diff --git a/tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp b/tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp index 83f65f9d087a913855545eeb7b9865f43b02a6a3..1ebb22cc91f3d52b8db5ca8e36f1b0a624d6a3fb 100644 --- a/tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp +++ b/tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp @@ -25,6 +25,7 @@ #include <qpainter.h> #include <qwebengineview.h> #include <qwebenginepage.h> +#include <qwebenginesettings.h> #include <qnetworkrequest.h> #include <qdiriterator.h> @@ -148,9 +149,7 @@ void tst_QWebEngineView::reusePage() QWebEngineView* view1 = new QWebEngineView; QPointer<QWebEnginePage> page = new QWebEnginePage; view1->setPage(page.data()); -#if defined(QWEBENGINESETTINGS) page.data()->settings()->setAttribute(QWebEngineSettings::PluginsEnabled, true); -#endif page->setHtml(html, QUrl::fromLocalFile(TESTS_SOURCE_DIR)); if (html.contains("</embed>")) { // some reasonable time for the PluginStream to feed test.swf to flash and start painting diff --git a/tests/auto/widgets/tests.pri b/tests/auto/widgets/tests.pri index f14afb59859ccb1fa24b1456a070429b7323cf01..afdf46f42c4638559d3bf45f112bcb174c960f1e 100644 --- a/tests/auto/widgets/tests.pri +++ b/tests/auto/widgets/tests.pri @@ -8,17 +8,11 @@ CONFIG += c++11 VPATH += $$_PRO_FILE_PWD_ TARGET = tst_$$TARGET -# Load mobilityconfig if Qt Mobility is available -load(mobilityconfig, true) -contains(MOBILITY_CONFIG, multimedia) { - # This define is used by tests depending on Qt Multimedia - DEFINES -= WTF_USE_QT_MULTIMEDIA=0 - DEFINES += WTF_USE_QT_MULTIMEDIA=1 -} - SOURCES += $${TARGET}.cpp INCLUDEPATH += $$PWD +exists($$_PRO_FILE_PWD_/$${TARGET}.qrc): RESOURCES += $${TARGET}.qrc + QT += testlib network webenginewidgets widgets macx: CONFIG -= app_bundle diff --git a/tests/auto/widgets/util.h b/tests/auto/widgets/util.h index 83067fe8dca460f6e864a694db2f2516e860c967..2b485fc0fcf49c9889ae90824e537a274c8c482b 100644 --- a/tests/auto/widgets/util.h +++ b/tests/auto/widgets/util.h @@ -166,6 +166,9 @@ static inline QUrl baseUrlSync(QWebEnginePage *page) #define W_QSKIP(a, b) QSKIP(a) #define W_QTEST_MAIN(TestObject, params) \ +QT_BEGIN_NAMESPACE \ +QTEST_ADD_GPU_BLACKLIST_SUPPORT_DEFS \ +QT_END_NAMESPACE \ int main(int argc, char *argv[]) \ { \ QVector<const char *> w_argv(argc); \ @@ -178,6 +181,8 @@ int main(int argc, char *argv[]) \ QApplication app(w_argc, const_cast<char **>(w_argv.data())); \ app.setAttribute(Qt::AA_Use96Dpi, true); \ QTEST_DISABLE_KEYPAD_NAVIGATION \ + QTEST_ADD_GPU_BLACKLIST_SUPPORT \ TestObject tc; \ + QTEST_SET_MAIN_SOURCE_PATH \ return QTest::qExec(&tc, argc, argv); \ } diff --git a/tests/auto/widgets/widgets.pro b/tests/auto/widgets/widgets.pro index 2dbb498d112d1acf2756e50075d7dd67c7c76ddf..b2df0880d44f75fee668aa88b174ad8cbcf939e0 100644 --- a/tests/auto/widgets/widgets.pro +++ b/tests/auto/widgets/widgets.pro @@ -4,7 +4,6 @@ CONFIG += ordered SUBDIRS += \ qwebengineaccessibility \ - qwebengineframe \ qwebenginepage \ qwebenginehistoryinterface \ qwebengineview \ diff --git a/tests/quicktestbrowser/ApplicationRoot.qml b/tests/quicktestbrowser/ApplicationRoot.qml index 71737694d7b8a9149990b40f01f48e54d933b87c..5641b89a37a840aa9154cbcdf959e8d95f39bee6 100644 --- a/tests/quicktestbrowser/ApplicationRoot.qml +++ b/tests/quicktestbrowser/ApplicationRoot.qml @@ -44,6 +44,8 @@ import QtWebEngine 1.1 QtObject { id: root + property bool thirdPartyCookiesEnabled: true + property QtObject testProfile: WebEngineProfile { storageName: "Test" } diff --git a/tests/quicktestbrowser/BrowserWindow.qml b/tests/quicktestbrowser/BrowserWindow.qml index 9f15d188e5dcb04baeb22d9d7dd108d5aaecb391..ca0b6499bae02da7ef840271b982df55ef741724 100644 --- a/tests/quicktestbrowser/BrowserWindow.qml +++ b/tests/quicktestbrowser/BrowserWindow.qml @@ -77,6 +77,7 @@ ApplicationWindow { property alias javaScriptEnabled: javaScriptEnabled.checked; property alias errorPageEnabled: errorPageEnabled.checked; property alias pluginsEnabled: pluginsEnabled.checked; + property alias thirdPartyCookiesEnabled: thirdPartyCookiesEnabled.checked; } // Make sure the Qt.WindowFullscreenButtonHint is set on OS X. @@ -251,6 +252,13 @@ ApplicationWindow { checkable: true checked: true } + MenuItem { + id: thirdPartyCookiesEnabled + text: "Third party cookies enabled" + checkable: true + checked: true + onToggled: applicationRoot.thirdPartyCookiesEnabled = checked + } MenuItem { id: offTheRecordEnabled text: "Off The Record" diff --git a/tests/quicktestbrowser/main.cpp b/tests/quicktestbrowser/main.cpp index 7171baf77eea74abade0b3acc0221ac67e6acb7d..166da4d5bf17b5603d57f9effd2e9030f4d02e73 100644 --- a/tests/quicktestbrowser/main.cpp +++ b/tests/quicktestbrowser/main.cpp @@ -50,7 +50,9 @@ typedef QGuiApplication Application; #endif #include <QtQml/QQmlApplicationEngine> #include <QtQml/QQmlContext> +#include <QtQml/QQmlComponent> #include <QtWebEngine/qtwebengineglobal.h> +#include <QtWebEngineCore/qwebenginecookiestoreclient.h> static QUrl startupUrl() { @@ -67,6 +69,24 @@ static QUrl startupUrl() return QUrl(QStringLiteral("http://qt.io/")); } +class CookieClient: public QWebEngineCookieStoreClient +{ + QMetaProperty m_settingProperty; + const QObject *m_object; +public: + CookieClient(const QObject *object) + : m_object(object) + { + const QMetaObject *rootMeta = object->metaObject(); + int index = rootMeta->indexOfProperty("thirdPartyCookiesEnabled"); + Q_ASSERT(index != -1); + m_settingProperty = rootMeta->property(index); + } + virtual bool acceptCookieFromUrl(const QByteArray &, const QUrl &) { + return m_settingProperty.read(m_object).toBool(); + } +}; + int main(int argc, char **argv) { Application app(argc, argv); @@ -80,7 +100,25 @@ int main(int argc, char **argv) Utils utils; appEngine.rootContext()->setContextProperty("utils", &utils); appEngine.load(QUrl("qrc:/ApplicationRoot.qml")); - QMetaObject::invokeMethod(appEngine.rootObjects().first(), "load", Q_ARG(QVariant, startupUrl())); + QObject *rootObject = appEngine.rootObjects().first(); + + QQmlComponent component(&appEngine); + component.setData(QByteArrayLiteral("import QtQuick 2.0\n" + "import QtWebEngine 1.1\n" + "WebEngineProfile {\n" + "storageName: \"Test\"\n" + "}") + , QUrl()); + QObject *profile = component.create(); + CookieClient client(rootObject); + QMetaObject::invokeMethod(profile, "setCookieStoreClient", Q_ARG(QWebEngineCookieStoreClient*, &client)); + const QMetaObject *rootMeta = rootObject->metaObject(); + int index = rootMeta->indexOfProperty("testProfile"); + Q_ASSERT(index != -1); + QMetaProperty profileProperty = rootMeta->property(index); + profileProperty.write(rootObject, qVariantFromValue(profile)); + + QMetaObject::invokeMethod(rootObject, "load", Q_ARG(QVariant, startupUrl())); return app.exec(); } diff --git a/tools/buildscripts/gyp_qtwebengine b/tools/buildscripts/gyp_qtwebengine index 116f8f2bdf734b059fd6636dd45d50a3b0411207..ce2a43328f6de7a07db2bbb7e3e51f8419734e4e 100755 --- a/tools/buildscripts/gyp_qtwebengine +++ b/tools/buildscripts/gyp_qtwebengine @@ -57,13 +57,19 @@ def additional_include_files(args=[]): # Always include common.gypi. AddInclude(os.path.join(script_dir, 'common.gypi')) - # Include extra gypi files for additional build tweaks such as file exclusions, - # common stuff we generate and extract from qmake and platform specific drop-in files. + # Include extra gypi files for additional build tweaks such as file exclusions + # and platform specific drop-in files. build_extras = glob.glob(os.path.join(qtwebengine_root, 'src', 'core', '*_extras.gypi')) for build in build_extras: print "Using extra options found in " + build AddInclude(build) + # Include extra gypi files for common stuff we generate and extract from qmake. + build_extras = glob.glob(os.path.join(output_dir, '*_extras.gypi')) + for build in build_extras: + print "Using extra options found in " + build + AddInclude(build) + # Optionally add supplemental .gypi files if present. supplements = glob.glob(os.path.join(chrome_src, '*', 'supplement.gypi')) for supplement in supplements: @@ -86,6 +92,11 @@ if __name__ == '__main__': if 'qt_cross_compile=1' in sys.argv: os.environ['GYP_CROSSCOMPILE'] = '1' + sysroot = 'sysroot=' + for opt in sys.argv: + if opt.startswith(sysroot): + os.environ['PKG_CONFIG_SYSROOT_DIR'] = opt[len(sysroot):] + gyp_helper.apply_chromium_gyp_env() # This could give false positives since it doesn't actually do real option @@ -134,11 +145,6 @@ if __name__ == '__main__': args.extend(['-D', 'qtwebengine_root=' + purifyGypVarPath(qtwebengine_root)]) args.extend(['-D', 'chromium_src_dir=' + purifyGypVarPath(chrome_src)]) - # linux_use_bundled_gold currently relies on a hardcoded relative path from chromium/src/out/(Release|Debug) - # Disable it along with the -Wl,--threads flag just in case gold isn't installed on the system. - args.extend(['-D', 'linux_use_bundled_gold=0']) - args.extend(['-D', 'linux_use_bundled_binutils=0']) - args.extend(['-D', 'linux_use_gold_flags=0']) args.extend(['-D', 'clang_use_chrome_plugins=0']) # We do not want to ship more external binary blobs, so let v8 embed its startup data. args.extend(['-D', 'v8_use_external_startup_data=0']) diff --git a/tools/qmake/config.tests/khr/khr.cpp b/tools/qmake/config.tests/khr/khr.cpp index 6182df2861e3c51ff8b8e720721ab00ca4f43cba..01c0c26ca0b49039d87130646905afccb620c547 100644 --- a/tools/qmake/config.tests/khr/khr.cpp +++ b/tools/qmake/config.tests/khr/khr.cpp @@ -38,7 +38,5 @@ int main(int, char **) { - const khronos_boolean_enum_t kfalse = KHRONOS_FALSE; - const khronos_boolean_enum_t ktrue = KHRONOS_TRUE; - return kfalse == ktrue; + return 0; } diff --git a/tools/qmake/config.tests/khr/khr.pro b/tools/qmake/config.tests/khr/khr.pro index 6abd2367a859cda1b69599c7c6e12aa5075e80ee..b8e935f5a3a6946b6225615fc1a11562dd67e41a 100644 --- a/tools/qmake/config.tests/khr/khr.pro +++ b/tools/qmake/config.tests/khr/khr.pro @@ -1,2 +1,6 @@ +!isEmpty(QMAKE_INCDIR_EGL): INCLUDEPATH += $$QMAKE_INCDIR_EGL +!isEmpty(QMAKE_INCDIR_OPENGL): INCLUDEPATH += $$QMAKE_INCDIR_OPENGL + CONFIG-=qt + linux:SOURCES += khr.cpp diff --git a/tools/qmake/mkspecs/features/configure.prf b/tools/qmake/mkspecs/features/configure.prf index 17bdc8ba1620e5b3220565e9f748770ada0a6620..321e67e92aaf63a5c8e18e1d6745dfc4b035b3b5 100644 --- a/tools/qmake/mkspecs/features/configure.prf +++ b/tools/qmake/mkspecs/features/configure.prf @@ -19,16 +19,23 @@ defineTest(runConfigure) { test ~= s/\\.pro$// qtCompileTest($$test) } - # libcap-dev package doesn't ship .pc files on Ubuntu. - linux:!config_libcap:skipBuild("libcap development package appears to be missing") - linux:!config_khr:skipBuild("khronos development headers appear to be missing (mesa/libegl1-mesa-dev)") - contains(QT_CONFIG, xcb) { - for(package, $$list("libdrm xcomposite xi xrandr xscrnsaver")) { - !packagesExist($$package):skipBuild("Unmet dependency: $$package") - } - } linux { + # libcap-dev package doesn't ship .pc files on Ubuntu. + !config_libcap:skipBuild("libcap development package appears to be missing") + !config_khr:skipBuild("khronos development headers appear to be missing (mesa/libegl1-mesa-dev)") + + REQUIRED_PACKAGES = dbus-1 fontconfig + contains(QT_CONFIG, xcb): REQUIRED_PACKAGES += libdrm xcomposite xcursor xi xrandr xscrnsaver xtst + contains(QT_CONFIG, pulseaudio): REQUIRED_PACKAGES += libpulse + contains(QT_CONFIG, system-png): REQUIRED_PACKAGES += libpng + contains(QT_CONFIG, system-jpeg): REQUIRED_PACKAGES += libjpeg + contains(QT_CONFIG, system-harfbuzz): REQUIRED_PACKAGES += harfbuzz + !cross_compile: REQUIRED_PACKAGES += libpci nss + + for(package, $$list($$REQUIRED_PACKAGES)) { + !packagesExist($$package):skipBuild("Unmet dependency: $$package") + } packagesExist(minizip, zlib): WEBENGINE_CONFIG += config_system_minizip else: log("System zlib or minizip not found. Using Chromium's copies.$${EOL}") packagesExist(libwebp,libwebpdemux): WEBENGINE_CONFIG += config_system_libwebp diff --git a/tools/qmake/mkspecs/features/functions.prf b/tools/qmake/mkspecs/features/functions.prf index ef0320da1af0bff25551c1288e7b4b982e6a74f7..c0e1f90bb92dcc69fe9ae9835f1f3f69b8410689 100644 --- a/tools/qmake/mkspecs/features/functions.prf +++ b/tools/qmake/mkspecs/features/functions.prf @@ -14,10 +14,10 @@ defineTest(isPlatformSupported) { linux-g++*:!isGCCVersionSupported(): return(false) !isPythonVersionSupported(): return(false) - linux-g++*|win32-msvc2013|macx-clang: return(true) + linux-g++*|linux-clang|win32-msvc2013|macx-clang*: return(true) boot2qt: return(true) - skipBuild("Qt WebEngine can currently only be built for Linux (GCC), Windows (MSVC 2013), OS X (XCode 5.1+) or Qt for Device Creation.") + skipBuild("Qt WebEngine can currently only be built for Linux (GCC/clang), Windows (MSVC 2013), OS X (XCode 5.1+) or Qt for Device Creation.") return(false) } diff --git a/tools/scripts/take_snapshot.py b/tools/scripts/take_snapshot.py index 836d230e86633ecd303fe4cc526e292c1dfc4814..e5df2d80bc63327edd69b1e0f13594e6623f1f21 100755 --- a/tools/scripts/take_snapshot.py +++ b/tools/scripts/take_snapshot.py @@ -163,6 +163,7 @@ def isInChromiumBlacklist(file_path): or file_path.startswith('third_party/cros_system_api') or file_path.startswith('third_party/cygwin') or file_path.startswith('third_party/cython') + or file_path.startswith('third_party/deqp') or file_path.startswith('third_party/elfutils') or file_path.startswith('third_party/google_input_tools') or file_path.startswith('third_party/gperf') @@ -171,7 +172,7 @@ def isInChromiumBlacklist(file_path): or file_path.startswith('third_party/google_appengine_cloudstorage') or file_path.startswith('third_party/google_toolbox_for_mac') or file_path.startswith('third_party/hunspell_dictionaries') - or file_path.startswith('third_party/hunspell_new') + or file_path.startswith('third_party/hunspell') or file_path.startswith('third_party/instrumented_libraries') or file_path.startswith('third_party/jsr-305/src') or file_path.startswith('third_party/junit') @@ -185,7 +186,7 @@ def isInChromiumBlacklist(file_path): or file_path.startswith('third_party/mingw-w64') or file_path.startswith('third_party/nacl_sdk_binaries') or (file_path.startswith('third_party/polymer') and - not file_path.startswith('third_party/polymer/components-chromium/')) + not file_path.startswith('third_party/polymer/v1_0/components-chromium/')) or file_path.startswith('third_party/pdfsqueeze') or file_path.startswith('third_party/pefile') or file_path.startswith('third_party/perl') @@ -209,9 +210,12 @@ def isInChromiumBlacklist(file_path): not file_path.startswith('tools/protoc_wrapper')) or file_path.startswith('ui/android/java') or file_path.startswith('ui/app_list') + or file_path.startswith('ui/base/ime/chromeos') or file_path.startswith('ui/chromeos') or file_path.startswith('ui/display/chromeos') + or file_path.startswith('ui/events/ozone/chromeos') or file_path.startswith('ui/file_manager') + or file_path.startswith('ui/gfx/chromeos') ): return True @@ -301,7 +305,10 @@ def exportChromium(): commandNotFound = subprocess.call(['which', 'dos2unix']) if not commandNotFound: - dos2unixVersion = StrictVersion(subprocess.Popen(['dos2unix', '-V', '| true'], stdout=subprocess.PIPE).communicate()[0].splitlines()[0].split()[1]) + dos2unixVersion , err = subprocess.Popen(['dos2unix', '-V', '| true'], stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate() + if not dos2unixVersion: + raise Exception("You need dos2unix version 6.0.6 minimum.") + dos2unixVersion = StrictVersion(dos2unixVersion.splitlines()[0].split()[1]) if commandNotFound or dos2unixVersion < StrictVersion('6.0.6'): raise Exception("You need dos2unix version 6.0.6 minimum.") diff --git a/tools/scripts/version_resolver.py b/tools/scripts/version_resolver.py index b223e4fefa514edb8ffa00e5705406cbd56df252..f6aaedf64c4736e74422e646c2e48bf02c65aec5 100644 --- a/tools/scripts/version_resolver.py +++ b/tools/scripts/version_resolver.py @@ -51,8 +51,8 @@ import json import urllib2 import git_submodule as GitSubmodule -chromium_version = '44.0.2403.91' -chromium_branch = '2403' +chromium_version = '45.0.2454.79' +chromium_branch = '2454' ninja_version = 'v1.5.3' json_url = 'http://omahaproxy.appspot.com/all.json'