Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(936)

Side by Side Diff: Source/core/page/CreateWindow.cpp

Issue 108333006: Adding a navigation policy for the "presentation" feature in window.open() Base URL: https://github.com/drott/blink-crosswalk.git@presentationWindow
Patch Set: Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Source/core/loader/NavigationPolicy.h ('k') | public/web/WebNavigationPolicy.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006, 2007, 2008, 2010 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2007, 2008, 2010 Apple 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 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 12 matching lines...) Expand all
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */ 25 */
26 26
27 #include "config.h" 27 #include "config.h"
28 #include "core/page/CreateWindow.h" 28 #include "core/page/CreateWindow.h"
29 29
30 #include "core/dom/Document.h" 30 #include "core/dom/Document.h"
31 #include "core/frame/Frame.h" 31 #include "core/frame/Frame.h"
32 #include "core/loader/FrameLoadRequest.h" 32 #include "core/loader/FrameLoadRequest.h"
33 #include "core/loader/NavigationPolicy.h"
33 #include "core/page/Chrome.h" 34 #include "core/page/Chrome.h"
34 #include "core/page/ChromeClient.h" 35 #include "core/page/ChromeClient.h"
35 #include "core/page/Page.h" 36 #include "core/page/Page.h"
36 #include "core/page/Settings.h" 37 #include "core/page/Settings.h"
37 #include "core/page/WindowFeatures.h" 38 #include "core/page/WindowFeatures.h"
38 #include "platform/network/ResourceRequest.h" 39 #include "platform/network/ResourceRequest.h"
39 #include "platform/weborigin/KURL.h" 40 #include "platform/weborigin/KURL.h"
40 #include "platform/weborigin/SecurityOrigin.h" 41 #include "platform/weborigin/SecurityOrigin.h"
41 #include "platform/weborigin/SecurityPolicy.h" 42 #include "platform/weborigin/SecurityPolicy.h"
42 43
(...skipping 23 matching lines...) Expand all
66 67
67 if (openerFrame->settings() && !openerFrame->settings()->supportsMultipleWin dows()) { 68 if (openerFrame->settings() && !openerFrame->settings()->supportsMultipleWin dows()) {
68 created = false; 69 created = false;
69 return openerFrame->tree().top(); 70 return openerFrame->tree().top();
70 } 71 }
71 72
72 Page* oldPage = openerFrame->page(); 73 Page* oldPage = openerFrame->page();
73 if (!oldPage) 74 if (!oldPage)
74 return 0; 75 return 0;
75 76
76 Page* page = oldPage->chrome().client().createWindow(openerFrame, request, f eatures, policy, shouldSendReferrer); 77 NavigationPolicy navigationPolicy = NavigationPolicyIgnore;
78 for (size_t i = 0; i < features.additionalFeatures.size(); ++i) {
79 if (features.additionalFeatures[i].lower() == "presentation")
80 navigationPolicy = NavigationPolicyPresentationWindow;
81 }
82 Page* page = oldPage->chrome().client().createWindow(openerFrame, request, f eatures, navigationPolicy, shouldSendReferrer);
83
77 if (!page) 84 if (!page)
78 return 0; 85 return 0;
79 86
80 Frame* frame = page->mainFrame(); 87 Frame* frame = page->mainFrame();
81 88
82 frame->loader().forceSandboxFlags(openerFrame->document()->sandboxFlags()); 89 frame->loader().forceSandboxFlags(openerFrame->document()->sandboxFlags());
83 90
84 if (request.frameName() != "_blank") 91 if (request.frameName() != "_blank")
85 frame->tree().setName(request.frameName()); 92 frame->tree().setName(request.frameName());
86 93
(...skipping 12 matching lines...) Expand all
99 windowRect.setY(features.y); 106 windowRect.setY(features.y);
100 if (features.widthSet) 107 if (features.widthSet)
101 windowRect.setWidth(features.width + (windowRect.width() - viewportSize. width())); 108 windowRect.setWidth(features.width + (windowRect.width() - viewportSize. width()));
102 if (features.heightSet) 109 if (features.heightSet)
103 windowRect.setHeight(features.height + (windowRect.height() - viewportSi ze.height())); 110 windowRect.setHeight(features.height + (windowRect.height() - viewportSi ze.height()));
104 111
105 // Ensure non-NaN values, minimum size as well as being within valid screen area. 112 // Ensure non-NaN values, minimum size as well as being within valid screen area.
106 FloatRect newWindowRect = DOMWindow::adjustWindowRect(page, windowRect); 113 FloatRect newWindowRect = DOMWindow::adjustWindowRect(page, windowRect);
107 114
108 page->chrome().setWindowRect(newWindowRect); 115 page->chrome().setWindowRect(newWindowRect);
109 page->chrome().show(policy); 116 page->chrome().show(navigationPolicy);
110 117
111 created = true; 118 created = true;
112 return frame; 119 return frame;
113 } 120 }
114 121
115 Frame* createWindow(const String& urlString, const AtomicString& frameName, cons t WindowFeatures& windowFeatures, 122 Frame* createWindow(const String& urlString, const AtomicString& frameName, cons t WindowFeatures& windowFeatures,
116 DOMWindow* activeWindow, Frame* firstFrame, Frame* openerFrame, DOMWindow::P repareDialogFunction function, void* functionContext) 123 DOMWindow* activeWindow, Frame* firstFrame, Frame* openerFrame, DOMWindow::P repareDialogFunction function, void* functionContext)
117 { 124 {
118 Frame* activeFrame = activeWindow->frame(); 125 Frame* activeFrame = activeWindow->frame();
119 126
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 if (shouldSendReferrer == MaybeSendReferrer) { 186 if (shouldSendReferrer == MaybeSendReferrer) {
180 newFrame->loader().setOpener(openerFrame); 187 newFrame->loader().setOpener(openerFrame);
181 newFrame->document()->setReferrerPolicy(openerFrame->document()->referre rPolicy()); 188 newFrame->document()->setReferrerPolicy(openerFrame->document()->referre rPolicy());
182 } 189 }
183 FrameLoadRequest newRequest(0, request.resourceRequest()); 190 FrameLoadRequest newRequest(0, request.resourceRequest());
184 newRequest.setFormState(request.formState()); 191 newRequest.setFormState(request.formState());
185 newFrame->loader().load(newRequest); 192 newFrame->loader().load(newRequest);
186 } 193 }
187 194
188 } // namespace WebCore 195 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/loader/NavigationPolicy.h ('k') | public/web/WebNavigationPolicy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698