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

Side by Side 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: Continue cleanup. Created 5 years, 8 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "mojo/services/html_viewer/html_document.h" 5 #include "mojo/services/html_viewer/html_document.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/message_loop/message_loop_proxy.h" 10 #include "base/message_loop/message_loop_proxy.h"
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 return true; 92 return true;
93 93
94 // Otherwise we don't know if we're the right app to handle this request. Ask 94 // Otherwise we don't know if we're the right app to handle this request. Ask
95 // host to do the navigation for us. 95 // host to do the navigation for us.
96 return false; 96 return false;
97 } 97 }
98 98
99 } // namespace 99 } // namespace
100 100
101 HTMLDocument::HTMLDocument( 101 HTMLDocument::HTMLDocument(
102 mojo::InterfaceRequest<mojo::ServiceProvider> services, 102 mojo::ServiceProviderImpl* service_provider,
103 URLResponsePtr response, 103 URLResponsePtr response,
104 mojo::Shell* shell, 104 mojo::Shell* shell,
105 scoped_refptr<base::MessageLoopProxy> compositor_thread, 105 scoped_refptr<base::MessageLoopProxy> compositor_thread,
106 WebMediaPlayerFactory* web_media_player_factory, 106 WebMediaPlayerFactory* web_media_player_factory,
107 bool is_headless) 107 bool is_headless)
108 : response_(response.Pass()), 108 : response_(response.Pass()),
109 shell_(shell), 109 shell_(shell),
110 web_view_(nullptr), 110 web_view_(nullptr),
111 root_(nullptr), 111 root_(nullptr),
112 view_manager_client_factory_(shell_, this), 112 view_manager_client_factory_(shell_, this),
113 compositor_thread_(compositor_thread), 113 compositor_thread_(compositor_thread),
114 web_media_player_factory_(web_media_player_factory), 114 web_media_player_factory_(web_media_player_factory),
115 is_headless_(is_headless) { 115 is_headless_(is_headless) {
116 exported_services_.AddService(this); 116 printf("MSW HTMLDocument::HTMLDocument\n");
117 exported_services_.AddService(&view_manager_client_factory_); 117 service_provider->AddService(this);
118 exported_services_.Bind(services.Pass()); 118 service_provider->AddService(&view_manager_client_factory_);
119 Load(response_.Pass()); 119 Load(response_.Pass());
120 } 120 }
121 121
122 HTMLDocument::~HTMLDocument() { 122 HTMLDocument::~HTMLDocument() {
123 STLDeleteElements(&ax_provider_impls_); 123 STLDeleteElements(&ax_provider_impls_);
124 124
125 if (web_view_) 125 if (web_view_)
126 web_view_->close(); 126 web_view_->close();
127 if (root_) 127 if (root_)
128 root_->RemoveObserver(this); 128 root_->RemoveObserver(this);
129 } 129 }
130 130
131 void HTMLDocument::OnEmbed( 131 void HTMLDocument::OnEmbed(
132 View* root, 132 View* root,
133 mojo::InterfaceRequest<mojo::ServiceProvider> services, 133 mojo::InterfaceRequest<mojo::ServiceProvider> services,
134 mojo::ServiceProviderPtr exposed_services) { 134 mojo::ServiceProviderPtr exposed_services) {
135 DCHECK(!is_headless_); 135 DCHECK(!is_headless_);
136 root_ = root; 136 root_ = root;
137 embedder_service_provider_ = exposed_services.Pass(); 137 embedder_service_provider_ = exposed_services.Pass();
138 navigator_host_.set_service_provider(embedder_service_provider_.get()); 138 navigator_host_.set_service_provider(embedder_service_provider_.get());
139 UpdateWebviewSizeFromViewSize(); 139 UpdateWebviewSizeFromViewSize();
140 web_layer_tree_view_impl_->set_view(root_); 140 web_layer_tree_view_impl_->set_view(root_);
141 root_->AddObserver(this); 141 root_->AddObserver(this);
142 } 142 }
143 143
144 void HTMLDocument::Create(mojo::ApplicationConnection* connection, 144 void HTMLDocument::Create(mojo::ApplicationConnection* connection,
145 mojo::InterfaceRequest<AxProvider> request) { 145 mojo::InterfaceRequest<AxProvider> request) {
146 printf("MSW HTMLDocument::Create (AxProvider) web_view=%p\n", web_view_);
146 if (!web_view_) 147 if (!web_view_)
147 return; 148 return;
148 ax_provider_impls_.insert( 149 ax_provider_impls_.insert(
149 WeakBindToRequest(new AxProviderImpl(web_view_), &request)); 150 WeakBindToRequest(new AxProviderImpl(web_view_), &request));
150 } 151 }
151 152
152 void HTMLDocument::OnViewManagerDisconnected(ViewManager* view_manager) { 153 void HTMLDocument::OnViewManagerDisconnected(ViewManager* view_manager) {
153 // TODO(aa): Need to figure out how shutdown works. 154 // TODO(aa): Need to figure out how shutdown works.
154 } 155 }
155 156
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 } 321 }
321 322
322 void HTMLDocument::OnViewInputEvent(View* view, const mojo::EventPtr& event) { 323 void HTMLDocument::OnViewInputEvent(View* view, const mojo::EventPtr& event) {
323 scoped_ptr<blink::WebInputEvent> web_event = 324 scoped_ptr<blink::WebInputEvent> web_event =
324 event.To<scoped_ptr<blink::WebInputEvent>>(); 325 event.To<scoped_ptr<blink::WebInputEvent>>();
325 if (web_event) 326 if (web_event)
326 web_view_->handleInputEvent(*web_event); 327 web_view_->handleInputEvent(*web_event);
327 } 328 }
328 329
329 } // namespace html_viewer 330 } // namespace html_viewer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698