OLD | NEW |
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 "sky/viewer/document_view.h" | 5 #include "sky/viewer/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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 case blink::WebNavigationPolicyNewPopup: | 58 case blink::WebNavigationPolicyNewPopup: |
59 return mojo::TARGET_NEW_NODE; | 59 return mojo::TARGET_NEW_NODE; |
60 default: | 60 default: |
61 return mojo::TARGET_DEFAULT; | 61 return mojo::TARGET_DEFAULT; |
62 } | 62 } |
63 } | 63 } |
64 | 64 |
65 } // namespace | 65 } // namespace |
66 | 66 |
67 DocumentView::DocumentView( | 67 DocumentView::DocumentView( |
| 68 const base::Closure& destruction_callback, |
| 69 mojo::ServiceProviderPtr provider, |
68 mojo::URLResponsePtr response, | 70 mojo::URLResponsePtr response, |
69 mojo::ShellPtr shell, | 71 mojo::Shell* shell, |
70 scoped_refptr<base::MessageLoopProxy> compositor_thread) | 72 scoped_refptr<base::MessageLoopProxy> compositor_thread) |
71 : response_(response.Pass()), | 73 : destruction_callback_(destruction_callback), |
72 shell_(shell.Pass()), | 74 response_(response.Pass()), |
| 75 shell_(shell), |
73 web_view_(NULL), | 76 web_view_(NULL), |
74 root_(NULL), | 77 root_(NULL), |
75 view_manager_client_factory_(shell_.get(), this), | 78 view_manager_client_factory_(shell_, this), |
76 inspector_service_factory_(this), | 79 inspector_service_factory_(this), |
77 compositor_thread_(compositor_thread), | 80 compositor_thread_(compositor_thread), |
78 weak_factory_(this) { | 81 weak_factory_(this) { |
79 shell_.set_client(this); | 82 exported_services_.AddService(&view_manager_client_factory_); |
| 83 mojo::WeakBindToPipe(&exported_services_, provider.PassMessagePipe()); |
80 } | 84 } |
81 | 85 |
82 DocumentView::~DocumentView() { | 86 DocumentView::~DocumentView() { |
83 if (web_view_) | 87 if (web_view_) |
84 web_view_->close(); | 88 web_view_->close(); |
85 if (root_) | 89 if (root_) |
86 root_->RemoveObserver(this); | 90 root_->RemoveObserver(this); |
| 91 destruction_callback_.Run(); |
87 } | 92 } |
88 | 93 |
89 base::WeakPtr<DocumentView> DocumentView::GetWeakPtr() { | 94 base::WeakPtr<DocumentView> DocumentView::GetWeakPtr() { |
90 return weak_factory_.GetWeakPtr(); | 95 return weak_factory_.GetWeakPtr(); |
91 } | 96 } |
92 | 97 |
93 void DocumentView::AcceptConnection(const mojo::String& requestor_url, | |
94 mojo::ServiceProviderPtr provider) { | |
95 exported_services_.AddService(&view_manager_client_factory_); | |
96 mojo::WeakBindToPipe(&exported_services_, provider.PassMessagePipe()); | |
97 } | |
98 | |
99 void DocumentView::Initialize(mojo::Array<mojo::String> args) { | |
100 } | |
101 | |
102 void DocumentView::OnEmbed( | 98 void DocumentView::OnEmbed( |
103 mojo::ViewManager* view_manager, | 99 mojo::ViewManager* view_manager, |
104 mojo::View* root, | 100 mojo::View* root, |
105 mojo::ServiceProviderImpl* exported_services, | 101 mojo::ServiceProviderImpl* exported_services, |
106 scoped_ptr<mojo::ServiceProvider> imported_services) { | 102 scoped_ptr<mojo::ServiceProvider> imported_services) { |
107 | 103 |
108 root_ = root; | 104 root_ = root; |
109 imported_services_ = imported_services.Pass(); | 105 imported_services_ = imported_services.Pass(); |
110 navigator_host_.set_service_provider(imported_services_.get()); | 106 navigator_host_.set_service_provider(imported_services_.get()); |
111 exported_services->AddService(&inspector_service_factory_); | 107 exported_services->AddService(&inspector_service_factory_); |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 | 231 |
236 void DocumentView::OnViewInputEvent( | 232 void DocumentView::OnViewInputEvent( |
237 mojo::View* view, const mojo::EventPtr& event) { | 233 mojo::View* view, const mojo::EventPtr& event) { |
238 scoped_ptr<blink::WebInputEvent> web_event = | 234 scoped_ptr<blink::WebInputEvent> web_event = |
239 event.To<scoped_ptr<blink::WebInputEvent> >(); | 235 event.To<scoped_ptr<blink::WebInputEvent> >(); |
240 if (web_event) | 236 if (web_event) |
241 web_view_->handleInputEvent(*web_event); | 237 web_view_->handleInputEvent(*web_event); |
242 } | 238 } |
243 | 239 |
244 } // namespace sky | 240 } // namespace sky |
OLD | NEW |