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

Side by Side Diff: mojo/services/html_viewer/html_document_view.cc

Issue 776553003: Fix html viewer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years 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_view.h" 5 #include "mojo/services/html_viewer/html_document_view.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/message_loop/message_loop_proxy.h" 9 #include "base/message_loop/message_loop_proxy.h"
10 #include "base/single_thread_task_runner.h" 10 #include "base/single_thread_task_runner.h"
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 return true; 79 return true;
80 80
81 // Otherwise we don't know if we're the right app to handle this request. Ask 81 // Otherwise we don't know if we're the right app to handle this request. Ask
82 // host to do the navigation for us. 82 // host to do the navigation for us.
83 return false; 83 return false;
84 } 84 }
85 85
86 } // namespace 86 } // namespace
87 87
88 HTMLDocumentView::HTMLDocumentView( 88 HTMLDocumentView::HTMLDocumentView(
89 const base::Closure& destruction_callback,
90 mojo::ServiceProviderPtr provider,
89 URLResponsePtr response, 91 URLResponsePtr response,
90 ShellPtr shell, 92 Shell* shell,
91 scoped_refptr<base::MessageLoopProxy> compositor_thread, 93 scoped_refptr<base::MessageLoopProxy> compositor_thread,
92 WebMediaPlayerFactory* web_media_player_factory) 94 WebMediaPlayerFactory* web_media_player_factory)
93 : response_(response.Pass()), 95 : destruction_callback_(destruction_callback),
94 shell_(shell.Pass()), 96 response_(response.Pass()),
97 shell_(shell),
Aaron Boodman 2014/12/03 16:42:11 This raw ptr is another way we can crash if the ap
qsr 2014/12/03 16:56:53 This raw ptr is owned by the application, and the
Aaron Boodman 2014/12/03 17:32:37 Right.
95 web_view_(NULL), 98 web_view_(NULL),
96 root_(NULL), 99 root_(NULL),
97 view_manager_client_factory_(shell_.get(), this), 100 view_manager_client_factory_(shell_, this),
98 compositor_thread_(compositor_thread), 101 compositor_thread_(compositor_thread),
99 web_media_player_factory_(web_media_player_factory) { 102 web_media_player_factory_(web_media_player_factory) {
100 shell_.set_client(this); 103 exported_services_.AddService(this);
104 exported_services_.AddService(&view_manager_client_factory_);
105 WeakBindToPipe(&exported_services_, provider.PassMessagePipe());
Aaron Boodman 2014/12/03 16:42:11 What deletes this class?
qsr 2014/12/03 16:56:53 Which class? exported_services_ is a member of thi
Aaron Boodman 2014/12/03 17:32:37 I meant HTMLDocumentView. I don't think OnViewDes
qsr 2014/12/04 10:11:17 Hum, what would be the right signal? This is not t
101 } 106 }
102 107
103 HTMLDocumentView::~HTMLDocumentView() { 108 HTMLDocumentView::~HTMLDocumentView() {
104 STLDeleteElements(&ax_provider_impls_); 109 STLDeleteElements(&ax_provider_impls_);
105 110
106 if (web_view_) 111 if (web_view_)
107 web_view_->close(); 112 web_view_->close();
108 if (root_) 113 if (root_)
109 root_->RemoveObserver(this); 114 root_->RemoveObserver(this);
110 } 115 destruction_callback_.Run();
111
112 void HTMLDocumentView::AcceptConnection(const String& requestor_url,
113 ServiceProviderPtr provider) {
114 exported_services_.AddService(this);
115 exported_services_.AddService(&view_manager_client_factory_);
116 WeakBindToPipe(&exported_services_, provider.PassMessagePipe());
117 Load(response_.Pass());
118 }
119
120 void HTMLDocumentView::Initialize(Array<String> args) {
121 } 116 }
122 117
123 void HTMLDocumentView::OnEmbed( 118 void HTMLDocumentView::OnEmbed(
124 ViewManager* view_manager, 119 ViewManager* view_manager,
125 View* root, 120 View* root,
126 ServiceProviderImpl* embedee_service_provider_impl, 121 ServiceProviderImpl* embedee_service_provider_impl,
127 scoped_ptr<ServiceProvider> embedder_service_provider) { 122 scoped_ptr<ServiceProvider> embedder_service_provider) {
128 root_ = root; 123 root_ = root;
129 embedder_service_provider_ = embedder_service_provider.Pass(); 124 embedder_service_provider_ = embedder_service_provider.Pass();
130 navigator_host_.set_service_provider(embedder_service_provider_.get()); 125 navigator_host_.set_service_provider(embedder_service_provider_.get());
131 126
127 Load(response_.Pass());
128
132 blink::WebSize root_size(root_->bounds().width, root_->bounds().height); 129 blink::WebSize root_size(root_->bounds().width, root_->bounds().height);
133 web_view_->resize(root_size); 130 web_view_->resize(root_size);
134 web_layer_tree_view_impl_->setViewportSize(root_size); 131 web_layer_tree_view_impl_->setViewportSize(root_size);
135 web_layer_tree_view_impl_->set_view(root_); 132 web_layer_tree_view_impl_->set_view(root_);
136 root_->AddObserver(this); 133 root_->AddObserver(this);
137 } 134 }
138 135
139 void HTMLDocumentView::Create(ApplicationConnection* connection, 136 void HTMLDocumentView::Create(ApplicationConnection* connection,
140 InterfaceRequest<AxProvider> request) { 137 InterfaceRequest<AxProvider> request) {
141 if (!web_view_) 138 if (!web_view_)
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 } 186 }
190 187
191 blink::WebLayerTreeView* HTMLDocumentView::layerTreeView() { 188 blink::WebLayerTreeView* HTMLDocumentView::layerTreeView() {
192 return web_layer_tree_view_impl_.get(); 189 return web_layer_tree_view_impl_.get();
193 } 190 }
194 191
195 blink::WebMediaPlayer* HTMLDocumentView::createMediaPlayer( 192 blink::WebMediaPlayer* HTMLDocumentView::createMediaPlayer(
196 blink::WebLocalFrame* frame, 193 blink::WebLocalFrame* frame,
197 const blink::WebURL& url, 194 const blink::WebURL& url,
198 blink::WebMediaPlayerClient* client) { 195 blink::WebMediaPlayerClient* client) {
199 return web_media_player_factory_->CreateMediaPlayer( 196 return web_media_player_factory_->CreateMediaPlayer(frame, url, client,
200 frame, url, client, shell_.get()); 197 shell_);
201 } 198 }
202 199
203 blink::WebMediaPlayer* HTMLDocumentView::createMediaPlayer( 200 blink::WebMediaPlayer* HTMLDocumentView::createMediaPlayer(
204 blink::WebLocalFrame* frame, 201 blink::WebLocalFrame* frame,
205 const blink::WebURL& url, 202 const blink::WebURL& url,
206 blink::WebMediaPlayerClient* client, 203 blink::WebMediaPlayerClient* client,
207 blink::WebContentDecryptionModule* initial_cdm) { 204 blink::WebContentDecryptionModule* initial_cdm) {
208 return createMediaPlayer(frame, url, client); 205 return createMediaPlayer(frame, url, client);
209 } 206 }
210 207
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 } 269 }
273 270
274 void HTMLDocumentView::OnViewInputEvent(View* view, const EventPtr& event) { 271 void HTMLDocumentView::OnViewInputEvent(View* view, const EventPtr& event) {
275 scoped_ptr<blink::WebInputEvent> web_event = 272 scoped_ptr<blink::WebInputEvent> web_event =
276 event.To<scoped_ptr<blink::WebInputEvent> >(); 273 event.To<scoped_ptr<blink::WebInputEvent> >();
277 if (web_event) 274 if (web_event)
278 web_view_->handleInputEvent(*web_event); 275 web_view_->handleInputEvent(*web_event);
279 } 276 }
280 277
281 } // namespace mojo 278 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698