OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome_frame/plugin_url_request.h" |
| 6 |
| 7 #include "chrome/test/automation/automation_messages.h" |
| 8 #include "chrome_frame/np_browser_functions.h" |
| 9 |
| 10 PluginUrlRequest::PluginUrlRequest() |
| 11 : request_handler_(NULL), tab_(0), remote_request_id_(0), |
| 12 status_(URLRequestStatus::IO_PENDING), |
| 13 frame_busting_enabled_(false) { |
| 14 } |
| 15 |
| 16 PluginUrlRequest::~PluginUrlRequest() { |
| 17 } |
| 18 |
| 19 bool PluginUrlRequest::Initialize(PluginRequestHandler* request_handler, |
| 20 int tab, int remote_request_id, const std::string& url, |
| 21 const std::string& method, const std::string& referrer, |
| 22 const std::string& extra_headers, net::UploadData* upload_data, |
| 23 bool enable_frame_busting) { |
| 24 request_handler_ = request_handler; |
| 25 tab_ = tab; |
| 26 remote_request_id_ = remote_request_id; |
| 27 url_ = url; |
| 28 method_ = method; |
| 29 referrer_ = referrer; |
| 30 extra_headers_ = extra_headers; |
| 31 upload_data_ = upload_data; |
| 32 frame_busting_enabled_ = enable_frame_busting; |
| 33 return true; |
| 34 } |
| 35 |
| 36 void PluginUrlRequest::OnResponseStarted(const char* mime_type, |
| 37 const char* headers, int size, base::Time last_modified, |
| 38 const std::string& persistent_cookies, |
| 39 const std::string& redirect_url, int redirect_status) { |
| 40 const IPC::AutomationURLResponse response = { |
| 41 mime_type, |
| 42 headers ? headers : "", |
| 43 size, |
| 44 last_modified, |
| 45 persistent_cookies, |
| 46 redirect_url, |
| 47 redirect_status |
| 48 }; |
| 49 request_handler_->Send(new AutomationMsg_RequestStarted(0, tab_, |
| 50 remote_request_id_, response)); |
| 51 } |
| 52 |
| 53 void PluginUrlRequest::OnResponseEnd(const URLRequestStatus& status) { |
| 54 DCHECK(!status.is_io_pending()); |
| 55 DCHECK(status.is_success() || status.os_error()); |
| 56 request_handler_->Send(new AutomationMsg_RequestEnd(0, tab_, |
| 57 remote_request_id_, status)); |
| 58 } |
| 59 |
| 60 void PluginUrlRequest::OnReadComplete(const void* buffer, int len) { |
| 61 std::string data(reinterpret_cast<const char*>(buffer), len); |
| 62 request_handler_->Send(new AutomationMsg_RequestData(0, tab_, |
| 63 remote_request_id_, data)); |
| 64 } |
| 65 |
OLD | NEW |