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

Side by Side Diff: Source/core/loader/NavigationScheduler.cpp

Issue 339593005: Set the target type when creating the request for main resource (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Switched to constructors Created 6 years, 6 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
« no previous file with comments | « Source/core/loader/FrameLoader.cpp ('k') | Source/core/page/CreateWindow.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, 2009, 2010 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved.
3 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) 3 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
4 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/) 4 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/)
5 * Copyright (C) 2009 Adam Barth. All rights reserved. 5 * Copyright (C) 2009 Adam Barth. All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 10 *
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 , m_referrer(referrer) 105 , m_referrer(referrer)
106 , m_shouldCheckMainWorldContentSecurityPolicy(CheckContentSecurityPolicy ) 106 , m_shouldCheckMainWorldContentSecurityPolicy(CheckContentSecurityPolicy )
107 { 107 {
108 if (ContentSecurityPolicy::shouldBypassMainWorld(originDocument)) 108 if (ContentSecurityPolicy::shouldBypassMainWorld(originDocument))
109 m_shouldCheckMainWorldContentSecurityPolicy = DoNotCheckContentSecur ityPolicy; 109 m_shouldCheckMainWorldContentSecurityPolicy = DoNotCheckContentSecur ityPolicy;
110 } 110 }
111 111
112 virtual void fire(LocalFrame* frame) OVERRIDE 112 virtual void fire(LocalFrame* frame) OVERRIDE
113 { 113 {
114 OwnPtr<UserGestureIndicator> gestureIndicator = createUserGestureIndicat or(); 114 OwnPtr<UserGestureIndicator> gestureIndicator = createUserGestureIndicat or();
115 FrameLoadRequest request(m_originDocument.get(), ResourceRequest(KURL(Pa rsedURLString, m_url), m_referrer), "_self", m_shouldCheckMainWorldContentSecuri tyPolicy); 115 ResourceRequest resourceRequest = ResourceRequest(KURL(ParsedURLString, m_url), frame->isMainFrame(), m_referrer);
116 FrameLoadRequest request(m_originDocument.get(), resourceRequest, "_self ", m_shouldCheckMainWorldContentSecurityPolicy);
116 request.setLockBackForwardList(lockBackForwardList()); 117 request.setLockBackForwardList(lockBackForwardList());
117 request.setClientRedirect(ClientRedirect); 118 request.setClientRedirect(ClientRedirect);
118 frame->loader().load(request); 119 frame->loader().load(request);
119 } 120 }
120 121
121 Document* originDocument() const { return m_originDocument.get(); } 122 Document* originDocument() const { return m_originDocument.get(); }
122 String url() const { return m_url; } 123 String url() const { return m_url; }
123 const Referrer& referrer() const { return m_referrer; } 124 const Referrer& referrer() const { return m_referrer; }
124 125
125 private: 126 private:
126 RefPtrWillBePersistent<Document> m_originDocument; 127 RefPtrWillBePersistent<Document> m_originDocument;
127 String m_url; 128 String m_url;
128 Referrer m_referrer; 129 Referrer m_referrer;
129 ContentSecurityPolicyCheck m_shouldCheckMainWorldContentSecurityPolicy; 130 ContentSecurityPolicyCheck m_shouldCheckMainWorldContentSecurityPolicy;
130 }; 131 };
131 132
132 class ScheduledRedirect FINAL : public ScheduledURLNavigation { 133 class ScheduledRedirect FINAL : public ScheduledURLNavigation {
133 public: 134 public:
134 ScheduledRedirect(double delay, Document* originDocument, const String& url, bool lockBackForwardList) 135 ScheduledRedirect(double delay, Document* originDocument, const String& url, bool lockBackForwardList)
135 : ScheduledURLNavigation(delay, originDocument, url, Referrer(), lockBac kForwardList, false) 136 : ScheduledURLNavigation(delay, originDocument, url, Referrer(), lockBac kForwardList, false)
136 { 137 {
137 clearUserGesture(); 138 clearUserGesture();
138 } 139 }
139 140
140 virtual bool shouldStartTimer(LocalFrame* frame) OVERRIDE { return frame->lo ader().allAncestorsAreComplete(); } 141 virtual bool shouldStartTimer(LocalFrame* frame) OVERRIDE { return frame->lo ader().allAncestorsAreComplete(); }
141 142
142 virtual void fire(LocalFrame* frame) OVERRIDE 143 virtual void fire(LocalFrame* frame) OVERRIDE
143 { 144 {
144 OwnPtr<UserGestureIndicator> gestureIndicator = createUserGestureIndicat or(); 145 OwnPtr<UserGestureIndicator> gestureIndicator = createUserGestureIndicat or();
145 FrameLoadRequest request(originDocument(), ResourceRequest(KURL(ParsedUR LString, url()), referrer()), "_self"); 146 ResourceRequest resourceRequest = ResourceRequest(KURL(ParsedURLString, url()), frame->isMainFrame(), referrer());
147 FrameLoadRequest request(originDocument(), resourceRequest, "_self");
146 request.setLockBackForwardList(lockBackForwardList()); 148 request.setLockBackForwardList(lockBackForwardList());
147 if (equalIgnoringFragmentIdentifier(frame->document()->url(), request.re sourceRequest().url())) 149 if (equalIgnoringFragmentIdentifier(frame->document()->url(), request.re sourceRequest().url()))
148 request.resourceRequest().setCachePolicy(ReloadIgnoringCacheData); 150 request.resourceRequest().setCachePolicy(ReloadIgnoringCacheData);
149 request.setClientRedirect(ClientRedirect); 151 request.setClientRedirect(ClientRedirect);
150 frame->loader().load(request); 152 frame->loader().load(request);
151 } 153 }
152 }; 154 };
153 155
154 class ScheduledLocationChange FINAL : public ScheduledURLNavigation { 156 class ScheduledLocationChange FINAL : public ScheduledURLNavigation {
155 public: 157 public:
156 ScheduledLocationChange(Document* originDocument, const String& url, const R eferrer& referrer, bool lockBackForwardList) 158 ScheduledLocationChange(Document* originDocument, const String& url, const R eferrer& referrer, bool lockBackForwardList)
157 : ScheduledURLNavigation(0.0, originDocument, url, referrer, lockBackFor wardList, true) { } 159 : ScheduledURLNavigation(0.0, originDocument, url, referrer, lockBackFor wardList, true) { }
158 }; 160 };
159 161
160 class ScheduledRefresh FINAL : public ScheduledURLNavigation { 162 class ScheduledRefresh FINAL : public ScheduledURLNavigation {
161 public: 163 public:
162 ScheduledRefresh(Document* originDocument, const String& url, const Referrer & referrer) 164 ScheduledRefresh(Document* originDocument, const String& url, const Referrer & referrer)
163 : ScheduledURLNavigation(0.0, originDocument, url, referrer, true, true) 165 : ScheduledURLNavigation(0.0, originDocument, url, referrer, true, true)
164 { 166 {
165 } 167 }
166 168
167 virtual void fire(LocalFrame* frame) OVERRIDE 169 virtual void fire(LocalFrame* frame) OVERRIDE
168 { 170 {
169 OwnPtr<UserGestureIndicator> gestureIndicator = createUserGestureIndicat or(); 171 OwnPtr<UserGestureIndicator> gestureIndicator = createUserGestureIndicat or();
170 FrameLoadRequest request(originDocument(), ResourceRequest(KURL(ParsedUR LString, url()), referrer(), ReloadIgnoringCacheData), "_self"); 172 ResourceRequest resourceRequest = ResourceRequest(KURL(ParsedURLString, url()), frame->isMainFrame(), referrer(), ReloadIgnoringCacheData);
173 FrameLoadRequest request(originDocument(), resourceRequest, "_self");
171 request.setLockBackForwardList(lockBackForwardList()); 174 request.setLockBackForwardList(lockBackForwardList());
172 request.setClientRedirect(ClientRedirect); 175 request.setClientRedirect(ClientRedirect);
173 frame->loader().load(request); 176 frame->loader().load(request);
174 } 177 }
175 }; 178 };
176 179
177 class ScheduledHistoryNavigation FINAL : public ScheduledNavigation { 180 class ScheduledHistoryNavigation FINAL : public ScheduledNavigation {
178 public: 181 public:
179 explicit ScheduledHistoryNavigation(int historySteps) 182 explicit ScheduledHistoryNavigation(int historySteps)
180 : ScheduledNavigation(0, false, true) 183 : ScheduledNavigation(0, false, true)
181 , m_historySteps(historySteps) 184 , m_historySteps(historySteps)
182 { 185 {
183 } 186 }
184 187
185 virtual void fire(LocalFrame* frame) OVERRIDE 188 virtual void fire(LocalFrame* frame) OVERRIDE
186 { 189 {
187 OwnPtr<UserGestureIndicator> gestureIndicator = createUserGestureIndicat or(); 190 OwnPtr<UserGestureIndicator> gestureIndicator = createUserGestureIndicat or();
188 191
189 if (!m_historySteps) { 192 if (!m_historySteps) {
190 FrameLoadRequest frameRequest(frame->document(), ResourceRequest(fra me->document()->url())); 193 ResourceRequest resourceRequest = ResourceRequest(frame->document()- >url(), frame->isMainFrame());
194 FrameLoadRequest frameRequest(frame->document(), resourceRequest);
191 frameRequest.setLockBackForwardList(lockBackForwardList()); 195 frameRequest.setLockBackForwardList(lockBackForwardList());
192 // Special case for go(0) from a frame -> reload only the frame 196 // Special case for go(0) from a frame -> reload only the frame
193 // To follow Firefox and IE's behavior, history reload can only navi gate the self frame. 197 // To follow Firefox and IE's behavior, history reload can only navi gate the self frame.
194 frame->loader().load(frameRequest); 198 frame->loader().load(frameRequest);
195 return; 199 return;
196 } 200 }
197 // go(i!=0) from a frame navigates into the history of the frame only, 201 // go(i!=0) from a frame navigates into the history of the frame only,
198 // in both IE and NS (but not in Mozilla). We can't easily do that. 202 // in both IE and NS (but not in Mozilla). We can't easily do that.
199 frame->page()->deprecatedLocalMainFrame()->loader().client()->navigateBa ckForward(m_historySteps); 203 frame->page()->deprecatedLocalMainFrame()->loader().client()->navigateBa ckForward(m_historySteps);
200 } 204 }
201 205
202 private: 206 private:
203 int m_historySteps; 207 int m_historySteps;
204 }; 208 };
205 209
206 class ScheduledFormSubmission FINAL : public ScheduledNavigation { 210 class ScheduledFormSubmission FINAL : public ScheduledNavigation {
207 public: 211 public:
208 ScheduledFormSubmission(PassRefPtrWillBeRawPtr<FormSubmission> submission, b ool lockBackForwardList) 212 ScheduledFormSubmission(PassRefPtrWillBeRawPtr<FormSubmission> submission, b ool lockBackForwardList)
209 : ScheduledNavigation(0, lockBackForwardList, true) 213 : ScheduledNavigation(0, lockBackForwardList, true)
210 , m_submission(submission) 214 , m_submission(submission)
211 { 215 {
212 ASSERT(m_submission->state()); 216 ASSERT(m_submission->state());
213 } 217 }
214 218
215 virtual void fire(LocalFrame* frame) OVERRIDE 219 virtual void fire(LocalFrame* frame) OVERRIDE
216 { 220 {
217 OwnPtr<UserGestureIndicator> gestureIndicator = createUserGestureIndicat or(); 221 OwnPtr<UserGestureIndicator> gestureIndicator = createUserGestureIndicat or();
218 FrameLoadRequest frameRequest(m_submission->state()->sourceDocument()); 222 ResourceRequest resourceRequest = ResourceRequest(blankURL(), frame->isM ainFrame());
223 FrameLoadRequest frameRequest(m_submission->state()->sourceDocument(), r esourceRequest);
219 m_submission->populateFrameLoadRequest(frameRequest); 224 m_submission->populateFrameLoadRequest(frameRequest);
220 frameRequest.setLockBackForwardList(lockBackForwardList()); 225 frameRequest.setLockBackForwardList(lockBackForwardList());
221 frameRequest.setTriggeringEvent(m_submission->event()); 226 frameRequest.setTriggeringEvent(m_submission->event());
222 frameRequest.setFormState(m_submission->state()); 227 frameRequest.setFormState(m_submission->state());
223 frame->loader().load(frameRequest); 228 frame->loader().load(frameRequest);
224 } 229 }
225 230
226 virtual bool isForm() const OVERRIDE { return true; } 231 virtual bool isForm() const OVERRIDE { return true; }
227 FormSubmission* submission() const { return m_submission.get(); } 232 FormSubmission* submission() const { return m_submission.get(); }
228 233
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 313
309 lockBackForwardList = lockBackForwardList || mustLockBackForwardList(m_frame ); 314 lockBackForwardList = lockBackForwardList || mustLockBackForwardList(m_frame );
310 315
311 // If the URL we're going to navigate to is the same as the current one, exc ept for the 316 // If the URL we're going to navigate to is the same as the current one, exc ept for the
312 // fragment part, we don't need to schedule the location change. We'll skip this 317 // fragment part, we don't need to schedule the location change. We'll skip this
313 // optimization for cross-origin navigations to minimize the navigator's abi lity to 318 // optimization for cross-origin navigations to minimize the navigator's abi lity to
314 // execute timing attacks. 319 // execute timing attacks.
315 if (originDocument->securityOrigin()->canAccess(m_frame->document()->securit yOrigin())) { 320 if (originDocument->securityOrigin()->canAccess(m_frame->document()->securit yOrigin())) {
316 KURL parsedURL(ParsedURLString, url); 321 KURL parsedURL(ParsedURLString, url);
317 if (parsedURL.hasFragmentIdentifier() && equalIgnoringFragmentIdentifier (m_frame->document()->url(), parsedURL)) { 322 if (parsedURL.hasFragmentIdentifier() && equalIgnoringFragmentIdentifier (m_frame->document()->url(), parsedURL)) {
318 FrameLoadRequest request(originDocument, ResourceRequest(m_frame->do cument()->completeURL(url), referrer), "_self"); 323 ResourceRequest resourceRequest = ResourceRequest(m_frame->document( )->completeURL(url), m_frame->isMainFrame(), referrer);
324 FrameLoadRequest request(originDocument, resourceRequest, "_self");
319 request.setLockBackForwardList(lockBackForwardList); 325 request.setLockBackForwardList(lockBackForwardList);
320 if (lockBackForwardList) 326 if (lockBackForwardList)
321 request.setClientRedirect(ClientRedirect); 327 request.setClientRedirect(ClientRedirect);
322 m_frame->loader().load(request); 328 m_frame->loader().load(request);
323 return; 329 return;
324 } 330 }
325 } 331 }
326 332
327 schedule(adoptPtr(new ScheduledLocationChange(originDocument, url, referrer, lockBackForwardList))); 333 schedule(adoptPtr(new ScheduledLocationChange(originDocument, url, referrer, lockBackForwardList)));
328 } 334 }
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 420
415 void NavigationScheduler::cancel() 421 void NavigationScheduler::cancel()
416 { 422 {
417 if (m_timer.isActive()) 423 if (m_timer.isActive())
418 InspectorInstrumentation::frameClearedScheduledNavigation(m_frame); 424 InspectorInstrumentation::frameClearedScheduledNavigation(m_frame);
419 m_timer.stop(); 425 m_timer.stop();
420 m_redirect.clear(); 426 m_redirect.clear();
421 } 427 }
422 428
423 } // namespace WebCore 429 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/loader/FrameLoader.cpp ('k') | Source/core/page/CreateWindow.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698