void WebContents::ReadyToCommitNavigation(
    content::NavigationHandle* navigation_handle) {
  // Don't focus content in an inactive window.
  if (!owner_window())
    return;
#if defined(OS_MAC)
  if (!owner_window()->IsActive())
    return;
#else
  if (!owner_window()->widget()->IsActive())
    return;
#endif
  // Don't focus content after subframe navigations.
  if (!navigation_handle->IsInMainFrame())
    return;
  // Only focus for top-level contents.
  if (type_ != Type::kBrowserWindow)
    return;
  web_contents()->SetInitialFocus();
}
void WebContents::ReadyToCommitNavigation(
    content::NavigationHandle* navigation_handle) {
   
  if (!owner_window())
    return;
#if defined(OS_MAC)
  if (!owner_window()->IsActive())
    return;
#else
  if (!owner_window()->widget()->IsActive())
    return;
#endif
   
  if (!navigation_handle->IsInMainFrame())
    return;
   
  if (type_ != Type::kBrowserWindow)
    return;
  web_contents()->SetInitialFocus();
}