fix: do not allow the window to grab focus when tabbing / shift+tabbing (#16042)

* fix: do not allow the window to grab focus when tabbing / shift+tabbing

* test: add tests.
This commit is contained in:
Pedro Pontes 2018-12-19 07:44:51 +01:00 committed by Shelley Vohr
parent ed3e5739dc
commit 9c783f53ba
5 changed files with 171 additions and 0 deletions

View file

@ -346,6 +346,19 @@ blink::WebSecurityStyle CommonWebContentsDelegate::GetSecurityStyle(
security_style_explanations);
}
bool CommonWebContentsDelegate::TakeFocus(content::WebContents* source,
bool reverse) {
if (source && source->GetOutermostWebContents() == source) {
// If this is the outermost web contents and the user has tabbed or
// shift + tabbed through all the elements, reset the focus back to
// the first or last element so that it doesn't stay in the body.
source->FocusThroughTabTraversal(reverse);
return true;
}
return false;
}
void CommonWebContentsDelegate::DevToolsSaveToFile(const std::string& url,
const std::string& content,
bool save_as) {