Both, but mostly Margaery. In terms of what she can achieve – it gets her out of prison, it improves the monarchy’s popularity with the smallfolk in the short-term (which if you’re going to face-off against the High Sparrow in the future, you’re going to need to do), and it blunts if not completely neutralizes’ the HS’ more radical ambitions, because now he’s bought into the system.
It’s a defensive desperation play – it doesn’t get Loras back or the Faith Militant disarmed – but it’s probably the best she’s got at the moment.