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

Side by Side Diff: chrome/browser/renderer_host/cross_site_resource_handler.cc

Issue 7276: Adding security info to canceled requests (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 10 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
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <string>
6
5 #include "chrome/browser/renderer_host/cross_site_resource_handler.h" 7 #include "chrome/browser/renderer_host/cross_site_resource_handler.h"
6 8
7 #include "chrome/browser/renderer_host/render_view_host.h" 9 #include "chrome/browser/renderer_host/render_view_host.h"
8 #include "chrome/browser/tab_contents/tab_util.h" 10 #include "chrome/browser/tab_contents/tab_util.h"
9 #include "chrome/browser/tab_contents/web_contents.h" 11 #include "chrome/browser/tab_contents/web_contents.h"
10 12
11 namespace { 13 namespace {
12 // Task to notify the WebContents that a cross-site response has begun, so that 14 // Task to notify the WebContents that a cross-site response has begun, so that
13 // WebContents can tell the old page to run its onunload handler. 15 // WebContents can tell the old page to run its onunload handler.
14 class CrossSiteNotifyTabTask : public Task { 16 class CrossSiteNotifyTabTask : public Task {
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 bool CrossSiteResourceHandler::OnReadCompleted(int request_id, 124 bool CrossSiteResourceHandler::OnReadCompleted(int request_id,
123 int* bytes_read) { 125 int* bytes_read) {
124 if (!in_cross_site_transition_) { 126 if (!in_cross_site_transition_) {
125 return next_handler_->OnReadCompleted(request_id, bytes_read); 127 return next_handler_->OnReadCompleted(request_id, bytes_read);
126 } 128 }
127 return true; 129 return true;
128 } 130 }
129 131
130 bool CrossSiteResourceHandler::OnResponseCompleted( 132 bool CrossSiteResourceHandler::OnResponseCompleted(
131 int request_id, 133 int request_id,
132 const URLRequestStatus& status) { 134 const URLRequestStatus& status,
135 const std::string& security_info) {
133 if (!in_cross_site_transition_) { 136 if (!in_cross_site_transition_) {
134 if (has_started_response_) { 137 if (has_started_response_) {
135 // We've already completed the transition, so just pass it through. 138 // We've already completed the transition, so just pass it through.
136 return next_handler_->OnResponseCompleted(request_id, status); 139 return next_handler_->OnResponseCompleted(request_id, status,
140 security_info);
137 } else { 141 } else {
138 // Some types of failures will call OnResponseCompleted without calling 142 // Some types of failures will call OnResponseCompleted without calling
139 // CrossSiteResourceHandler::OnResponseStarted. 143 // CrossSiteResourceHandler::OnResponseStarted.
140 if (status.status() == URLRequestStatus::CANCELED) { 144 if (status.status() == URLRequestStatus::CANCELED) {
141 // Here the request was canceled, which happens when selecting "take me 145 // Here the request was canceled, which happens when selecting "take me
142 // back" from an interstitial. Nothing to do but cancel the pending 146 // back" from an interstitial. Nothing to do but cancel the pending
143 // render view host. 147 // render view host.
144 CancelPendingRenderViewTask* task = 148 CancelPendingRenderViewTask* task =
145 new CancelPendingRenderViewTask(render_process_host_id_, 149 new CancelPendingRenderViewTask(render_process_host_id_,
146 render_view_id_); 150 render_view_id_);
147 rdh_->ui_loop()->PostTask(FROM_HERE, task); 151 rdh_->ui_loop()->PostTask(FROM_HERE, task);
148 return next_handler_->OnResponseCompleted(request_id, status); 152 return next_handler_->OnResponseCompleted(request_id, status,
153 security_info);
149 } else { 154 } else {
150 // An error occured, we should wait now for the cross-site transition, 155 // An error occured, we should wait now for the cross-site transition,
151 // so that the error message (e.g., 404) can be displayed to the user. 156 // so that the error message (e.g., 404) can be displayed to the user.
152 // Also continue with the logic below to remember that we completed 157 // Also continue with the logic below to remember that we completed
153 // during the cross-site transition. 158 // during the cross-site transition.
154 ResourceDispatcherHost::GlobalRequestID global_id( 159 ResourceDispatcherHost::GlobalRequestID global_id(
155 render_process_host_id_, request_id); 160 render_process_host_id_, request_id);
156 StartCrossSiteTransition(request_id, NULL, global_id); 161 StartCrossSiteTransition(request_id, NULL, global_id);
157 } 162 }
158 } 163 }
159 } 164 }
160 165
161 // We have to buffer the call until after the transition completes. 166 // We have to buffer the call until after the transition completes.
162 completed_during_transition_ = true; 167 completed_during_transition_ = true;
163 completed_status_ = status; 168 completed_status_ = status;
169 completed_security_info_ = security_info;
164 170
165 // Return false to tell RDH not to notify the world or clean up the 171 // Return false to tell RDH not to notify the world or clean up the
166 // pending request. We will do so in ResumeResponse. 172 // pending request. We will do so in ResumeResponse.
167 return false; 173 return false;
168 } 174 }
169 175
170 // We can now send the response to the new renderer, which will cause 176 // We can now send the response to the new renderer, which will cause
171 // WebContents to swap in the new renderer and destroy the old one. 177 // WebContents to swap in the new renderer and destroy the old one.
172 void CrossSiteResourceHandler::ResumeResponse() { 178 void CrossSiteResourceHandler::ResumeResponse() {
173 DCHECK(request_id_ != -1); 179 DCHECK(request_id_ != -1);
(...skipping 20 matching lines...) Expand all
194 // directed toward the new renderer. 200 // directed toward the new renderer.
195 rdh_->PauseRequest(render_process_host_id_, request_id_, false); 201 rdh_->PauseRequest(render_process_host_id_, request_id_, false);
196 } 202 }
197 203
198 // Remove ourselves from the ExtraRequestInfo. 204 // Remove ourselves from the ExtraRequestInfo.
199 info->cross_site_handler = NULL; 205 info->cross_site_handler = NULL;
200 206
201 // If the response completed during the transition, notify the next 207 // If the response completed during the transition, notify the next
202 // event handler. 208 // event handler.
203 if (completed_during_transition_) { 209 if (completed_during_transition_) {
204 next_handler_->OnResponseCompleted(request_id_, completed_status_); 210 next_handler_->OnResponseCompleted(request_id_, completed_status_,
211 completed_security_info_);
205 212
206 // Since we didn't notify the world or clean up the pending request in 213 // Since we didn't notify the world or clean up the pending request in
207 // RDH::OnResponseCompleted during the transition, we should do it now. 214 // RDH::OnResponseCompleted during the transition, we should do it now.
208 rdh_->NotifyResponseCompleted(request, render_process_host_id_); 215 rdh_->NotifyResponseCompleted(request, render_process_host_id_);
209 rdh_->RemovePendingRequest(render_process_host_id_, request_id_); 216 rdh_->RemovePendingRequest(render_process_host_id_, request_id_);
210 } 217 }
211 } 218 }
212 219
213 // Prepare to render the cross-site response in a new RenderViewHost, by 220 // Prepare to render the cross-site response in a new RenderViewHost, by
214 // telling the old RenderViewHost to run its onunload handler. 221 // telling the old RenderViewHost to run its onunload handler.
(...skipping 27 matching lines...) Expand all
242 249
243 // Tell the tab responsible for this request that a cross-site response is 250 // Tell the tab responsible for this request that a cross-site response is
244 // starting, so that it can tell its old renderer to run its onunload 251 // starting, so that it can tell its old renderer to run its onunload
245 // handler now. We will wait to hear the corresponding ClosePage_ACK. 252 // handler now. We will wait to hear the corresponding ClosePage_ACK.
246 CrossSiteNotifyTabTask* task = 253 CrossSiteNotifyTabTask* task =
247 new CrossSiteNotifyTabTask(render_process_host_id_, 254 new CrossSiteNotifyTabTask(render_process_host_id_,
248 render_view_id_, 255 render_view_id_,
249 request_id); 256 request_id);
250 rdh_->ui_loop()->PostTask(FROM_HERE, task); 257 rdh_->ui_loop()->PostTask(FROM_HERE, task);
251 } 258 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698