Chromium Code Reviews| 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 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 229 // TODO(hclam): Re-consider the way we communicate with Javascript. | 229 // TODO(hclam): Re-consider the way we communicate with Javascript. |
| 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: |
|
Wez
2011/11/03 00:25:02
Is there any point in keeping this case?
Sergey Ulanov
2011/11/03 01:21:12
Yes, to avoid compiler warnings, otherwise I would
| |
| 240 scriptable_obj->SignalLoginChallenge(); | |
| 241 break; | 240 break; |
| 242 | 241 |
| 243 case protocol::ConnectionToHost::AUTHENTICATED: | 242 case protocol::ConnectionToHost::AUTHENTICATED: |
| 244 UnsetSolidFill(); | 243 UnsetSolidFill(); |
| 245 break; | 244 break; |
| 246 | 245 |
| 247 case protocol::ConnectionToHost::CLOSED: | 246 case protocol::ConnectionToHost::CLOSED: |
| 248 SetSolidFill(kDisconnectedColor); | 247 SetSolidFill(kDisconnectedColor); |
| 249 scriptable_obj->SetConnectionStatus( | 248 scriptable_obj->SetConnectionStatus( |
| 250 ChromotingScriptableObject::STATUS_CLOSED, | 249 ChromotingScriptableObject::STATUS_CLOSED, |
| 251 ConvertConnectionError(error)); | 250 ConvertConnectionError(error)); |
| 252 break; | 251 break; |
| 253 | 252 |
| 254 case protocol::ConnectionToHost::FAILED: | 253 case protocol::ConnectionToHost::FAILED: |
| 255 SetSolidFill(kFailedColor); | 254 SetSolidFill(kFailedColor); |
| 256 scriptable_obj->SetConnectionStatus( | 255 scriptable_obj->SetConnectionStatus( |
| 257 ChromotingScriptableObject::STATUS_FAILED, | 256 ChromotingScriptableObject::STATUS_FAILED, |
| 258 ConvertConnectionError(error)); | 257 ConvertConnectionError(error)); |
| 259 break; | 258 break; |
| 260 } | 259 } |
| 261 } | 260 } |
| 262 | 261 |
| 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) { | 262 bool PepperView::SetPluginSize(const SkISize& plugin_size) { |
| 278 if (plugin_size_ == plugin_size) | 263 if (plugin_size_ == plugin_size) |
| 279 return false; | 264 return false; |
| 280 plugin_size_ = plugin_size; | 265 plugin_size_ = plugin_size; |
| 281 | 266 |
| 282 pp::Size pp_size = pp::Size(plugin_size.width(), plugin_size.height()); | 267 pp::Size pp_size = pp::Size(plugin_size.width(), plugin_size.height()); |
| 283 | 268 |
| 284 graphics2d_ = pp::Graphics2D(instance_, pp_size, true); | 269 graphics2d_ = pp::Graphics2D(instance_, pp_size, true); |
| 285 if (!instance_->BindGraphics(graphics2d_)) { | 270 if (!instance_->BindGraphics(graphics2d_)) { |
| 286 LOG(ERROR) << "Couldn't bind the device context."; | 271 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()); | 348 (base::Time::Now() - paint_start).InMilliseconds()); |
| 364 | 349 |
| 365 // If the last flush failed because there was already another one in progress | 350 // If the last flush failed because there was already another one in progress |
| 366 // then we perform the flush now. | 351 // then we perform the flush now. |
| 367 if (flush_blocked_) | 352 if (flush_blocked_) |
| 368 FlushGraphics(base::Time::Now()); | 353 FlushGraphics(base::Time::Now()); |
| 369 return; | 354 return; |
| 370 } | 355 } |
| 371 | 356 |
| 372 } // namespace remoting | 357 } // namespace remoting |
| OLD | NEW |