OLD | NEW |
---|---|
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "blimp/engine/session/blimp_engine_session.h" | 5 #include "blimp/engine/session/blimp_engine_session.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
286 void BlimpEngineSession::RegisterFeatures() { | 286 void BlimpEngineSession::RegisterFeatures() { |
287 thread_pipe_manager_.reset(new ThreadPipeManager( | 287 thread_pipe_manager_.reset(new ThreadPipeManager( |
288 content::BrowserThread::GetMessageLoopProxyForThread( | 288 content::BrowserThread::GetMessageLoopProxyForThread( |
289 content::BrowserThread::IO), | 289 content::BrowserThread::IO), |
290 content::BrowserThread::GetMessageLoopProxyForThread( | 290 content::BrowserThread::GetMessageLoopProxyForThread( |
291 content::BrowserThread::UI), | 291 content::BrowserThread::UI), |
292 net_components_->GetBrowserConnectionHandler())); | 292 net_components_->GetBrowserConnectionHandler())); |
293 | 293 |
294 // Register features' message senders and receivers. | 294 // Register features' message senders and receivers. |
295 tab_control_message_sender_ = | 295 tab_control_message_sender_ = |
296 thread_pipe_manager_->RegisterFeature(BlimpMessage::TAB_CONTROL, this); | 296 thread_pipe_manager_->RegisterFeature(BlimpMessage::kTabControl, this); |
297 navigation_message_sender_ = | 297 navigation_message_sender_ = |
298 thread_pipe_manager_->RegisterFeature(BlimpMessage::NAVIGATION, this); | 298 thread_pipe_manager_->RegisterFeature(BlimpMessage::kNavigation, this); |
299 render_widget_feature_.set_render_widget_message_sender( | 299 render_widget_feature_.set_render_widget_message_sender( |
300 thread_pipe_manager_->RegisterFeature(BlimpMessage::RENDER_WIDGET, | 300 thread_pipe_manager_->RegisterFeature(BlimpMessage::kRenderWidget, |
301 &render_widget_feature_)); | 301 &render_widget_feature_)); |
302 render_widget_feature_.set_input_message_sender( | 302 render_widget_feature_.set_input_message_sender( |
303 thread_pipe_manager_->RegisterFeature(BlimpMessage::INPUT, | 303 thread_pipe_manager_->RegisterFeature(BlimpMessage::kInput, |
304 &render_widget_feature_)); | 304 &render_widget_feature_)); |
305 render_widget_feature_.set_compositor_message_sender( | 305 render_widget_feature_.set_compositor_message_sender( |
306 thread_pipe_manager_->RegisterFeature(BlimpMessage::COMPOSITOR, | 306 thread_pipe_manager_->RegisterFeature(BlimpMessage::kCompositor, |
307 &render_widget_feature_)); | 307 &render_widget_feature_)); |
308 render_widget_feature_.set_ime_message_sender( | 308 render_widget_feature_.set_ime_message_sender( |
309 thread_pipe_manager_->RegisterFeature(BlimpMessage::IME, | 309 thread_pipe_manager_->RegisterFeature(BlimpMessage::kIme, |
310 &render_widget_feature_)); | 310 &render_widget_feature_)); |
311 | 311 |
312 // The Settings feature does not need an outgoing message processor, since we | 312 // The Settings feature does not need an outgoing message processor, since we |
313 // don't send any messages to the client right now. | 313 // don't send any messages to the client right now. |
314 thread_pipe_manager_->RegisterFeature(BlimpMessage::SETTINGS, | 314 thread_pipe_manager_->RegisterFeature(BlimpMessage::kSettings, |
315 &settings_feature_); | 315 &settings_feature_); |
316 } | 316 } |
317 | 317 |
318 bool BlimpEngineSession::CreateWebContents(const int target_tab_id) { | 318 bool BlimpEngineSession::CreateWebContents(const int target_tab_id) { |
319 DVLOG(1) << "Create tab " << target_tab_id; | 319 DVLOG(1) << "Create tab " << target_tab_id; |
320 // TODO(haibinlu): Support more than one active WebContents (crbug/547231). | 320 // TODO(haibinlu): Support more than one active WebContents (crbug/547231). |
321 if (web_contents_) { | 321 if (web_contents_) { |
322 DLOG(WARNING) << "Tab " << target_tab_id << " already existed"; | 322 DLOG(WARNING) << "Tab " << target_tab_id << " already existed"; |
323 return false; | 323 return false; |
324 } | 324 } |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
447 web_contents_->GetRenderWidgetHostView()->GetRenderWidgetHost(), | 447 web_contents_->GetRenderWidgetHostView()->GetRenderWidgetHost(), |
448 window_tree_host_->GetInputMethod()->GetTextInputClient()); | 448 window_tree_host_->GetInputMethod()->GetTextInputClient()); |
449 } | 449 } |
450 | 450 |
451 void BlimpEngineSession::ProcessMessage( | 451 void BlimpEngineSession::ProcessMessage( |
452 std::unique_ptr<BlimpMessage> message, | 452 std::unique_ptr<BlimpMessage> message, |
453 const net::CompletionCallback& callback) { | 453 const net::CompletionCallback& callback) { |
454 TRACE_EVENT1("blimp", "BlimpEngineSession::ProcessMessage", "TabId", | 454 TRACE_EVENT1("blimp", "BlimpEngineSession::ProcessMessage", "TabId", |
455 message->target_tab_id()); | 455 message->target_tab_id()); |
456 DCHECK(!callback.is_null()); | 456 DCHECK(!callback.is_null()); |
457 DCHECK(message->type() == BlimpMessage::TAB_CONTROL || | 457 DCHECK(BlimpMessage::kTabControl == message->feature_case() || |
458 message->type() == BlimpMessage::NAVIGATION); | 458 BlimpMessage::kNavigation == message->feature_case()); |
459 | 459 |
460 net::Error result = net::OK; | 460 net::Error result = net::OK; |
461 if (message->type() == BlimpMessage::TAB_CONTROL) { | 461 if (message->has_tab_control()) { |
Kevin M
2016/05/20 18:28:15
Check the feature case
shaktisahu
2016/05/20 22:29:41
Why? We are already doing that in the DCHECK above
Kevin M
2016/05/21 00:32:05
Consistency in how we are checking the type. In so
| |
462 switch (message->tab_control().type()) { | 462 switch (message->tab_control().type()) { |
463 case TabControlMessage::CREATE_TAB: | 463 case TabControlMessage::CREATE_TAB: |
464 if (!CreateWebContents(message->target_tab_id())) | 464 if (!CreateWebContents(message->target_tab_id())) |
465 result = net::ERR_FAILED; | 465 result = net::ERR_FAILED; |
466 break; | 466 break; |
467 case TabControlMessage::CLOSE_TAB: | 467 case TabControlMessage::CLOSE_TAB: |
468 CloseWebContents(message->target_tab_id()); | 468 CloseWebContents(message->target_tab_id()); |
469 case TabControlMessage::SIZE: | 469 case TabControlMessage::SIZE: |
470 HandleResize(message->tab_control().size().device_pixel_ratio(), | 470 HandleResize(message->tab_control().size().device_pixel_ratio(), |
471 gfx::Size(message->tab_control().size().width(), | 471 gfx::Size(message->tab_control().size().width(), |
472 message->tab_control().size().height())); | 472 message->tab_control().size().height())); |
473 break; | 473 break; |
474 default: | 474 default: |
475 NOTIMPLEMENTED(); | 475 NOTIMPLEMENTED(); |
476 result = net::ERR_NOT_IMPLEMENTED; | 476 result = net::ERR_NOT_IMPLEMENTED; |
477 } | 477 } |
478 } else if (message->type() == BlimpMessage::NAVIGATION && web_contents_) { | 478 } else if (message->has_navigation() && web_contents_) { |
Kevin M
2016/05/20 18:28:15
Check the feature case
shaktisahu
2016/05/20 22:29:41
Ditto
| |
479 switch (message->navigation().type()) { | 479 switch (message->navigation().type()) { |
480 case NavigationMessage::LOAD_URL: | 480 case NavigationMessage::LOAD_URL: |
481 LoadUrl(message->target_tab_id(), | 481 LoadUrl(message->target_tab_id(), |
482 GURL(message->navigation().load_url().url())); | 482 GURL(message->navigation().load_url().url())); |
483 break; | 483 break; |
484 case NavigationMessage::GO_BACK: | 484 case NavigationMessage::GO_BACK: |
485 GoBack(message->target_tab_id()); | 485 GoBack(message->target_tab_id()); |
486 break; | 486 break; |
487 case NavigationMessage::GO_FORWARD: | 487 case NavigationMessage::GO_FORWARD: |
488 GoForward(message->target_tab_id()); | 488 GoForward(message->target_tab_id()); |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
648 | 648 |
649 aura::Window* parent = window_tree_host_->window(); | 649 aura::Window* parent = window_tree_host_->window(); |
650 aura::Window* content = web_contents_->GetNativeView(); | 650 aura::Window* content = web_contents_->GetNativeView(); |
651 if (!parent->Contains(content)) | 651 if (!parent->Contains(content)) |
652 parent->AddChild(content); | 652 parent->AddChild(content); |
653 content->Show(); | 653 content->Show(); |
654 } | 654 } |
655 | 655 |
656 } // namespace engine | 656 } // namespace engine |
657 } // namespace blimp | 657 } // namespace blimp |
OLD | NEW |