Code: NavigationPolicy EffectiveNavigationPolicy(NavigationPolicy policy,
                                           const WebInputEvent* current_event,
                                           const WebWindowFeatures& features) {
  if (policy == kNavigationPolicyIgnore)
    return GetNavigationPolicy(current_event, features);
   if (policy == kNavigationPolicyNewBackgroundTab &&
      GetNavigationPolicy(current_event, features) !=
          kNavigationPolicyNewBackgroundTab &&
       !UIEventWithKeyState::NewTabModifierSetFromIsolatedWorld()) {
     return kNavigationPolicyNewForegroundTab;
   }
   return policy;
 }

Commit Message: Only allow downloading in response to real keyboard modifiers

BUG=848531

Change-Id: I97554c8d312243b55647f1376945aee32dbd95bf
Reviewed-on: https://chromium-review.googlesource.com/1082216
Reviewed-by: Mike West <mkwst@chromium.org>
Commit-Queue: Jochen Eisinger <jochen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#564051}
CWE ID: 
NavigationPolicy EffectiveNavigationPolicy(NavigationPolicy policy,
   if (policy == kNavigationPolicyNewBackgroundTab &&
      user_policy != kNavigationPolicyNewBackgroundTab &&
       !UIEventWithKeyState::NewTabModifierSetFromIsolatedWorld()) {
    // Don't allow background tabs to be opened via script setting the
    // event modifiers.
     return kNavigationPolicyNewForegroundTab;
   }

  if (policy == kNavigationPolicyDownload &&
      user_policy != kNavigationPolicyDownload) {
    // Don't allow downloads to be triggered via script setting the event
    // modifiers.
    return kNavigationPolicyNewForegroundTab;
  }

   return policy;
 }
