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 448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
459 if (m_webFrame->client()) | 459 if (m_webFrame->client()) |
460 m_webFrame->client()->didFirstVisuallyNonEmptyLayout(m_webFrame); | 460 m_webFrame->client()->didFirstVisuallyNonEmptyLayout(m_webFrame); |
461 } | 461 } |
462 | 462 |
463 void FrameLoaderClientImpl::dispatchDidChangeThemeColor() | 463 void FrameLoaderClientImpl::dispatchDidChangeThemeColor() |
464 { | 464 { |
465 if (m_webFrame->client()) | 465 if (m_webFrame->client()) |
466 m_webFrame->client()->didChangeThemeColor(); | 466 m_webFrame->client()->didChangeThemeColor(); |
467 } | 467 } |
468 | 468 |
| 469 static bool allowCreatingBackgroundTabs() |
| 470 { |
| 471 const WebInputEvent* inputEvent = WebViewImpl::currentInputEvent(); |
| 472 if (!inputEvent || inputEvent->type != WebInputEvent::MouseUp) |
| 473 return false; |
| 474 |
| 475 const WebMouseEvent* mouseEvent = static_cast<const WebMouseEvent*>(inputEve
nt); |
| 476 |
| 477 unsigned short buttonNumber; |
| 478 switch (mouseEvent->button) { |
| 479 case WebMouseEvent::ButtonLeft: |
| 480 buttonNumber = 0; |
| 481 break; |
| 482 case WebMouseEvent::ButtonMiddle: |
| 483 buttonNumber = 1; |
| 484 break; |
| 485 case WebMouseEvent::ButtonRight: |
| 486 buttonNumber = 2; |
| 487 break; |
| 488 default: |
| 489 return false; |
| 490 } |
| 491 bool ctrl = mouseEvent->modifiers & WebMouseEvent::ControlKey; |
| 492 bool shift = mouseEvent->modifiers & WebMouseEvent::ShiftKey; |
| 493 bool alt = mouseEvent->modifiers & WebMouseEvent::AltKey; |
| 494 bool meta = mouseEvent->modifiers & WebMouseEvent::MetaKey; |
| 495 |
| 496 NavigationPolicy userPolicy; |
| 497 if (!navigationPolicyFromMouseEvent(buttonNumber, ctrl, shift, alt, meta, &u
serPolicy)) |
| 498 return false; |
| 499 return userPolicy == NavigationPolicyNewBackgroundTab; |
| 500 } |
| 501 |
469 NavigationPolicy FrameLoaderClientImpl::decidePolicyForNavigation(const Resource
Request& request, DocumentLoader* loader, NavigationPolicy policy, bool isTransi
tionNavigation) | 502 NavigationPolicy FrameLoaderClientImpl::decidePolicyForNavigation(const Resource
Request& request, DocumentLoader* loader, NavigationPolicy policy, bool isTransi
tionNavigation) |
470 { | 503 { |
471 if (!m_webFrame->client()) | 504 if (!m_webFrame->client()) |
472 return NavigationPolicyIgnore; | 505 return NavigationPolicyIgnore; |
| 506 |
| 507 if (policy == NavigationPolicyNewBackgroundTab && !allowCreatingBackgroundTa
bs()) |
| 508 policy = NavigationPolicyNewForegroundTab; |
| 509 |
473 WebDataSourceImpl* ds = WebDataSourceImpl::fromDocumentLoader(loader); | 510 WebDataSourceImpl* ds = WebDataSourceImpl::fromDocumentLoader(loader); |
474 | 511 |
475 WrappedResourceRequest wrappedResourceRequest(request); | 512 WrappedResourceRequest wrappedResourceRequest(request); |
476 WebFrameClient::NavigationPolicyInfo navigationInfo(wrappedResourceRequest); | 513 WebFrameClient::NavigationPolicyInfo navigationInfo(wrappedResourceRequest); |
477 navigationInfo.frame = m_webFrame; | 514 navigationInfo.frame = m_webFrame; |
478 navigationInfo.extraData = ds->extraData(); | 515 navigationInfo.extraData = ds->extraData(); |
479 navigationInfo.navigationType = ds->navigationType(); | 516 navigationInfo.navigationType = ds->navigationType(); |
480 navigationInfo.defaultPolicy = static_cast<WebNavigationPolicy>(policy); | 517 navigationInfo.defaultPolicy = static_cast<WebNavigationPolicy>(policy); |
481 navigationInfo.isRedirect = ds->isRedirect(); | 518 navigationInfo.isRedirect = ds->isRedirect(); |
482 navigationInfo.isTransitionNavigation = isTransitionNavigation; | 519 navigationInfo.isTransitionNavigation = isTransitionNavigation; |
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
889 | 926 |
890 unsigned FrameLoaderClientImpl::backForwardLength() | 927 unsigned FrameLoaderClientImpl::backForwardLength() |
891 { | 928 { |
892 WebViewImpl* webview = m_webFrame->viewImpl(); | 929 WebViewImpl* webview = m_webFrame->viewImpl(); |
893 if (!webview || !webview->client()) | 930 if (!webview || !webview->client()) |
894 return 0; | 931 return 0; |
895 return webview->client()->historyBackListCount() + 1 + webview->client()->hi
storyForwardListCount(); | 932 return webview->client()->historyBackListCount() + 1 + webview->client()->hi
storyForwardListCount(); |
896 } | 933 } |
897 | 934 |
898 } // namespace blink | 935 } // namespace blink |
OLD | NEW |