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

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: Made the setter method private 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
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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 : ScheduledNavigation(delay, lockBackForwardList, isLocationChange) 100 : ScheduledNavigation(delay, lockBackForwardList, isLocationChange)
101 , m_originDocument(originDocument) 101 , m_originDocument(originDocument)
102 , m_url(url) 102 , m_url(url)
103 , m_referrer(referrer) 103 , m_referrer(referrer)
104 { 104 {
105 } 105 }
106 106
107 virtual void fire(LocalFrame* frame) OVERRIDE 107 virtual void fire(LocalFrame* frame) OVERRIDE
108 { 108 {
109 OwnPtr<UserGestureIndicator> gestureIndicator = createUserGestureIndicat or(); 109 OwnPtr<UserGestureIndicator> gestureIndicator = createUserGestureIndicat or();
110 FrameLoadRequest request(m_originDocument.get(), ResourceRequest(KURL(Pa rsedURLString, m_url), m_referrer), "_self"); 110 ResourceRequest resourceRequest = ResourceRequest::createMainResourceReq uest(
111 KURL(ParsedURLString, m_url), frame->isMainFrame(), m_referrer);
112 FrameLoadRequest request(m_originDocument.get(), resourceRequest, "_self ");
111 request.setLockBackForwardList(lockBackForwardList()); 113 request.setLockBackForwardList(lockBackForwardList());
112 request.setClientRedirect(ClientRedirect); 114 request.setClientRedirect(ClientRedirect);
113 frame->loader().load(request); 115 frame->loader().load(request);
114 } 116 }
115 117
116 Document* originDocument() const { return m_originDocument.get(); } 118 Document* originDocument() const { return m_originDocument.get(); }
117 String url() const { return m_url; } 119 String url() const { return m_url; }
118 const Referrer& referrer() const { return m_referrer; } 120 const Referrer& referrer() const { return m_referrer; }
119 121
120 private: 122 private:
121 RefPtrWillBePersistent<Document> m_originDocument; 123 RefPtrWillBePersistent<Document> m_originDocument;
122 String m_url; 124 String m_url;
123 Referrer m_referrer; 125 Referrer m_referrer;
124 }; 126 };
125 127
126 class ScheduledRedirect FINAL : public ScheduledURLNavigation { 128 class ScheduledRedirect FINAL : public ScheduledURLNavigation {
127 public: 129 public:
128 ScheduledRedirect(double delay, Document* originDocument, const String& url, bool lockBackForwardList) 130 ScheduledRedirect(double delay, Document* originDocument, const String& url, bool lockBackForwardList)
129 : ScheduledURLNavigation(delay, originDocument, url, Referrer(), lockBac kForwardList, false) 131 : ScheduledURLNavigation(delay, originDocument, url, Referrer(), lockBac kForwardList, false)
130 { 132 {
131 clearUserGesture(); 133 clearUserGesture();
132 } 134 }
133 135
134 virtual bool shouldStartTimer(LocalFrame* frame) OVERRIDE { return frame->lo ader().allAncestorsAreComplete(); } 136 virtual bool shouldStartTimer(LocalFrame* frame) OVERRIDE { return frame->lo ader().allAncestorsAreComplete(); }
135 137
136 virtual void fire(LocalFrame* frame) OVERRIDE 138 virtual void fire(LocalFrame* frame) OVERRIDE
137 { 139 {
138 OwnPtr<UserGestureIndicator> gestureIndicator = createUserGestureIndicat or(); 140 OwnPtr<UserGestureIndicator> gestureIndicator = createUserGestureIndicat or();
139 FrameLoadRequest request(originDocument(), ResourceRequest(KURL(ParsedUR LString, url()), referrer()), "_self"); 141 ResourceRequest resourceRequest = ResourceRequest::createMainResourceReq uest(
142 KURL(ParsedURLString, url()), frame->isMainFrame(), referrer());
143 FrameLoadRequest request(originDocument(), resourceRequest, "_self");
140 request.setLockBackForwardList(lockBackForwardList()); 144 request.setLockBackForwardList(lockBackForwardList());
141 if (equalIgnoringFragmentIdentifier(frame->document()->url(), request.re sourceRequest().url())) 145 if (equalIgnoringFragmentIdentifier(frame->document()->url(), request.re sourceRequest().url()))
142 request.resourceRequest().setCachePolicy(ReloadIgnoringCacheData); 146 request.resourceRequest().setCachePolicy(ReloadIgnoringCacheData);
143 request.setClientRedirect(ClientRedirect); 147 request.setClientRedirect(ClientRedirect);
144 frame->loader().load(request); 148 frame->loader().load(request);
145 } 149 }
146 }; 150 };
147 151
148 class ScheduledLocationChange FINAL : public ScheduledURLNavigation { 152 class ScheduledLocationChange FINAL : public ScheduledURLNavigation {
149 public: 153 public:
150 ScheduledLocationChange(Document* originDocument, const String& url, const R eferrer& referrer, bool lockBackForwardList) 154 ScheduledLocationChange(Document* originDocument, const String& url, const R eferrer& referrer, bool lockBackForwardList)
151 : ScheduledURLNavigation(0.0, originDocument, url, referrer, lockBackFor wardList, true) { } 155 : ScheduledURLNavigation(0.0, originDocument, url, referrer, lockBackFor wardList, true) { }
152 }; 156 };
153 157
154 class ScheduledRefresh FINAL : public ScheduledURLNavigation { 158 class ScheduledRefresh FINAL : public ScheduledURLNavigation {
155 public: 159 public:
156 ScheduledRefresh(Document* originDocument, const String& url, const Referrer & referrer) 160 ScheduledRefresh(Document* originDocument, const String& url, const Referrer & referrer)
157 : ScheduledURLNavigation(0.0, originDocument, url, referrer, true, true) 161 : ScheduledURLNavigation(0.0, originDocument, url, referrer, true, true)
158 { 162 {
159 } 163 }
160 164
161 virtual void fire(LocalFrame* frame) OVERRIDE 165 virtual void fire(LocalFrame* frame) OVERRIDE
162 { 166 {
163 OwnPtr<UserGestureIndicator> gestureIndicator = createUserGestureIndicat or(); 167 OwnPtr<UserGestureIndicator> gestureIndicator = createUserGestureIndicat or();
164 FrameLoadRequest request(originDocument(), ResourceRequest(KURL(ParsedUR LString, url()), referrer(), ReloadIgnoringCacheData), "_self"); 168 ResourceRequest resourceRequest = ResourceRequest::createMainResourceReq uest(
169 KURL(ParsedURLString, url()), frame->isMainFrame(), referrer(), Relo adIgnoringCacheData);
170 FrameLoadRequest request(originDocument(), resourceRequest, "_self");
165 request.setLockBackForwardList(lockBackForwardList()); 171 request.setLockBackForwardList(lockBackForwardList());
166 request.setClientRedirect(ClientRedirect); 172 request.setClientRedirect(ClientRedirect);
167 frame->loader().load(request); 173 frame->loader().load(request);
168 } 174 }
169 }; 175 };
170 176
171 class ScheduledHistoryNavigation FINAL : public ScheduledNavigation { 177 class ScheduledHistoryNavigation FINAL : public ScheduledNavigation {
172 public: 178 public:
173 explicit ScheduledHistoryNavigation(int historySteps) 179 explicit ScheduledHistoryNavigation(int historySteps)
174 : ScheduledNavigation(0, false, true) 180 : ScheduledNavigation(0, false, true)
175 , m_historySteps(historySteps) 181 , m_historySteps(historySteps)
176 { 182 {
177 } 183 }
178 184
179 virtual void fire(LocalFrame* frame) OVERRIDE 185 virtual void fire(LocalFrame* frame) OVERRIDE
180 { 186 {
181 OwnPtr<UserGestureIndicator> gestureIndicator = createUserGestureIndicat or(); 187 OwnPtr<UserGestureIndicator> gestureIndicator = createUserGestureIndicat or();
182 188
183 if (!m_historySteps) { 189 if (!m_historySteps) {
184 FrameLoadRequest frameRequest(frame->document(), ResourceRequest(fra me->document()->url())); 190 ResourceRequest resourceRequest = ResourceRequest::createMainResourc eRequest(
191 frame->document()->url(), frame->isMainFrame());
192 FrameLoadRequest frameRequest(frame->document(), resourceRequest);
185 frameRequest.setLockBackForwardList(lockBackForwardList()); 193 frameRequest.setLockBackForwardList(lockBackForwardList());
186 // Special case for go(0) from a frame -> reload only the frame 194 // Special case for go(0) from a frame -> reload only the frame
187 // To follow Firefox and IE's behavior, history reload can only navi gate the self frame. 195 // To follow Firefox and IE's behavior, history reload can only navi gate the self frame.
188 frame->loader().load(frameRequest); 196 frame->loader().load(frameRequest);
189 return; 197 return;
190 } 198 }
191 // go(i!=0) from a frame navigates into the history of the frame only, 199 // go(i!=0) from a frame navigates into the history of the frame only,
192 // in both IE and NS (but not in Mozilla). We can't easily do that. 200 // in both IE and NS (but not in Mozilla). We can't easily do that.
193 frame->page()->deprecatedLocalMainFrame()->loader().client()->navigateBa ckForward(m_historySteps); 201 frame->page()->deprecatedLocalMainFrame()->loader().client()->navigateBa ckForward(m_historySteps);
194 } 202 }
195 203
196 private: 204 private:
197 int m_historySteps; 205 int m_historySteps;
198 }; 206 };
199 207
200 class ScheduledFormSubmission FINAL : public ScheduledNavigation { 208 class ScheduledFormSubmission FINAL : public ScheduledNavigation {
201 public: 209 public:
202 ScheduledFormSubmission(PassRefPtrWillBeRawPtr<FormSubmission> submission, b ool lockBackForwardList) 210 ScheduledFormSubmission(PassRefPtrWillBeRawPtr<FormSubmission> submission, b ool lockBackForwardList)
203 : ScheduledNavigation(0, lockBackForwardList, true) 211 : ScheduledNavigation(0, lockBackForwardList, true)
204 , m_submission(submission) 212 , m_submission(submission)
205 { 213 {
206 ASSERT(m_submission->state()); 214 ASSERT(m_submission->state());
207 } 215 }
208 216
209 virtual void fire(LocalFrame* frame) OVERRIDE 217 virtual void fire(LocalFrame* frame) OVERRIDE
210 { 218 {
211 OwnPtr<UserGestureIndicator> gestureIndicator = createUserGestureIndicat or(); 219 OwnPtr<UserGestureIndicator> gestureIndicator = createUserGestureIndicat or();
212 FrameLoadRequest frameRequest(m_submission->state()->sourceDocument()); 220 ResourceRequest resourceRequest = ResourceRequest::createMainResourceReq uest(
221 blankURL(), frame->isMainFrame());
222 FrameLoadRequest frameRequest(m_submission->state()->sourceDocument(), r esourceRequest);
213 m_submission->populateFrameLoadRequest(frameRequest); 223 m_submission->populateFrameLoadRequest(frameRequest);
214 frameRequest.setLockBackForwardList(lockBackForwardList()); 224 frameRequest.setLockBackForwardList(lockBackForwardList());
215 frameRequest.setTriggeringEvent(m_submission->event()); 225 frameRequest.setTriggeringEvent(m_submission->event());
216 frameRequest.setFormState(m_submission->state()); 226 frameRequest.setFormState(m_submission->state());
217 frame->loader().load(frameRequest); 227 frame->loader().load(frameRequest);
218 } 228 }
219 229
220 virtual bool isForm() const OVERRIDE { return true; } 230 virtual bool isForm() const OVERRIDE { return true; }
221 FormSubmission* submission() const { return m_submission.get(); } 231 FormSubmission* submission() const { return m_submission.get(); }
222 232
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 312
303 lockBackForwardList = lockBackForwardList || mustLockBackForwardList(m_frame ); 313 lockBackForwardList = lockBackForwardList || mustLockBackForwardList(m_frame );
304 314
305 // If the URL we're going to navigate to is the same as the current one, exc ept for the 315 // If the URL we're going to navigate to is the same as the current one, exc ept for the
306 // fragment part, we don't need to schedule the location change. We'll skip this 316 // fragment part, we don't need to schedule the location change. We'll skip this
307 // optimization for cross-origin navigations to minimize the navigator's abi lity to 317 // optimization for cross-origin navigations to minimize the navigator's abi lity to
308 // execute timing attacks. 318 // execute timing attacks.
309 if (originDocument->securityOrigin()->canAccess(m_frame->document()->securit yOrigin())) { 319 if (originDocument->securityOrigin()->canAccess(m_frame->document()->securit yOrigin())) {
310 KURL parsedURL(ParsedURLString, url); 320 KURL parsedURL(ParsedURLString, url);
311 if (parsedURL.hasFragmentIdentifier() && equalIgnoringFragmentIdentifier (m_frame->document()->url(), parsedURL)) { 321 if (parsedURL.hasFragmentIdentifier() && equalIgnoringFragmentIdentifier (m_frame->document()->url(), parsedURL)) {
312 FrameLoadRequest request(originDocument, ResourceRequest(m_frame->do cument()->completeURL(url), referrer), "_self"); 322 ResourceRequest resourceRequest = ResourceRequest::createMainResourc eRequest(
323 m_frame->document()->completeURL(url), m_frame->isMainFrame(), r eferrer);
324 FrameLoadRequest request(originDocument, resourceRequest, "_self");
313 request.setLockBackForwardList(lockBackForwardList); 325 request.setLockBackForwardList(lockBackForwardList);
314 if (lockBackForwardList) 326 if (lockBackForwardList)
315 request.setClientRedirect(ClientRedirect); 327 request.setClientRedirect(ClientRedirect);
316 m_frame->loader().load(request); 328 m_frame->loader().load(request);
317 return; 329 return;
318 } 330 }
319 } 331 }
320 332
321 schedule(adoptPtr(new ScheduledLocationChange(originDocument, url, referrer, lockBackForwardList))); 333 schedule(adoptPtr(new ScheduledLocationChange(originDocument, url, referrer, lockBackForwardList)));
322 } 334 }
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 420
409 void NavigationScheduler::cancel() 421 void NavigationScheduler::cancel()
410 { 422 {
411 if (m_timer.isActive()) 423 if (m_timer.isActive())
412 InspectorInstrumentation::frameClearedScheduledNavigation(m_frame); 424 InspectorInstrumentation::frameClearedScheduledNavigation(m_frame);
413 m_timer.stop(); 425 m_timer.stop();
414 m_redirect.clear(); 426 m_redirect.clear();
415 } 427 }
416 428
417 } // namespace WebCore 429 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698