blob: 1c3c46404bb4b1b96c297708f2f1630f03379c68 [file] [log] [blame]
Torne (Richard Coles)58218062012-11-14 11:43:16 +00001// Copyright (c) 2012 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/common/automation_messages.h"
8
9PluginUrlRequest::PluginUrlRequest()
10 : delegate_(NULL),
11 remote_request_id_(-1),
12 post_data_len_(0),
13 enable_frame_busting_(false),
14 resource_type_(ResourceType::MAIN_FRAME),
15 load_flags_(0),
16 is_chunked_upload_(false) {
17}
18
19PluginUrlRequest::~PluginUrlRequest() {
20}
21
22bool PluginUrlRequest::Initialize(PluginUrlRequestDelegate* delegate,
23 int remote_request_id, const std::string& url, const std::string& method,
24 const std::string& referrer, const std::string& extra_headers,
25 net::UploadData* upload_data, ResourceType::Type resource_type,
26 bool enable_frame_busting, int load_flags) {
27 delegate_ = delegate;
28 remote_request_id_ = remote_request_id;
29 url_ = url;
30 method_ = method;
31 referrer_ = referrer;
32 extra_headers_ = extra_headers;
33 resource_type_ = resource_type;
34 load_flags_ = load_flags;
Torne (Richard Coles)f2477e02013-11-28 11:55:43 +000035 enable_frame_busting_ = enable_frame_busting;
Torne (Richard Coles)58218062012-11-14 11:43:16 +000036
37 if (upload_data) {
38 // We store a pointer to UrlmonUploadDataStream and not net::UploadData
39 // since UrlmonUploadDataStream implements thread safe ref counting and
40 // UploadData does not.
41 CComObject<UrlmonUploadDataStream>* upload_stream = NULL;
42 HRESULT hr = CComObject<UrlmonUploadDataStream>::CreateInstance(
43 &upload_stream);
44 if (FAILED(hr)) {
45 NOTREACHED();
46 } else {
47 upload_stream->AddRef();
Torne (Richard Coles)f2477e02013-11-28 11:55:43 +000048 if (!upload_stream->Initialize(upload_data)) {
49 upload_stream->Release();
50 return true;
51 }
52
Torne (Richard Coles)58218062012-11-14 11:43:16 +000053 upload_data_.Attach(upload_stream);
54 is_chunked_upload_ = upload_data->is_chunked();
55 STATSTG stat;
56 upload_stream->Stat(&stat, STATFLAG_NONAME);
57 post_data_len_ = stat.cbSize.QuadPart;
58 }
59 }
60
Torne (Richard Coles)58218062012-11-14 11:43:16 +000061 return true;
62}