Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2265)

Unified Diff: mojo/services/html_viewer/html_document.cc

Issue 1049013004: Add some simple HTMLViewer apptests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use net::SpawnedTestServer instead of mojo:http_server. Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mojo/services/html_viewer/html_document.h ('k') | mojo/services/html_viewer/html_viewer.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/services/html_viewer/html_document.cc
diff --git a/mojo/services/html_viewer/html_document.cc b/mojo/services/html_viewer/html_document.cc
index 2d56d142c7f88ff40e012a6ea89938d1fb59a92d..101ad35c0ee971956ab031f6df7943f0660ec70d 100644
--- a/mojo/services/html_viewer/html_document.cc
+++ b/mojo/services/html_viewer/html_document.cc
@@ -99,7 +99,7 @@ bool CanNavigateLocally(blink::WebFrame* frame,
} // namespace
HTMLDocument::HTMLDocument(
- mojo::InterfaceRequest<mojo::ServiceProvider> services,
+ mojo::ServiceProviderImpl* service_provider,
URLResponsePtr response,
mojo::Shell* shell,
scoped_refptr<base::MessageLoopProxy> compositor_thread,
@@ -113,14 +113,14 @@ HTMLDocument::HTMLDocument(
compositor_thread_(compositor_thread),
web_media_player_factory_(web_media_player_factory),
is_headless_(is_headless) {
- exported_services_.AddService(this);
- exported_services_.AddService(&view_manager_client_factory_);
- exported_services_.Bind(services.Pass());
+ printf("MSW HTMLDocument::HTMLDocument\n");
+ service_provider->AddService(this);
+ service_provider->AddService(&view_manager_client_factory_);
Load(response_.Pass());
}
HTMLDocument::~HTMLDocument() {
- STLDeleteElements(&ax_provider_impls_);
+ STLDeleteElements(&ax_providers_);
if (web_view_)
web_view_->close();
@@ -132,6 +132,7 @@ void HTMLDocument::OnEmbed(
View* root,
mojo::InterfaceRequest<mojo::ServiceProvider> services,
mojo::ServiceProviderPtr exposed_services) {
+ printf("MSW HTMLDocument::OnEmbed\n");
DCHECK(!is_headless_);
root_ = root;
embedder_service_provider_ = exposed_services.Pass();
@@ -141,19 +142,40 @@ void HTMLDocument::OnEmbed(
root_->AddObserver(this);
}
+void HTMLDocument::OnViewManagerDisconnected(ViewManager* view_manager) {
+ // TODO(aa): Need to figure out how shutdown works.
+}
+
void HTMLDocument::Create(mojo::ApplicationConnection* connection,
mojo::InterfaceRequest<AxProvider> request) {
- if (!web_view_)
- return;
- ax_provider_impls_.insert(
- WeakBindToRequest(new AxProviderImpl(web_view_), &request));
+ printf("MSW HTMLDocument::Create (AxProvider) web_view=%p\n", web_view_);
+ if (!did_finish_load_) {
+ // Cache AxProvider interface requests until the document finishes loading.
+ mojo::InterfaceRequest<AxProvider>* cached_request =
+ new mojo::InterfaceRequest<AxProvider>();
+ *cached_request = request.Pass();
+ ax_provider_requests_.insert(cached_request);
+ } else {
+ ax_providers_.insert(
+ WeakBindToRequest(new AxProviderImpl(web_view_), &request));
+ }
}
-void HTMLDocument::OnViewManagerDisconnected(ViewManager* view_manager) {
- // TODO(aa): Need to figure out how shutdown works.
-}
+// void HTMLDocument::GetLayoutTreeAsText(
+// const GetLayoutTreeAsTextCallback& callback) {
+// //callback.Run("foo");
+// callback.Run(web_view_->mainFrame()->layoutTreeAsText()->utf8());
+// }
+
+// void HTMLDocument::Create(
+// mojo::ApplicationConnection* connection,
+// mojo::InterfaceRequest<mojo::HTMLDocumentTestAPI> request) {
+// WeakBindToRequest(this, &request);
+// //BindToRequest(this, &request);
+// }
void HTMLDocument::Load(URLResponsePtr response) {
+ printf("MSW HTMLDocument::Load\n");
web_view_ = blink::WebView::create(this);
web_layer_tree_view_impl_->set_widget(web_view_);
ConfigureSettings(web_view_->settings());
@@ -170,9 +192,11 @@ void HTMLDocument::Load(URLResponsePtr response) {
web_request.setExtraData(extra_data);
web_view_->mainFrame()->loadRequest(web_request);
+ web_view_->layout();
}
void HTMLDocument::UpdateWebviewSizeFromViewSize() {
+ printf("MSW HTMLDocument::UpdateWebviewSizeFromViewSize\n");
web_view_->setDeviceScaleFactor(root_->viewport_metrics().device_pixel_ratio);
const gfx::Size size_in_pixels(root_->bounds().width, root_->bounds().height);
const gfx::Size size_in_dips = gfx::ConvertSizeToDIP(
@@ -187,6 +211,7 @@ blink::WebStorageNamespace* HTMLDocument::createSessionStorageNamespace() {
}
void HTMLDocument::initializeLayerTreeView() {
+ printf("MSW HTMLDocument::initializeLayerTreeView\n");
if (is_headless_) {
web_layer_tree_view_impl_.reset(
new WebLayerTreeViewImpl(compositor_thread_, nullptr, nullptr));
@@ -288,10 +313,20 @@ void HTMLDocument::didAddMessageToConsole(
<< message.text.utf8();
}
+void HTMLDocument::didFinishLoad(blink::WebLocalFrame* frame) {
+ did_finish_load_ = true;
+ printf("MSW HTMLDocument::didFinishLoad\n");
+ // Bind any pending AxProviderImpl interface requests...
+ for (auto it : ax_provider_requests_)
+ ax_providers_.insert(WeakBindToRequest(new AxProviderImpl(web_view_), it));
+ STLDeleteElements(&ax_provider_requests_);
+}
+
void HTMLDocument::didNavigateWithinPage(
blink::WebLocalFrame* frame,
const blink::WebHistoryItem& history_item,
blink::WebHistoryCommitType commit_type) {
+ printf("MSW HTMLDocument::didNavigateWithinPage\n");
if (navigator_host_.get())
navigator_host_->DidNavigateLocally(history_item.urlString().utf8());
}
« no previous file with comments | « mojo/services/html_viewer/html_document.h ('k') | mojo/services/html_viewer/html_viewer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698