Chromium Code Reviews| 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 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 197 m_webView->client()->setKeyboardFocusURL(focusURL); | 197 m_webView->client()->setKeyboardFocusURL(focusURL); |
| 198 } | 198 } |
| 199 | 199 |
| 200 void ChromeClientImpl::focusedFrameChanged(LocalFrame* frame) | 200 void ChromeClientImpl::focusedFrameChanged(LocalFrame* frame) |
| 201 { | 201 { |
| 202 WebLocalFrameImpl* webframe = WebLocalFrameImpl::fromFrame(frame); | 202 WebLocalFrameImpl* webframe = WebLocalFrameImpl::fromFrame(frame); |
| 203 if (webframe && webframe->client()) | 203 if (webframe && webframe->client()) |
| 204 webframe->client()->frameFocused(); | 204 webframe->client()->frameFocused(); |
| 205 } | 205 } |
| 206 | 206 |
| 207 Page* ChromeClientImpl::createWindow(LocalFrame* frame, const FrameLoadRequest& r, const WindowFeatures& features, | 207 namespace { |
| 208 NavigationPolicy navigationPolicy, ShouldSendReferrer shouldSendReferrer) | |
| 209 { | |
| 210 if (!m_webView->client()) | |
| 211 return nullptr; | |
| 212 | 208 |
| 213 WebNavigationPolicy policy = static_cast<WebNavigationPolicy>(navigationPoli cy); | 209 inline void updatePolicyForEvent(const WebInputEvent* inputEvent, NavigationPoli cy* policy) |
|
Mike West
2015/05/18 15:07:56
Why drop 'static'?
jochen (gone - plz use gerrit)
2015/05/18 22:45:14
it's in an anon namespace now
| |
| 214 if (policy == WebNavigationPolicyIgnore) | |
| 215 policy = getNavigationPolicy(features); | |
| 216 else if (policy == WebNavigationPolicyNewBackgroundTab && getNavigationPolic y(features) != WebNavigationPolicyNewBackgroundTab && !UIEventWithKeyState::newT abModifierSetFromIsolatedWorld()) | |
| 217 policy = WebNavigationPolicyNewForegroundTab; | |
| 218 | |
| 219 ASSERT(frame->document()); | |
| 220 Fullscreen::fullyExitFullscreen(*frame->document()); | |
| 221 | |
| 222 WebViewImpl* newView = toWebViewImpl( | |
| 223 m_webView->client()->createView(WebLocalFrameImpl::fromFrame(frame), Wra ppedResourceRequest(r.resourceRequest()), features, r.frameName(), policy, shoul dSendReferrer == NeverSendReferrer)); | |
| 224 if (!newView) | |
| 225 return nullptr; | |
| 226 return newView->page(); | |
| 227 } | |
| 228 | |
| 229 static inline void updatePolicyForEvent(const WebInputEvent* inputEvent, Navigat ionPolicy* policy) | |
| 230 { | 210 { |
| 231 if (!inputEvent || inputEvent->type != WebInputEvent::MouseUp) | 211 if (!inputEvent || inputEvent->type != WebInputEvent::MouseUp) |
| 232 return; | 212 return; |
| 233 | 213 |
| 234 const WebMouseEvent* mouseEvent = static_cast<const WebMouseEvent*>(inputEve nt); | 214 const WebMouseEvent* mouseEvent = static_cast<const WebMouseEvent*>(inputEve nt); |
| 235 | 215 |
| 236 unsigned short buttonNumber; | 216 unsigned short buttonNumber; |
| 237 switch (mouseEvent->button) { | 217 switch (mouseEvent->button) { |
| 238 case WebMouseEvent::ButtonLeft: | 218 case WebMouseEvent::ButtonLeft: |
| 239 buttonNumber = 0; | 219 buttonNumber = 0; |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 253 bool meta = mouseEvent->modifiers & WebMouseEvent::MetaKey; | 233 bool meta = mouseEvent->modifiers & WebMouseEvent::MetaKey; |
| 254 | 234 |
| 255 NavigationPolicy userPolicy = *policy; | 235 NavigationPolicy userPolicy = *policy; |
| 256 navigationPolicyFromMouseEvent(buttonNumber, ctrl, shift, alt, meta, &userPo licy); | 236 navigationPolicyFromMouseEvent(buttonNumber, ctrl, shift, alt, meta, &userPo licy); |
| 257 // User and app agree that we want a new window; let the app override the de corations. | 237 // User and app agree that we want a new window; let the app override the de corations. |
| 258 if (userPolicy == NavigationPolicyNewWindow && *policy == NavigationPolicyNe wPopup) | 238 if (userPolicy == NavigationPolicyNewWindow && *policy == NavigationPolicyNe wPopup) |
| 259 return; | 239 return; |
| 260 *policy = userPolicy; | 240 *policy = userPolicy; |
| 261 } | 241 } |
| 262 | 242 |
| 263 WebNavigationPolicy ChromeClientImpl::getNavigationPolicy(const WindowFeatures& features) | 243 WebNavigationPolicy getNavigationPolicy(const WindowFeatures& features) |
|
Mike West
2015/05/18 15:09:44
Nit: static?
| |
| 264 { | 244 { |
| 265 // If our default configuration was modified by a script or wasn't | 245 // If our default configuration was modified by a script or wasn't |
| 266 // created by a user gesture, then show as a popup. Else, let this | 246 // created by a user gesture, then show as a popup. Else, let this |
| 267 // new window be opened as a toplevel window. | 247 // new window be opened as a toplevel window. |
| 268 bool asPopup = !features.toolBarVisible | 248 bool asPopup = !features.toolBarVisible |
| 269 || !features.statusBarVisible | 249 || !features.statusBarVisible |
| 270 || !features.scrollbarsVisible | 250 || !features.scrollbarsVisible |
| 271 || !features.menuBarVisible | 251 || !features.menuBarVisible |
| 272 || !features.resizable; | 252 || !features.resizable; |
| 273 | 253 |
| 274 NavigationPolicy policy = NavigationPolicyNewForegroundTab; | 254 NavigationPolicy policy = NavigationPolicyNewForegroundTab; |
| 275 if (asPopup) | 255 if (asPopup) |
| 276 policy = NavigationPolicyNewPopup; | 256 policy = NavigationPolicyNewPopup; |
| 277 updatePolicyForEvent(WebViewImpl::currentInputEvent(), &policy); | 257 updatePolicyForEvent(WebViewImpl::currentInputEvent(), &policy); |
| 278 | 258 |
| 279 return static_cast<WebNavigationPolicy>(policy); | 259 return static_cast<WebNavigationPolicy>(policy); |
| 280 } | 260 } |
| 281 | 261 |
| 262 WebNavigationPolicy effectiveNavigationPolicy(NavigationPolicy navigationPolicy, const WindowFeatures& features) | |
|
Mike West
2015/05/18 15:09:44
Nit: static?
| |
| 263 { | |
| 264 WebNavigationPolicy policy = static_cast<WebNavigationPolicy>(navigationPoli cy); | |
| 265 if (policy == WebNavigationPolicyIgnore) | |
| 266 return getNavigationPolicy(features); | |
| 267 if (policy == WebNavigationPolicyNewBackgroundTab && getNavigationPolicy(fea tures) != WebNavigationPolicyNewBackgroundTab && !UIEventWithKeyState::newTabMod ifierSetFromIsolatedWorld()) | |
| 268 return WebNavigationPolicyNewForegroundTab; | |
| 269 | |
| 270 return policy; | |
| 271 } | |
| 272 | |
| 273 } // namespace | |
| 274 | |
| 275 Page* ChromeClientImpl::createWindow(LocalFrame* frame, const FrameLoadRequest& r, const WindowFeatures& features, | |
| 276 NavigationPolicy navigationPolicy, ShouldSendReferrer shouldSendReferrer) | |
| 277 { | |
| 278 if (!m_webView->client()) | |
| 279 return nullptr; | |
| 280 | |
| 281 WebNavigationPolicy policy = effectiveNavigationPolicy(navigationPolicy, fea tures); | |
| 282 ASSERT(frame->document()); | |
| 283 Fullscreen::fullyExitFullscreen(*frame->document()); | |
| 284 | |
| 285 WebViewImpl* newView = toWebViewImpl( | |
| 286 m_webView->client()->createView(WebLocalFrameImpl::fromFrame(frame), Wra ppedResourceRequest(r.resourceRequest()), features, r.frameName(), policy, shoul dSendReferrer == NeverSendReferrer)); | |
| 287 if (!newView) | |
| 288 return nullptr; | |
| 289 return newView->page(); | |
| 290 } | |
| 291 | |
| 282 void ChromeClientImpl::show(NavigationPolicy navigationPolicy) | 292 void ChromeClientImpl::show(NavigationPolicy navigationPolicy) |
| 283 { | 293 { |
| 284 if (!m_webView->client()) | 294 if (!m_webView->client()) |
| 285 return; | 295 return; |
| 286 | 296 |
| 287 WebNavigationPolicy policy = static_cast<WebNavigationPolicy>(navigationPoli cy); | 297 WebNavigationPolicy policy = effectiveNavigationPolicy(navigationPolicy, m_w indowFeatures); |
| 288 if (policy == WebNavigationPolicyIgnore) | |
| 289 policy = getNavigationPolicy(m_windowFeatures); | |
| 290 else if (policy == WebNavigationPolicyNewBackgroundTab && getNavigationPolic y(m_windowFeatures) != WebNavigationPolicyNewBackgroundTab && !UIEventWithKeySta te::newTabModifierSetFromIsolatedWorld()) | |
| 291 policy = WebNavigationPolicyNewForegroundTab; | |
| 292 m_webView->client()->show(policy); | 298 m_webView->client()->show(policy); |
| 293 } | 299 } |
| 294 | 300 |
| 295 void ChromeClientImpl::setToolbarsVisible(bool value) | 301 void ChromeClientImpl::setToolbarsVisible(bool value) |
| 296 { | 302 { |
| 297 m_windowFeatures.toolBarVisible = value; | 303 m_windowFeatures.toolBarVisible = value; |
| 298 } | 304 } |
| 299 | 305 |
| 300 bool ChromeClientImpl::toolbarsVisible() | 306 bool ChromeClientImpl::toolbarsVisible() |
| 301 { | 307 { |
| (...skipping 608 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 910 if (m_webView->rootGraphicsLayer() && m_webView->layerTreeView()) | 916 if (m_webView->rootGraphicsLayer() && m_webView->layerTreeView()) |
| 911 m_webView->page()->frameHost().pinchViewport().registerLayersWithTreeVie w(m_webView->layerTreeView()); | 917 m_webView->page()->frameHost().pinchViewport().registerLayersWithTreeVie w(m_webView->layerTreeView()); |
| 912 } | 918 } |
| 913 | 919 |
| 914 void ChromeClientImpl::didUpdateTopControls() const | 920 void ChromeClientImpl::didUpdateTopControls() const |
| 915 { | 921 { |
| 916 m_webView->didUpdateTopControls(); | 922 m_webView->didUpdateTopControls(); |
| 917 } | 923 } |
| 918 | 924 |
| 919 } // namespace blink | 925 } // namespace blink |
| OLD | NEW |