Chromium Code Reviews| 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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 57 case blink::WebNavigationPolicyNewWindow: | 57 case blink::WebNavigationPolicyNewWindow: |
| 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 static int s_next_debugger_id = 1; | |
| 68 | |
| 67 DocumentView::DocumentView( | 69 DocumentView::DocumentView( |
| 68 mojo::URLResponsePtr response, | 70 mojo::URLResponsePtr response, |
| 69 mojo::ShellPtr shell, | 71 mojo::ShellPtr shell, |
| 70 scoped_refptr<base::MessageLoopProxy> compositor_thread) | 72 scoped_refptr<base::MessageLoopProxy> compositor_thread) |
| 71 : response_(response.Pass()), | 73 : response_(response.Pass()), |
| 72 shell_(shell.Pass()), | 74 shell_(shell.Pass()), |
| 73 web_view_(NULL), | 75 web_view_(NULL), |
| 74 root_(NULL), | 76 root_(NULL), |
| 75 view_manager_client_factory_(shell_.get(), this), | 77 view_manager_client_factory_(shell_.get(), this), |
| 76 inspector_service_factory_(this), | 78 inspector_service_factory_(this), |
| 77 compositor_thread_(compositor_thread), | 79 compositor_thread_(compositor_thread), |
| 80 debugger_id_(s_next_debugger_id++), | |
|
eseidel
2014/11/18 19:38:48
This ended up not being used, will remove.
abarth-chromium
2014/11/18 22:37:37
ok
| |
| 78 weak_factory_(this) { | 81 weak_factory_(this) { |
| 79 shell_.set_client(this); | 82 shell_.set_client(this); |
| 80 } | 83 } |
| 81 | 84 |
| 82 DocumentView::~DocumentView() { | 85 DocumentView::~DocumentView() { |
| 83 if (web_view_) | 86 if (web_view_) |
| 84 web_view_->close(); | 87 web_view_->close(); |
| 85 if (root_) | 88 if (root_) |
| 86 root_->RemoveObserver(this); | 89 root_->RemoveObserver(this); |
| 87 } | 90 } |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 184 const blink::WebConsoleMessage& message, | 187 const blink::WebConsoleMessage& message, |
| 185 const blink::WebString& source_name, | 188 const blink::WebString& source_name, |
| 186 unsigned source_line, | 189 unsigned source_line, |
| 187 const blink::WebString& stack_trace) { | 190 const blink::WebString& stack_trace) { |
| 188 } | 191 } |
| 189 | 192 |
| 190 void DocumentView::didCreateScriptContext(blink::WebLocalFrame* frame, | 193 void DocumentView::didCreateScriptContext(blink::WebLocalFrame* frame, |
| 191 v8::Handle<v8::Context> context, | 194 v8::Handle<v8::Context> context, |
| 192 int extensionGroup, | 195 int extensionGroup, |
| 193 int worldId) { | 196 int worldId) { |
| 194 if (frame != web_view_->mainFrame()) | |
| 195 return; | |
| 196 script_runner_.reset(new ScriptRunner(frame, context)); | 197 script_runner_.reset(new ScriptRunner(frame, context)); |
| 197 | 198 |
| 198 v8::Isolate* isolate = context->GetIsolate(); | 199 v8::Isolate* isolate = context->GetIsolate(); |
| 199 gin::Handle<Internals> internals = Internals::Create(isolate, this); | 200 gin::Handle<Internals> internals = Internals::Create(isolate, this); |
| 200 context->Global()->Set(gin::StringToV8(isolate, "internals"), | 201 context->Global()->Set(gin::StringToV8(isolate, "internals"), |
| 201 gin::ConvertToV8(isolate, internals)); | 202 gin::ConvertToV8(isolate, internals)); |
| 202 } | 203 } |
| 203 | 204 |
| 204 blink::ServiceProvider& DocumentView::services() { | 205 blink::ServiceProvider& DocumentView::services() { |
| 205 return *this; | 206 return *this; |
| 206 } | 207 } |
| 207 | 208 |
| 208 mojo::NavigatorHost* DocumentView::NavigatorHost() { | 209 mojo::NavigatorHost* DocumentView::NavigatorHost() { |
| 209 return navigator_host_.get(); | 210 return navigator_host_.get(); |
| 210 } | 211 } |
| 211 | 212 |
| 213 mojo::Shell* DocumentView::Shell() { | |
| 214 return shell_.get(); | |
| 215 } | |
| 216 | |
| 212 void DocumentView::OnViewBoundsChanged(mojo::View* view, | 217 void DocumentView::OnViewBoundsChanged(mojo::View* view, |
| 213 const mojo::Rect& old_bounds, | 218 const mojo::Rect& old_bounds, |
| 214 const mojo::Rect& new_bounds) { | 219 const mojo::Rect& new_bounds) { |
| 215 DCHECK_EQ(view, root_); | 220 DCHECK_EQ(view, root_); |
| 216 gfx::Size size = new_bounds.To<gfx::Rect>().size(); | 221 gfx::Size size = new_bounds.To<gfx::Rect>().size(); |
| 217 web_view_->resize(size); | 222 web_view_->resize(size); |
| 218 web_layer_tree_view_impl_->setViewportSize(size); | 223 web_layer_tree_view_impl_->setViewportSize(size); |
| 219 } | 224 } |
| 220 | 225 |
| 221 void DocumentView::OnViewFocusChanged(mojo::View* gained_focus, | 226 void DocumentView::OnViewFocusChanged(mojo::View* gained_focus, |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 235 | 240 |
| 236 void DocumentView::OnViewInputEvent( | 241 void DocumentView::OnViewInputEvent( |
| 237 mojo::View* view, const mojo::EventPtr& event) { | 242 mojo::View* view, const mojo::EventPtr& event) { |
| 238 scoped_ptr<blink::WebInputEvent> web_event = | 243 scoped_ptr<blink::WebInputEvent> web_event = |
| 239 event.To<scoped_ptr<blink::WebInputEvent> >(); | 244 event.To<scoped_ptr<blink::WebInputEvent> >(); |
| 240 if (web_event) | 245 if (web_event) |
| 241 web_view_->handleInputEvent(*web_event); | 246 web_view_->handleInputEvent(*web_event); |
| 242 } | 247 } |
| 243 | 248 |
| 244 } // namespace sky | 249 } // namespace sky |
| OLD | NEW |