Add a CefHandler::HandleSetFocus() callback that gets called when the browser control or a child widget requests focus. This callback gives the client an opportunity to cancel the focus change. (Issue #34, initial patch by tux316).

git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@29 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
Marshall Greenblatt
2009-06-16 13:52:35 +00:00
parent ff7e8379fb
commit d953faf7f8
8 changed files with 74 additions and 15 deletions

View File

@@ -548,13 +548,19 @@ bool CefBrowserImpl::UIT_Navigate(const BrowserNavigationEntry& entry,
// In case LoadRequest failed before DidCreateDataSource was called.
delegate_->set_pending_extra_data(NULL);
// Restore focus to the main frame prior to loading new request.
// This makes sure that we don't have a focused iframe. Otherwise, that
// iframe would keep focus when the SetFocus called immediately after
// LoadRequest, thus making some tests fail (see http://b/issue?id=845337
// for more details).
GetWebView()->SetFocusedFrame(frame);
UIT_SetFocus(GetWebViewHost(), true);
if (handler_.get() && handler_->HandleSetFocus(this, false) == RV_CONTINUE) {
// Restore focus to the main frame prior to loading new request.
// This makes sure that we don't have a focused iframe. Otherwise, that
// iframe would keep focus when the SetFocus called immediately after
// LoadRequest, thus making some tests fail (see http://b/issue?id=845337
// for more details).
// TODO(cef): The above comment may be wrong, or the below call to
// SetFocusedFrame() may be unnecessary or in the wrong place. See this
// thread for additional details:
// http://groups.google.com/group/chromium-dev/browse_thread/thread/42bcd31b59e3a168
GetWebView()->SetFocusedFrame(frame);
UIT_SetFocus(GetWebViewHost(), true);
}
return true;
}