fix: persist permission granted to serial ports (#30209)

This commit is contained in:
John Kleinschmidt 2021-07-26 13:10:57 -04:00 committed by GitHub
parent d2989de5d9
commit 461db8f1ab
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 138 additions and 38 deletions

View file

@ -68,8 +68,7 @@ SerialChooserController::SerialChooserController(
filters_(std::move(filters)),
callback_(std::move(callback)),
serial_delegate_(serial_delegate) {
requesting_origin_ = render_frame_host->GetLastCommittedOrigin();
embedding_origin_ = web_contents->GetMainFrame()->GetLastCommittedOrigin();
origin_ = web_contents->GetMainFrame()->GetLastCommittedOrigin();
chooser_context_ = SerialChooserContextFactory::GetForBrowserContext(
web_contents->GetBrowserContext())
@ -125,8 +124,7 @@ void SerialChooserController::OnDeviceChosen(const std::string& port_id) {
return ptr->token.ToString() == port_id;
});
if (it != ports_.end()) {
chooser_context_->GrantPortPermission(requesting_origin_,
embedding_origin_, *it->get());
chooser_context_->GrantPortPermission(origin_, *it->get());
RunCallback(it->Clone());
} else {
RunCallback(/*port=*/nullptr);