OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 Google Inc. All rights reserved. |
3 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). | 3 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
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 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 bool meta = inputEvent->modifiers & WebInputEvent::MetaKey; | 242 bool meta = inputEvent->modifiers & WebInputEvent::MetaKey; |
243 | 243 |
244 NavigationPolicy userPolicy = *policy; | 244 NavigationPolicy userPolicy = *policy; |
245 navigationPolicyFromMouseEvent(buttonNumber, ctrl, shift, alt, meta, &userPo
licy); | 245 navigationPolicyFromMouseEvent(buttonNumber, ctrl, shift, alt, meta, &userPo
licy); |
246 // User and app agree that we want a new window; let the app override the de
corations. | 246 // User and app agree that we want a new window; let the app override the de
corations. |
247 if (userPolicy == NavigationPolicyNewWindow && *policy == NavigationPolicyNe
wPopup) | 247 if (userPolicy == NavigationPolicyNewWindow && *policy == NavigationPolicyNe
wPopup) |
248 return; | 248 return; |
249 *policy = userPolicy; | 249 *policy = userPolicy; |
250 } | 250 } |
251 | 251 |
252 WebNavigationPolicy getNavigationPolicy(const WindowFeatures& features) | 252 WebNavigationPolicy getNavigationPolicy(const WindowFeatures& features, CreateWi
ndowReason createWindowReason) |
253 { | 253 { |
254 // If our default configuration was modified by a script or wasn't | 254 // If our default configuration was modified by a script or wasn't |
255 // created by a user gesture, then show as a popup. Else, let this | 255 // created by a user gesture, then show as a popup. Else, let this |
256 // new window be opened as a toplevel window. | 256 // new window be opened as a toplevel window. |
257 bool asPopup = !features.toolBarVisible | 257 bool asPopup = !features.toolBarVisible |
258 || !features.statusBarVisible | 258 || !features.statusBarVisible |
259 || !features.scrollbarsVisible | 259 || !features.scrollbarsVisible |
260 || !features.menuBarVisible | 260 || !features.menuBarVisible |
261 || !features.resizable; | 261 || !features.resizable; |
262 | 262 |
263 NavigationPolicy policy = NavigationPolicyNewForegroundTab; | 263 NavigationPolicy policy = NavigationPolicyNewForegroundTab; |
264 if (asPopup) | 264 if (asPopup) |
265 policy = NavigationPolicyNewPopup; | 265 policy = NavigationPolicyNewPopup; |
266 updatePolicyForEvent(WebViewImpl::currentInputEvent(), &policy); | 266 if (createWindowReason == CreatedFromLoadRequest) |
| 267 updatePolicyForEvent(WebViewImpl::currentInputEvent(), &policy); |
267 | 268 |
268 return static_cast<WebNavigationPolicy>(policy); | 269 return static_cast<WebNavigationPolicy>(policy); |
269 } | 270 } |
270 | 271 |
271 WebNavigationPolicy effectiveNavigationPolicy(NavigationPolicy navigationPolicy,
const WindowFeatures& features) | 272 WebNavigationPolicy effectiveNavigationPolicy(NavigationPolicy navigationPolicy,
const WindowFeatures& features, CreateWindowReason createWindowReason) |
272 { | 273 { |
273 WebNavigationPolicy policy = static_cast<WebNavigationPolicy>(navigationPoli
cy); | 274 WebNavigationPolicy policy = static_cast<WebNavigationPolicy>(navigationPoli
cy); |
274 if (policy == WebNavigationPolicyIgnore) | 275 if (policy == WebNavigationPolicyIgnore) |
275 return getNavigationPolicy(features); | 276 return getNavigationPolicy(features, createWindowReason); |
276 if (policy == WebNavigationPolicyNewBackgroundTab && getNavigationPolicy(fea
tures) != WebNavigationPolicyNewBackgroundTab && !UIEventWithKeyState::newTabMod
ifierSetFromIsolatedWorld()) | 277 if (policy == WebNavigationPolicyNewBackgroundTab && getNavigationPolicy(fea
tures, createWindowReason) != WebNavigationPolicyNewBackgroundTab && !UIEventWit
hKeyState::newTabModifierSetFromIsolatedWorld()) |
277 return WebNavigationPolicyNewForegroundTab; | 278 return WebNavigationPolicyNewForegroundTab; |
278 | 279 |
279 return policy; | 280 return policy; |
280 } | 281 } |
281 | 282 |
282 } // namespace | 283 } // namespace |
283 | 284 |
284 Page* ChromeClientImpl::createWindow(LocalFrame* frame, const FrameLoadRequest&
r, const WindowFeatures& features, | 285 Page* ChromeClientImpl::createWindow(LocalFrame* frame, const FrameLoadRequest&
r, const WindowFeatures& features, |
285 NavigationPolicy navigationPolicy, ShouldSendReferrer shouldSendReferrer) | 286 NavigationPolicy navigationPolicy, ShouldSendReferrer shouldSendReferrer, Cr
eateWindowReason createWindowReason) |
286 { | 287 { |
287 if (!m_webView->client()) | 288 if (!m_webView->client()) |
288 return nullptr; | 289 return nullptr; |
289 | 290 |
290 WebNavigationPolicy policy = effectiveNavigationPolicy(navigationPolicy, fea
tures); | 291 WebNavigationPolicy policy = effectiveNavigationPolicy(navigationPolicy, fea
tures, createWindowReason); |
291 ASSERT(frame->document()); | 292 ASSERT(frame->document()); |
292 Fullscreen::fullyExitFullscreen(*frame->document()); | 293 Fullscreen::fullyExitFullscreen(*frame->document()); |
293 | 294 |
294 WebViewImpl* newView = toWebViewImpl( | 295 WebViewImpl* newView = toWebViewImpl( |
295 m_webView->client()->createView(WebLocalFrameImpl::fromFrame(frame), Wra
ppedResourceRequest(r.resourceRequest()), features, r.frameName(), policy, shoul
dSendReferrer == NeverSendReferrer)); | 296 m_webView->client()->createView(WebLocalFrameImpl::fromFrame(frame), Wra
ppedResourceRequest(r.resourceRequest()), features, r.frameName(), policy, shoul
dSendReferrer == NeverSendReferrer)); |
296 if (!newView) | 297 if (!newView) |
297 return nullptr; | 298 return nullptr; |
298 return newView->page(); | 299 return newView->page(); |
299 } | 300 } |
300 | 301 |
301 void ChromeClientImpl::didOverscroll(const FloatSize& unusedDelta, const FloatSi
ze& accumulatedRootOverScroll, const FloatPoint& position, const FloatSize& velo
city) | 302 void ChromeClientImpl::didOverscroll(const FloatSize& unusedDelta, const FloatSi
ze& accumulatedRootOverScroll, const FloatPoint& position, const FloatSize& velo
city) |
302 { | 303 { |
303 if (!m_webView->client()) | 304 if (!m_webView->client()) |
304 return; | 305 return; |
305 | 306 |
306 m_webView->client()->didOverscroll(unusedDelta, accumulatedRootOverScroll, p
osition, velocity); | 307 m_webView->client()->didOverscroll(unusedDelta, accumulatedRootOverScroll, p
osition, velocity); |
307 } | 308 } |
308 | 309 |
309 void ChromeClientImpl::show(NavigationPolicy navigationPolicy) | 310 void ChromeClientImpl::show(NavigationPolicy navigationPolicy, CreateWindowReaso
n createWindowReason) |
310 { | 311 { |
311 if (m_webView->client()) | 312 if (m_webView->client()) |
312 m_webView->client()->show(effectiveNavigationPolicy(navigationPolicy, m_
windowFeatures)); | 313 m_webView->client()->show(effectiveNavigationPolicy(navigationPolicy, m_
windowFeatures, createWindowReason)); |
313 } | 314 } |
314 | 315 |
315 void ChromeClientImpl::setToolbarsVisible(bool value) | 316 void ChromeClientImpl::setToolbarsVisible(bool value) |
316 { | 317 { |
317 m_windowFeatures.toolBarVisible = value; | 318 m_windowFeatures.toolBarVisible = value; |
318 } | 319 } |
319 | 320 |
320 bool ChromeClientImpl::toolbarsVisible() | 321 bool ChromeClientImpl::toolbarsVisible() |
321 { | 322 { |
322 return m_windowFeatures.toolBarVisible; | 323 return m_windowFeatures.toolBarVisible; |
(...skipping 637 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
960 for (const auto& observer : observers) | 961 for (const auto& observer : observers) |
961 observer->willOpenPopup(); | 962 observer->willOpenPopup(); |
962 } | 963 } |
963 | 964 |
964 FloatSize ChromeClientImpl::elasticOverscroll() const | 965 FloatSize ChromeClientImpl::elasticOverscroll() const |
965 { | 966 { |
966 return m_webView->elasticOverscroll(); | 967 return m_webView->elasticOverscroll(); |
967 } | 968 } |
968 | 969 |
969 } // namespace blink | 970 } // namespace blink |
OLD | NEW |