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

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

Issue 31063004: Have Frame::loader() return a reference (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 2 months 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/loader/appcache/ApplicationCache.cpp ('k') | Source/core/page/DragController.cpp » ('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 29 matching lines...) Expand all
40 #include "weborigin/SecurityOrigin.h" 40 #include "weborigin/SecurityOrigin.h"
41 #include "weborigin/SecurityPolicy.h" 41 #include "weborigin/SecurityPolicy.h"
42 42
43 namespace WebCore { 43 namespace WebCore {
44 44
45 static Frame* createWindow(Frame* openerFrame, Frame* lookupFrame, const FrameLo adRequest& request, const WindowFeatures& features, bool& created) 45 static Frame* createWindow(Frame* openerFrame, Frame* lookupFrame, const FrameLo adRequest& request, const WindowFeatures& features, bool& created)
46 { 46 {
47 ASSERT(!features.dialog || request.frameName().isEmpty()); 47 ASSERT(!features.dialog || request.frameName().isEmpty());
48 48
49 if (!request.frameName().isEmpty() && request.frameName() != "_blank") { 49 if (!request.frameName().isEmpty() && request.frameName() != "_blank") {
50 if (Frame* frame = lookupFrame->loader()->findFrameForNavigation(request .frameName(), openerFrame->document())) { 50 if (Frame* frame = lookupFrame->loader().findFrameForNavigation(request. frameName(), openerFrame->document())) {
51 if (request.frameName() != "_self") { 51 if (request.frameName() != "_self") {
52 if (Page* page = frame->page()) 52 if (Page* page = frame->page())
53 page->chrome().focus(); 53 page->chrome().focus();
54 } 54 }
55 created = false; 55 created = false;
56 return frame; 56 return frame;
57 } 57 }
58 } 58 }
59 59
60 // Sandboxed frames cannot open new auxiliary browsing contexts. 60 // Sandboxed frames cannot open new auxiliary browsing contexts.
(...skipping 11 matching lines...) Expand all
72 Page* oldPage = openerFrame->page(); 72 Page* oldPage = openerFrame->page();
73 if (!oldPage) 73 if (!oldPage)
74 return 0; 74 return 0;
75 75
76 Page* page = oldPage->chrome().client().createWindow(openerFrame, request, f eatures); 76 Page* page = oldPage->chrome().client().createWindow(openerFrame, request, f eatures);
77 if (!page) 77 if (!page)
78 return 0; 78 return 0;
79 79
80 Frame* frame = page->mainFrame(); 80 Frame* frame = page->mainFrame();
81 81
82 frame->loader()->forceSandboxFlags(openerFrame->document()->sandboxFlags()); 82 frame->loader().forceSandboxFlags(openerFrame->document()->sandboxFlags());
83 83
84 if (request.frameName() != "_blank") 84 if (request.frameName() != "_blank")
85 frame->tree().setName(request.frameName()); 85 frame->tree().setName(request.frameName());
86 86
87 page->chrome().setWindowFeatures(features); 87 page->chrome().setWindowFeatures(features);
88 88
89 // 'x' and 'y' specify the location of the window, while 'width' and 'height ' 89 // 'x' and 'y' specify the location of the window, while 'width' and 'height '
90 // specify the size of the viewport. We can only resize the window, so adjus t 90 // specify the size of the viewport. We can only resize the window, so adjus t
91 // for the difference between the window size and the viewport size. 91 // for the difference between the window size and the viewport size.
92 92
(...skipping 25 matching lines...) Expand all
118 Frame* activeFrame = activeWindow->frame(); 118 Frame* activeFrame = activeWindow->frame();
119 119
120 KURL completedURL = urlString.isEmpty() ? KURL(ParsedURLString, emptyString( )) : firstFrame->document()->completeURL(urlString); 120 KURL completedURL = urlString.isEmpty() ? KURL(ParsedURLString, emptyString( )) : firstFrame->document()->completeURL(urlString);
121 if (!completedURL.isEmpty() && !completedURL.isValid()) { 121 if (!completedURL.isEmpty() && !completedURL.isValid()) {
122 // Don't expose client code to invalid URLs. 122 // Don't expose client code to invalid URLs.
123 activeWindow->printErrorMessage("Unable to open a window with invalid UR L '" + completedURL.string() + "'.\n"); 123 activeWindow->printErrorMessage("Unable to open a window with invalid UR L '" + completedURL.string() + "'.\n");
124 return 0; 124 return 0;
125 } 125 }
126 126
127 // For whatever reason, Firefox uses the first frame to determine the outgoi ngReferrer. We replicate that behavior here. 127 // For whatever reason, Firefox uses the first frame to determine the outgoi ngReferrer. We replicate that behavior here.
128 String referrer = SecurityPolicy::generateReferrerHeader(firstFrame->documen t()->referrerPolicy(), completedURL, firstFrame->loader()->outgoingReferrer()); 128 String referrer = SecurityPolicy::generateReferrerHeader(firstFrame->documen t()->referrerPolicy(), completedURL, firstFrame->loader().outgoingReferrer());
129 129
130 ResourceRequest request(completedURL, referrer); 130 ResourceRequest request(completedURL, referrer);
131 FrameLoader::addHTTPOriginIfNeeded(request, firstFrame->loader()->outgoingOr igin()); 131 FrameLoader::addHTTPOriginIfNeeded(request, firstFrame->loader().outgoingOri gin());
132 FrameLoadRequest frameRequest(activeWindow->document()->securityOrigin(), re quest, frameName); 132 FrameLoadRequest frameRequest(activeWindow->document()->securityOrigin(), re quest, frameName);
133 133
134 // We pass the opener frame for the lookupFrame in case the active frame is different from 134 // We pass the opener frame for the lookupFrame in case the active frame is different from
135 // the opener frame, and the name references a frame relative to the opener frame. 135 // the opener frame, and the name references a frame relative to the opener frame.
136 bool created; 136 bool created;
137 Frame* newFrame = createWindow(activeFrame, openerFrame, frameRequest, windo wFeatures, created); 137 Frame* newFrame = createWindow(activeFrame, openerFrame, frameRequest, windo wFeatures, created);
138 if (!newFrame) 138 if (!newFrame)
139 return 0; 139 return 0;
140 140
141 newFrame->loader()->setOpener(openerFrame); 141 newFrame->loader().setOpener(openerFrame);
142 newFrame->page()->setOpenedByDOM(); 142 newFrame->page()->setOpenedByDOM();
143 143
144 if (newFrame->domWindow()->isInsecureScriptAccess(activeWindow, completedURL )) 144 if (newFrame->domWindow()->isInsecureScriptAccess(activeWindow, completedURL ))
145 return newFrame; 145 return newFrame;
146 146
147 if (function) 147 if (function)
148 function(newFrame->domWindow(), functionContext); 148 function(newFrame->domWindow(), functionContext);
149 149
150 if (created) { 150 if (created) {
151 FrameLoadRequest request(activeWindow->document()->securityOrigin(), Res ourceRequest(completedURL, referrer)); 151 FrameLoadRequest request(activeWindow->document()->securityOrigin(), Res ourceRequest(completedURL, referrer));
152 newFrame->loader()->load(request); 152 newFrame->loader().load(request);
153 } else if (!urlString.isEmpty()) { 153 } else if (!urlString.isEmpty()) {
154 newFrame->navigationScheduler().scheduleLocationChange(activeWindow->doc ument()->securityOrigin(), completedURL.string(), referrer, false); 154 newFrame->navigationScheduler().scheduleLocationChange(activeWindow->doc ument()->securityOrigin(), completedURL.string(), referrer, false);
155 } 155 }
156 return newFrame; 156 return newFrame;
157 } 157 }
158 158
159 } // namespace WebCore 159 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/loader/appcache/ApplicationCache.cpp ('k') | Source/core/page/DragController.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698