| 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 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 if (frame != web_view_->mainFrame()) | 175 if (frame != web_view_->mainFrame()) |
| 176 return; | 176 return; |
| 177 script_runner_.reset(new ScriptRunner(frame, context)); | 177 script_runner_.reset(new ScriptRunner(frame, context)); |
| 178 | 178 |
| 179 v8::Isolate* isolate = context->GetIsolate(); | 179 v8::Isolate* isolate = context->GetIsolate(); |
| 180 gin::Handle<Internals> internals = Internals::Create(isolate, this); | 180 gin::Handle<Internals> internals = Internals::Create(isolate, this); |
| 181 context->Global()->Set(gin::StringToV8(isolate, "internals"), | 181 context->Global()->Set(gin::StringToV8(isolate, "internals"), |
| 182 gin::ConvertToV8(isolate, internals)); | 182 gin::ConvertToV8(isolate, internals)); |
| 183 } | 183 } |
| 184 | 184 |
| 185 blink::ServiceProvider* DocumentView::services() { |
| 186 return this; |
| 187 } |
| 188 |
| 189 mojo::NavigatorHost* DocumentView::NavigatorHost() { |
| 190 return navigator_host_.get(); |
| 191 } |
| 192 |
| 185 void DocumentView::OnViewBoundsChanged(mojo::View* view, | 193 void DocumentView::OnViewBoundsChanged(mojo::View* view, |
| 186 const mojo::Rect& old_bounds, | 194 const mojo::Rect& old_bounds, |
| 187 const mojo::Rect& new_bounds) { | 195 const mojo::Rect& new_bounds) { |
| 188 DCHECK_EQ(view, root_); | 196 DCHECK_EQ(view, root_); |
| 189 gfx::Size size = new_bounds.To<gfx::Rect>().size(); | 197 gfx::Size size = new_bounds.To<gfx::Rect>().size(); |
| 190 web_view_->resize(size); | 198 web_view_->resize(size); |
| 191 web_layer_tree_view_impl_->setViewportSize(size); | 199 web_layer_tree_view_impl_->setViewportSize(size); |
| 192 } | 200 } |
| 193 | 201 |
| 194 void DocumentView::OnViewDestroyed(mojo::View* view) { | 202 void DocumentView::OnViewDestroyed(mojo::View* view) { |
| 195 DCHECK_EQ(view, root_); | 203 DCHECK_EQ(view, root_); |
| 196 delete this; | 204 delete this; |
| 197 } | 205 } |
| 198 | 206 |
| 199 void DocumentView::OnViewInputEvent( | 207 void DocumentView::OnViewInputEvent( |
| 200 mojo::View* view, const mojo::EventPtr& event) { | 208 mojo::View* view, const mojo::EventPtr& event) { |
| 201 scoped_ptr<blink::WebInputEvent> web_event = | 209 scoped_ptr<blink::WebInputEvent> web_event = |
| 202 event.To<scoped_ptr<blink::WebInputEvent> >(); | 210 event.To<scoped_ptr<blink::WebInputEvent> >(); |
| 203 if (web_event) | 211 if (web_event) |
| 204 web_view_->handleInputEvent(*web_event); | 212 web_view_->handleInputEvent(*web_event); |
| 205 } | 213 } |
| 206 | 214 |
| 207 } // namespace sky | 215 } // namespace sky |
| OLD | NEW |