Index: mojo/services/html_viewer/html_document_view.cc |
diff --git a/mojo/services/html_viewer/html_document_view.cc b/mojo/services/html_viewer/html_document_view.cc |
index f7a08cb957799285f06d90b253102fc78b5bf8d0..84373b56bb27df0f3e594931367ef2d259fbc77b 100644 |
--- a/mojo/services/html_viewer/html_document_view.cc |
+++ b/mojo/services/html_viewer/html_document_view.cc |
@@ -9,6 +9,8 @@ |
#include "base/single_thread_task_runner.h" |
#include "base/strings/string_util.h" |
#include "base/thread_task_runner_handle.h" |
+#include "mojo/public/cpp/application/application_connection.h" |
+#include "mojo/public/cpp/application/service_provider_impl.h" |
#include "mojo/public/cpp/system/data_pipe.h" |
#include "mojo/services/html_viewer/blink_input_events_type_converters.h" |
#include "mojo/services/html_viewer/blink_url_request_type_converters.h" |
@@ -78,14 +80,22 @@ bool CanNavigateLocally(blink::WebFrame* frame, |
} // namespace |
-HTMLDocumentView::HTMLDocumentView(ServiceProvider* service_provider, |
- ViewManager* view_manager) |
- : view_manager_(view_manager), |
- navigator_host_(service_provider), |
+HTMLDocumentView::HTMLDocumentView( |
+ ContentHandlerResponsePtr response, |
+ scoped_ptr<ServiceProvider> imported_services, |
+ ServiceProviderImpl* exported_services, |
+ ApplicationConnection* application_connection) |
+ : response_(response.Pass()), |
+ imported_services_(imported_services.Pass()), |
+ navigator_host_(application_connection->ConnectToApplication( |
+ "mojo://mojo_window_manager/")->GetServiceProvider()), |
web_view_(NULL), |
root_(NULL), |
+ view_manager_client_factory_(this), |
repaint_pending_(false), |
weak_factory_(this) { |
+ exported_services->AddService(&view_manager_client_factory_); |
+ Load(response_->response.Pass()); |
} |
HTMLDocumentView::~HTMLDocumentView() { |
@@ -95,20 +105,24 @@ HTMLDocumentView::~HTMLDocumentView() { |
root_->RemoveObserver(this); |
} |
-void HTMLDocumentView::AttachToView(View* view) { |
- root_ = view; |
+void HTMLDocumentView::OnEmbed(ViewManager* view_manager, |
+ View* root, |
+ ServiceProviderImpl* exported_services, |
+ scoped_ptr<ServiceProvider> imported_services) { |
+ root_ = root; |
root_->SetColor(SK_ColorCYAN); // Dummy background color. |
- |
- web_view_ = blink::WebView::create(this); |
- ConfigureSettings(web_view_->settings()); |
- web_view_->setMainFrame(blink::WebLocalFrame::create(this)); |
web_view_->resize(root_->bounds().size()); |
- |
root_->AddObserver(this); |
} |
+void HTMLDocumentView::OnViewManagerDisconnected(ViewManager* view_manager) { |
+ // TODO(aa) |
+} |
+ |
void HTMLDocumentView::Load(URLResponsePtr response) { |
- DCHECK(web_view_); |
+ web_view_ = blink::WebView::create(this); |
+ ConfigureSettings(web_view_->settings()); |
+ web_view_->setMainFrame(blink::WebLocalFrame::create(this)); |
GURL url(response->url); |
@@ -223,6 +237,9 @@ void HTMLDocumentView::OnViewInputEvent(View* view, const EventPtr& event) { |
void HTMLDocumentView::Repaint() { |
repaint_pending_ = false; |
+ if (!root_) |
+ return; |
+ |
web_view_->animate(0.0); |
web_view_->layout(); |