OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2009, 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2009, 2012 Google Inc. All rights reserved. |
3 * Copyright (C) 2011 Apple Inc. All rights reserved. | 3 * Copyright (C) 2011 Apple Inc. All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
7 * met: | 7 * met: |
8 * | 8 * |
9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
452 if (m_webFrame->client()) | 452 if (m_webFrame->client()) |
453 m_webFrame->client()->didFirstVisuallyNonEmptyLayout(m_webFrame); | 453 m_webFrame->client()->didFirstVisuallyNonEmptyLayout(m_webFrame); |
454 } | 454 } |
455 | 455 |
456 void FrameLoaderClientImpl::dispatchDidChangeThemeColor() | 456 void FrameLoaderClientImpl::dispatchDidChangeThemeColor() |
457 { | 457 { |
458 if (m_webFrame->client()) | 458 if (m_webFrame->client()) |
459 m_webFrame->client()->didChangeThemeColor(); | 459 m_webFrame->client()->didChangeThemeColor(); |
460 } | 460 } |
461 | 461 |
462 static bool allowCreatingBackgroundTabs() | |
463 { | |
464 const WebInputEvent* inputEvent = WebViewImpl::currentInputEvent(); | |
465 if (!inputEvent || inputEvent->type != WebInputEvent::MouseUp) | |
Mike West
2014/11/12 12:20:08
Why can we only create a new tab on MouseUp? I mea
| |
466 return false; | |
467 | |
468 const WebMouseEvent* mouseEvent = static_cast<const WebMouseEvent*>(inputEve nt); | |
469 | |
470 unsigned short buttonNumber; | |
471 switch (mouseEvent->button) { | |
472 case WebMouseEvent::ButtonLeft: | |
473 buttonNumber = 0; | |
474 break; | |
475 case WebMouseEvent::ButtonMiddle: | |
476 buttonNumber = 1; | |
477 break; | |
478 case WebMouseEvent::ButtonRight: | |
479 buttonNumber = 2; | |
480 break; | |
481 default: | |
482 return false; | |
483 } | |
484 bool ctrl = mouseEvent->modifiers & WebMouseEvent::ControlKey; | |
485 bool shift = mouseEvent->modifiers & WebMouseEvent::ShiftKey; | |
486 bool alt = mouseEvent->modifiers & WebMouseEvent::AltKey; | |
487 bool meta = mouseEvent->modifiers & WebMouseEvent::MetaKey; | |
488 | |
489 NavigationPolicy userPolicy; | |
490 if (!navigationPolicyFromMouseEvent(buttonNumber, ctrl, shift, alt, meta, &u serPolicy)) | |
491 return false; | |
492 return userPolicy == NavigationPolicyNewBackgroundTab; | |
493 } | |
494 | |
462 NavigationPolicy FrameLoaderClientImpl::decidePolicyForNavigation(const Resource Request& request, DocumentLoader* loader, NavigationPolicy policy, bool isTransi tionNavigation) | 495 NavigationPolicy FrameLoaderClientImpl::decidePolicyForNavigation(const Resource Request& request, DocumentLoader* loader, NavigationPolicy policy, bool isTransi tionNavigation) |
463 { | 496 { |
464 if (!m_webFrame->client()) | 497 if (!m_webFrame->client()) |
465 return NavigationPolicyIgnore; | 498 return NavigationPolicyIgnore; |
499 | |
500 if (policy == NavigationPolicyNewBackgroundTab && !allowCreatingBackgroundTa bs()) | |
501 policy = NavigationPolicyNewForegroundTab; | |
502 | |
466 WebDataSourceImpl* ds = WebDataSourceImpl::fromDocumentLoader(loader); | 503 WebDataSourceImpl* ds = WebDataSourceImpl::fromDocumentLoader(loader); |
467 | 504 |
468 WrappedResourceRequest wrappedResourceRequest(request); | 505 WrappedResourceRequest wrappedResourceRequest(request); |
469 WebFrameClient::NavigationPolicyInfo navigationInfo(wrappedResourceRequest); | 506 WebFrameClient::NavigationPolicyInfo navigationInfo(wrappedResourceRequest); |
470 navigationInfo.frame = m_webFrame; | 507 navigationInfo.frame = m_webFrame; |
471 navigationInfo.extraData = ds->extraData(); | 508 navigationInfo.extraData = ds->extraData(); |
472 navigationInfo.navigationType = ds->navigationType(); | 509 navigationInfo.navigationType = ds->navigationType(); |
473 navigationInfo.defaultPolicy = static_cast<WebNavigationPolicy>(policy); | 510 navigationInfo.defaultPolicy = static_cast<WebNavigationPolicy>(policy); |
474 navigationInfo.isRedirect = ds->isRedirect(); | 511 navigationInfo.isRedirect = ds->isRedirect(); |
475 navigationInfo.isTransitionNavigation = isTransitionNavigation; | 512 navigationInfo.isTransitionNavigation = isTransitionNavigation; |
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
868 | 905 |
869 unsigned FrameLoaderClientImpl::backForwardLength() | 906 unsigned FrameLoaderClientImpl::backForwardLength() |
870 { | 907 { |
871 WebViewImpl* webview = m_webFrame->viewImpl(); | 908 WebViewImpl* webview = m_webFrame->viewImpl(); |
872 if (!webview || !webview->client()) | 909 if (!webview || !webview->client()) |
873 return 0; | 910 return 0; |
874 return webview->client()->historyBackListCount() + 1 + webview->client()->hi storyForwardListCount(); | 911 return webview->client()->historyBackListCount() + 1 + webview->client()->hi storyForwardListCount(); |
875 } | 912 } |
876 | 913 |
877 } // namespace blink | 914 } // namespace blink |
OLD | NEW |