| 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 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 std::unique_ptr<BlimpBrowserContext> browser_context, | 201 std::unique_ptr<BlimpBrowserContext> browser_context, |
| 202 net::NetLog* net_log, | 202 net::NetLog* net_log, |
| 203 BlimpEngineConfig* engine_config, | 203 BlimpEngineConfig* engine_config, |
| 204 SettingsManager* settings_manager) | 204 SettingsManager* settings_manager) |
| 205 : browser_context_(std::move(browser_context)), | 205 : browser_context_(std::move(browser_context)), |
| 206 engine_config_(engine_config), | 206 engine_config_(engine_config), |
| 207 screen_(new BlimpScreen), | 207 screen_(new BlimpScreen), |
| 208 settings_manager_(settings_manager), | 208 settings_manager_(settings_manager), |
| 209 settings_feature_(settings_manager_), | 209 settings_feature_(settings_manager_), |
| 210 render_widget_feature_(settings_manager_), | 210 render_widget_feature_(settings_manager_), |
| 211 page_load_tracker_(this), |
| 211 net_components_( | 212 net_components_( |
| 212 new EngineNetworkComponents(net_log, | 213 new EngineNetworkComponents(net_log, |
| 213 QuitCurrentMessageLoopClosure())) { | 214 QuitCurrentMessageLoopClosure())) { |
| 214 DCHECK(engine_config_); | 215 DCHECK(engine_config_); |
| 215 DCHECK(settings_manager_); | 216 DCHECK(settings_manager_); |
| 216 screen_->UpdateDisplayScaleAndSize(kDefaultScaleFactor, | 217 screen_->UpdateDisplayScaleAndSize(kDefaultScaleFactor, |
| 217 gfx::Size(kDefaultDisplayWidth, | 218 gfx::Size(kDefaultDisplayWidth, |
| 218 kDefaultDisplayHeight)); | 219 kDefaultDisplayHeight)); |
| 219 render_widget_feature_.SetDelegate(kDummyTabId, this); | 220 render_widget_feature_.SetDelegate(kDummyTabId, this); |
| 220 } | 221 } |
| (...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 571 if (changed_flags & content::InvalidateTypes::INVALIDATE_TYPE_TITLE) | 572 if (changed_flags & content::InvalidateTypes::INVALIDATE_TYPE_TITLE) |
| 572 details->set_title(base::UTF16ToUTF8(source->GetTitle())); | 573 details->set_title(base::UTF16ToUTF8(source->GetTitle())); |
| 573 | 574 |
| 574 if (changed_flags & content::InvalidateTypes::INVALIDATE_TYPE_LOAD) | 575 if (changed_flags & content::InvalidateTypes::INVALIDATE_TYPE_LOAD) |
| 575 details->set_loading(source->IsLoading()); | 576 details->set_loading(source->IsLoading()); |
| 576 | 577 |
| 577 navigation_message_sender_->ProcessMessage(std::move(message), | 578 navigation_message_sender_->ProcessMessage(std::move(message), |
| 578 net::CompletionCallback()); | 579 net::CompletionCallback()); |
| 579 } | 580 } |
| 580 | 581 |
| 581 void BlimpEngineSession::LoadProgressChanged( | |
| 582 content::WebContents* source, double progress) { | |
| 583 if (source != web_contents_.get()) | |
| 584 return; | |
| 585 | |
| 586 bool page_load_completed = (progress == 1.0); | |
| 587 | |
| 588 // If the client has been notified of a page load completed change, avoid | |
| 589 // sending another message. For the first navigation, the initial value used | |
| 590 // by the client is already false. | |
| 591 if (last_page_load_completed_value_ == page_load_completed) | |
| 592 return; | |
| 593 | |
| 594 NavigationMessage* navigation_message = nullptr; | |
| 595 std::unique_ptr<BlimpMessage> message = | |
| 596 CreateBlimpMessage(&navigation_message, kDummyTabId); | |
| 597 navigation_message->set_type(NavigationMessage::NAVIGATION_STATE_CHANGED); | |
| 598 NavigationStateChangeMessage* details = | |
| 599 navigation_message->mutable_navigation_state_changed(); | |
| 600 details->set_page_load_completed(page_load_completed); | |
| 601 | |
| 602 navigation_message_sender_->ProcessMessage(std::move(message), | |
| 603 net::CompletionCallback()); | |
| 604 | |
| 605 last_page_load_completed_value_ = page_load_completed; | |
| 606 } | |
| 607 | |
| 608 void BlimpEngineSession::RenderViewCreated( | 582 void BlimpEngineSession::RenderViewCreated( |
| 609 content::RenderViewHost* render_view_host) { | 583 content::RenderViewHost* render_view_host) { |
| 610 render_widget_feature_.OnRenderWidgetCreated(kDummyTabId, | 584 render_widget_feature_.OnRenderWidgetCreated(kDummyTabId, |
| 611 render_view_host->GetWidget()); | 585 render_view_host->GetWidget()); |
| 612 } | 586 } |
| 613 | 587 |
| 614 void BlimpEngineSession::RenderViewHostChanged( | 588 void BlimpEngineSession::RenderViewHostChanged( |
| 615 content::RenderViewHost* old_host, | 589 content::RenderViewHost* old_host, |
| 616 content::RenderViewHost* new_host) { | 590 content::RenderViewHost* new_host) { |
| 617 // Informs client that WebContents swaps its visible RenderViewHost with | 591 // Informs client that WebContents swaps its visible RenderViewHost with |
| 618 // another one. | 592 // another one. |
| 619 render_widget_feature_.OnRenderWidgetInitialized(kDummyTabId, | 593 render_widget_feature_.OnRenderWidgetInitialized(kDummyTabId, |
| 620 new_host->GetWidget()); | 594 new_host->GetWidget()); |
| 621 } | 595 } |
| 622 | 596 |
| 623 void BlimpEngineSession::RenderViewDeleted( | 597 void BlimpEngineSession::RenderViewDeleted( |
| 624 content::RenderViewHost* render_view_host) { | 598 content::RenderViewHost* render_view_host) { |
| 625 render_widget_feature_.OnRenderWidgetDeleted(kDummyTabId, | 599 render_widget_feature_.OnRenderWidgetDeleted(kDummyTabId, |
| 626 render_view_host->GetWidget()); | 600 render_view_host->GetWidget()); |
| 627 } | 601 } |
| 628 | 602 |
| 603 void BlimpEngineSession::DidStartProvisionalLoadForFrame( |
| 604 content::RenderFrameHost* render_frame_host, |
| 605 const GURL& validated_url, |
| 606 bool is_error_page, |
| 607 bool is_iframe_srcdoc) { |
| 608 page_load_tracker_.DidStartProvisionalLoadForFrame(render_frame_host); |
| 609 } |
| 610 |
| 611 void BlimpEngineSession::DidFinishLoad( |
| 612 content::RenderFrameHost* render_frame_host, |
| 613 const GURL& validated_url) { |
| 614 page_load_tracker_.DidFinishLoad(render_frame_host); |
| 615 } |
| 616 |
| 617 void BlimpEngineSession::DidFailLoad( |
| 618 content::RenderFrameHost* render_frame_host, |
| 619 const GURL& validated_url, |
| 620 int error_code, |
| 621 const base::string16& error_description, |
| 622 bool was_ignored_by_handler) { |
| 623 page_load_tracker_.DidFailLoad(render_frame_host); |
| 624 } |
| 625 |
| 626 void BlimpEngineSession::DidFirstPaintAfterLoad( |
| 627 content::RenderWidgetHost* render_widget_host) { |
| 628 page_load_tracker_.DidFirstPaintAfterLoad(render_widget_host); |
| 629 } |
| 630 |
| 631 void BlimpEngineSession::SendPageLoadStatusUpdate(bool load_status) { |
| 632 NavigationMessage* navigation_message = nullptr; |
| 633 std::unique_ptr<BlimpMessage> message = |
| 634 CreateBlimpMessage(&navigation_message, kDummyTabId); |
| 635 navigation_message->set_type(NavigationMessage::NAVIGATION_STATE_CHANGED); |
| 636 NavigationStateChangeMessage* details = |
| 637 navigation_message->mutable_navigation_state_changed(); |
| 638 details->set_page_load_completed(load_status); |
| 639 |
| 640 navigation_message_sender_->ProcessMessage(std::move(message), |
| 641 net::CompletionCallback()); |
| 642 } |
| 643 |
| 629 void BlimpEngineSession::PlatformSetContents( | 644 void BlimpEngineSession::PlatformSetContents( |
| 630 std::unique_ptr<content::WebContents> new_contents) { | 645 std::unique_ptr<content::WebContents> new_contents) { |
| 631 new_contents->SetDelegate(this); | 646 new_contents->SetDelegate(this); |
| 632 Observe(new_contents.get()); | 647 Observe(new_contents.get()); |
| 633 web_contents_ = std::move(new_contents); | 648 web_contents_ = std::move(new_contents); |
| 634 | 649 |
| 635 aura::Window* parent = window_tree_host_->window(); | 650 aura::Window* parent = window_tree_host_->window(); |
| 636 aura::Window* content = web_contents_->GetNativeView(); | 651 aura::Window* content = web_contents_->GetNativeView(); |
| 637 if (!parent->Contains(content)) | 652 if (!parent->Contains(content)) |
| 638 parent->AddChild(content); | 653 parent->AddChild(content); |
| 639 content->Show(); | 654 content->Show(); |
| 640 } | 655 } |
| 641 | 656 |
| 642 } // namespace engine | 657 } // namespace engine |
| 643 } // namespace blimp | 658 } // namespace blimp |
| OLD | NEW |