OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // 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 | 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 "content/renderer/npapi/webplugin_delegate_proxy.h" | 5 #include "content/renderer/npapi/webplugin_delegate_proxy.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 | 112 |
113 void InitializeForSeekableStream(unsigned long resource_id, | 113 void InitializeForSeekableStream(unsigned long resource_id, |
114 int range_request_id) { | 114 int range_request_id) { |
115 resource_id_ = resource_id; | 115 resource_id_ = resource_id; |
116 multibyte_response_expected_ = true; | 116 multibyte_response_expected_ = true; |
117 channel_->Send(new PluginMsg_HTTPRangeRequestReply( | 117 channel_->Send(new PluginMsg_HTTPRangeRequestReply( |
118 instance_id_, resource_id, range_request_id)); | 118 instance_id_, resource_id, range_request_id)); |
119 } | 119 } |
120 | 120 |
121 // PluginResourceClient implementation: | 121 // PluginResourceClient implementation: |
122 virtual void WillSendRequest(const GURL& url, int http_status_code) OVERRIDE { | 122 virtual void WillSendRequest(const GURL& url, int http_status_code) override { |
123 DCHECK(channel_.get() != NULL); | 123 DCHECK(channel_.get() != NULL); |
124 channel_->Send(new PluginMsg_WillSendRequest( | 124 channel_->Send(new PluginMsg_WillSendRequest( |
125 instance_id_, resource_id_, url, http_status_code)); | 125 instance_id_, resource_id_, url, http_status_code)); |
126 } | 126 } |
127 | 127 |
128 virtual void DidReceiveResponse(const std::string& mime_type, | 128 virtual void DidReceiveResponse(const std::string& mime_type, |
129 const std::string& headers, | 129 const std::string& headers, |
130 uint32 expected_length, | 130 uint32 expected_length, |
131 uint32 last_modified, | 131 uint32 last_modified, |
132 bool request_is_seekable) OVERRIDE { | 132 bool request_is_seekable) override { |
133 DCHECK(channel_.get() != NULL); | 133 DCHECK(channel_.get() != NULL); |
134 PluginMsg_DidReceiveResponseParams params; | 134 PluginMsg_DidReceiveResponseParams params; |
135 params.id = resource_id_; | 135 params.id = resource_id_; |
136 params.mime_type = mime_type; | 136 params.mime_type = mime_type; |
137 params.headers = headers; | 137 params.headers = headers; |
138 params.expected_length = expected_length; | 138 params.expected_length = expected_length; |
139 params.last_modified = last_modified; | 139 params.last_modified = last_modified; |
140 params.request_is_seekable = request_is_seekable; | 140 params.request_is_seekable = request_is_seekable; |
141 // Grab a reference on the underlying channel so it does not get | 141 // Grab a reference on the underlying channel so it does not get |
142 // deleted from under us. | 142 // deleted from under us. |
143 scoped_refptr<PluginChannelHost> channel_ref(channel_); | 143 scoped_refptr<PluginChannelHost> channel_ref(channel_); |
144 channel_->Send(new PluginMsg_DidReceiveResponse(instance_id_, params)); | 144 channel_->Send(new PluginMsg_DidReceiveResponse(instance_id_, params)); |
145 } | 145 } |
146 | 146 |
147 virtual void DidReceiveData(const char* buffer, | 147 virtual void DidReceiveData(const char* buffer, |
148 int length, | 148 int length, |
149 int data_offset) OVERRIDE { | 149 int data_offset) override { |
150 DCHECK(channel_.get() != NULL); | 150 DCHECK(channel_.get() != NULL); |
151 DCHECK_GT(length, 0); | 151 DCHECK_GT(length, 0); |
152 std::vector<char> data; | 152 std::vector<char> data; |
153 data.resize(static_cast<size_t>(length)); | 153 data.resize(static_cast<size_t>(length)); |
154 memcpy(&data.front(), buffer, length); | 154 memcpy(&data.front(), buffer, length); |
155 // Grab a reference on the underlying channel so it does not get | 155 // Grab a reference on the underlying channel so it does not get |
156 // deleted from under us. | 156 // deleted from under us. |
157 scoped_refptr<PluginChannelHost> channel_ref(channel_); | 157 scoped_refptr<PluginChannelHost> channel_ref(channel_); |
158 channel_->Send(new PluginMsg_DidReceiveData(instance_id_, resource_id_, | 158 channel_->Send(new PluginMsg_DidReceiveData(instance_id_, resource_id_, |
159 data, data_offset)); | 159 data, data_offset)); |
160 } | 160 } |
161 | 161 |
162 virtual void DidFinishLoading(unsigned long resource_id) OVERRIDE { | 162 virtual void DidFinishLoading(unsigned long resource_id) override { |
163 DCHECK(channel_.get() != NULL); | 163 DCHECK(channel_.get() != NULL); |
164 DCHECK_EQ(resource_id, resource_id_); | 164 DCHECK_EQ(resource_id, resource_id_); |
165 channel_->Send(new PluginMsg_DidFinishLoading(instance_id_, resource_id_)); | 165 channel_->Send(new PluginMsg_DidFinishLoading(instance_id_, resource_id_)); |
166 channel_ = NULL; | 166 channel_ = NULL; |
167 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this); | 167 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this); |
168 } | 168 } |
169 | 169 |
170 virtual void DidFail(unsigned long resource_id) OVERRIDE { | 170 virtual void DidFail(unsigned long resource_id) override { |
171 DCHECK(channel_.get() != NULL); | 171 DCHECK(channel_.get() != NULL); |
172 DCHECK_EQ(resource_id, resource_id_); | 172 DCHECK_EQ(resource_id, resource_id_); |
173 channel_->Send(new PluginMsg_DidFail(instance_id_, resource_id_)); | 173 channel_->Send(new PluginMsg_DidFail(instance_id_, resource_id_)); |
174 channel_ = NULL; | 174 channel_ = NULL; |
175 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this); | 175 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this); |
176 } | 176 } |
177 | 177 |
178 virtual bool IsMultiByteResponseExpected() OVERRIDE { | 178 virtual bool IsMultiByteResponseExpected() override { |
179 return multibyte_response_expected_; | 179 return multibyte_response_expected_; |
180 } | 180 } |
181 | 181 |
182 virtual int ResourceId() OVERRIDE { | 182 virtual int ResourceId() override { |
183 return resource_id_; | 183 return resource_id_; |
184 } | 184 } |
185 | 185 |
186 private: | 186 private: |
187 scoped_refptr<PluginChannelHost> channel_; | 187 scoped_refptr<PluginChannelHost> channel_; |
188 int instance_id_; | 188 int instance_id_; |
189 unsigned long resource_id_; | 189 unsigned long resource_id_; |
190 // Set to true if the response expected is a multibyte response. | 190 // Set to true if the response expected is a multibyte response. |
191 // For e.g. response for a HTTP byte range request. | 191 // For e.g. response for a HTTP byte range request. |
192 bool multibyte_response_expected_; | 192 bool multibyte_response_expected_; |
(...skipping 1049 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1242 | 1242 |
1243 plugin_->URLRedirectResponse(allow, resource_id); | 1243 plugin_->URLRedirectResponse(allow, resource_id); |
1244 } | 1244 } |
1245 | 1245 |
1246 void WebPluginDelegateProxy::OnCheckIfRunInsecureContent(const GURL& url, | 1246 void WebPluginDelegateProxy::OnCheckIfRunInsecureContent(const GURL& url, |
1247 bool* result) { | 1247 bool* result) { |
1248 *result = plugin_->CheckIfRunInsecureContent(url); | 1248 *result = plugin_->CheckIfRunInsecureContent(url); |
1249 } | 1249 } |
1250 | 1250 |
1251 } // namespace content | 1251 } // namespace content |
OLD | NEW |