OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome_frame/npapi_url_request.h" | 5 #include "chrome_frame/npapi_url_request.h" |
6 | 6 |
7 #include "base/string_number_conversions.h" | 7 #include "base/string_number_conversions.h" |
8 #include "base/threading/platform_thread.h" | 8 #include "base/threading/platform_thread.h" |
9 #include "chrome_frame/chrome_frame_npapi.h" | |
9 #include "chrome_frame/np_browser_functions.h" | 10 #include "chrome_frame/np_browser_functions.h" |
10 #include "chrome_frame/np_utils.h" | 11 #include "chrome_frame/np_utils.h" |
11 #include "net/base/net_errors.h" | 12 #include "net/base/net_errors.h" |
12 | 13 |
13 class NPAPIUrlRequest : public PluginUrlRequest { | 14 class NPAPIUrlRequest : public PluginUrlRequest { |
14 public: | 15 public: |
15 explicit NPAPIUrlRequest(NPP instance); | 16 explicit NPAPIUrlRequest(NPP instance); |
16 ~NPAPIUrlRequest(); | 17 ~NPAPIUrlRequest(); |
17 | 18 |
18 virtual bool Start(); | 19 virtual bool Start(); |
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
363 return NPERR_NO_ERROR; | 364 return NPERR_NO_ERROR; |
364 | 365 |
365 // This stream is being constructed for a request that has already been | 366 // This stream is being constructed for a request that has already been |
366 // canceled. Signal its immediate termination. | 367 // canceled. Signal its immediate termination. |
367 if (net::URLRequestStatus::CANCELED == request->status().status()) { | 368 if (net::URLRequestStatus::CANCELED == request->status().status()) { |
368 return npapi::DestroyStream(request->instance(), | 369 return npapi::DestroyStream(request->instance(), |
369 stream, NPRES_USER_BREAK); | 370 stream, NPRES_USER_BREAK); |
370 } | 371 } |
371 | 372 |
372 DCHECK(request_map_.find(request->id()) != request_map_.end()); | 373 DCHECK(request_map_.find(request->id()) != request_map_.end()); |
374 | |
375 // If the host browser does not support the NPAPI redirect notification | |
376 // spec, and if the request URL is implicitly redirected, we need to | |
377 // inform Chrome about the redirect and allow it to follow the redirect. | |
378 // We achieve this by comparing the URL requested with the URL received in | |
379 // the response and if they don't match we assume a redirect. This would have | |
380 // a sideffect that two GET requests would be sent out in this case. | |
381 if (!BrowserSupportsRedirectNotification()) { | |
382 if (GURL(request->url().c_str()) != GURL(stream->url)) { | |
383 DVLOG(1) << "Request URL:" | |
384 << request->url() | |
385 << " was redirected to:" | |
386 << stream->url; | |
387 delegate_->OnResponseStarted(request->id(), "", "", 0, base::Time(), | |
388 stream->url, 302); | |
389 return NPERR_GENERIC_ERROR; | |
Sigurður Ásgeirsson
2011/01/20 21:39:36
do you need to destroy the stream with npapi::Dest
ananta
2011/01/20 22:52:00
No. The host should destroy the stream on receivin
| |
390 } | |
391 } | |
373 // We need to return the requested stream mode if we are returning a success | 392 // We need to return the requested stream mode if we are returning a success |
374 // code. If we don't do this it causes Opera to blow up. | 393 // code. If we don't do this it causes Opera to blow up. |
375 *stream_type = NP_NORMAL; | 394 *stream_type = NP_NORMAL; |
376 return request->OnStreamCreated(type, stream); | 395 return request->OnStreamCreated(type, stream); |
377 } | 396 } |
378 | 397 |
379 int32 NPAPIUrlRequestManager::WriteReady(NPStream* stream) { | 398 int32 NPAPIUrlRequestManager::WriteReady(NPStream* stream) { |
380 NPAPIUrlRequest* request = RequestFromNotifyData(stream->notifyData); | 399 NPAPIUrlRequest* request = RequestFromNotifyData(stream->notifyData); |
381 if (!request) | 400 if (!request) |
382 return 0x7FFFFFFF; | 401 return 0x7FFFFFFF; |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
431 } | 450 } |
432 } | 451 } |
433 | 452 |
434 scoped_refptr<NPAPIUrlRequest> NPAPIUrlRequestManager::LookupRequest( | 453 scoped_refptr<NPAPIUrlRequest> NPAPIUrlRequestManager::LookupRequest( |
435 int request_id) { | 454 int request_id) { |
436 RequestMap::iterator index = request_map_.find(request_id); | 455 RequestMap::iterator index = request_map_.find(request_id); |
437 if (index != request_map_.end()) | 456 if (index != request_map_.end()) |
438 return index->second; | 457 return index->second; |
439 return NULL; | 458 return NULL; |
440 } | 459 } |
OLD | NEW |