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 "remoting/client/plugin/pepper_view.h" | 5 #include "remoting/client/plugin/pepper_view.h" |
6 | 6 |
7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
9 #include "ppapi/cpp/graphics_2d.h" | 9 #include "ppapi/cpp/graphics_2d.h" |
10 #include "ppapi/cpp/image_data.h" | 10 #include "ppapi/cpp/image_data.h" |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 ChromotingScriptableObject* scriptable_obj = instance_->GetScriptableObject(); | 230 ChromotingScriptableObject* scriptable_obj = instance_->GetScriptableObject(); |
231 switch (state) { | 231 switch (state) { |
232 case protocol::ConnectionToHost::CONNECTING: | 232 case protocol::ConnectionToHost::CONNECTING: |
233 SetSolidFill(kCreatedColor); | 233 SetSolidFill(kCreatedColor); |
234 scriptable_obj->SetConnectionStatus( | 234 scriptable_obj->SetConnectionStatus( |
235 ChromotingScriptableObject::STATUS_CONNECTING, | 235 ChromotingScriptableObject::STATUS_CONNECTING, |
236 ConvertConnectionError(error)); | 236 ConvertConnectionError(error)); |
237 break; | 237 break; |
238 | 238 |
239 case protocol::ConnectionToHost::CONNECTED: | 239 case protocol::ConnectionToHost::CONNECTED: |
240 scriptable_obj->SignalLoginChallenge(); | |
241 break; | 240 break; |
242 | 241 |
243 case protocol::ConnectionToHost::AUTHENTICATED: | 242 case protocol::ConnectionToHost::AUTHENTICATED: |
244 UnsetSolidFill(); | 243 UnsetSolidFill(); |
| 244 scriptable_obj->SetConnectionStatus( |
| 245 ChromotingScriptableObject::STATUS_CONNECTED, |
| 246 ConvertConnectionError(error)); |
245 break; | 247 break; |
246 | 248 |
247 case protocol::ConnectionToHost::CLOSED: | 249 case protocol::ConnectionToHost::CLOSED: |
248 SetSolidFill(kDisconnectedColor); | 250 SetSolidFill(kDisconnectedColor); |
249 scriptable_obj->SetConnectionStatus( | 251 scriptable_obj->SetConnectionStatus( |
250 ChromotingScriptableObject::STATUS_CLOSED, | 252 ChromotingScriptableObject::STATUS_CLOSED, |
251 ConvertConnectionError(error)); | 253 ConvertConnectionError(error)); |
252 break; | 254 break; |
253 | 255 |
254 case protocol::ConnectionToHost::FAILED: | 256 case protocol::ConnectionToHost::FAILED: |
255 SetSolidFill(kFailedColor); | 257 SetSolidFill(kFailedColor); |
256 scriptable_obj->SetConnectionStatus( | 258 scriptable_obj->SetConnectionStatus( |
257 ChromotingScriptableObject::STATUS_FAILED, | 259 ChromotingScriptableObject::STATUS_FAILED, |
258 ConvertConnectionError(error)); | 260 ConvertConnectionError(error)); |
259 break; | 261 break; |
260 } | 262 } |
261 } | 263 } |
262 | 264 |
263 void PepperView::UpdateLoginStatus(bool success, const std::string& info) { | |
264 DCHECK(context_->main_message_loop()->BelongsToCurrentThread()); | |
265 | |
266 // TODO(hclam): Re-consider the way we communicate with Javascript. | |
267 ChromotingScriptableObject* scriptable_obj = instance_->GetScriptableObject(); | |
268 if (success) { | |
269 scriptable_obj->SetConnectionStatus( | |
270 ChromotingScriptableObject::STATUS_CONNECTED, | |
271 ChromotingScriptableObject::ERROR_NONE); | |
272 } else { | |
273 scriptable_obj->SignalLoginChallenge(); | |
274 } | |
275 } | |
276 | |
277 bool PepperView::SetPluginSize(const SkISize& plugin_size) { | 265 bool PepperView::SetPluginSize(const SkISize& plugin_size) { |
278 if (plugin_size_ == plugin_size) | 266 if (plugin_size_ == plugin_size) |
279 return false; | 267 return false; |
280 plugin_size_ = plugin_size; | 268 plugin_size_ = plugin_size; |
281 | 269 |
282 pp::Size pp_size = pp::Size(plugin_size.width(), plugin_size.height()); | 270 pp::Size pp_size = pp::Size(plugin_size.width(), plugin_size.height()); |
283 | 271 |
284 graphics2d_ = pp::Graphics2D(instance_, pp_size, true); | 272 graphics2d_ = pp::Graphics2D(instance_, pp_size, true); |
285 if (!instance_->BindGraphics(graphics2d_)) { | 273 if (!instance_->BindGraphics(graphics2d_)) { |
286 LOG(ERROR) << "Couldn't bind the device context."; | 274 LOG(ERROR) << "Couldn't bind the device context."; |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
363 (base::Time::Now() - paint_start).InMilliseconds()); | 351 (base::Time::Now() - paint_start).InMilliseconds()); |
364 | 352 |
365 // If the last flush failed because there was already another one in progress | 353 // If the last flush failed because there was already another one in progress |
366 // then we perform the flush now. | 354 // then we perform the flush now. |
367 if (flush_blocked_) | 355 if (flush_blocked_) |
368 FlushGraphics(base::Time::Now()); | 356 FlushGraphics(base::Time::Now()); |
369 return; | 357 return; |
370 } | 358 } |
371 | 359 |
372 } // namespace remoting | 360 } // namespace remoting |
OLD | NEW |