M117 stage 2

This commit is contained in:
Alexander Frick 2023-10-08 07:14:53 -05:00
parent 4c8a8a5ce7
commit 1eea8773fb
24 changed files with 816 additions and 5568 deletions

12
SECURITY.md Normal file
View File

@ -0,0 +1,12 @@
# Security
### Thorium Security Policy
- If it is a vulnerability in Chromium, please report it upstream [Here](https://bugs.chromium.org/p/chromium/issues/entry).
- If it is a vulnerability in Thorium, file an issue on GitHub. However, if it is major and/or a zero day, please email me instead at Alex313031@gmail.com
### List of major vulnerabilities fixed in Thorium
libwebp WebP bug [CVE-2023-4863](https://nvd.nist.gov/vuln/detail/CVE-2023-4863) - Fixed in M117
libvpx VP8 bug [CVE-2023-5217](https://nvd.nist.gov/vuln/detail/CVE-2023-5217) - Fixed in M117

View File

@ -49,6 +49,7 @@
<DT><A HREF="https://source.chromium.org/chromium/chromium/src/+/refs/tags/117.0.5938.157:chrome/app/theme/theme_resources.grd;bpv=1" ADD_DATE="1661054752" ICON="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAADIUlEQVQ4jW1TXWwUZRQ955ufnZ3dlm4VpE2Q+lND1cSQYDBaKY2VEkUFa1d9K4laBROEIg+mDfvkg5Bu9MWoD/hkTJdqJBFCMRENEqONRkMbIiWGWn5SjWw7OzO7szPf9UFCCnrebu7JuTc55xA3QURYKkEtXw7+1gDm0mDWBtMm+GcAnb+P0VI+lw4fTIp7C6O7dU3nlKFyisxp0TmDRpMmmyDSCqLY96D1HUQIUsxrd9nfD3VrHDbDTi/ENi5V/TCdtmlQ0Y60dmwANNXT0HpodEx+2kNUb/4e45PSUhBR/1lcw6Gvf3fGf4gmJn6NBgGgUBBFAHj+vepdKSvp2r5m/pPu7juqA4fEOTcXvhaG2KAMVjOp5MjJ4eynBOTIz7Vnzs5Jcfoiej9+1TlHAHjyneArKrl/XcVtnQLcS/A/b23J9DzUBgQRcPo84JX90VOF7JCIGFsOBLMCTB/dl3lc9b+7uA1O+jHb4OuFAvVl+oOtLZmekc1JbUc36nt7pb6zK0mslL2n6+3wUZJJyuIuOm7Ps8Xyc8qP3Q+TMDj+2W73MABUatK5vg26vcVQf3navOqL+Ui7kay53dJeEG8AgPE33PEkDI6HSfZ9BRFAQJF/LSVYDSIQEBiKsE0lsRaGNSiTEl43X4SAQKWN8GUj427qG/XyAJB15IvTM+CJKW04FuoiEpd+1Grmj8BvzPIYAGwten2mm9mUsauDBIAnDvgnAHQMrHZX5/NMOguLBy07NXTPKhvVGnDhb0BH3pvfDjcelDExnpoNLormmS/3uT0KAFY0xDs2dhiLqXZsBoBThca9QK1z8mxlZPpCZZeq+2dMqi2AcGYtzOZG9dayrHoFACgiJCkTU9FAJZCtCxX7he3dvCFl60b8ta6lh2/T2Rdf2oam3gc4f2MXRLi7NOd0tq34iFS/aNFHIwBhJLGVSLRqZd3rWNYQfj+L5igOdb6YvoISNEC5LgBSDk9G6ynYScgVrbGgFMsQKSdiLIhIWSe6rGifzz/M8H/bCABjU2L781BeOCMrK5FcvfNeuexB8M1J7N+/MSEpS/n/AGH0clblBN69AAAAAElFTkSuQmCC">theme - Chromium Code Search</A>
<DT><A HREF="https://source.chromium.org/chromium/chromium/src/+/refs/tags/117.0.5938.157:content/gpu/BUILD.gn;bpv=1" ADD_DATE="1661054752" ICON="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAADIUlEQVQ4jW1TXWwUZRQ955ufnZ3dlm4VpE2Q+lND1cSQYDBaKY2VEkUFa1d9K4laBROEIg+mDfvkg5Bu9MWoD/hkTJdqJBFCMRENEqONRkMbIiWGWn5SjWw7OzO7szPf9UFCCnrebu7JuTc55xA3QURYKkEtXw7+1gDm0mDWBtMm+GcAnb+P0VI+lw4fTIp7C6O7dU3nlKFyisxp0TmDRpMmmyDSCqLY96D1HUQIUsxrd9nfD3VrHDbDTi/ENi5V/TCdtmlQ0Y60dmwANNXT0HpodEx+2kNUb/4e45PSUhBR/1lcw6Gvf3fGf4gmJn6NBgGgUBBFAHj+vepdKSvp2r5m/pPu7juqA4fEOTcXvhaG2KAMVjOp5MjJ4eynBOTIz7Vnzs5Jcfoiej9+1TlHAHjyneArKrl/XcVtnQLcS/A/b23J9DzUBgQRcPo84JX90VOF7JCIGFsOBLMCTB/dl3lc9b+7uA1O+jHb4OuFAvVl+oOtLZmekc1JbUc36nt7pb6zK0mslL2n6+3wUZJJyuIuOm7Ps8Xyc8qP3Q+TMDj+2W73MABUatK5vg26vcVQf3navOqL+Ui7kay53dJeEG8AgPE33PEkDI6HSfZ9BRFAQJF/LSVYDSIQEBiKsE0lsRaGNSiTEl43X4SAQKWN8GUj427qG/XyAJB15IvTM+CJKW04FuoiEpd+1Grmj8BvzPIYAGwten2mm9mUsauDBIAnDvgnAHQMrHZX5/NMOguLBy07NXTPKhvVGnDhb0BH3pvfDjcelDExnpoNLormmS/3uT0KAFY0xDs2dhiLqXZsBoBThca9QK1z8mxlZPpCZZeq+2dMqi2AcGYtzOZG9dayrHoFACgiJCkTU9FAJZCtCxX7he3dvCFl60b8ta6lh2/T2Rdf2oam3gc4f2MXRLi7NOd0tq34iFS/aNFHIwBhJLGVSLRqZd3rWNYQfj+L5igOdb6YvoISNEC5LgBSDk9G6ynYScgVrbGgFMsQKSdiLIhIWSe6rGifzz/M8H/bCABjU2L781BeOCMrK5FcvfNeuexB8M1J7N+/MSEpS/n/AGH0clblBN69AAAAAElFTkSuQmCC">BUILD.gn - Chromium Code Search</A>
<DT><A HREF="https://source.chromium.org/chromium/chromium/src/+/refs/tags/117.0.5938.157:media/base/media_switches.cc;bpv=1" ADD_DATE="1661054752" ICON="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAADIUlEQVQ4jW1TXWwUZRQ955ufnZ3dlm4VpE2Q+lND1cSQYDBaKY2VEkUFa1d9K4laBROEIg+mDfvkg5Bu9MWoD/hkTJdqJBFCMRENEqONRkMbIiWGWn5SjWw7OzO7szPf9UFCCnrebu7JuTc55xA3QURYKkEtXw7+1gDm0mDWBtMm+GcAnb+P0VI+lw4fTIp7C6O7dU3nlKFyisxp0TmDRpMmmyDSCqLY96D1HUQIUsxrd9nfD3VrHDbDTi/ENi5V/TCdtmlQ0Y60dmwANNXT0HpodEx+2kNUb/4e45PSUhBR/1lcw6Gvf3fGf4gmJn6NBgGgUBBFAHj+vepdKSvp2r5m/pPu7juqA4fEOTcXvhaG2KAMVjOp5MjJ4eynBOTIz7Vnzs5Jcfoiej9+1TlHAHjyneArKrl/XcVtnQLcS/A/b23J9DzUBgQRcPo84JX90VOF7JCIGFsOBLMCTB/dl3lc9b+7uA1O+jHb4OuFAvVl+oOtLZmekc1JbUc36nt7pb6zK0mslL2n6+3wUZJJyuIuOm7Ps8Xyc8qP3Q+TMDj+2W73MABUatK5vg26vcVQf3navOqL+Ui7kay53dJeEG8AgPE33PEkDI6HSfZ9BRFAQJF/LSVYDSIQEBiKsE0lsRaGNSiTEl43X4SAQKWN8GUj427qG/XyAJB15IvTM+CJKW04FuoiEpd+1Grmj8BvzPIYAGwten2mm9mUsauDBIAnDvgnAHQMrHZX5/NMOguLBy07NXTPKhvVGnDhb0BH3pvfDjcelDExnpoNLormmS/3uT0KAFY0xDs2dhiLqXZsBoBThca9QK1z8mxlZPpCZZeq+2dMqi2AcGYtzOZG9dayrHoFACgiJCkTU9FAJZCtCxX7he3dvCFl60b8ta6lh2/T2Rdf2oam3gc4f2MXRLi7NOd0tq34iFS/aNFHIwBhJLGVSLRqZd3rWNYQfj+L5igOdb6YvoISNEC5LgBSDk9G6ynYScgVrbGgFMsQKSdiLIhIWSe6rGifzz/M8H/bCABjU2L781BeOCMrK5FcvfNeuexB8M1J7N+/MSEpS/n/AGH0clblBN69AAAAAElFTkSuQmCC">media_switches.cc - Chromium Code Search</A>
<DT><A HREF="https://source.chromium.org/chromium/chromium/src/+/refs/tags/117.0.5938.157:media/filters/ffmpeg_video_decoder.cc;bpv=1" ADD_DATE="1661054752" ICON="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAADIUlEQVQ4jW1TXWwUZRQ955ufnZ3dlm4VpE2Q+lND1cSQYDBaKY2VEkUFa1d9K4laBROEIg+mDfvkg5Bu9MWoD/hkTJdqJBFCMRENEqONRkMbIiWGWn5SjWw7OzO7szPf9UFCCnrebu7JuTc55xA3QURYKkEtXw7+1gDm0mDWBtMm+GcAnb+P0VI+lw4fTIp7C6O7dU3nlKFyisxp0TmDRpMmmyDSCqLY96D1HUQIUsxrd9nfD3VrHDbDTi/ENi5V/TCdtmlQ0Y60dmwANNXT0HpodEx+2kNUb/4e45PSUhBR/1lcw6Gvf3fGf4gmJn6NBgGgUBBFAHj+vepdKSvp2r5m/pPu7juqA4fEOTcXvhaG2KAMVjOp5MjJ4eynBOTIz7Vnzs5Jcfoiej9+1TlHAHjyneArKrl/XcVtnQLcS/A/b23J9DzUBgQRcPo84JX90VOF7JCIGFsOBLMCTB/dl3lc9b+7uA1O+jHb4OuFAvVl+oOtLZmekc1JbUc36nt7pb6zK0mslL2n6+3wUZJJyuIuOm7Ps8Xyc8qP3Q+TMDj+2W73MABUatK5vg26vcVQf3navOqL+Ui7kay53dJeEG8AgPE33PEkDI6HSfZ9BRFAQJF/LSVYDSIQEBiKsE0lsRaGNSiTEl43X4SAQKWN8GUj427qG/XyAJB15IvTM+CJKW04FuoiEpd+1Grmj8BvzPIYAGwten2mm9mUsauDBIAnDvgnAHQMrHZX5/NMOguLBy07NXTPKhvVGnDhb0BH3pvfDjcelDExnpoNLormmS/3uT0KAFY0xDs2dhiLqXZsBoBThca9QK1z8mxlZPpCZZeq+2dMqi2AcGYtzOZG9dayrHoFACgiJCkTU9FAJZCtCxX7he3dvCFl60b8ta6lh2/T2Rdf2oam3gc4f2MXRLi7NOd0tq34iFS/aNFHIwBhJLGVSLRqZd3rWNYQfj+L5igOdb6YvoISNEC5LgBSDk9G6ynYScgVrbGgFMsQKSdiLIhIWSe6rGifzz/M8H/bCABjU2L781BeOCMrK5FcvfNeuexB8M1J7N+/MSEpS/n/AGH0clblBN69AAAAAElFTkSuQmCC">ffmpeg_video_decoder.cc - Chromium Code Search</A>
<DT><A HREF="https://source.chromium.org/chromium/chromium/src/+/refs/tags/117.0.5938.157:media/gpu/gpu_video_decode_accelerator_factory.cc;bpv=1" ADD_DATE="1661054752" ICON="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAADIUlEQVQ4jW1TXWwUZRQ955ufnZ3dlm4VpE2Q+lND1cSQYDBaKY2VEkUFa1d9K4laBROEIg+mDfvkg5Bu9MWoD/hkTJdqJBFCMRENEqONRkMbIiWGWn5SjWw7OzO7szPf9UFCCnrebu7JuTc55xA3QURYKkEtXw7+1gDm0mDWBtMm+GcAnb+P0VI+lw4fTIp7C6O7dU3nlKFyisxp0TmDRpMmmyDSCqLY96D1HUQIUsxrd9nfD3VrHDbDTi/ENi5V/TCdtmlQ0Y60dmwANNXT0HpodEx+2kNUb/4e45PSUhBR/1lcw6Gvf3fGf4gmJn6NBgGgUBBFAHj+vepdKSvp2r5m/pPu7juqA4fEOTcXvhaG2KAMVjOp5MjJ4eynBOTIz7Vnzs5Jcfoiej9+1TlHAHjyneArKrl/XcVtnQLcS/A/b23J9DzUBgQRcPo84JX90VOF7JCIGFsOBLMCTB/dl3lc9b+7uA1O+jHb4OuFAvVl+oOtLZmekc1JbUc36nt7pb6zK0mslL2n6+3wUZJJyuIuOm7Ps8Xyc8qP3Q+TMDj+2W73MABUatK5vg26vcVQf3navOqL+Ui7kay53dJeEG8AgPE33PEkDI6HSfZ9BRFAQJF/LSVYDSIQEBiKsE0lsRaGNSiTEl43X4SAQKWN8GUj427qG/XyAJB15IvTM+CJKW04FuoiEpd+1Grmj8BvzPIYAGwten2mm9mUsauDBIAnDvgnAHQMrHZX5/NMOguLBy07NXTPKhvVGnDhb0BH3pvfDjcelDExnpoNLormmS/3uT0KAFY0xDs2dhiLqXZsBoBThca9QK1z8mxlZPpCZZeq+2dMqi2AcGYtzOZG9dayrHoFACgiJCkTU9FAJZCtCxX7he3dvCFl60b8ta6lh2/T2Rdf2oam3gc4f2MXRLi7NOd0tq34iFS/aNFHIwBhJLGVSLRqZd3rWNYQfj+L5igOdb6YvoISNEC5LgBSDk9G6ynYScgVrbGgFMsQKSdiLIhIWSe6rGifzz/M8H/bCABjU2L781BeOCMrK5FcvfNeuexB8M1J7N+/MSEpS/n/AGH0clblBN69AAAAAElFTkSuQmCC">gpu_video_decode_accelerator_factory.cc - Chromium Code Search</A>
<DT><A HREF="https://source.chromium.org/chromium/chromium/src/+/refs/tags/117.0.5938.157:media/gpu/ipc/service/gpu_video_decode_accelerator.cc;bpv=1" ADD_DATE="1661054752" ICON="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAADIUlEQVQ4jW1TXWwUZRQ955ufnZ3dlm4VpE2Q+lND1cSQYDBaKY2VEkUFa1d9K4laBROEIg+mDfvkg5Bu9MWoD/hkTJdqJBFCMRENEqONRkMbIiWGWn5SjWw7OzO7szPf9UFCCnrebu7JuTc55xA3QURYKkEtXw7+1gDm0mDWBtMm+GcAnb+P0VI+lw4fTIp7C6O7dU3nlKFyisxp0TmDRpMmmyDSCqLY96D1HUQIUsxrd9nfD3VrHDbDTi/ENi5V/TCdtmlQ0Y60dmwANNXT0HpodEx+2kNUb/4e45PSUhBR/1lcw6Gvf3fGf4gmJn6NBgGgUBBFAHj+vepdKSvp2r5m/pPu7juqA4fEOTcXvhaG2KAMVjOp5MjJ4eynBOTIz7Vnzs5Jcfoiej9+1TlHAHjyneArKrl/XcVtnQLcS/A/b23J9DzUBgQRcPo84JX90VOF7JCIGFsOBLMCTB/dl3lc9b+7uA1O+jHb4OuFAvVl+oOtLZmekc1JbUc36nt7pb6zK0mslL2n6+3wUZJJyuIuOm7Ps8Xyc8qP3Q+TMDj+2W73MABUatK5vg26vcVQf3navOqL+Ui7kay53dJeEG8AgPE33PEkDI6HSfZ9BRFAQJF/LSVYDSIQEBiKsE0lsRaGNSiTEl43X4SAQKWN8GUj427qG/XyAJB15IvTM+CJKW04FuoiEpd+1Grmj8BvzPIYAGwten2mm9mUsauDBIAnDvgnAHQMrHZX5/NMOguLBy07NXTPKhvVGnDhb0BH3pvfDjcelDExnpoNLormmS/3uT0KAFY0xDs2dhiLqXZsBoBThca9QK1z8mxlZPpCZZeq+2dMqi2AcGYtzOZG9dayrHoFACgiJCkTU9FAJZCtCxX7he3dvCFl60b8ta6lh2/T2Rdf2oam3gc4f2MXRLi7NOd0tq34iFS/aNFHIwBhJLGVSLRqZd3rWNYQfj+L5igOdb6YvoISNEC5LgBSDk9G6ynYScgVrbGgFMsQKSdiLIhIWSe6rGifzz/M8H/bCABjU2L781BeOCMrK5FcvfNeuexB8M1J7N+/MSEpS/n/AGH0clblBN69AAAAAElFTkSuQmCC">gpu_video_decode_accelerator.cc - Chromium Code Search</A>
<DT><A HREF="https://source.chromium.org/chromium/chromium/src/+/refs/tags/117.0.5938.157:media/gpu/vaapi/vaapi_video_decode_accelerator.cc;bpv=1" ADD_DATE="1661054752" ICON="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAADIUlEQVQ4jW1TXWwUZRQ955ufnZ3dlm4VpE2Q+lND1cSQYDBaKY2VEkUFa1d9K4laBROEIg+mDfvkg5Bu9MWoD/hkTJdqJBFCMRENEqONRkMbIiWGWn5SjWw7OzO7szPf9UFCCnrebu7JuTc55xA3QURYKkEtXw7+1gDm0mDWBtMm+GcAnb+P0VI+lw4fTIp7C6O7dU3nlKFyisxp0TmDRpMmmyDSCqLY96D1HUQIUsxrd9nfD3VrHDbDTi/ENi5V/TCdtmlQ0Y60dmwANNXT0HpodEx+2kNUb/4e45PSUhBR/1lcw6Gvf3fGf4gmJn6NBgGgUBBFAHj+vepdKSvp2r5m/pPu7juqA4fEOTcXvhaG2KAMVjOp5MjJ4eynBOTIz7Vnzs5Jcfoiej9+1TlHAHjyneArKrl/XcVtnQLcS/A/b23J9DzUBgQRcPo84JX90VOF7JCIGFsOBLMCTB/dl3lc9b+7uA1O+jHb4OuFAvVl+oOtLZmekc1JbUc36nt7pb6zK0mslL2n6+3wUZJJyuIuOm7Ps8Xyc8qP3Q+TMDj+2W73MABUatK5vg26vcVQf3navOqL+Ui7kay53dJeEG8AgPE33PEkDI6HSfZ9BRFAQJF/LSVYDSIQEBiKsE0lsRaGNSiTEl43X4SAQKWN8GUj427qG/XyAJB15IvTM+CJKW04FuoiEpd+1Grmj8BvzPIYAGwten2mm9mUsauDBIAnDvgnAHQMrHZX5/NMOguLBy07NXTPKhvVGnDhb0BH3pvfDjcelDExnpoNLormmS/3uT0KAFY0xDs2dhiLqXZsBoBThca9QK1z8mxlZPpCZZeq+2dMqi2AcGYtzOZG9dayrHoFACgiJCkTU9FAJZCtCxX7he3dvCFl60b8ta6lh2/T2Rdf2oam3gc4f2MXRLi7NOd0tq34iFS/aNFHIwBhJLGVSLRqZd3rWNYQfj+L5igOdb6YvoISNEC5LgBSDk9G6ynYScgVrbGgFMsQKSdiLIhIWSe6rGifzz/M8H/bCABjU2L781BeOCMrK5FcvfNeuexB8M1J7N+/MSEpS/n/AGH0clblBN69AAAAAElFTkSuQmCC">vaapi_video_decode_accelerator.cc - Chromium Code Search</A>

View File

@ -426,9 +426,18 @@ If you update this file, be sure also to update google_chrome_strings.grd. -->
Not used in Thorium. Placeholder to keep resource maps in sync.
</message>
</if>
<message name="IDS_ABOUT_TERMS_OF_SERVICE" desc="The terms of service label in the About box." translateable="false">
Not used in Thorium. Placeholder to keep resource maps in sync.
</message>
<if expr="_is_chrome_for_testing_branded">
<then>
<message name="IDS_ABOUT_TERMS_OF_SERVICE" desc="The terms of service label in the About box.">
Terms of Service
</message>
</then>
<else>
<message name="IDS_ABOUT_TERMS_OF_SERVICE" desc="The terms of service label in the About box." translateable="false">
Not used in Thorium. Placeholder to keep resource maps in sync.
</message>
</else>
</if>
<if expr="is_macosx">
<message name="IDS_MAC_10_13_OBSOLETE" desc="A message displayed on an at-launch infobar and About (Help) page warning the user that the OS version they are using will soon be or is already unsupported.">
To get future Thorium updates, you'll need macOS 10.15 or later. This computer is using macOS 10.13.
@ -684,11 +693,9 @@ Permissions you've already given to websites and apps may apply to this account.
desc="Subpage summary of warning for Deep Scanning.">
Thorium recommends scanning this file because it may be dangerous
</message>
<!-- Tailored Warning in Download Bubble Items -->
<message name="IDS_DOWNLOAD_BUBBLE_SUBPAGE_SUMMARY_SUSPICIOUS_ARCHIVE"
desc="Subpage summary for suspicious archive warning.">
Thorium blocked this archive file because it may hide malware
<message name="IDS_DOWNLOAD_BUBBLE_SUBPAGE_SUMMARY_WARNING_BLOCKED_LEARN_MORE_LINK"
desc="Text for the link to the help page about why Thorium blocks some downloaded files. This string will be embedded in a longer sentence that makes up the whole label.">
Thorium blocks some downloads
</message>
<!-- Download Shelf Items -->
@ -771,11 +778,14 @@ Permissions you've already given to websites and apps may apply to this account.
<message name="IDS_SAFETY_CHECK_EXTENSIONS_MALWARE" desc="The text explaining the reason for disabling extension. The extension in question contains malware.">
This extension contains malware and is unsafe. Remove it from Thorium so it can no longer see and change your data on sites you visit, including your personal info.
</message>
<message name="IDS_SAFETY_CHECK_EXTENSIONS_POLICY_VIOLATION" desc="The text explaining the reason for disabling extension. The extension in question violates Thorium Web Store policy.">
This extension violates the Chrome Web Store policy, and might be unsafe. Remove it from Thorium so it can no longer see and change your data on sites you visit, including your personal info.
<message name="IDS_SAFETY_CHECK_EXTENSIONS_POLICY_VIOLATION" desc="The text explaining the reason for disabling extension. The extension in question violates Thorium Web Store policy.">
This extension violates the Chrome Web Store policy, and might be unsafe. Remove it from Thorium so it can no longer see and change your data on sites you visit, including your personal info.
</message>
<message name="IDS_SAFETY_CHECK_EXTENSIONS_UNPUBLISHED" desc="The text explaining the reason for disabling extension. The extension in question was unpublished by the developer.">
This extension was unpublished by its developer, and might be unsafe. Remove it from Thorium so it can no longer see and change your data on sites you visit, including your personal info.
This extension was unpublished by its developer, and might be unsafe. Remove it from Thorium so it can no longer see and change your data on sites you visit, including your personal info.
</message>
<message name="IDS_EXTENSIONS_SAFETY_CHECK_PRIMARY_LABEL" desc="Alerts the user that the extension should be reviewed.">
Thorium recommends you review this extension
</message>
<!-- chrome://settings/extensions page -->
@ -946,9 +956,18 @@ Permissions you've already given to websites and apps may apply to this account.
</if>
<!-- NTP strings -->
<message name="IDS_NTP_CUSTOMIZE_BUTTON_LABEL" desc="Label for button on the New Tab Page that opens dialog to customize Thorium browser.">
Customize Thorium
</message>
<if expr="_is_chrome_for_testing_branded">
<then>
<message name="IDS_NTP_CUSTOMIZE_BUTTON_LABEL" desc="Label for button on the New Tab Page that opens dialog to customize Thorium for Testing browser.">
Customize Thorium for Testing
</message>
</then>
<else>
<message name="IDS_NTP_CUSTOMIZE_BUTTON_LABEL" desc="Label for button on the New Tab Page that opens dialog to customize Thorium browser.">
Customize Thorium
</message>
</else>
</if>
<!-- Signin Email Confirmation tab modal dialog -->
<if expr="not chromeos_ash">
@ -1058,17 +1077,19 @@ Permissions you've already given to websites and apps may apply to this account.
<if expr="not is_android">
<!-- WebHID system tray icon -->
<message name="IDS_WEBHID_SYSTEM_TRAY_ICON_TITLE_SINGLE_EXTENSION" desc="Title for the WebHID system tray icon when one or more HID devices are being accessed by an extension.">
<message name="IDS_WEBHID_SYSTEM_TRAY_ICON_TITLE" desc="Title for the WebHID system tray icon">
{NUM_DEVICES, plural,
=0 {A Thorium extension was accessing HID devices}
=1 {A Thorium extension is accessing 1 HID device}
other {A Thorium extension is accessing # HID devices}}
=0 {1 HID device was being accessed by one or more Thorium extensions}
=1 {1 HID device is being accessed by one or more Thorium extensions}
other {# HID devices are being accessed by one or more Thorium extensions}}
</message>
<message name="IDS_WEBHID_SYSTEM_TRAY_ICON_TITLE_MULTIPLE_EXTENSIONS" desc="Title for the WebHID system tray icon when HID devices are being accessed by multiple extensions.">
<!-- WebUSB system tray icon -->
<message name="IDS_WEBUSB_SYSTEM_TRAY_ICON_TITLE" desc="Title for the WebUSB system tray icon">
{NUM_DEVICES, plural,
=0 {Thorium extensions were accessing HID devices}
=1 {Thorium extensions are accessing HID devices}
other {Thorium extensions are accessing # HID devices}}
=0 {1 USB device was being accessed by one or more Thorium extensions}
=1 {1 USB device is being accessed by one or more Thorium extensions}
other {# USB devices are being accessed by one or more Thorium extensions}}
</message>
</if>
@ -1474,8 +1495,8 @@ Permissions you've already given to websites and apps may apply to this account.
</message>
<message name="IDS_IDLE_TIMEOUT_CLEAR_BODY" desc="First sentence in the Idle Timeout dialog, warning the user that Thorium is going to clear data automatically.">
{COUNT, plural,
=1 {Your organization automatically deletes browsing data when Thorium isn't used for 1 minute. This could include history, autofill, and downloads. Your existing tabs will remain open.}
other {Your organization automatically deletes browsing data when Thorium isn't used for # minutes. This could include history, autofill, and downloads. Your existing tabs will remain open.}}
=1 {Your organization automatically deletes browsing data when Thorium isn't used for 1 minute. This could include history, autofill, and downloads. Your tabs will stay open.}
other {Your organization automatically deletes browsing data when Thorium isn't used for # minutes. This could include history, autofill, and downloads. Your tabs will stay open.}}
</message>
<message name="IDS_IDLE_TIMEOUT_CLOSE_AND_CLEAR_BODY" desc="First sentence in the Idle Timeout dialog, warning the user that Thorium is going to close and clear data automatically.">
{COUNT, plural,
@ -1492,13 +1513,11 @@ Permissions you've already given to websites and apps may apply to this account.
Help us improve Thorium
</message>
</if>
<!-- Thorium parent extension/app install blocking dialog. -->
<if expr="enable_extensions and enable_supervised_users">
<message name="IDS_EXTENSION_INSTALL_BLOCKED_BY_PARENT_PROMPT_MESSAGE" desc="Text for the dialog indicating that a parent has blocked extensions and apps.">
Your parent has turned off "Permissions for sites, apps and extensions" for Thorium. Adding this <ph name="EXTENSION_TYPE_PARAMETER">$1<ex>extension</ex></ph> is not allowed.
</message>
<message name="IDS_EXTENSION_ENABLE_BLOCKED_BY_PARENT_PROMPT_MESSAGE" desc="Text for the dialog indicating that a parent has blocked extensions and apps.">
Your parent has turned off "Permissions for sites, apps and extensions" for Thorium. Enabling this <ph name="EXTENSION_TYPE_PARAMETER">$1<ex>extension</ex></ph> is not allowed.
<message name="IDS_EXTENSION_PERMISSIONS_BLOCKED_BY_PARENT_PROMPT_MESSAGE" desc="Text for the dialog indicating that a parent has blocked extensions and apps.">
Your parent has turned off "Permissions for sites, apps and extensions" for Thorium
</message>
</if>
@ -1535,9 +1554,6 @@ Permissions you've already given to websites and apps may apply to this account.
<message name="IDS_PROFILE_PICKER_PROFILE_CREATION_FLOW_PROFILE_TYPE_CHOICE_TITLE" desc="Profile picker profile type choice title">
Set up your new Thorium profile
</message>
<message name="IDS_PROFILE_PICKER_PROFILE_CREATION_FLOW_LOCAL_PROFILE_CREATION_TITLE" desc="Title for the local profile customiztion screen on the picker.">
Customize your Thorium profile
</message>
<message name="IDS_PROFILE_PICKER_IPH_FOR_PROFILES_TEXT" desc="Text of the IPH bubble for introducing profiles.">
Each profile holds its own Thorium info like bookmarks, history, passwords, and more
</message>
@ -1581,6 +1597,17 @@ Permissions you've already given to websites and apps may apply to this account.
</message>
</if>
<!-- Default Browser Promo -->
<message name="IDS_FRE_DEFAULT_BROWSER_TITLE" desc="Title for the page that prompts user to set Thorium as their default browser in the first run experience.">
Set Thorium as your default browser
</message>
<message name="IDS_FRE_DEFAULT_BROWSER_SUBTITLE_NEW" desc="Subtitle for the page that prompts user to set Thorium as their default browser in the first run experience.">
Use Thorium anytime you click links in messages, documents, and other apps
</message>
<message name="IDS_FRE_DEFAULT_BROWSER_ILLUSTRATION_ALT_TEXT" desc="Alt text for the illustration in the page that prompts user to set Thorium as their default browser.">
Thorium logo inside a computer screen.
</message>
<!-- Profile switch IPH -->
<message name="IDS_PROFILE_SWITCH_PROMO" desc="Text of the In-Product-Help bubble for profile switching.">
You can switch between Thorium profiles here

View File

@ -1,375 +0,0 @@
// Copyright 2023 The Chromium Authors and Alex313031. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/common/media/cdm_registration.h"
#include "base/check.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/logging.h"
#include "base/path_service.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "content/public/common/cdm_info.h"
#include "media/cdm/cdm_capability.h"
#include "media/cdm/cdm_type.h"
#include "media/cdm/clear_key_cdm_common.h"
#include "third_party/widevine/cdm/buildflags.h"
#if BUILDFLAG(ENABLE_LIBRARY_CDMS)
#include "base/command_line.h"
#include "media/base/media_switches.h"
#include "media/cdm/cdm_paths.h" // nogncheck
#endif
#if BUILDFLAG(ENABLE_WIDEVINE)
#include "third_party/widevine/cdm/widevine_cdm_common.h" // nogncheck
#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_WIN)
#include "base/native_library.h"
#include "chrome/common/chrome_paths.h"
#endif // BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_WIN)
#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
#include "base/no_destructor.h"
#include "components/cdm/common/cdm_manifest.h"
#include "media/cdm/supported_audio_codecs.h"
// Needed for WIDEVINE_CDM_MIN_GLIBC_VERSION. This file is in
// SHARED_INTERMEDIATE_DIR.
#include "widevine_cdm_version.h" // nogncheck
// The following must be after widevine_cdm_version.h.
#if defined(WIDEVINE_CDM_MIN_GLIBC_VERSION)
#include <gnu/libc-version.h>
#include "base/version.h"
#endif // defined(WIDEVINE_CDM_MIN_GLIBC_VERSION)
#if !BUILDFLAG(IS_CHROMEOS_ASH)
#include "chrome/common/media/component_widevine_cdm_hint_file_linux.h"
#endif // !BUILDFLAG(IS_CHROMEOS_ASH)
#endif // BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
#endif // BUILDFLAG(ENABLE_WIDEVINE)
#if BUILDFLAG(IS_ANDROID)
#include "components/cdm/common/android_cdm_registration.h"
#endif // BUILDFLAG(IS_ANDROID)
namespace {
using Robustness = content::CdmInfo::Robustness;
#if BUILDFLAG(ENABLE_WIDEVINE)
#if (BUILDFLAG(BUNDLE_WIDEVINE_CDM) || \
BUILDFLAG(ENABLE_WIDEVINE_CDM_COMPONENT)) && \
(BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS))
// Create a CdmInfo for a Widevine CDM, using |version|, |cdm_library_path|, and
// |capability|.
std::unique_ptr<content::CdmInfo> CreateWidevineCdmInfo(
const base::Version& version,
const base::FilePath& cdm_library_path,
media::CdmCapability capability) {
return std::make_unique<content::CdmInfo>(
kWidevineKeySystem, Robustness::kSoftwareSecure, std::move(capability),
/*supports_sub_key_systems=*/false, kWidevineCdmDisplayName,
kWidevineCdmType, version, cdm_library_path);
}
// On desktop Linux and ChromeOS, given |cdm_base_path| that points to a folder
// containing the Widevine CDM and associated files, read the manifest included
// in that directory and create a CdmInfo. If that is successful, return the
// CdmInfo. If not, return nullptr.
std::unique_ptr<content::CdmInfo> CreateCdmInfoFromWidevineDirectory(
const base::FilePath& cdm_base_path) {
// Library should be inside a platform specific directory.
auto cdm_library_path =
media::GetPlatformSpecificDirectory(cdm_base_path)
.Append(base::GetNativeLibraryName(kWidevineCdmLibraryName));
if (!base::PathExists(cdm_library_path)) {
return nullptr;
}
// Manifest should be at the top level.
auto manifest_path = cdm_base_path.Append(FILE_PATH_LITERAL("manifest.json"));
base::Version version;
media::CdmCapability capability;
if (!ParseCdmManifestFromPath(manifest_path, &version, &capability)) {
return nullptr;
}
return CreateWidevineCdmInfo(version, cdm_library_path,
std::move(capability));
}
#endif // (BUILDFLAG(BUNDLE_WIDEVINE_CDM) ||
// BUILDFLAG(ENABLE_WIDEVINE_CDM_COMPONENT)) && (BUILDFLAG(IS_LINUX) ||
// BUILDFLAG(IS_CHROMEOS))
#if (BUILDFLAG(ENABLE_WIDEVINE_CDM_COMPONENT) || BUILDFLAG(BUNDLE_WIDEVINE_CDM)) && \
(BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS))
// On Linux/ChromeOS we have to preload the CDM since it uses the zygote
// sandbox. On Windows and Mac, the bundled CDM is handled by the component
// updater.
// This code checks to see if the Widevine CDM was bundled with Chrome. If one
// can be found and looks valid, it returns the CdmInfo for the CDM. Otherwise
// it returns nullptr.
content::CdmInfo* GetBundledWidevine() {
// We only want to do this on the first call, as if Widevine wasn't bundled
// with Chrome (or it was deleted/removed) it won't be loaded into the zygote.
static base::NoDestructor<std::unique_ptr<content::CdmInfo>> s_cdm_info(
[]() -> std::unique_ptr<content::CdmInfo> {
base::FilePath install_dir;
CHECK(base::PathService::Get(chrome::DIR_BUNDLED_WIDEVINE_CDM,
&install_dir));
return CreateCdmInfoFromWidevineDirectory(install_dir);
}());
return s_cdm_info->get();
}
#endif // (BUILDFLAG(ENABLE_WIDEVINE_CDM_COMPONENT) || BUILDFLAG(BUNDLE_WIDEVINE_CDM)) && (BUILDFLAG(IS_LINUX) ||
// BUILDFLAG(IS_CHROMEOS))
#if BUILDFLAG(ENABLE_WIDEVINE_CDM_COMPONENT) && \
(BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS))
// This code checks to see if a component updated Widevine CDM can be found. If
// there is one and it looks valid, return the CdmInfo for that CDM. Otherwise
// return nullptr.
content::CdmInfo* GetComponentUpdatedWidevine() {
// We only want to do this on the first call, as the component updater may run
// and download a new version once Chrome has been running for a while. Since
// the first returned version will be the one loaded into the zygote, we want
// to return the same thing on subsequent calls.
static base::NoDestructor<std::unique_ptr<content::CdmInfo>> s_cdm_info(
[]() -> std::unique_ptr<content::CdmInfo> {
auto install_dir = GetLatestComponentUpdatedWidevineCdmDirectory();
if (install_dir.empty()) {
return nullptr;
}
return CreateCdmInfoFromWidevineDirectory(install_dir);
}());
return s_cdm_info->get();
}
#endif // BUILDFLAG(ENABLE_WIDEVINE_CDM_COMPONENT) && (BUILDFLAG(IS_LINUX) ||
// BUILDFLAG(IS_CHROMEOS))
void AddSoftwareSecureWidevine(std::vector<content::CdmInfo>* cdms) {
DVLOG(1) << __func__;
#if BUILDFLAG(IS_ANDROID)
// On Android Widevine is done by MediaDrm, and should be supported on all
// devices. Register Widevine without any capabilities so that it will be
// checked the first time some page attempts to play protected content.
cdms->emplace_back(
kWidevineKeySystem, Robustness::kSoftwareSecure, absl::nullopt,
/*supports_sub_key_systems=*/false, kWidevineCdmDisplayName,
kWidevineCdmType, base::Version(), base::FilePath());
#elif BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
#if defined(WIDEVINE_CDM_MIN_GLIBC_VERSION)
base::Version glibc_version(gnu_get_libc_version());
DCHECK(glibc_version.IsValid());
if (glibc_version < base::Version(WIDEVINE_CDM_MIN_GLIBC_VERSION)) {
LOG(WARNING) << "Widevine not registered because glibc version is too low";
return;
}
#endif // defined(WIDEVINE_CDM_MIN_GLIBC_VERSION)
// The Widevine CDM on Linux needs to be registered (and loaded) before the
// zygote is locked down. The CDM can be found from the version bundled with
// Chrome (if BUNDLE_WIDEVINE_CDM = true) and/or the version downloaded by
// the component updater (if ENABLE_WIDEVINE_CDM_COMPONENT = true). If two
// versions exist, take the one with the higher version number.
//
// Note that the component updater will detect the bundled version, and if
// there is no newer version available, select the bundled version. In this
// case both versions will be the same and point to the same directory, so
// it doesn't matter which one is loaded.
content::CdmInfo* bundled_widevine = nullptr;
#if (BUILDFLAG(ENABLE_WIDEVINE_CDM_COMPONENT) || BUILDFLAG(BUNDLE_WIDEVINE_CDM))
bundled_widevine = GetBundledWidevine();
#endif
content::CdmInfo* updated_widevine = nullptr;
#if BUILDFLAG(ENABLE_WIDEVINE_CDM_COMPONENT)
updated_widevine = GetComponentUpdatedWidevine();
#endif
// If only a bundled version is available, or both are available and the
// bundled version is not less than the updated version, register the
// bundled version. If only the updated version is available, or both are
// available and the updated version is greater, then register the updated
// version. If neither are available, then nothing is registered.
if (bundled_widevine &&
(!updated_widevine ||
bundled_widevine->version >= updated_widevine->version)) {
VLOG(1) << "Registering bundled Widevine " << bundled_widevine->version;
cdms->push_back(*bundled_widevine);
} else if (updated_widevine) {
VLOG(1) << "Registering component updated Widevine "
<< updated_widevine->version;
cdms->push_back(*updated_widevine);
} else {
VLOG(1) << "Widevine enabled but no library found";
}
#endif // BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
}
void AddHardwareSecureWidevine(std::vector<content::CdmInfo>* cdms) {
DVLOG(1) << __func__;
#if BUILDFLAG(IS_ANDROID)
// On Android Widevine is done by MediaDrm, and should be supported on all
// devices. Register Widevine without any capabilities so that it will be
// checked the first time some page attempts to play protected content.
cdms->emplace_back(
kWidevineKeySystem, Robustness::kHardwareSecure, absl::nullopt,
/*supports_sub_key_systems=*/false, kWidevineCdmDisplayName,
kWidevineCdmType, base::Version(), base::FilePath());
#elif BUILDFLAG(USE_CHROMEOS_PROTECTED_MEDIA)
#if BUILDFLAG(IS_CHROMEOS_LACROS)
if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kLacrosUseChromeosProtectedMedia)) {
return;
}
#endif // BUILDFLAG(IS_CHROMEOS_LACROS)
media::CdmCapability capability;
// The following audio formats are supported for decrypt-only.
capability.audio_codecs = media::GetCdmSupportedAudioCodecs();
// We currently support VP9, H264 and HEVC video formats with
// decrypt-and-decode. Not specifying any profiles to indicate that all
// relevant profiles should be considered supported.
const media::VideoCodecInfo kAllProfiles;
capability.video_codecs.emplace(media::VideoCodec::kVP9, kAllProfiles);
#if BUILDFLAG(USE_PROPRIETARY_CODECS)
capability.video_codecs.emplace(media::VideoCodec::kH264, kAllProfiles);
#endif
#if BUILDFLAG(ENABLE_PLATFORM_HEVC)
#if BUILDFLAG(IS_CHROMEOS_LACROS)
if (base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kLacrosEnablePlatformHevc)) {
capability.video_codecs.emplace(media::VideoCodec::kHEVC, kAllProfiles);
}
#elif BUILDFLAG(IS_CHROMEOS_ASH)
if (base::FeatureList::IsEnabled(media::kPlatformHEVCDecoderSupport)) {
capability.video_codecs.emplace(media::VideoCodec::kHEVC, kAllProfiles);
}
#else
capability.video_codecs.emplace(media::VideoCodec::kHEVC, kAllProfiles);
#endif // BUILDFLAG(IS_CHROMEOS_LACROS)
#endif
#if BUILDFLAG(USE_CHROMEOS_PROTECTED_AV1)
capability.video_codecs.emplace(media::VideoCodec::kAV1, kAllProfiles);
#elif BUILDFLAG(IS_CHROMEOS_LACROS)
if (base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kLacrosUseChromeosProtectedAv1)) {
capability.video_codecs.emplace(media::VideoCodec::kAV1, kAllProfiles);
}
#endif
// Both encryption schemes are supported on ChromeOS.
capability.encryption_schemes.insert(media::EncryptionScheme::kCenc);
capability.encryption_schemes.insert(media::EncryptionScheme::kCbcs);
// Both temporary and persistent sessions are supported on ChromeOS.
capability.session_types.insert(media::CdmSessionType::kTemporary);
capability.session_types.insert(media::CdmSessionType::kPersistentLicense);
cdms->push_back(
content::CdmInfo(kWidevineKeySystem, Robustness::kHardwareSecure,
std::move(capability), content::kChromeOsCdmType));
#endif // BUILDFLAG(USE_CHROMEOS_PROTECTED_MEDIA)
}
void AddWidevine(std::vector<content::CdmInfo>* cdms) {
AddSoftwareSecureWidevine(cdms);
AddHardwareSecureWidevine(cdms);
}
#endif // BUILDFLAG(ENABLE_WIDEVINE)
#if BUILDFLAG(ENABLE_LIBRARY_CDMS)
void AddExternalClearKey(std::vector<content::CdmInfo>* cdms) {
// Register Clear Key CDM if specified in command line.
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
base::FilePath clear_key_cdm_path =
command_line->GetSwitchValuePath(switches::kClearKeyCdmPathForTesting);
if (clear_key_cdm_path.empty() || !base::PathExists(clear_key_cdm_path)) {
return;
}
// Supported codecs are hard-coded in ExternalClearKeyKeySystemInfo.
media::CdmCapability capability(
{}, {}, {media::EncryptionScheme::kCenc, media::EncryptionScheme::kCbcs},
{media::CdmSessionType::kTemporary,
media::CdmSessionType::kPersistentLicense});
// Register media::kExternalClearKeyDifferentCdmTypeTestKeySystem first
// separately. Otherwise, it'll be treated as a sub-key-system of normal
// media::kExternalClearKeyKeySystem. See MultipleCdmTypes test in
// ECKEncryptedMediaTest.
cdms->push_back(content::CdmInfo(
media::kExternalClearKeyDifferentCdmTypeTestKeySystem,
Robustness::kSoftwareSecure, capability,
/*supports_sub_key_systems=*/false, media::kClearKeyCdmDisplayName,
media::kClearKeyCdmDifferentCdmType, base::Version("0.1.0.0"),
clear_key_cdm_path));
cdms->push_back(content::CdmInfo(
media::kExternalClearKeyKeySystem, Robustness::kSoftwareSecure,
capability,
/*supports_sub_key_systems=*/true, media::kClearKeyCdmDisplayName,
media::kClearKeyCdmType, base::Version("0.1.0.0"), clear_key_cdm_path));
}
#endif // BUILDFLAG(ENABLE_LIBRARY_CDMS)
#if BUILDFLAG(IS_WIN)
void AddMediaFoundationClearKey(std::vector<content::CdmInfo>* cdms) {
if (!base::FeatureList::IsEnabled(media::kExternalClearKeyForTesting)) {
return;
}
// Register MediaFoundation Clear Key CDM if specified in feature list.
base::FilePath clear_key_cdm_path = base::FilePath::FromASCII(
media::kMediaFoundationClearKeyCdmPathForTesting.Get());
if (clear_key_cdm_path.empty() || !base::PathExists(clear_key_cdm_path)) {
return;
}
// Supported codecs are hard-coded in ExternalClearKeyKeySystemInfo.
media::CdmCapability capability(
{}, {}, {media::EncryptionScheme::kCenc, media::EncryptionScheme::kCbcs},
{media::CdmSessionType::kTemporary});
cdms->push_back(
content::CdmInfo(media::kMediaFoundationClearKeyKeySystem,
Robustness::kHardwareSecure, capability,
/*supports_sub_key_systems=*/false,
media::kMediaFoundationClearKeyCdmDisplayName,
media::kMediaFoundationClearKeyCdmType,
base::Version("0.1.0.0"), clear_key_cdm_path));
}
#endif // BUILDFLAG(IS_WIN)
} // namespace
void RegisterCdmInfo(std::vector<content::CdmInfo>* cdms) {
DVLOG(1) << __func__;
DCHECK(cdms);
DCHECK(cdms->empty());
#if BUILDFLAG(ENABLE_WIDEVINE)
AddWidevine(cdms);
#endif
#if BUILDFLAG(ENABLE_LIBRARY_CDMS)
AddExternalClearKey(cdms);
#endif
#if BUILDFLAG(IS_WIN)
AddMediaFoundationClearKey(cdms);
#endif
#if BUILDFLAG(IS_ANDROID)
cdm::AddOtherAndroidCdms(cdms);
#endif // BUILDFLAG(IS_ANDROID)
DVLOG(3) << __func__ << " done with " << cdms->size() << " cdms";
}

View File

@ -81,7 +81,6 @@ cp -r -v src/third_party/devtools-frontend/src/front_end/Images/src/chromeSelect
copyMacOS () {
printf "\n" &&
printf "${YEL}Copying files for MacOS...${c0}\n" &&
cp -r -v other/Mac/cdm_registration.cc ${CR_SRC_DIR}/chrome/common/media/ &&
cp -r -v arm/mac_arm.gni ${CR_SRC_DIR}/build/config/arm.gni &&
printf "\n"
}

View File

@ -17,7 +17,7 @@ import sys
from gn_helpers import ToGNString
# VS 2022 17.5 with 10.0.22621.0 SDK with ARM64 libraries and UWP support.
# VS 2022 17.7 with 10.0.22621.1778 SDK with ARM64 libraries and UWP support.
# See go/chromium-msvc-toolchain for instructions about how to update the
# toolchain.
#
@ -39,7 +39,7 @@ from gn_helpers import ToGNString
# Maps between Visual Studio version and MSVC toolset
# * MSVS_VERSIONS in this file
# Records the packaged and default version of Visual Studio
TOOLCHAIN_HASH = '336d7fa644'
TOOLCHAIN_HASH = '7eee888925'
SDK_VERSION = '10.0.22621.0'
script_dir = os.path.dirname(os.path.realpath(__file__))

View File

@ -365,10 +365,6 @@ if (!is_android && !is_mac) {
if (is_chromeos_ash) {
data_deps += [ "//mojo/core:shared_libraries_for_arc" ]
if (is_chromeos_device) {
configs += [ "//build/config/chromeos:print_orderfile" ]
configs += [ "//build/config/compiler:chrome_orderfile_config" ]
}
}
# These files are used by the installer so we need a public dep.
@ -536,7 +532,7 @@ if (is_win) {
sources = [ "app/chrome_exe_main_mac.cc" ]
extra_configs = [ "//build/config/compiler:wexit_time_destructors" ]
configs += [ "//build/config/compiler:wexit_time_destructors" ]
deps = [
":chrome_app_strings_bundle_data",
@ -778,7 +774,7 @@ if (is_win) {
sources = [ "app/chrome_exe_main_mac.cc" ]
extra_configs = [ "//build/config/compiler:wexit_time_destructors" ]
configs += [ "//build/config/compiler:wexit_time_destructors" ]
defines = [ "HELPER_EXECUTABLE" ]
@ -1143,6 +1139,24 @@ if (is_win) {
]
}
# Limit the exported symbols of the framework library.
config("chrome_dll_symbol_exports") {
inputs = [ rebase_path("app/framework.exports") ]
ldflags = [
"-Wl,-exported_symbols_list",
"-Wl," + rebase_path("app/framework.exports", root_build_dir),
]
}
# Control the order of exported symbols in the framework library.
config("chrome_dll_symbol_order") {
inputs = [ rebase_path("app/framework.order") ]
ldflags = [
"-Wl,-order_file",
"-Wl," + rebase_path("app/framework.order", root_build_dir),
]
}
# On Mac, speed up the component build by not re-bundling the framework
# every time it changes. Instead, place all the sources and their deps in
# a library that the bundled framework links (and re-exports). That way
@ -1190,16 +1204,15 @@ if (is_win) {
frameworks = [ "Carbon.framework" ]
}
ldflags = [
"-Wl,-order_file",
"-Wl," + rebase_path("app/framework.order", root_build_dir),
"-ObjC",
]
ldflags = [ "-ObjC" ]
configs += [
"//build/config/compiler:enable_arc",
":chrome_dll_symbol_order",
"//build/config/compiler:wexit_time_destructors",
]
if (!is_component_build && !using_sanitizer) {
configs += [ ":chrome_dll_symbol_exports" ]
}
}
mac_framework_bundle("chrome_framework") {
@ -1252,12 +1265,16 @@ if (is_win) {
bundle_deps += [ ":preinstalled_apps" ]
}
configs += [ ":chrome_dll_symbol_order" ]
if (!is_component_build && !using_sanitizer) {
configs += [ ":chrome_dll_symbol_exports" ]
}
ldflags = [
"-compatibility_version",
chrome_dylib_version,
"-current_version",
chrome_dylib_version,
"-Wl,-order_file," + rebase_path("app/framework.order", root_build_dir),
]
if (!is_component_build) {
@ -1452,7 +1469,7 @@ group("dependencies") {
"//components/about_ui",
"//components/devtools/devtools_pipe",
"//components/memory_system",
"//components/startup_metric_utils/browser",
"//components/startup_metric_utils",
"//components/sync",
"//components/upload_list:upload_list",
"//content/public/child",

View File

@ -778,7 +778,7 @@ Permissions you've already given to websites and apps may apply to this account.
This extension contains malware and is unsafe. Remove it from Thorium so it can no longer see and change your data on sites you visit, including your personal info.
</message>
<message name="IDS_SAFETY_CHECK_EXTENSIONS_POLICY_VIOLATION" desc="The text explaining the reason for disabling extension. The extension in question violates Thorium Web Store policy.">
This extension violates the Thorium Web Store policy, and might be unsafe. Remove it from Thorium so it can no longer see and change your data on sites you visit, including your personal info.
This extension violates the Chrome Web Store policy, and might be unsafe. Remove it from Thorium so it can no longer see and change your data on sites you visit, including your personal info.
</message>
<message name="IDS_SAFETY_CHECK_EXTENSIONS_UNPUBLISHED" desc="The text explaining the reason for disabling extension. The extension in question was unpublished by the developer.">
This extension was unpublished by its developer, and might be unsafe. Remove it from Thorium so it can no longer see and change your data on sites you visit, including your personal info.

View File

@ -108,7 +108,7 @@
</then>
<else>
<message name="IDS_SETTINGS_DEFAULT_BROWSER_SECONDARY" desc="The text displayed when Thorium is installed in side-by-side mode, which does not support setting as the default browser.">
This is a secondary installation of Thorium, and cannot be made your default browser.
This is a secondary installation of Chromium, and cannot be made your default browser.
</message>
</else>
</if>

View File

@ -1,5 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) 2023 Alex313031. -->
<!-- This grd file contains images that are pre-scaled for device scale
factors. The image returned by ui::ResourceBundle::GetImageNamed()
will contain multiple gfx:ImageSkiaReps for each scale factors. The
@ -129,6 +128,14 @@
<structure type="chrome_scaled_image" name="IDR_NTP_FAVICON" file="common/favicon_ntp.png" />
<structure type="chrome_scaled_image" name="IDR_PASSWORD_CHECK" file="common/password_check.png" />
<structure type="chrome_scaled_image" name="IDR_PASSWORD_CHECK_DARK" file="common/password_check_dark.png" />
<if expr="_google_chrome">
<then>
<structure type="chrome_scaled_image" name="IDR_PASSWORD_MANAGER_FAVICON" file="google_chrome/favicon_chrome_password_manager.png" />
</then>
<else>
<structure type="chrome_scaled_image" name="IDR_PASSWORD_MANAGER_FAVICON" file="chromium/favicon_password_manager.png" />
</else>
</if>
</if>
<structure type="chrome_scaled_image" name="IDR_PLUGINS_FAVICON" file="common/favicon_plugins.png" />
<if expr="not is_android">

View File

@ -1,4 +1,4 @@
// Copyright 2023 The Chromium Authors and Alex313031. All rights reserved.
// Copyright 2023 The Chromium Authors and Alex313031
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@ -31,6 +31,7 @@
#endif // BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_WIN)
#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
#include "base/no_destructor.h"
#include "chrome/common/media/component_widevine_cdm_hint_file_linux.h"
#include "components/cdm/common/cdm_manifest.h"
#include "media/cdm/supported_audio_codecs.h"
// Needed for WIDEVINE_CDM_MIN_GLIBC_VERSION. This file is in
@ -41,9 +42,6 @@
#include <gnu/libc-version.h>
#include "base/version.h"
#endif // defined(WIDEVINE_CDM_MIN_GLIBC_VERSION)
#if !BUILDFLAG(IS_CHROMEOS_ASH)
#include "chrome/common/media/component_widevine_cdm_hint_file_linux.h"
#endif // !BUILDFLAG(IS_CHROMEOS_ASH)
#endif // BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
#endif // BUILDFLAG(ENABLE_WIDEVINE)
@ -82,6 +80,7 @@ std::unique_ptr<content::CdmInfo> CreateCdmInfoFromWidevineDirectory(
media::GetPlatformSpecificDirectory(cdm_base_path)
.Append(base::GetNativeLibraryName(kWidevineCdmLibraryName));
if (!base::PathExists(cdm_library_path)) {
DLOG(ERROR) << __func__ << " no directory: " << cdm_library_path;
return nullptr;
}
@ -90,6 +89,7 @@ std::unique_ptr<content::CdmInfo> CreateCdmInfoFromWidevineDirectory(
base::Version version;
media::CdmCapability capability;
if (!ParseCdmManifestFromPath(manifest_path, &version, &capability)) {
DLOG(ERROR) << __func__ << " no manifest: " << manifest_path;
return nullptr;
}
@ -145,8 +145,8 @@ content::CdmInfo* GetComponentUpdatedWidevine() {
}());
return s_cdm_info->get();
}
#endif // BUILDFLAG(ENABLE_WIDEVINE_CDM_COMPONENT) && (BUILDFLAG(IS_LINUX) ||
// BUILDFLAG(IS_CHROMEOS))
#endif // BUILDFLAG(ENABLE_WIDEVINE_CDM_COMPONENT) &&
// (BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS))
void AddSoftwareSecureWidevine(std::vector<content::CdmInfo>* cdms) {
DVLOG(1) << __func__;
@ -207,7 +207,7 @@ void AddSoftwareSecureWidevine(std::vector<content::CdmInfo>* cdms) {
} else {
VLOG(1) << "Widevine enabled but no library found";
}
#endif // BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
#endif // BUILDFLAG(IS_ANDROID)
}
void AddHardwareSecureWidevine(std::vector<content::CdmInfo>* cdms) {
@ -276,7 +276,7 @@ void AddHardwareSecureWidevine(std::vector<content::CdmInfo>* cdms) {
cdms->push_back(
content::CdmInfo(kWidevineKeySystem, Robustness::kHardwareSecure,
std::move(capability), content::kChromeOsCdmType));
#endif // BUILDFLAG(USE_CHROMEOS_PROTECTED_MEDIA)
#endif // BUILDFLAG(IS_ANDROID)
}
void AddWidevine(std::vector<content::CdmInfo>* cdms) {

View File

@ -336,12 +336,12 @@ BASE_FEATURE(kPlatformHEVCDecoderSupport,
"PlatformHEVCDecoderSupport",
base::FEATURE_ENABLED_BY_DEFAULT);
#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_APPLE)
// Enables HEVC hardware accelerated encoding for Windows and Mac.
#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_APPLE) || BUILDFLAG(IS_ANDROID)
// Enables HEVC hardware accelerated encoding for Windows, Mac, and Android.
BASE_FEATURE(kPlatformHEVCEncoderSupport,
"PlatformHEVCEncoderSupport",
base::FEATURE_ENABLED_BY_DEFAULT);
#endif // BUILDFLAG(IS_WIN) || BUILDFLAG(IS_APPLE)
#endif // BUILDFLAG(IS_WIN) || BUILDFLAG(IS_APPLE) || BUILDFLAG(IS_ANDROID)
#endif // BUILDFLAG(ENABLE_PLATFORM_HEVC)
// Only decode preload=metadata elements upon visibility.
@ -438,12 +438,7 @@ BASE_FEATURE(kContextMenuCopyVideoFrame,
// playback going to a specific output device in the audio service.
BASE_FEATURE(kChromeWideEchoCancellation,
"ChromeWideEchoCancellation",
#if BUILDFLAG(IS_CHROMEOS_DEVICE)
base::FEATURE_DISABLED_BY_DEFAULT
#else
base::FEATURE_ENABLED_BY_DEFAULT
#endif
);
base::FEATURE_ENABLED_BY_DEFAULT);
// When audio processing is done in the audio process, at the renderer side IPC
// is set up to receive audio at the processing sample rate. This is a
@ -510,7 +505,7 @@ BASE_FEATURE(kCrOSEnforceSystemAecAgc,
base::FEATURE_DISABLED_BY_DEFAULT);
BASE_FEATURE(kCrOSEnforceSystemAec,
"CrOSEnforceSystemAec",
base::FEATURE_DISABLED_BY_DEFAULT);
base::FEATURE_ENABLED_BY_DEFAULT);
BASE_FEATURE(kCrOSDspBasedAecDeactivatedGroups,
"CrOSDspBasedAecDeactivatedGroups",
@ -538,6 +533,10 @@ BASE_FEATURE(kIgnoreUiGains,
BASE_FEATURE(kShowForceRespectUiGainsToggle,
"ShowForceRespectUiGainsToggle",
base::FEATURE_DISABLED_BY_DEFAULT);
BASE_FEATURE(kCrOSSystemVoiceIsolationOption,
"CrOSSystemVoiceIsolationOption",
base::FEATURE_DISABLED_BY_DEFAULT);
#endif
// Make MSE garbage collection algorithm more aggressive when we are under
@ -562,7 +561,12 @@ BASE_FEATURE(kUseMultiPlaneFormatForHardwareVideo,
// software video decoders.
BASE_FEATURE(kUseMultiPlaneFormatForSoftwareVideo,
"UseMultiPlaneFormatForSoftwareVideo",
base::FEATURE_DISABLED_BY_DEFAULT);
#if BUILDFLAG(IS_MAC)
base::FEATURE_ENABLED_BY_DEFAULT
#else
base::FEATURE_DISABLED_BY_DEFAULT
#endif
);
// Enables binding software video NV12/P010 GMBs as separate shared images.
BASE_FEATURE(kMultiPlaneSoftwareVideoSharedImages,
@ -807,7 +811,7 @@ BASE_FEATURE(kVaapiVp9kSVCHWEncoding,
"VaapiVp9kSVCHWEncoding",
base::FEATURE_ENABLED_BY_DEFAULT);
#endif // defined(ARCH_CPU_X86_FAMILY) && BUILDFLAG(IS_CHROMEOS)
#if defined(ARCH_CPU_ARM_FAMILY) && BUILDFLAG(IS_CHROMEOS)
#if BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_LINUX)
// Enables the new V4L2StatefulVideoDecoder instead of V4L2VideoDecoder.
BASE_FEATURE(kV4L2FlatStatelessVideoDecoder,
"V4L2FlatStatelessVideoDecoder",
@ -955,6 +959,12 @@ BASE_FEATURE(kHardwareSecureDecryptionFallback,
"HardwareSecureDecryptionFallback",
base::FEATURE_ENABLED_BY_DEFAULT);
// Whether disabling hardware secure Content Decryption Module
// (CDM) after failures or crashes to fallback to software secure CDMs should
// use per site logic.
const base::FeatureParam<bool> kHardwareSecureDecryptionFallbackPerSite{
&kHardwareSecureDecryptionFallback, "per_site", false};
// The minimum and maximum number of days to disable hardware secure Content
// Decryption Module (CDM) as part of the fallback logic.
const base::FeatureParam<int> kHardwareSecureDecryptionFallbackMinDisablingDays{
@ -1029,7 +1039,12 @@ BASE_FEATURE(kAllowNonSecureOverlays,
"AllowNonSecureOverlays",
base::FEATURE_ENABLED_BY_DEFAULT);
// Enable a gesture to make the media controls expaned into the display cutout.
// Allow FrameInfoHelper to guess coded size information for MediaCodec frames.
BASE_FEATURE(kMediaCodecCodedSizeGuessing,
"MediaCodecCodedSizeGuessing",
base::FEATURE_ENABLED_BY_DEFAULT);
// Enable a gesture to make the media controls expanded into the display cutout.
// TODO(beccahughes): Remove this.
BASE_FEATURE(kMediaControlsExpandGesture,
"MediaControlsExpandGesture",
@ -1079,8 +1094,8 @@ BASE_FEATURE(kUseAudioLatencyFromHAL,
"UseAudioLatencyFromHAL",
base::FEATURE_DISABLED_BY_DEFAULT);
// Enable pooling of SharedImageVideo objects for use by MCVD, to save a hop to
// the GPU main thread during VideoFrame construction.
// Enable pooling of AndroidVideoImageBacking objects for use by MCVD, to save a
// hop to the GPU main thread during VideoFrame construction.
BASE_FEATURE(kUsePooledSharedImageVideoProvider,
"UsePooledSharedImageVideoProvider",
base::FEATURE_ENABLED_BY_DEFAULT);
@ -1146,6 +1161,14 @@ BASE_FEATURE(kUSeSequencedTaskRunnerForVEA,
BASE_FEATURE(kPreferGLImageProcessor,
"PreferGLImageProcessor",
base::FEATURE_DISABLED_BY_DEFAULT);
// Experimental support for software based MT21 conversion. On some (older)
// architectures, the hardware video decoder outputs frames in a pixel format
// known as MT21. Normally a hardware block performs to the conversion between
// this pixel format and NV12, but this flag will use a software equivalent
// instead.
BASE_FEATURE(kPreferSoftwareMT21,
"PreferSoftwareMT21",
base::FEATURE_DISABLED_BY_DEFAULT);
#endif // defined(ARCH_CPU_ARM_FAMILY)
#if BUILDFLAG(IS_CHROMEOS)
// ChromeOS has one of two VideoDecoder implementations active based on
@ -1338,6 +1361,21 @@ BASE_FEATURE(kUseTaskRunnerForMojoVEAService,
#endif
);
// Feature flag to run the MojoAudioDecoderService in a sequence different than
// the other mojo media services. On some Android devices, MediaCodec may block
// the thread which leads to frequent audio decoder underrun in renderer.
// Running the audio decoder in a separate sequence can improve the performance.
// Note: running audio decoder in a separate thread/sequence will cause
// multithread access to mojo media services. For Android audio decoder, the
// thread safety is easier to guarantee because:
// 1. The audio decoder and most of the other mojo media services don't cross
// reference each other.
// 2. The only exception is CDM so we use a lock inside MojoCdmServiceContext
// for thread safety.
BASE_FEATURE(kUseTaskRunnerForMojoAudioDecoderService,
"UseTaskRunnerForMojoAudioDecoderService",
base::FEATURE_DISABLED_BY_DEFAULT);
std::string GetEffectiveAutoplayPolicy(const base::CommandLine& command_line) {
// Return the autoplay policy set in the command line, if any.
if (command_line.HasSwitch(switches::kAutoplayPolicy))
@ -1449,13 +1487,11 @@ BASE_FEATURE(kAudioFocusLossSuspendMediaSession,
"AudioFocusMediaSession",
base::FEATURE_ENABLED_BY_DEFAULT);
#if !BUILDFLAG(IS_ANDROID)
// Hides the media metadata from the OS' media player if running in an Incognito
// session.
BASE_FEATURE(kHideIncognitoMediaMetadata,
"HideIncognitoMediaMetadata",
base::FEATURE_DISABLED_BY_DEFAULT);
#endif
// Enables the internal Media Session logic without enabling the Media Session
// service.
@ -1496,7 +1532,7 @@ BASE_FEATURE(kCastStreamingAv1,
BASE_FEATURE(kCastStreamingPerformanceOverlay,
"CastStreamingPerformanceOverlay",
base::FEATURE_DISABLED_BY_DEFAULT);
base::FEATURE_ENABLED_BY_DEFAULT);
// Controls whether mirroring negotiations will include the VP9 codec for video
// encoding.
@ -1522,14 +1558,6 @@ BASE_FEATURE(kVideoDecodeBatching,
bool IsChromeWideEchoCancellationEnabled() {
#if BUILDFLAG(CHROME_WIDE_ECHO_CANCELLATION)
#if BUILDFLAG(IS_CHROMEOS_DEVICE)
if (base::FeatureList::IsEnabled(kCrOSEnforceSystemAecNsAgc) ||
base::FeatureList::IsEnabled(kCrOSEnforceSystemAecNs) ||
base::FeatureList::IsEnabled(kCrOSEnforceSystemAecAgc) ||
base::FeatureList::IsEnabled(kCrOSEnforceSystemAec)) {
return false;
}
#endif
return base::FeatureList::IsEnabled(kChromeWideEchoCancellation);
#else
return false;

View File

@ -0,0 +1,508 @@
// Copyright 2023 The Chromium Authors and Alex313031
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "media/filters/ffmpeg_video_decoder.h"
#include <stddef.h>
#include <stdint.h>
#include <memory>
#include <numeric>
#include "base/bits.h"
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/location.h"
#include "base/memory/raw_ptr.h"
#include "base/task/bind_post_task.h"
#include "base/task/sequenced_task_runner.h"
#include "media/base/decoder_buffer.h"
#include "media/base/limits.h"
#include "media/base/media_log.h"
#include "media/base/timestamp_constants.h"
#include "media/base/video_aspect_ratio.h"
#include "media/base/video_frame.h"
#include "media/base/video_util.h"
#include "media/ffmpeg/ffmpeg_common.h"
#include "media/ffmpeg/ffmpeg_decoding_loop.h"
namespace media {
namespace {
// Dynamically allocated AVBuffer opaque data.
struct OpaqueData {
OpaqueData(void* fb,
scoped_refptr<FrameBufferPool> pool,
uint8_t* d,
size_t z,
VideoFrameLayout l)
: fb_priv(fb),
frame_pool(std::move(pool)),
data(d),
size(z),
layout(std::move(l)) {}
// FrameBufferPool key that we'll free when the AVBuffer is unused.
raw_ptr<void> fb_priv = nullptr;
// Pool which owns `fb_priv`.
scoped_refptr<FrameBufferPool> frame_pool;
// Data pointer from `fb_priv`. This is owned by `fb_priv`; do not free it.
raw_ptr<uint8_t> data = nullptr;
// Size of `data`.
size_t size = 0;
// Layout used to compute the size / stride / etc.
VideoFrameLayout layout;
};
} // namespace
// Returns the number of threads given the FFmpeg CodecID. Also inspects the
// command line for a valid --video-threads flag.
static int GetFFmpegVideoDecoderThreadCount(const VideoDecoderConfig& config) {
// Most codecs are so old that more threads aren't really needed.
int desired_threads = limits::kMinVideoDecodeThreads;
// Some ffmpeg codecs don't actually benefit from using more threads.
// Only add more threads for those codecs that we know will benefit.
switch (config.codec()) {
case VideoCodec::kUnknown:
case VideoCodec::kVC1:
case VideoCodec::kMPEG2:
case VideoCodec::kVP9:
case VideoCodec::kAV1:
case VideoCodec::kDolbyVision:
// We do not compile ffmpeg with support for any of these codecs.
break;
case VideoCodec::kTheora:
case VideoCodec::kMPEG4:
// No extra threads for these codecs.
break;
case VideoCodec::kHEVC:
case VideoCodec::kH264:
case VideoCodec::kVP8:
// Normalize to three threads for 1080p content, then scale linearly
// with number of pixels.
// Examples:
// 4k: 12 threads
// 1440p: 5 threads
// 1080p: 3 threads
// anything lower than 1080p: 2 threads
desired_threads = config.coded_size().width() *
config.coded_size().height() * 3 / 1920 / 1080;
}
return VideoDecoder::GetRecommendedThreadCount(desired_threads);
}
static int GetVideoBufferImpl(struct AVCodecContext* s,
AVFrame* frame,
int flags) {
FFmpegVideoDecoder* decoder = static_cast<FFmpegVideoDecoder*>(s->opaque);
return decoder->GetVideoBuffer(s, frame, flags);
}
static void ReleaseVideoBufferImpl(void* opaque, uint8_t* data) {
if (!opaque) {
return;
}
OpaqueData* opaque_data = static_cast<OpaqueData*>(opaque);
opaque_data->frame_pool->ReleaseFrameBuffer(opaque_data->fb_priv);
delete opaque_data;
}
// static
bool FFmpegVideoDecoder::IsCodecSupported(VideoCodec codec) {
return avcodec_find_decoder(VideoCodecToCodecID(codec)) != nullptr;
}
FFmpegVideoDecoder::FFmpegVideoDecoder(MediaLog* media_log)
: media_log_(media_log) {
DVLOG(1) << __func__;
DETACH_FROM_SEQUENCE(sequence_checker_);
}
int FFmpegVideoDecoder::GetVideoBuffer(struct AVCodecContext* codec_context,
AVFrame* frame,
int flags) {
// Don't use |codec_context_| here! With threaded decoding,
// it will contain unsynchronized width/height/pix_fmt values. Accessing
// `codec_context` is also somewhat unreliable, sometimes providing incorrect
// values in a "missing memory barriers" kind of way.
//
// Instead, use `frame` for width / height / pix_fmt.
// Do not trust `codec_context->pix_fmt`.
const auto format = AVPixelFormatToVideoPixelFormat(
static_cast<AVPixelFormat>(frame->format));
if (format == PIXEL_FORMAT_UNKNOWN)
return AVERROR(EINVAL);
DCHECK(format == PIXEL_FORMAT_I420 || format == PIXEL_FORMAT_I422 ||
format == PIXEL_FORMAT_I444 || format == PIXEL_FORMAT_YUV420P9 ||
format == PIXEL_FORMAT_YUV420P10 || format == PIXEL_FORMAT_YUV422P9 ||
format == PIXEL_FORMAT_YUV422P10 || format == PIXEL_FORMAT_YUV444P9 ||
format == PIXEL_FORMAT_YUV444P10 || format == PIXEL_FORMAT_YUV420P12 ||
format == PIXEL_FORMAT_YUV422P12 || format == PIXEL_FORMAT_YUV444P12);
// Do not trust `codec_context` sizes either. Use whatever `frame` requests.
gfx::Size coded_size(frame->width, frame->height);
const int ret =
av_image_check_size(coded_size.width(), coded_size.height(), 0, nullptr);
if (ret < 0)
return ret;
VideoAspectRatio aspect_ratio = config_.aspect_ratio();
if (!aspect_ratio.IsValid() && codec_context->sample_aspect_ratio.num > 0) {
aspect_ratio =
VideoAspectRatio::PAR(codec_context->sample_aspect_ratio.num,
codec_context->sample_aspect_ratio.den);
}
// When lowres is non-zero, dimensions should be divided by 2^(lowres), but
// since we don't use this, just DCHECK that it's zero.
DCHECK_EQ(codec_context->lowres, 0);
if (force_allocation_error_)
return AVERROR(EINVAL);
// FFmpeg has specific requirements on the allocation size of the frame. The
// following logic replicates FFmpeg's allocation strategy to ensure buffers
// are not overread / overwritten. See ff_init_buffer_info() for details.
auto layout =
VideoFrame::CreateFullySpecifiedLayoutWithStrides(format, coded_size);
if (!layout) {
return AVERROR(EINVAL);
}
const size_t num_planes = layout->planes().size();
size_t allocation_size = layout->buffer_addr_align();
for (size_t plane = 0; plane < num_planes; plane++) {
allocation_size += layout->planes()[plane].size;
}
// Round up the allocation, but keep `allocation_size` as the usable
// allocation after aligning `data`.
void* fb_priv = nullptr;
uint8_t* data = frame_pool_->GetFrameBuffer(allocation_size, &fb_priv);
if (!data) {
return AVERROR(EINVAL);
}
data = base::bits::AlignUp(data, layout->buffer_addr_align());
for (size_t plane = 0; plane < num_planes; ++plane) {
frame->data[plane] = data + layout->planes()[plane].offset;
frame->linesize[plane] = layout->planes()[plane].stride;
}
// This seems unsafe, given threaded decoding. However, `reordered_opaque` is
// also going away upstream, so we need a whole new mechanism either way.
frame->reordered_opaque = codec_context->reordered_opaque;
// This will be freed by `ReleaseVideoBufferImpl`.
auto* opaque = new OpaqueData(fb_priv, frame_pool_, data, allocation_size,
std::move(*layout));
frame->buf[0] = av_buffer_create(
frame->data[0], VideoFrame::AllocationSize(format, coded_size),
ReleaseVideoBufferImpl, opaque,
/*flags=*/0);
return 0;
}
VideoDecoderType FFmpegVideoDecoder::GetDecoderType() const {
return VideoDecoderType::kFFmpeg;
}
void FFmpegVideoDecoder::Initialize(const VideoDecoderConfig& config,
bool low_delay,
CdmContext* /* cdm_context */,
InitCB init_cb,
const OutputCB& output_cb,
const WaitingCB& /* waiting_cb */) {
DVLOG(1) << __func__ << ": " << config.AsHumanReadableString();
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
DCHECK(config.IsValidConfig());
DCHECK(output_cb);
if (!frame_pool_) {
// FFmpeg expects the initial allocation to be zero-initialized. Failure to
// do so can lead to uninitialized value usage. See http://crbug.com/390941
frame_pool_ =
base::MakeRefCounted<FrameBufferPool>(/*clear_allocations=*/true);
}
InitCB bound_init_cb = base::BindPostTaskToCurrentDefault(std::move(init_cb));
if (config.is_encrypted()) {
std::move(bound_init_cb)
.Run(DecoderStatus::Codes::kUnsupportedEncryptionMode);
return;
}
if (!ConfigureDecoder(config, low_delay)) {
std::move(bound_init_cb).Run(DecoderStatus::Codes::kUnsupportedConfig);
return;
}
// Success!
config_ = config;
output_cb_ = output_cb;
state_ = DecoderState::kNormal;
std::move(bound_init_cb).Run(DecoderStatus::Codes::kOk);
}
void FFmpegVideoDecoder::Decode(scoped_refptr<DecoderBuffer> buffer,
DecodeCB decode_cb) {
DVLOG(3) << __func__;
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
DCHECK(buffer.get());
DCHECK(decode_cb);
CHECK_NE(state_, DecoderState::kUninitialized);
DecodeCB decode_cb_bound =
base::BindPostTaskToCurrentDefault(std::move(decode_cb));
if (state_ == DecoderState::kError) {
std::move(decode_cb_bound).Run(DecoderStatus::Codes::kFailed);
return;
}
if (state_ == DecoderState::kDecodeFinished) {
std::move(decode_cb_bound).Run(DecoderStatus::Codes::kOk);
return;
}
DCHECK_EQ(state_, DecoderState::kNormal);
// During decode, because reads are issued asynchronously, it is possible to
// receive multiple end of stream buffers since each decode is acked. There
// are three states the decoder can be in:
//
// DecoderState::kNormal: This is the starting state. Buffers are decoded.
// Decode errors are discarded.
// DecoderState::kDecodeFinished: All calls return empty frames.
// DecoderState::kError: Unexpected error happened.
//
// These are the possible state transitions.
//
// DecoderState::kNormal -> DecoderState::kDecodeFinished:
// When EOS buffer is received and the codec has been flushed.
// DecoderState::kNormal -> DecoderState::kError:
// A decoding error occurs and decoding needs to stop.
// (any state) -> DecoderState::kNormal:
// Any time Reset() is called.
if (!FFmpegDecode(*buffer)) {
state_ = DecoderState::kError;
std::move(decode_cb_bound).Run(DecoderStatus::Codes::kFailed);
return;
}
if (buffer->end_of_stream())
state_ = DecoderState::kDecodeFinished;
// VideoDecoderShim expects that |decode_cb| is called only after
// |output_cb_|.
std::move(decode_cb_bound).Run(DecoderStatus::Codes::kOk);
}
void FFmpegVideoDecoder::Reset(base::OnceClosure closure) {
DVLOG(2) << __func__;
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
avcodec_flush_buffers(codec_context_.get());
state_ = DecoderState::kNormal;
// PostTask() to avoid calling |closure| immediately.
base::SequencedTaskRunner::GetCurrentDefault()->PostTask(FROM_HERE,
std::move(closure));
}
FFmpegVideoDecoder::~FFmpegVideoDecoder() {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
if (state_ != DecoderState::kUninitialized)
ReleaseFFmpegResources();
if (frame_pool_) {
frame_pool_->Shutdown();
}
}
bool FFmpegVideoDecoder::FFmpegDecode(const DecoderBuffer& buffer) {
// Create a packet for input data.
// Due to FFmpeg API changes we no longer have const read-only pointers.
// av_init_packet is deprecated and being removed, and ffmpeg clearly does
// not want to allow on-stack allocation of AVPackets.
AVPacket* packet = av_packet_alloc();
if (buffer.end_of_stream()) {
packet->data = NULL;
packet->size = 0;
} else {
packet->data = const_cast<uint8_t*>(buffer.data());
packet->size = buffer.data_size();
DCHECK(packet->data);
DCHECK_GT(packet->size, 0);
// Let FFmpeg handle presentation timestamp reordering.
codec_context_->reordered_opaque = buffer.timestamp().InMicroseconds();
}
FFmpegDecodingLoop::DecodeStatus decode_status = decoding_loop_->DecodePacket(
packet, base::BindRepeating(&FFmpegVideoDecoder::OnNewFrame,
base::Unretained(this)));
av_packet_free(&packet);
switch (decode_status) {
case FFmpegDecodingLoop::DecodeStatus::kSendPacketFailed:
MEDIA_LOG(ERROR, media_log_)
<< "Failed to send video packet for decoding: "
<< buffer.AsHumanReadableString();
return false;
case FFmpegDecodingLoop::DecodeStatus::kFrameProcessingFailed:
// OnNewFrame() should have already issued a MEDIA_LOG for this.
return false;
case FFmpegDecodingLoop::DecodeStatus::kDecodeFrameFailed:
MEDIA_LOG(DEBUG, media_log_)
<< GetDecoderType() << " failed to decode a video frame: "
<< AVErrorToString(decoding_loop_->last_averror_code()) << ", at "
<< buffer.AsHumanReadableString();
return false;
case FFmpegDecodingLoop::DecodeStatus::kOkay:
break;
}
return true;
}
bool FFmpegVideoDecoder::OnNewFrame(AVFrame* frame) {
// TODO(fbarchard): Work around for FFmpeg http://crbug.com/27675
// The decoder is in a bad state and not decoding correctly.
// Checking for NULL avoids a crash in CopyPlane().
if (!frame->data[VideoFrame::kYPlane] || !frame->data[VideoFrame::kUPlane] ||
!frame->data[VideoFrame::kVPlane]) {
DLOG(ERROR) << "Video frame was produced yet has invalid frame data.";
return false;
}
auto* opaque = static_cast<OpaqueData*>(av_buffer_get_opaque(frame->buf[0]));
CHECK(!!opaque);
// `frame->width,height` may be different from what they were when we
// allocated the buffer. Presumably `width` is always the same, but in
// practice `height` can be smaller. They are advertised as the coded size,
// though, so that's how we use them here. `crop*` take this difference into
// account, and are meant to be applied to `width` and `height` as they are.
const gfx::Size coded_size(frame->width, frame->height);
const gfx::Rect visible_rect(frame->crop_left, frame->crop_top,
frame->width - frame->crop_right,
frame->height - frame->crop_bottom);
// Why do we prefer the container aspect ratio here?
VideoAspectRatio aspect_ratio = config_.aspect_ratio();
if (!aspect_ratio.IsValid() && frame->sample_aspect_ratio.num > 0) {
aspect_ratio = VideoAspectRatio::PAR(frame->sample_aspect_ratio.num,
frame->sample_aspect_ratio.den);
}
gfx::Size natural_size = aspect_ratio.GetNaturalSize(visible_rect);
const auto pts = base::Microseconds(frame->reordered_opaque);
auto video_frame = VideoFrame::WrapExternalDataWithLayout(
opaque->layout, visible_rect, natural_size, opaque->data, opaque->size,
pts);
if (!video_frame) {
return false;
}
auto config_cs = config_.color_space_info().ToGfxColorSpace();
gfx::ColorSpace color_space;
if (codec_context_->codec_id == AV_CODEC_ID_VP8 &&
frame->color_range == AVCOL_RANGE_JPEG &&
frame->color_primaries == AVCOL_PRI_UNSPECIFIED &&
frame->color_trc == AVCOL_TRC_UNSPECIFIED &&
frame->colorspace == AVCOL_SPC_BT470BG && !config_cs.IsValid()) {
// vp8 has no colorspace information, except for the color range, so prefer
// the config color space if it exists.
//
// However, because of a comment in the vp8 spec, ffmpeg sets the
// colorspace to BT470BG. We detect this and treat it as unset.
// If the color range is set to full range, we use the jpeg color space.
color_space = gfx::ColorSpace::CreateJpeg();
} else if (codec_context_->codec_id == AV_CODEC_ID_H264 &&
frame->colorspace == AVCOL_SPC_RGB &&
video_frame->format() == PIXEL_FORMAT_I420) {
// Some H.264 videos contain a VUI that specifies a color matrix of GBR,
// when they are actually ordinary YUV. Only 4:2:0 formats are checked,
// because GBR is reasonable for 4:4:4 content. See crbug.com/1067377.
color_space = gfx::ColorSpace::CreateREC709();
} else if (frame->color_primaries != AVCOL_PRI_UNSPECIFIED ||
frame->color_trc != AVCOL_TRC_UNSPECIFIED ||
frame->colorspace != AVCOL_SPC_UNSPECIFIED) {
color_space = VideoColorSpace(frame->color_primaries, frame->color_trc,
frame->colorspace,
frame->color_range != AVCOL_RANGE_MPEG
? gfx::ColorSpace::RangeID::FULL
: gfx::ColorSpace::RangeID::LIMITED)
.ToGfxColorSpace();
} else if (frame->color_range == AVCOL_RANGE_JPEG) {
// None of primaries, transfer, or colorspace are specified at this point,
// so guess BT.709 full range for historical reasons.
color_space = gfx::ColorSpace::CreateJpeg();
}
// Prefer the frame color space over what's in the config.
video_frame->set_color_space(color_space.IsValid() ? color_space : config_cs);
video_frame->metadata().power_efficient = false;
video_frame->AddDestructionObserver(
frame_pool_->CreateFrameCallback(opaque->fb_priv));
output_cb_.Run(video_frame);
return true;
}
void FFmpegVideoDecoder::ReleaseFFmpegResources() {
decoding_loop_.reset();
codec_context_.reset();
}
bool FFmpegVideoDecoder::ConfigureDecoder(const VideoDecoderConfig& config,
bool low_delay) {
DCHECK(config.IsValidConfig());
DCHECK(!config.is_encrypted());
// Release existing decoder resources if necessary.
ReleaseFFmpegResources();
// Initialize AVCodecContext structure.
codec_context_.reset(avcodec_alloc_context3(NULL));
VideoDecoderConfigToAVCodecContext(config, codec_context_.get());
codec_context_->thread_count = GetFFmpegVideoDecoderThreadCount(config);
codec_context_->thread_type =
FF_THREAD_SLICE | (low_delay ? 0 : FF_THREAD_FRAME);
codec_context_->opaque = this;
codec_context_->get_buffer2 = GetVideoBufferImpl;
if (decode_nalus_)
codec_context_->flags2 |= AV_CODEC_FLAG2_CHUNKS;
const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
if (!codec || avcodec_open2(codec_context_.get(), codec, NULL) < 0) {
ReleaseFFmpegResources();
return false;
}
decoding_loop_ = std::make_unique<FFmpegDecodingLoop>(codec_context_.get());
return true;
}
} // namespace media

File diff suppressed because it is too large Load Diff

View File

@ -1,722 +0,0 @@
// Copyright 2023 The Chromium Authors and Alex313031
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// This file contains an implementation of VaapiWrapper, used by
// VaapiVideoDecodeAccelerator and VaapiH264Decoder for decode,
// and VaapiVideoEncodeAccelerator for encode, to interface
// with libva (VA-API library for hardware video codec).
#ifndef MEDIA_GPU_VAAPI_VAAPI_WRAPPER_H_
#define MEDIA_GPU_VAAPI_VAAPI_WRAPPER_H_
#include <stddef.h>
#include <stdint.h>
#include <va/va.h>
#include <map>
#include <memory>
#include <set>
#include <vector>
#include "base/files/file.h"
#include "base/gtest_prod_util.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_refptr.h"
#include "base/synchronization/lock.h"
#include "base/thread_annotations.h"
#include "build/chromeos_buildflags.h"
#include "media/gpu/chromeos/fourcc.h"
#include "media/gpu/media_gpu_export.h"
#include "media/gpu/vaapi/va_surface.h"
#include "media/gpu/vaapi/vaapi_utils.h"
#include "media/video/video_decode_accelerator.h"
#include "media/video/video_encode_accelerator.h"
#include "third_party/abseil-cpp/absl/types/optional.h"
#include "ui/gfx/geometry/size.h"
#if BUILDFLAG(USE_VAAPI_X11)
#include "ui/gfx/x/xproto.h" // nogncheck
#endif // BUILDFLAG(USE_VAAPI_X11)
namespace gfx {
enum class BufferFormat : uint8_t;
class NativePixmap;
class NativePixmapDmaBuf;
class Rect;
}
#define MAYBE_ASSERT_ACQUIRED(lock) \
if (lock) \
lock->AssertAcquired()
namespace media {
constexpr unsigned int kInvalidVaRtFormat = 0u;
class VADisplayStateSingleton;
class VideoFrame;
// Enum, function and callback type to allow VaapiWrapper to log errors in VA
// function calls executed on behalf of its owner. |histogram_name| is prebound
// to allow for disinguishing such owners.
enum class VaapiFunctions;
void ReportVaapiErrorToUMA(const std::string& histogram_name,
VaapiFunctions value);
using ReportErrorToUMACB = base::RepeatingCallback<void(VaapiFunctions)>;
// This struct holds a NativePixmapDmaBuf, usually the result of exporting a VA
// surface, and some associated size information needed to tell clients about
// the underlying buffer.
struct NativePixmapAndSizeInfo {
NativePixmapAndSizeInfo();
~NativePixmapAndSizeInfo();
// The VA-API internal buffer dimensions, which may be different than the
// dimensions requested at the time of creation of the surface (but always
// larger than or equal to those). This can be used for validation in, e.g.,
// testing.
gfx::Size va_surface_resolution;
// The size of the underlying Buffer Object. A use case for this is when an
// image decode is requested and the caller needs to know the size of the
// allocated buffer for caching purposes.
size_t byte_size = 0u;
// Contains the information needed to use the surface in a graphics API,
// including the visible size (|pixmap|->GetBufferSize()) which should be no
// larger than |va_surface_resolution|.
scoped_refptr<gfx::NativePixmapDmaBuf> pixmap;
};
enum class VAImplementation {
kMesaGallium,
kIntelI965,
kIntelIHD,
kNVIDIAVDPAU,
kOther,
kInvalid,
};
// A VADisplayStateHandle is somewhat like a scoped_refptr for a
// VADisplayStateSingleton (an internal class used to keep track of a singleton
// VADisplay). As long as a non-null VADisplayStateHandle exists, the underlying
// VADisplay is initialized and can be used. When the last non-null
// VADisplayStateHandle is destroyed, the underlying VADisplay is cleaned up.
//
// Unlike a scoped_refptr, a VADisplayStateHandle is move-only.
//
// Note: a VADisplayStateHandle instance is thread- and sequence-safe, but the
// underlying VADisplay may need protection. See the comments for the
// VADisplayStateSingleton documentation.
class VADisplayStateHandle {
public:
// Creates a null VADisplayStateHandle.
VADisplayStateHandle();
VADisplayStateHandle(VADisplayStateHandle&& other) = default;
VADisplayStateHandle& operator=(VADisplayStateHandle&& other) = default;
VADisplayStateHandle(const VADisplayStateHandle&) = delete;
VADisplayStateHandle& operator=(const VADisplayStateHandle&) = delete;
~VADisplayStateHandle();
VADisplayStateSingleton* operator->() { return va_display_state_; }
explicit operator bool() const { return !!va_display_state_; }
private:
friend class VADisplayStateSingleton;
explicit VADisplayStateHandle(VADisplayStateSingleton* va_display_state);
raw_ptr<VADisplayStateSingleton> va_display_state_;
};
// This class handles VA-API calls and ensures proper locking of VA-API calls
// to libva, the userspace shim to the HW codec driver. The thread safety of
// libva depends on the backend. If the backend is not thread-safe, we need to
// maintain a global lock that guards all libva calls. This class is fully
// synchronous and its constructor, all of its methods, and its destructor must
// be called on the same sequence. These methods may wait on the |va_lock_|
// which guards libva calls across all VaapiWrapper instances and other libva
// call sites. If the backend is known to be thread safe and
// |enforce_sequence_affinity_| is true when the |kGlobalVaapiLock| flag is
// disabled, |va_lock_| will be null and won't guard any libva calls.
//
// This class is responsible for managing VAAPI connection, contexts and state.
// It is also responsible for managing and freeing VABuffers (not VASurfaces),
// which are used to queue parameters and slice data to the HW codec,
// as well as underlying memory for VASurfaces themselves.
//
// Historical note: the sequence affinity characteristic was introduced as a
// pre-requisite to remove the global *|va_lock_|. However, the legacy
// VaapiVideoDecodeAccelerator is known to use its VaapiWrapper from multiple
// threads. Therefore, to avoid doing a large refactoring of a legacy class, we
// allow it to call VaapiWrapper::Create() or
// VaapiWrapper::CreateForVideoCodec() with |enforce_sequence_affinity| == false
// so that sequence affinity is not enforced. This also indicates that the
// global lock will still be in effect for the VaapiVideoDecodeAccelerator.
class MEDIA_GPU_EXPORT VaapiWrapper
: public base::RefCountedThreadSafe<VaapiWrapper> {
public:
// Whether it's okay or not to try to disable the VA-API global lock on the
// current process. This is intended to be set only once during process
// start-up.
static bool allow_disabling_global_lock_;
enum CodecMode {
kDecode,
#if BUILDFLAG(IS_CHROMEOS_ASH)
// NOTE: A kDecodeProtected VaapiWrapper is created using the actual video
// profile and an extra VAProfileProtected, each with some special added
// VAConfigAttribs. Then when CreateProtectedSession() is called, it will
// then create a protected session using protected profile & entrypoint
// which gets attached to the decoding context (or attached when the
// decoding context is created or re-created). This then enables
// decrypt + decode support in the driver and encrypted frame data can then
// be submitted.
kDecodeProtected, // Decrypt + decode to protected surface.
#endif
kEncodeConstantBitrate, // Encode with Constant Bitrate algorithm.
kEncodeConstantQuantizationParameter, // Encode with Constant Quantization
// Parameter algorithm.
kEncodeVariableBitrate, // Encode with variable bitrate algorithm.
kVideoProcess,
kCodecModeMax,
};
// This is enum associated with VASurfaceAttribUsageHint.
enum class SurfaceUsageHint : int32_t {
kGeneric = VA_SURFACE_ATTRIB_USAGE_HINT_GENERIC,
kVideoDecoder = VA_SURFACE_ATTRIB_USAGE_HINT_DECODER,
kVideoEncoder = VA_SURFACE_ATTRIB_USAGE_HINT_ENCODER,
kVideoProcessWrite = VA_SURFACE_ATTRIB_USAGE_HINT_VPP_WRITE,
};
using InternalFormats = struct {
bool yuv420 : 1;
bool yuv420_10 : 1;
bool yuv422 : 1;
bool yuv444 : 1;
};
// Returns the type of the underlying VA-API implementation.
static VAImplementation GetImplementationType();
// Return an instance of VaapiWrapper initialized for |va_profile| and
// |mode|. |report_error_to_uma_cb| will be called independently from
// reporting errors to clients via method return values.
static scoped_refptr<VaapiWrapper> Create(
CodecMode mode,
VAProfile va_profile,
EncryptionScheme encryption_scheme,
const ReportErrorToUMACB& report_error_to_uma_cb,
bool enforce_sequence_affinity = true);
// Create VaapiWrapper for VideoCodecProfile. It maps VideoCodecProfile
// |profile| to VAProfile.
// |report_error_to_uma_cb| will be called independently from reporting
// errors to clients via method return values.
static scoped_refptr<VaapiWrapper> CreateForVideoCodec(
CodecMode mode,
VideoCodecProfile profile,
EncryptionScheme encryption_scheme,
const ReportErrorToUMACB& report_error_to_uma_cb,
bool enforce_sequence_affinity = true);
VaapiWrapper(const VaapiWrapper&) = delete;
VaapiWrapper& operator=(const VaapiWrapper&) = delete;
// Returns the supported SVC scalability modes for specified profile.
static std::vector<SVCScalabilityMode> GetSupportedScalabilityModes(
VideoCodecProfile media_profile,
VAProfile va_profile);
// Return the supported video encode profiles.
static VideoEncodeAccelerator::SupportedProfiles GetSupportedEncodeProfiles();
// Return the supported video decode profiles.
static VideoDecodeAccelerator::SupportedProfiles GetSupportedDecodeProfiles();
// Return true when decoding using |va_profile| is supported.
static bool IsDecodeSupported(VAProfile va_profile);
// Returns the supported internal formats for decoding using |va_profile|. If
// decoding is not supported for that profile, returns InternalFormats{}.
static InternalFormats GetDecodeSupportedInternalFormats(
VAProfile va_profile);
// Returns true if |rt_format| is supported for decoding using |va_profile|.
// Returns false if |rt_format| or |va_profile| is not supported for decoding.
static bool IsDecodingSupportedForInternalFormat(VAProfile va_profile,
unsigned int rt_format);
// Gets the minimum and maximum surface sizes allowed for |va_profile| in
// |codec_mode|. Returns true if both sizes can be obtained, false otherwise.
// Each dimension in |min_size| will be at least 1 (as long as this method
// returns true). Additionally, because of the initialization in
// VASupportedProfiles::FillProfileInfo_Locked(), the |max_size| is guaranteed
// to not be empty (as long as this method returns true).
static bool GetSupportedResolutions(VAProfile va_profile,
CodecMode codec_mode,
gfx::Size& min_size,
gfx::Size& max_size);
// Obtains a suitable FOURCC that can be used in vaCreateImage() +
// vaGetImage(). |rt_format| corresponds to the JPEG's subsampling format.
// |preferred_fourcc| is the FOURCC of the format preferred by the caller. If
// it is determined that the VAAPI driver can do the conversion from the
// internal format (|rt_format|), *|suitable_fourcc| is set to
// |preferred_fourcc|. Otherwise, it is set to a supported format. Returns
// true if a suitable FOURCC could be determined, false otherwise (e.g., if
// the |rt_format| is unsupported by the driver). If |preferred_fourcc| is not
// a supported image format, *|suitable_fourcc| is set to VA_FOURCC_I420.
static bool GetJpegDecodeSuitableImageFourCC(unsigned int rt_format,
uint32_t preferred_fourcc,
uint32_t* suitable_fourcc);
// Checks to see if VAProfileNone is supported on this decoder
static bool IsVppProfileSupported();
// Checks the surface size is allowed for VPP. Returns true if the size is
// supported, false otherwise.
static bool IsVppResolutionAllowed(const gfx::Size& size);
// Returns true if the VPP supports converting from/to |fourcc|.
static bool IsVppFormatSupported(uint32_t fourcc);
// Returns the pixel formats supported by the VPP.
static std::vector<Fourcc> GetVppSupportedFormats();
// Returns true if VPP supports the format conversion from a JPEG decoded
// internal surface to a FOURCC. |rt_format| corresponds to the JPEG's
// subsampling format. |fourcc| is the output surface's FOURCC.
static bool IsVppSupportedForJpegDecodedSurfaceToFourCC(
unsigned int rt_format,
uint32_t fourcc);
// Return true when JPEG encode is supported.
static bool IsJpegEncodeSupported();
// Return true when the specified image format is supported.
static bool IsImageFormatSupported(const VAImageFormat& format);
// Returns the list of VAImageFormats supported by the driver.
static const std::vector<VAImageFormat>& GetSupportedImageFormatsForTesting();
// Returns the list of supported profiles and entrypoints for a given |mode|.
static std::map<VAProfile, std::vector<VAEntrypoint>>
GetSupportedConfigurationsForCodecModeForTesting(CodecMode mode);
static VAEntrypoint GetDefaultVaEntryPoint(CodecMode mode, VAProfile profile);
static uint32_t BufferFormatToVARTFormat(gfx::BufferFormat fmt);
// Creates |num_surfaces| VASurfaceIDs of |va_format|, |size| and
// |surface_usage_hints| and, if successful, creates a |va_context_id_| of the
// same size. |surface_usage_hints| may affect an alignment and tiling of the
// created surface. Returns true if successful, with the created IDs in
// |va_surfaces|. The client is responsible for destroying |va_surfaces| via
// DestroyContextAndSurfaces() to free the allocated surfaces.
[[nodiscard]] virtual bool CreateContextAndSurfaces(
unsigned int va_format,
const gfx::Size& size,
const std::vector<SurfaceUsageHint>& surface_usage_hints,
size_t num_surfaces,
std::vector<VASurfaceID>* va_surfaces);
// Creates |num_surfaces| ScopedVASurfaces of |va_format| and |size| and, if
// successful, creates a |va_context_id_| of the same size. Returns an empty
// vector if creation failed. If |visible_size| is supplied, the returned
// ScopedVASurface's size is set to it. Otherwise, it's set to |size| (refer
// to CreateScopedVASurfaces() for details).
virtual std::vector<std::unique_ptr<ScopedVASurface>>
CreateContextAndScopedVASurfaces(
unsigned int va_format,
const gfx::Size& size,
const std::vector<SurfaceUsageHint>& usage_hints,
size_t num_surfaces,
const absl::optional<gfx::Size>& visible_size);
// Attempts to create a protected session that will be attached to the
// decoding context to enable encrypted video decoding. If it cannot be
// attached now, it will be attached when the decoding context is created or
// re-created. |encryption| should be the encryption scheme from the
// DecryptConfig. |hw_config| should have been obtained from the OEMCrypto
// implementation via the CdmFactoryDaemonProxy. |hw_identifier_out| is an
// output parameter which will return session specific information which can
// be passed through the ChromeOsCdmContext to retrieve encrypted key
// information. Returns true on success and false otherwise.
bool CreateProtectedSession(media::EncryptionScheme encryption,
const std::vector<uint8_t>& hw_config,
std::vector<uint8_t>* hw_identifier_out);
// Returns true if and only if we have created a protected session and
// querying libva indicates that our protected session is no longer alive,
// otherwise this will return false.
bool IsProtectedSessionDead();
#if BUILDFLAG(IS_CHROMEOS_ASH)
// Returns true if and only if |va_protected_session_id| is not VA_INVALID_ID
// and querying libva indicates that the protected session identified by
// |va_protected_session_id| is no longer alive.
bool IsProtectedSessionDead(VAProtectedSessionID va_protected_session_id);
// Returns the ID of the current protected session or VA_INVALID_ID if there's
// none. This must be called on the same sequence as other methods that use
// the protected session ID internally.
//
// TODO(b/183515581): update this documentation once we force the VaapiWrapper
// to be used on a single sequence.
VAProtectedSessionID GetProtectedSessionID() const;
#endif
// If we have a protected session, destroys it immediately. This should be
// used as part of recovering dead protected sessions.
void DestroyProtectedSession();
// Releases the |va_surfaces| and destroys |va_context_id_|.
void DestroyContextAndSurfaces(std::vector<VASurfaceID> va_surfaces);
// Creates a VAContextID of |size| (unless it's a Vpp context in which case
// |size| is ignored and 0x0 is used instead). The client is responsible for
// releasing said context via DestroyContext() or DestroyContextAndSurfaces(),
// or it will be released on dtor. If a valid |va_protected_session_id_|
// exists, it will be attached to the newly created |va_context_id_| as well.
[[nodiscard]] virtual bool CreateContext(const gfx::Size& size);
// Destroys the context identified by |va_context_id_|.
virtual void DestroyContext();
// Requests |num_surfaces| ScopedVASurfaces of size |size|, |va_rt_format| and
// optionally |va_fourcc|. Returns self-cleaning ScopedVASurfaces or empty
// vector if creation failed. If |visible_size| is supplied, the returned
// ScopedVASurfaces' size are set to it: for example, we may want to request a
// 16x16 surface to decode a 13x12 JPEG: we may want to keep track of the
// visible size 13x12 inside the ScopedVASurface to inform the surface's users
// that that's the only region with meaningful content. If |visible_size| is
// not supplied, we store |size| in the returned ScopedVASurfaces.
virtual std::vector<std::unique_ptr<ScopedVASurface>> CreateScopedVASurfaces(
unsigned int va_rt_format,
const gfx::Size& size,
const std::vector<SurfaceUsageHint>& usage_hints,
size_t num_surfaces,
const absl::optional<gfx::Size>& visible_size,
const absl::optional<uint32_t>& va_fourcc);
// Creates a self-releasing VASurface from |pixmap|. The created VASurface
// shares the ownership of the underlying buffer represented by |pixmap|. The
// ownership of the surface is transferred to the caller. A caller can destroy
// |pixmap| after this method returns and the underlying buffer will be kept
// alive by the VASurface. |protected_content| should only be true if the
// format needs VA_RT_FORMAT_PROTECTED (currently only true for AMD).
virtual scoped_refptr<VASurface> CreateVASurfaceForPixmap(
scoped_refptr<gfx::NativePixmap> pixmap,
bool protected_content = false);
// Creates a self-releasing VASurface from |buffers|. The ownership of the
// surface is transferred to the caller. |buffers| should be a pointer array
// of size 1, with |buffer_size| corresponding to its size. |size| should be
// the desired surface dimensions (which does not need to map to |buffer_size|
// in any relevant way). |buffers| should be kept alive when using the
// VASurface and for accessing the data after the operation is complete.
scoped_refptr<VASurface> CreateVASurfaceForUserPtr(const gfx::Size& size,
uintptr_t* buffers,
size_t buffer_size);
// Creates a self-releasing VASurface with specified usage hints. The
// ownership of the surface is transferred to the caller. |size| should be
// the desired surface dimensions.
scoped_refptr<VASurface> CreateVASurfaceWithUsageHints(
unsigned int va_rt_format,
const gfx::Size& size,
const std::vector<SurfaceUsageHint>& usage_hints);
// Implementations of the pixmap exporter for both types of VASurface.
// See ExportVASurfaceAsNativePixmapDmaBufUnwrapped() for further
// documentation.
std::unique_ptr<NativePixmapAndSizeInfo> ExportVASurfaceAsNativePixmapDmaBuf(
const VASurface& va_surface);
std::unique_ptr<NativePixmapAndSizeInfo> ExportVASurfaceAsNativePixmapDmaBuf(
const ScopedVASurface& scoped_va_surface);
// Synchronize the VASurface explicitly. This is useful when sharing a surface
// between contexts.
[[nodiscard]] bool SyncSurface(VASurfaceID va_surface_id);
// Calls SubmitBuffer_Locked() to request libva to allocate a new VABufferID
// of |va_buffer_type| and |size|, and to map-and-copy the |data| into it. The
// allocated VABufferIDs stay alive until DestroyPendingBuffers_Locked(). Note
// that this method does not submit the buffers for execution, they are simply
// stored until ExecuteAndDestroyPendingBuffers()/Execute_Locked(). The
// ownership of |data| stays with the caller. On failure, all pending buffers
// are destroyed.
[[nodiscard]] bool SubmitBuffer(VABufferType va_buffer_type,
size_t size,
const void* data);
// Convenient templatized version of SubmitBuffer() where |size| is deduced to
// be the size of the type of |*data|.
template <typename T>
[[nodiscard]] bool SubmitBuffer(VABufferType va_buffer_type, const T* data) {
CHECK(!enforce_sequence_affinity_ ||
sequence_checker_.CalledOnValidSequence());
return SubmitBuffer(va_buffer_type, sizeof(T), data);
}
// Batch-version of SubmitBuffer(), where the lock for accessing libva is
// acquired only once.
struct VABufferDescriptor {
VABufferType type;
size_t size;
raw_ptr<const void, DanglingUntriaged> data;
};
[[nodiscard]] bool SubmitBuffers(
const std::vector<VABufferDescriptor>& va_buffers);
// Destroys all |pending_va_buffers_| sent via SubmitBuffer*(). Useful when a
// pending job is to be cancelled (on reset or error).
void DestroyPendingBuffers();
// Executes job in hardware on target |va_surface_id| and destroys pending
// buffers. Returns false if Execute() fails.
[[nodiscard]] virtual bool ExecuteAndDestroyPendingBuffers(
VASurfaceID va_surface_id);
// Maps each |va_buffers| ID and copies the data described by the associated
// VABufferDescriptor into it; then calls Execute_Locked() on |va_surface_id|.
[[nodiscard]] bool MapAndCopyAndExecute(
VASurfaceID va_surface_id,
const std::vector<std::pair<VABufferID, VABufferDescriptor>>& va_buffers);
#if BUILDFLAG(USE_VAAPI_X11)
// Put data from |va_surface_id| into |x_pixmap| of size
// |dest_size|, converting/scaling to it.
[[nodiscard]] bool PutSurfaceIntoPixmap(VASurfaceID va_surface_id,
x11::Pixmap x_pixmap,
gfx::Size dest_size);
#endif // BUILDFLAG(USE_VAAPI_X11)
// Creates a ScopedVAImage from a VASurface |va_surface_id| and map it into
// memory with the given |format| and |size|. If |format| is not equal to the
// internal format, the underlying implementation will do format conversion if
// supported. |size| should be smaller than or equal to the surface. If |size|
// is smaller, the image will be cropped.
std::unique_ptr<ScopedVAImage> CreateVaImage(VASurfaceID va_surface_id,
VAImageFormat* format,
const gfx::Size& size);
// Uploads contents of |frame| into |va_surface_id| for encode.
[[nodiscard]] virtual bool UploadVideoFrameToSurface(
const VideoFrame& frame,
VASurfaceID va_surface_id,
const gfx::Size& va_surface_size);
// Creates a buffer of |size| bytes to be used as encode output.
virtual std::unique_ptr<ScopedVABuffer> CreateVABuffer(VABufferType type,
size_t size);
// Gets the encoded frame linear size of the buffer with given |buffer_id|.
// |sync_surface_id| will be used as a sync point, i.e. it will have to become
// idle before starting the acquirement. |sync_surface_id| should be the
// source surface passed to the encode job. Returns 0 if it fails for any
// reason.
[[nodiscard]] virtual uint64_t GetEncodedChunkSize(
VABufferID buffer_id,
VASurfaceID sync_surface_id);
// Downloads the contents of the buffer with given |buffer_id| into a buffer
// of size |target_size|, pointed to by |target_ptr|. The number of bytes
// downloaded will be returned in |coded_data_size|. |sync_surface_id| will
// be used as a sync point, i.e. it will have to become idle before starting
// the download. |sync_surface_id| should be the source surface passed
// to the encode job. |sync_surface_id| will be nullopt when it has already
// been synced in GetEncodedChunkSize(). In the case vaSyncSurface()
// is not executed. Returns false if it fails for any reason. For example, the
// linear size of the resulted encoded frame is larger than |target_size|.
[[nodiscard]] virtual bool DownloadFromVABuffer(
VABufferID buffer_id,
absl::optional<VASurfaceID> sync_surface_id,
uint8_t* target_ptr,
size_t target_size,
size_t* coded_data_size);
// Get the max number of reference frames for encoding supported by the
// driver.
// For H.264 encoding, the value represents the maximum number of reference
// frames for both the reference picture list 0 (bottom 16 bits) and the
// reference picture list 1 (top 16 bits).
[[nodiscard]] virtual bool GetVAEncMaxNumOfRefFrames(
VideoCodecProfile profile,
size_t* max_ref_frames);
// Gets packed headers are supported for encoding. This is called for
// H264 encoding. |packed_sps|, |packed_pps| and |packed_slice| stands for
// whether packed slice parameter set, packed picture parameter set and packed
// slice header is supported, respectively.
[[nodiscard]] virtual bool GetSupportedPackedHeaders(
VideoCodecProfile profile,
bool& packed_sps,
bool& packed_pps,
bool& packed_slice);
// Checks if the driver supports frame rotation.
bool IsRotationSupported();
// Blits a VASurface |va_surface_src| into another VASurface
// |va_surface_dest| applying pixel format conversion, rotation, cropping
// and scaling if needed. |src_rect| and |dest_rect| are optional. They can
// be used to specify the area used in the blit. If |va_protected_session_id|
// is provided and is not VA_INVALID_ID, the corresponding protected session
// is attached to the VPP context prior to submitting the VPP buffers and
// detached after submitting those buffers.
[[nodiscard]] virtual bool BlitSurface(
const VASurface& va_surface_src,
const VASurface& va_surface_dest,
absl::optional<gfx::Rect> src_rect = absl::nullopt,
absl::optional<gfx::Rect> dest_rect = absl::nullopt,
VideoRotation rotation = VIDEO_ROTATION_0
#if BUILDFLAG(IS_CHROMEOS_ASH)
,
VAProtectedSessionID va_protected_session_id = VA_INVALID_ID
#endif
);
// Initialize static data before sandbox is enabled.
static void PreSandboxInitialization(
bool allow_disabling_global_lock = false);
// vaDestroySurfaces() a vector or a single VASurfaceID.
virtual void DestroySurfaces(std::vector<VASurfaceID> va_surfaces);
virtual void DestroySurface(VASurfaceID va_surface_id);
protected:
VaapiWrapper(VADisplayStateHandle va_display_state_handle,
CodecMode mode,
bool enforce_sequence_affinity = true);
virtual ~VaapiWrapper();
private:
friend class base::RefCountedThreadSafe<VaapiWrapper>;
friend class VaapiWrapperTest;
friend class VaapiVideoEncodeAcceleratorTest;
FRIEND_TEST_ALL_PREFIXES(VaapiTest, LowQualityEncodingSetting);
FRIEND_TEST_ALL_PREFIXES(VaapiUtilsTest, ScopedVAImage);
FRIEND_TEST_ALL_PREFIXES(VaapiUtilsTest, BadScopedVAImage);
FRIEND_TEST_ALL_PREFIXES(VaapiUtilsTest, BadScopedVABufferMapping);
FRIEND_TEST_ALL_PREFIXES(VaapiMinigbmTest, AllocateAndCompareWithMinigbm);
[[nodiscard]] bool Initialize(VAProfile va_profile,
EncryptionScheme encryption_scheme);
void Deinitialize();
[[nodiscard]] bool VaInitialize(
const ReportErrorToUMACB& report_error_to_uma_cb);
// Tries to allocate |num_surfaces| VASurfaceIDs of |size| and |va_format|.
// Fills |va_surfaces| and returns true if successful, or returns false.
[[nodiscard]] bool CreateSurfaces(
unsigned int va_format,
const gfx::Size& size,
const std::vector<SurfaceUsageHint>& usage_hints,
size_t num_surfaces,
std::vector<VASurfaceID>* va_surfaces);
// Syncs and exports |va_surface_id| as a gfx::NativePixmapDmaBuf. Currently,
// the only VAAPI surface pixel formats supported are VA_FOURCC_IMC3 and
// VA_FOURCC_NV12.
//
// Notes:
//
// - For VA_FOURCC_IMC3, the format of the returned NativePixmapDmaBuf is
// gfx::BufferFormat::YVU_420 because we don't have a YUV_420 format. The
// planes are flipped accordingly, i.e.,
// gfx::NativePixmapDmaBuf::GetDmaBufOffset(1) refers to the V plane.
// TODO(andrescj): revisit once crrev.com/c/1573718 lands.
//
// - For VA_FOURCC_NV12, the format of the returned NativePixmapDmaBuf is
// gfx::BufferFormat::YUV_420_BIPLANAR.
//
// Returns nullptr on failure, or if the exported surface can't contain
// |va_surface_size|.
std::unique_ptr<NativePixmapAndSizeInfo>
ExportVASurfaceAsNativePixmapDmaBufUnwrapped(
VASurfaceID va_surface_id,
const gfx::Size& va_surface_size);
// Carries out the vaBeginPicture()-vaRenderPicture()-vaEndPicture() on target
// |va_surface_id|. Returns false if any of these calls fails.
[[nodiscard]] bool Execute_Locked(VASurfaceID va_surface_id,
const std::vector<VABufferID>& va_buffers)
EXCLUSIVE_LOCKS_REQUIRED(va_lock_);
virtual void DestroyPendingBuffers_Locked()
EXCLUSIVE_LOCKS_REQUIRED(va_lock_);
// Requests libva to allocate a new VABufferID of type |va_buffer.type|, then
// maps-and-copies |va_buffer.size| contents of |va_buffer.data| to it. If a
// failure occurs, calls DestroyPendingBuffers_Locked() and returns false.
[[nodiscard]] virtual bool SubmitBuffer_Locked(
const VABufferDescriptor& va_buffer) EXCLUSIVE_LOCKS_REQUIRED(va_lock_);
// Maps |va_buffer_id| and, if successful, copies the contents of |va_buffer|
// into it.
[[nodiscard]] bool MapAndCopy_Locked(VABufferID va_buffer_id,
const VABufferDescriptor& va_buffer)
EXCLUSIVE_LOCKS_REQUIRED(va_lock_);
// Queries whether |va_profile_| and |va_entrypoint_| support encoding quality
// setting and, if available, configures it to its maximum value, for lower
// consumption and maximum speed.
void MaybeSetLowQualityEncoding_Locked() EXCLUSIVE_LOCKS_REQUIRED(va_lock_);
// If a protected session is active, attaches it to the decoding context.
[[nodiscard]] bool MaybeAttachProtectedSession_Locked()
EXCLUSIVE_LOCKS_REQUIRED(va_lock_);
const CodecMode mode_;
const bool enforce_sequence_affinity_;
base::SequenceCheckerImpl sequence_checker_;
// This is declared before |va_display_| and |va_lock_| to guarantee their
// validity for as long as the VaapiWrapper is alive.
VADisplayStateHandle va_display_state_handle_;
// If using a global VA lock, this is a pointer to VADisplayStateSingleton's
// member |va_lock_|. Guaranteed to be valid for the lifetime of the
// VaapiWrapper due to the |va_display_state_handle_| above.
raw_ptr<base::Lock> va_lock_;
// Guaranteed to be valid for the lifetime of the VaapiWrapper due to the
// |va_display_state_handle_| above.
VADisplay va_display_ GUARDED_BY(va_lock_);
// VA handles.
// All valid after successful Initialize() and until Deinitialize().
VAConfigID va_config_id_{VA_INVALID_ID};
// Created in CreateContext() or CreateContextAndSurfaces() and valid until
// DestroyContext() or DestroyContextAndSurfaces().
VAContextID va_context_id_{VA_INVALID_ID};
// Profile and entrypoint configured for the corresponding |va_context_id_|.
VAProfile va_profile_;
VAEntrypoint va_entrypoint_;
// Data queued up for HW codec, to be committed on next execution.
// TODO(b/166646505): let callers manage the lifetime of these buffers.
std::vector<VABufferID> pending_va_buffers_;
// VA buffer to be used for kVideoProcess. Allocated the first time around,
// and reused afterwards.
std::unique_ptr<ScopedVABuffer> va_buffer_for_vpp_;
#if BUILDFLAG(IS_CHROMEOS_ASH)
// For protected decode mode.
VAConfigID va_protected_config_id_{VA_INVALID_ID};
VAProtectedSessionID va_protected_session_id_{VA_INVALID_ID};
#endif
// Called to report codec errors to UMA. Errors to clients are reported via
// return values from public methods.
ReportErrorToUMACB report_error_to_uma_cb_;
};
} // namespace media
#endif // MEDIA_GPU_VAAPI_VAAPI_WRAPPER_H_

View File

@ -1,4 +1,4 @@
// Copyright (c) 2023 The Chromium Authors and Alex313031
// Copyright 2023 The Chromium Authors and Alex313031
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@ -104,6 +104,13 @@ LOAD_FLAG(RESTRICTED_PREFETCH, 1 << 15)
// trusted process.
LOAD_FLAG(CAN_USE_RESTRICTED_PREFETCH, 1 << 16)
// Indicates that this load can use a shared dictionary.
LOAD_FLAG(CAN_USE_SHARED_DICTIONARY, 1 << 17)
// Indicates that CAN_USE_SHARED_DICTIONARY must be disabled after a redirect to
// another origin.
LOAD_FLAG(DISABLE_SHARED_DICTIONARY_AFTER_CROSS_ORIGIN_REDIRECT, 1 << 18)
// This load will not send Accept-Language or User-Agent headers, and not
// advertise brotli encoding.
// Used to comply with IETF (draft) DNS-over-HTTPS:

View File

@ -265,7 +265,7 @@ class DnsClientImpl : public DnsClient {
config.nameservers.clear();
if (!config.IsValid()) {
LOG(WARNING) << "BuildEffectiveConfig(): invalid configuration";
LOG(WARNING) << "BuildEffectiveConfig(): invalid configuration";
return absl::nullopt;
}

View File

@ -76,9 +76,11 @@
#include "net/socket/stream_socket.h"
#include "net/third_party/uri_template/uri_template.h"
#include "net/traffic_annotation/network_traffic_annotation.h"
#include "net/url_request/url_request.h"
#include "net/url_request/url_request_context.h"
#include "net/url_request/url_request_context_builder.h"
#include "third_party/abseil-cpp/absl/types/optional.h"
#include "url/url_constants.h"
namespace net {
@ -556,6 +558,15 @@ class DnsHTTPAttempt : public DnsAttempt, public URLRequest::Delegate {
OnReadCompleted(request_.get(), bytes_read);
}
void OnReceivedRedirect(URLRequest* request,
const RedirectInfo& redirect_info,
bool* defer_redirect) override {
// Section 5 of RFC 8484 states that scheme must be https.
if (!redirect_info.new_url.SchemeIs(url::kHttpsScheme)) {
request->Cancel();
}
}
void OnReadCompleted(net::URLRequest* request, int bytes_read) override {
// bytes_read can be an error.
if (bytes_read < 0) {
@ -1225,7 +1236,7 @@ class DnsTransactionImpl : public DnsTransaction,
: rv(rv), attempt(attempt) {}
int rv;
raw_ptr<const DnsAttempt, DanglingUntriaged> attempt;
raw_ptr<const DnsAttempt, AcrossTasksDanglingUntriaged> attempt;
};
// Used in UMA (DNS.AttemptType). Do not renumber or remove values.

View File

@ -15,6 +15,7 @@
#include "base/command_line.h"
#include "base/compiler_specific.h"
#include "base/containers/adapters.h"
#include "base/feature_list.h"
#include "base/file_version_info.h"
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
@ -60,7 +61,6 @@
#include "net/filter/source_stream.h"
#include "net/filter/zstd_source_stream.h"
#include "net/first_party_sets/first_party_set_metadata.h"
#include "net/first_party_sets/same_party_context.h"
#include "net/http/http_content_disposition.h"
#include "net/http/http_log_util.h"
#include "net/http/http_network_session.h"
@ -83,6 +83,7 @@
#include "net/ssl/ssl_cert_request_info.h"
#include "net/ssl/ssl_config_service.h"
#include "net/ssl/ssl_connection_status_flags.h"
#include "net/url_request/clear_site_data.h"
#include "net/url_request/redirect_util.h"
#include "net/url_request/url_request.h"
#include "net/url_request/url_request_context.h"
@ -144,22 +145,11 @@ void LogTrustAnchor(const net::HashValueVector& spki_hashes) {
}
net::CookieOptions CreateCookieOptions(
net::CookieOptions::SameSiteCookieContext same_site_context,
const net::SamePartyContext& same_party_context,
const net::IsolationInfo& isolation_info,
bool is_in_nontrivial_first_party_set) {
net::CookieOptions::SameSiteCookieContext same_site_context) {
net::CookieOptions options;
options.set_return_excluded_cookies();
options.set_include_httponly();
options.set_same_site_cookie_context(same_site_context);
options.set_same_party_context(same_party_context);
if (isolation_info.party_context().has_value()) {
// Count the top-frame site since it's not in the party_context.
options.set_full_party_context_size(isolation_info.party_context()->size() +
1);
}
options.set_is_in_nontrivial_first_party_set(
is_in_nontrivial_first_party_set);
return options;
}
@ -187,6 +177,17 @@ GURL UpgradeSchemeToCryptographic(const GURL& insecure_url) {
return secure_url;
}
// These values are persisted to logs. Entries should not be renumbered and
// numeric values should never be reused.
enum class ContentEncodingType {
kUnknown = 0,
kBrotli = 1,
kGZip = 2,
kDeflate = 3,
kZstd = 4,
kMaxValue = kZstd,
};
} // namespace
namespace net {
@ -262,6 +263,7 @@ void URLRequestHttpJob::Start() {
request_->isolation_info().network_anonymization_key();
request_info_.possibly_top_frame_origin =
request_->isolation_info().top_frame_origin();
request_info_.frame_origin = request_->isolation_info().frame_origin();
request_info_.is_subframe_document_resource =
request_->isolation_info().request_type() ==
net::IsolationInfo::RequestType::kSubFrame;
@ -272,9 +274,6 @@ void URLRequestHttpJob::Start() {
net::MutableNetworkTrafficAnnotationTag(request_->traffic_annotation());
request_info_.socket_tag = request_->socket_tag();
request_info_.idempotency = request_->GetIdempotency();
request_info_.pervasive_payloads_index_for_logging =
request_->pervasive_payloads_index_for_logging();
request_info_.checksum = request_->expected_response_checksum();
#if BUILDFLAG(ENABLE_REPORTING)
request_info_.reporting_upload_depth = request_->reporting_upload_depth();
#endif
@ -352,20 +351,20 @@ void URLRequestHttpJob::OnGotFirstPartySetCacheFilterMatchInfo(
GURL referrer(request_->referrer());
if (!(request_info_.load_flags & LOAD_MINIMAL_HEADERS)) {
// Our consumer should have made sure that this is a safe referrer (e.g. via
// URLRequestJob::ComputeReferrerForPolicy).
if (referrer.is_valid()) {
std::string referer_value = referrer.spec();
request_info_.extra_headers.SetHeader(HttpRequestHeaders::kReferer,
referer_value);
}
// Our consumer should have made sure that this is a safe referrer (e.g. via
// URLRequestJob::ComputeReferrerForPolicy).
if (referrer.is_valid()) {
std::string referer_value = referrer.spec();
request_info_.extra_headers.SetHeader(HttpRequestHeaders::kReferer,
referer_value);
}
}
if (!(request_info_.load_flags & LOAD_MINIMAL_HEADERS)) {
request_info_.extra_headers.SetHeaderIfMissing(
HttpRequestHeaders::kUserAgent,
http_user_agent_settings_ ?
http_user_agent_settings_->GetUserAgent() : std::string());
request_info_.extra_headers.SetHeaderIfMissing(
HttpRequestHeaders::kUserAgent,
http_user_agent_settings_ ?
http_user_agent_settings_->GetUserAgent() : std::string());
}
AddExtraHeaders();
@ -590,6 +589,10 @@ void URLRequestHttpJob::StartTransactionInternal() {
transaction_->SetEarlyResponseHeadersCallback(
early_response_headers_callback_);
transaction_->SetResponseHeadersCallback(response_headers_callback_);
if (is_shared_dictionary_read_allowed_callback_) {
transaction_->SetIsSharedDictionaryReadAllowedCallback(
is_shared_dictionary_read_allowed_callback_);
}
if (!throttling_entry_.get() ||
!throttling_entry_->ShouldRejectRequest(*request_)) {
@ -619,7 +622,8 @@ void URLRequestHttpJob::StartTransactionInternal() {
void URLRequestHttpJob::AddExtraHeaders() {
request_info_.extra_headers.SetAcceptEncodingIfMissing(
request()->url(), request()->accepted_stream_types(),
!(request_info_.load_flags & LOAD_MINIMAL_HEADERS) && request()->context()->enable_brotli());
!(request_info_.load_flags & LOAD_MINIMAL_HEADERS) && request()->context()->enable_brotli(),
!(request_info_.load_flags & LOAD_MINIMAL_HEADERS) && request()->context()->enable_zstd());
if (!(request_info_.load_flags & LOAD_MINIMAL_HEADERS) && http_user_agent_settings_) {
// Only add default Accept-Language if the request didn't have it
@ -655,11 +659,7 @@ void URLRequestHttpJob::AddCookieHeaderAndStart() {
request_->site_for_cookies(), request_->initiator(),
is_main_frame_navigation, force_ignore_site_for_cookies);
bool is_in_nontrivial_first_party_set =
first_party_set_metadata_.frame_entry().has_value();
CookieOptions options = CreateCookieOptions(
same_site_context, first_party_set_metadata_.context(),
request_->isolation_info(), is_in_nontrivial_first_party_set);
CookieOptions options = CreateCookieOptions(same_site_context);
cookie_store->GetCookieListWithOptionsAsync(
request_->url(), options,
@ -705,14 +705,23 @@ void URLRequestHttpJob::SetCookieHeaderAndStart(
CookieInclusionStatus::EXCLUDE_USER_PREFERENCES);
}
}
// TODO(https://crbug.com/1469135): Consolidate the following `if` blocks so
// that all the cookies should be passed into
// `AnnotateAndMoveUserBlockedCookies` to be associated with the correct
// inclusion status.
if (ShouldBlockUnpartitionedCookiesOnly(request_info_.privacy_mode)) {
auto partition_it = base::ranges::stable_partition(
maybe_included_cookies, [](const CookieWithAccessResult& el) {
return el.cookie.IsPartitioned();
});
for (auto it = partition_it; it < maybe_included_cookies.end(); ++it) {
it->access_result.status.AddExclusionReason(
CookieInclusionStatus::EXCLUDE_USER_PREFERENCES);
if (!cookie_util::IsForceThirdPartyCookieBlockingEnabled()) {
it->access_result.status.AddExclusionReason(
CookieInclusionStatus::EXCLUDE_USER_PREFERENCES);
} else {
it->access_result.status.AddExclusionReason(
CookieInclusionStatus::EXCLUDE_THIRD_PARTY_PHASEOUT);
}
if (first_party_set_metadata_.AreSitesInSameFirstPartySet()) {
it->access_result.status.AddExclusionReason(
CookieInclusionStatus::
@ -851,6 +860,24 @@ void URLRequestHttpJob::SaveCookiesAndNotifyHeadersComplete(int result) {
return;
}
HttpResponseHeaders* headers = GetResponseHeaders();
// If we're clearing the cookies as part of a clear-site-data header we must
// not also write new ones in the same response.
bool clear_site_data_prevents_cookies_from_being_stored = false;
std::string clear_site_data_header;
headers->GetNormalizedHeader(kClearSiteDataHeader, &clear_site_data_header);
std::vector<std::string> clear_site_data_types =
ClearSiteDataHeaderContents(clear_site_data_header);
std::set<std::string> clear_site_data_set(clear_site_data_types.begin(),
clear_site_data_types.end());
if (clear_site_data_set.find(kDatatypeCookies) != clear_site_data_set.end() ||
(base::FeatureList::IsEnabled(features::kClearSiteDataWildcardSupport) &&
clear_site_data_set.find(kDatatypeWildcard) !=
clear_site_data_set.end())) {
clear_site_data_prevents_cookies_from_being_stored = true;
}
base::Time response_date;
absl::optional<base::Time> server_time = absl::nullopt;
if (GetResponseHeaders()->GetDateValue(&response_date))
@ -873,18 +900,13 @@ void URLRequestHttpJob::SaveCookiesAndNotifyHeadersComplete(int result) {
request_->initiator(), is_main_frame_navigation,
force_ignore_site_for_cookies);
bool is_in_nontrivial_first_party_set =
first_party_set_metadata_.frame_entry().has_value();
CookieOptions options = CreateCookieOptions(
same_site_context, first_party_set_metadata_.context(),
request_->isolation_info(), is_in_nontrivial_first_party_set);
CookieOptions options = CreateCookieOptions(same_site_context);
// Set all cookies, without waiting for them to be set. Any subsequent
// read will see the combined result of all cookie operation.
const base::StringPiece name("Set-Cookie");
std::string cookie_string;
size_t iter = 0;
HttpResponseHeaders* headers = GetResponseHeaders();
// NotifyHeadersComplete needs to be called once and only once after the
// list has been fully processed, and it can either be called in the
@ -910,9 +932,20 @@ void URLRequestHttpJob::SaveCookiesAndNotifyHeadersComplete(int result) {
// Make a copy of the cookie if we successfully made one.
cookie_to_return = *cookie;
}
if (cookie && !CanSetCookie(*cookie, &options)) {
// Check cookie accessibility with cookie_settings.
if (cookie && !CanSetCookie(*cookie, &options, &returned_status)) {
// Cookie allowed by cookie_settings checks could be blocked explicitly,
// e.g. via Android Webview APIs, we need to manually add exclusion reason
// in this case.
if (returned_status.IsInclude()) {
returned_status.AddExclusionReason(
net::CookieInclusionStatus::EXCLUDE_USER_PREFERENCES);
}
}
if (clear_site_data_prevents_cookies_from_being_stored) {
returned_status.AddExclusionReason(
CookieInclusionStatus::EXCLUDE_USER_PREFERENCES);
CookieInclusionStatus::EXCLUDE_FAILURE_TO_STORE);
}
if (!returned_status.IsInclude()) {
OnSetCookieResult(options, cookie_to_return, std::move(cookie_string),
@ -1280,18 +1313,25 @@ std::unique_ptr<SourceStream> URLRequestHttpJob::SetUpSourceStream() {
}
}
ContentEncodingType content_encoding_type = ContentEncodingType::kUnknown;
for (const auto& type : base::Reversed(types)) {
std::unique_ptr<FilterSourceStream> downstream;
switch (type) {
case SourceStream::TYPE_BROTLI:
downstream = CreateBrotliSourceStream(std::move(upstream));
content_encoding_type = ContentEncodingType::kBrotli;
break;
case SourceStream::TYPE_GZIP:
case SourceStream::TYPE_DEFLATE:
downstream = GzipSourceStream::Create(std::move(upstream), type);
content_encoding_type = type == SourceStream::TYPE_GZIP
? ContentEncodingType::kGZip
: ContentEncodingType::kDeflate;
break;
case SourceStream::TYPE_ZSTD:
downstream = CreateZstdSourceStream(std::move(upstream));
content_encoding_type = ContentEncodingType::kZstd;
break;
case SourceStream::TYPE_NONE:
case SourceStream::TYPE_UNKNOWN:
@ -1303,6 +1343,10 @@ std::unique_ptr<SourceStream> URLRequestHttpJob::SetUpSourceStream() {
upstream = std::move(downstream);
}
// Note: If multiple encoding types were specified, this only records the last
// encoding type.
UMA_HISTOGRAM_ENUMERATION("Net.ContentEncodingType", content_encoding_type);
return upstream;
}
@ -1595,6 +1639,13 @@ void URLRequestHttpJob::SetEarlyResponseHeadersCallback(
early_response_headers_callback_ = std::move(callback);
}
void URLRequestHttpJob::SetIsSharedDictionaryReadAllowedCallback(
base::RepeatingCallback<bool()> callback) {
DCHECK(!transaction_);
DCHECK(!is_shared_dictionary_read_allowed_callback_);
is_shared_dictionary_read_allowed_callback_ = std::move(callback);
}
void URLRequestHttpJob::SetResponseHeadersCallback(
ResponseHeadersCallback callback) {
DCHECK(!transaction_);
@ -1653,8 +1704,20 @@ void URLRequestHttpJob::RecordCompletionHistograms(CompletionCause reason) {
prefilter_bytes_read(), 1, 50000000, 50);
} else {
UMA_HISTOGRAM_TIMES("Net.HttpJob.TotalTimeNotCached", total_time);
if (response_info_->was_ip_protected) {
UMA_HISTOGRAM_TIMES("Net.HttpJob.IpProtection.TotalTimeNotCached",
total_time);
UMA_HISTOGRAM_CUSTOM_COUNTS("Net.HttpJob.IpProtection.BytesSent",
GetTotalSentBytes(), 1, 50000000, 50);
UMA_HISTOGRAM_CUSTOM_COUNTS(
"Net.HttpJob.IpProtection.PrefilterBytesRead.Net",
prefilter_bytes_read(), 1, 50000000, 50);
}
UMA_HISTOGRAM_CUSTOM_COUNTS("Net.HttpJob.PrefilterBytesRead.Net",
prefilter_bytes_read(), 1, 50000000, 50);
if (is_https_google && used_quic) {
UMA_HISTOGRAM_MEDIUM_TIMES("Net.HttpJob.TotalTimeNotCached.Secure.Quic",
total_time);

View File

@ -1,80 +0,0 @@
# Copyright 2023 The Chromium Authors and Alex313031
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import("//build/config/arm.gni")
import("//third_party/libgav1/options.gni")
config("public_libgav1_config") {
include_dirs = [
"src",
"src/src",
]
defines = [
"LIBGAV1_MAX_BITDEPTH=10",
"LIBGAV1_THREADPOOL_USE_STD_MUTEX", # to avoid abseil dependency.
"LIBGAV1_ENABLE_LOGGING=0", # to avoid debug log of libgav1 in chromium
# debug build.
# Don't let libgav1 export any symbols. Otherwise the verify_order step on
# macOS can fail since these exports end up in the final Chromium binary.
"LIBGAV1_PUBLIC=",
]
}
config("private_libgav1_config") {
configs = []
# dsp intrinsics will generate much better code when optimized for speed
# rather than size.
if (!is_debug) {
# configs += [ "//build/config/compiler:optimize_max" ]
}
if (current_cpu == "arm64" ||
(current_cpu == "arm" && arm_version >= 7 && arm_use_neon)) {
# The default thumb mode will impact performance of dsp intrinsics.
configs += [ "//build/config/compiler:compiler_arm" ]
}
}
if (use_libgav1_parser) {
static_library("libgav1_parser") {
configs -= [ "//build/config/compiler:chromium_code" ]
configs += [ "//build/config/compiler:no_chromium_code" ]
configs += [ ":private_libgav1_config" ]
public_configs = [ ":public_libgav1_config" ]
sources = [
"//third_party/libgav1/src/src/buffer_pool.cc",
"//third_party/libgav1/src/src/buffer_pool.h",
"//third_party/libgav1/src/src/frame_buffer.cc",
"//third_party/libgav1/src/src/internal_frame_buffer_list.cc",
"//third_party/libgav1/src/src/internal_frame_buffer_list.h",
"//third_party/libgav1/src/src/obu_parser.cc",
"//third_party/libgav1/src/src/obu_parser.h",
"//third_party/libgav1/src/src/quantizer.cc",
"//third_party/libgav1/src/src/quantizer.h",
"//third_party/libgav1/src/src/status_code.cc",
"//third_party/libgav1/src/src/symbol_decoder_context.cc",
"//third_party/libgav1/src/src/symbol_decoder_context.h",
"//third_party/libgav1/src/src/utils/bit_reader.cc",
"//third_party/libgav1/src/src/utils/bit_reader.h",
"//third_party/libgav1/src/src/utils/constants.cc",
"//third_party/libgav1/src/src/utils/constants.h",
"//third_party/libgav1/src/src/utils/logging.cc",
"//third_party/libgav1/src/src/utils/logging.h",
"//third_party/libgav1/src/src/utils/raw_bit_reader.cc",
"//third_party/libgav1/src/src/utils/raw_bit_reader.h",
"//third_party/libgav1/src/src/utils/segmentation.cc",
"//third_party/libgav1/src/src/utils/segmentation.h",
"//third_party/libgav1/src/src/utils/segmentation_map.cc",
"//third_party/libgav1/src/src/utils/segmentation_map.h",
"//third_party/libgav1/src/src/warp_prediction.cc",
"//third_party/libgav1/src/src/warp_prediction.h",
"//third_party/libgav1/src/src/yuv_buffer.cc",
"//third_party/libgav1/src/src/yuv_buffer.h",
]
}
}

View File

@ -38,12 +38,10 @@ enable_library_widevine_cdm =
enable_widevine && enable_library_cdms && library_widevine_cdm_available
# Widevine CDM can be deployed as a component. Currently only supported on
# Mac, Windows, and desktop Linux. The CDM can be bundled regardless whether
# desktop platforms. The CDM can be bundled regardless whether
# it's a component. See below.
# Note: Not enabled on ChromeOS. See https://crbug.com/971433
enable_widevine_cdm_component =
enable_library_widevine_cdm &&
(is_win || is_mac || is_linux || is_chromeos_lacros)
enable_library_widevine_cdm && (is_win || is_mac || is_linux || is_chromeos)
# Enable (Windows) Media Foundation Widevine CDM component.
declare_args() {

View File

@ -1,539 +0,0 @@
# Copyright 2023 The Chromium Authors and Alex313031. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import("//build/config/compiler/compiler.gni")
declare_args() {
# Expose zlib's symbols, used by Node.js to provide zlib APIs for its native
# modules.
zlib_symbols_visible = false
}
if (build_with_chromium) {
import("//testing/test.gni")
}
if (current_cpu == "arm" || current_cpu == "arm64") {
import("//build/config/arm.gni")
}
config("zlib_config") {
include_dirs = [ "." ]
if (zlib_symbols_visible) {
defines = [ "ZLIB_DLL" ]
}
}
config("zlib_internal_config") {
defines = [ "ZLIB_IMPLEMENTATION" ]
if (!is_debug) {
# Build code using -O3, see: crbug.com/1084371.
configs = [ "//build/config/compiler:optimize_speed" ]
}
if (is_debug || use_fuzzing_engine) {
# Enable zlib's asserts in debug and fuzzer builds.
defines += [ "ZLIB_DEBUG" ]
}
if (is_win && !is_clang) {
# V8 supports building with msvc, these silence some warnings that
# causes compilation to fail (https://crbug.com/1255096).
cflags = [
"/wd4244",
"/wd4100",
"/wd4702",
"/wd4127",
]
}
}
source_set("zlib_common_headers") {
visibility = [ ":*" ]
sources = [
"chromeconf.h",
"deflate.h",
"inffast.h",
"inffixed.h",
"inflate.h",
"inftrees.h",
"zconf.h",
"zlib.h",
"zutil.h",
]
}
use_arm_neon_optimizations = false
if ((current_cpu == "arm" || current_cpu == "arm64") &&
!(is_win && !is_clang)) {
# TODO(richard.townsend@arm.com): Optimizations temporarily disabled for
# Windows on Arm MSVC builds, see http://crbug.com/v8/10012.
if (arm_use_neon) {
use_arm_neon_optimizations = true
}
}
use_x86_x64_optimizations =
(current_cpu == "x86" || current_cpu == "x64") && !is_ios
config("zlib_adler32_simd_config") {
if (use_x86_x64_optimizations) {
defines = [ "ADLER32_SIMD_SSSE3" ]
if (is_win) {
defines += [ "X86_WINDOWS" ]
} else {
defines += [ "X86_NOT_WINDOWS" ]
}
}
if (use_arm_neon_optimizations) {
defines = [ "ADLER32_SIMD_NEON" ]
}
}
source_set("zlib_adler32_simd") {
visibility = [ ":*" ]
if (use_x86_x64_optimizations) {
sources = [
"adler32_simd.c",
"adler32_simd.h",
]
if (!is_win || is_clang) {
cflags = [ "-mssse3" ]
}
}
if (use_arm_neon_optimizations) {
sources = [
"adler32_simd.c",
"adler32_simd.h",
]
}
configs += [ ":zlib_internal_config" ]
public_configs = [ ":zlib_adler32_simd_config" ]
public_deps = [ ":zlib_common_headers" ]
}
if (use_arm_neon_optimizations) {
config("zlib_arm_crc32_config") {
# Disabled for iPhone, as described in DDI0487C_a_armv8_arm:
# "All implementations of the ARMv8.1 architecture are required to
# implement the CRC32* instructions. These are optional in ARMv8.0."
if (!is_ios) {
defines = [ "CRC32_ARMV8_CRC32" ]
if (is_android) {
defines += [ "ARMV8_OS_ANDROID" ]
} else if (is_linux || is_chromeos) {
defines += [ "ARMV8_OS_LINUX" ]
} else if (is_mac) {
defines += [ "ARMV8_OS_MACOS" ]
} else if (is_fuchsia) {
defines += [ "ARMV8_OS_FUCHSIA" ]
} else if (is_win) {
defines += [ "ARMV8_OS_WINDOWS" ]
} else {
assert(false, "Unsupported ARM OS")
}
}
}
source_set("zlib_arm_crc32") {
visibility = [ ":*" ]
if (!is_ios) {
include_dirs = [ "." ]
if (!is_win && !is_clang) {
assert(!use_thin_lto,
"ThinLTO fails mixing different module-level targets")
cflags_c = [ "-march=armv8-a+aes+crc" ]
}
sources = [
"crc32_simd.c",
"crc32_simd.h",
]
}
configs += [ ":zlib_internal_config" ]
public_configs = [ ":zlib_arm_crc32_config" ]
public_deps = [ ":zlib_common_headers" ]
}
}
config("zlib_inflate_chunk_simd_config") {
if (use_x86_x64_optimizations) {
defines = [ "INFLATE_CHUNK_SIMD_SSE2" ]
if (current_cpu == "x64") {
defines += [ "INFLATE_CHUNK_READ_64LE" ]
}
}
if (use_arm_neon_optimizations) {
defines = [ "INFLATE_CHUNK_SIMD_NEON" ]
if (current_cpu == "arm64") {
defines += [ "INFLATE_CHUNK_READ_64LE" ]
}
}
}
source_set("zlib_inflate_chunk_simd") {
visibility = [ ":*" ]
if (use_x86_x64_optimizations || use_arm_neon_optimizations) {
include_dirs = [ "." ]
sources = [
"contrib/optimizations/chunkcopy.h",
"contrib/optimizations/inffast_chunk.c",
"contrib/optimizations/inffast_chunk.h",
"contrib/optimizations/inflate.c",
]
}
configs += [ ":zlib_internal_config" ]
# Needed for MSVC, which is still supported by V8 and PDFium. zlib uses K&R C
# style function declarations, which triggers warning C4131.
configs -= [ "//build/config/compiler:chromium_code" ]
configs += [ "//build/config/compiler:no_chromium_code" ]
configs += [ ":zlib_warnings" ]
public_configs = [ ":zlib_inflate_chunk_simd_config" ]
public_deps = [ ":zlib_common_headers" ]
}
config("zlib_crc32_simd_config") {
if (use_x86_x64_optimizations) {
defines = [ "CRC32_SIMD_SSE42_PCLMUL" ]
}
}
source_set("zlib_crc32_simd") {
visibility = [ ":*" ]
if (use_x86_x64_optimizations) {
sources = [
"crc32_simd.c",
"crc32_simd.h",
"crc_folding.c",
]
if (!is_win || is_clang) {
cflags = [
"-msse4.2",
"-mpclmul",
]
}
}
configs += [ ":zlib_internal_config" ]
public_configs = [ ":zlib_crc32_simd_config" ]
public_deps = [ ":zlib_common_headers" ]
}
config("zlib_slide_hash_simd_config") {
if (use_x86_x64_optimizations) {
defines = [ "DEFLATE_SLIDE_HASH_SSE2" ]
}
if (use_arm_neon_optimizations) {
defines = [ "DEFLATE_SLIDE_HASH_NEON" ]
}
}
source_set("zlib_slide_hash_simd") {
visibility = [ ":*" ]
if (use_x86_x64_optimizations) {
sources = [ "slide_hash_simd.h" ]
}
if (use_arm_neon_optimizations) {
sources = [ "slide_hash_simd.h" ]
}
configs += [ ":zlib_internal_config" ]
public_configs = [ ":zlib_slide_hash_simd_config" ]
public_deps = [ ":zlib_common_headers" ]
}
config("zlib_warnings") {
if (is_clang) {
cflags = [
"-Wno-deprecated-non-prototype",
"-Wno-incompatible-pointer-types",
"-Wunused-variable",
]
}
}
component("zlib") {
if (!is_win) {
# Don't stomp on "libzlib" on other platforms.
output_name = "chrome_zlib"
}
sources = [
"adler32.c",
"chromeconf.h",
"compress.c",
"contrib/optimizations/insert_string.h",
"cpu_features.c",
"cpu_features.h",
"crc32.c",
"crc32.h",
"deflate.c",
"deflate.h",
"gzclose.c",
"gzguts.h",
"gzlib.c",
"gzread.c",
"gzwrite.c",
"infback.c",
"inffast.c",
"inffast.h",
"inffixed.h",
"inflate.h",
"inftrees.c",
"inftrees.h",
"trees.c",
"trees.h",
"uncompr.c",
"zconf.h",
"zlib.h",
"zutil.c",
"zutil.h",
]
defines = []
deps = []
if (!use_x86_x64_optimizations && !use_arm_neon_optimizations) {
# Apparently android_cronet bot builds with NEON disabled and
# we also should disable optimizations for iOS@x86 (a.k.a. simulator).
defines += [ "CPU_NO_SIMD" ]
}
if (is_ios) {
# iOS@ARM is a special case where we always have NEON but don't check
# for crypto extensions.
# TODO(cavalcantii): verify what is the current state of CPU features
# shipped on latest iOS devices.
defines += [ "ARM_OS_IOS" ]
}
if (use_x86_x64_optimizations || use_arm_neon_optimizations) {
deps += [
":zlib_adler32_simd",
":zlib_inflate_chunk_simd",
":zlib_slide_hash_simd",
]
if (use_x86_x64_optimizations) {
deps += [ ":zlib_crc32_simd" ]
} else if (use_arm_neon_optimizations) {
deps += [ ":zlib_arm_crc32" ]
}
} else {
sources += [ "inflate.c" ]
}
if (is_android) {
import("//build/config/android/config.gni")
if (defined(android_ndk_root) && android_ndk_root != "") {
deps += [ "//third_party/cpu_features:ndk_compat" ]
} else {
assert(false, "CPU detection requires the Android NDK")
}
}
configs -= [ "//build/config/compiler:chromium_code" ]
configs += [ "//build/config/compiler:no_chromium_code" ]
if (zlib_symbols_visible) {
configs -= [ "//build/config/gcc:symbol_visibility_hidden" ]
configs += [ "//build/config/gcc:symbol_visibility_default" ]
}
public_configs = [ ":zlib_config" ]
configs += [
":zlib_internal_config",
# Must be after no_chromium_code for warning flags to be ordered correctly.
":zlib_warnings",
]
allow_circular_includes_from = deps
}
config("minizip_warnings") {
visibility = [ ":*" ]
if (is_clang) {
cflags = [
# zlib uses `if ((a == b))` for some reason.
"-Wno-parentheses-equality",
"-Wno-deprecated-non-prototype",
]
}
}
static_library("minizip") {
sources = [
"contrib/minizip/ioapi.c",
"contrib/minizip/ioapi.h",
"contrib/minizip/iowin32.c",
"contrib/minizip/iowin32.h",
"contrib/minizip/unzip.c",
"contrib/minizip/unzip.h",
"contrib/minizip/zip.c",
"contrib/minizip/zip.h",
]
if (!is_win) {
sources -= [
"contrib/minizip/iowin32.c",
"contrib/minizip/iowin32.h",
]
}
if (is_apple || is_android || is_nacl) {
# Mac, Android and the BSDs don't have fopen64, ftello64, or fseeko64. We
# use fopen, ftell, and fseek instead on these systems.
defines = [ "USE_FILE32API" ]
}
deps = [ ":zlib" ]
configs -= [ "//build/config/compiler:chromium_code" ]
configs += [ "//build/config/compiler:no_chromium_code" ]
public_configs = [ ":zlib_config" ]
configs += [
# Must be after no_chromium_code for warning flags to be ordered correctly.
":minizip_warnings",
]
}
executable("zlib_bench") {
include_dirs = [ "." ]
sources = [ "contrib/bench/zlib_bench.cc" ]
if (!is_debug) {
configs -= [ "//build/config/compiler:default_optimization" ]
# configs += [ "//build/config/compiler:optimize_speed" ]
}
deps = [ ":zlib" ]
configs -= [ "//build/config/compiler:chromium_code" ]
configs += [ "//build/config/compiler:no_chromium_code" ]
}
if (!is_win || target_os != "winuwp") {
executable("minizip_bin") {
include_dirs = [ "." ]
sources = [ "contrib/minizip/minizip.c" ]
if (is_clang) {
cflags = [
"-Wno-incompatible-pointer-types-discards-qualifiers",
"-Wno-deprecated-non-prototype",
]
}
if (!is_debug) {
configs -= [ "//build/config/compiler:default_optimization" ]
# configs += [ "//build/config/compiler:optimize_speed" ]
}
deps = [ ":minizip" ]
configs -= [ "//build/config/compiler:chromium_code" ]
configs += [ "//build/config/compiler:no_chromium_code" ]
}
executable("miniunz_bin") {
include_dirs = [ "." ]
sources = [ "contrib/minizip/miniunz.c" ]
if (is_clang) {
cflags = [
"-Wno-incompatible-pointer-types-discards-qualifiers",
"-Wno-deprecated-non-prototype",
]
}
if (!is_debug) {
configs -= [ "//build/config/compiler:default_optimization" ]
# configs += [ "//build/config/compiler:optimize_speed" ]
}
deps = [ ":minizip" ]
configs -= [ "//build/config/compiler:chromium_code" ]
configs += [ "//build/config/compiler:no_chromium_code" ]
}
}
if (build_with_chromium) {
test("zlib_unittests") {
testonly = true
sources = [
"contrib/tests/infcover.cc",
"contrib/tests/infcover.h",
"contrib/tests/run_all_unittests.cc",
"contrib/tests/utils_unittest.cc",
"google/compression_utils_unittest.cc",
"google/zip_reader_unittest.cc",
"google/zip_unittest.cc",
]
data = [ "google/test/data/" ]
if (is_ios) {
bundle_deps = [ "google:zlib_pak_bundle_data" ]
}
deps = [
":zlib",
"google:compression_utils",
"google:zip",
"//base/test:test_support",
"//testing/gtest",
]
configs -= [ "//build/config/compiler:chromium_code" ]
configs += [ "//build/config/compiler:no_chromium_code" ]
include_dirs = [
"//third_party/googletest/src/googletest/include/gtest",
".",
"google",
]
}
}

View File

@ -8,7 +8,6 @@
#include "ui/base/x/x11_util.h"
#include <ctype.h>
#include <sys/ipc.h>
#include <sys/shm.h>

View File

@ -548,7 +548,7 @@ Handle<JSObject> JSDisplayNames::ResolvedOptions(
// 4. Let options be ! ObjectCreate(%ObjectPrototype%).
Handle<JSObject> options = factory->NewJSObject(isolate->object_function());
DisplayNamesInternal* internal = display_names->internal().raw();
DisplayNamesInternal* internal = display_names->internal()->raw();
Maybe<std::string> maybe_locale = Intl::ToLanguageTag(internal->locale());
DCHECK(maybe_locale.IsJust());
@ -598,7 +598,7 @@ MaybeHandle<Object> JSDisplayNames::Of(Isolate* isolate,
Handle<String> code;
ASSIGN_RETURN_ON_EXCEPTION(isolate, code, Object::ToString(isolate, code_obj),
Object);
DisplayNamesInternal* internal = display_names->internal().raw();
DisplayNamesInternal* internal = display_names->internal()->raw();
Maybe<icu::UnicodeString> maybe_result =
internal->of(isolate, code->ToCString().get());
MAYBE_RETURN(maybe_result, Handle<Object>());