I have no idea on how to do it with shapefile with existing tools, but an algorithm that iteratively adds vertices of the polygon to the line that joins the two points (until the new line is fully inside the polygon) should work. This would be the opposite of Douglas-Peucker.
With existing tools, I suggest that you convert your polygon to raster and assign a value equal to your pixel size for all the pixels inside the polygon (no data or VERY large value outside of the polygon). Then you can compute the minimum cost path using either GRASS or SAGA tools in the processing toolbox (see Cost Distance Analyst In QGIS? ). This will yield an exact but unprecise value, and you can increase the precision by reducing the cell size (which will also increase the processing time).
When holes of the polygons have to be avoided
So, this is an extension to my previous answer Calculating the longest distance within polygon in QGIS but with some changes in the Step 3, particularly in the query.
SELECT p1.id, setsrid(make_line(p1.geometry, p2.geometry), #put your srid here),
max(st_length(make_line(p1.geometry, p2.geometry))) AS length
FROM "Points" AS p1, "polygons" AS p
JOIN "Points" AS p2 ON p1.id = p2.id
WHERE NOT st_equals(p1.geometry, p2.geometry)
AND st_within(make_line(p1.geometry, p2.geometry), st_buffer(p.geometry, 0.00005))
GROUP BY p1.id
Note that in the query above additionally the geometry of the original polygons were used.
To be more example-realisting I considered different polygons to those that I had in my previous answer, see image below.
The corresponding result will be looking as
Note that the result is approximate because a bigger distance was used on the step 'Points along geometry'
.
I made with 'Points along geometry'
, however it can also be done with the result of 'Extract vertices'
.
Best Answer
You can use PyQGIS to measure the distances between all vertices of each polygon and find max:
To save max distances in a field:
You can also create a line layer: