OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/shell/ui/engine.h" | 5 #include "sky/shell/ui/engine.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "mojo/public/cpp/application/connect.h" | 8 #include "mojo/public/cpp/application/connect.h" |
9 #include "sky/engine/public/platform/WebInputEvent.h" | 9 #include "sky/engine/public/platform/WebInputEvent.h" |
10 #include "sky/engine/public/web/Sky.h" | 10 #include "sky/engine/public/web/Sky.h" |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 | 112 |
113 void Engine::OnInputEvent(InputEventPtr event) { | 113 void Engine::OnInputEvent(InputEventPtr event) { |
114 scoped_ptr<blink::WebInputEvent> web_event = | 114 scoped_ptr<blink::WebInputEvent> web_event = |
115 ConvertEvent(event, device_pixel_ratio_); | 115 ConvertEvent(event, device_pixel_ratio_); |
116 if (!web_event) | 116 if (!web_event) |
117 return; | 117 return; |
118 web_view_->handleInputEvent(*web_event); | 118 web_view_->handleInputEvent(*web_event); |
119 } | 119 } |
120 | 120 |
121 void Engine::LoadURL(const mojo::String& url) { | 121 void Engine::LoadURL(const mojo::String& url) { |
122 web_view_ = blink::WebView::create(this); | 122 // Something bad happens if you try to call WebView::close and replace |
| 123 // the webview. So for now we just load into the existing one. :/ |
| 124 if (!web_view_) |
| 125 web_view_ = blink::WebView::create(this); |
123 ConfigureSettings(web_view_->settings()); | 126 ConfigureSettings(web_view_->settings()); |
124 web_view_->setMainFrame(blink::WebLocalFrame::create(this)); | 127 web_view_->setMainFrame(blink::WebLocalFrame::create(this)); |
125 UpdateWebViewSize(); | 128 UpdateWebViewSize(); |
126 web_view_->mainFrame()->load(GURL(url)); | 129 web_view_->mainFrame()->load(GURL(url)); |
127 } | 130 } |
128 | 131 |
| 132 void Engine::frameDetached(blink::WebFrame* frame) { |
| 133 // |frame| is invalid after here. |
| 134 frame->close(); |
| 135 } |
| 136 |
129 void Engine::initializeLayerTreeView() { | 137 void Engine::initializeLayerTreeView() { |
130 } | 138 } |
131 | 139 |
132 void Engine::scheduleVisualUpdate() { | 140 void Engine::scheduleVisualUpdate() { |
133 animator_->RequestFrame(); | 141 animator_->RequestFrame(); |
134 } | 142 } |
135 | 143 |
| 144 blink::ServiceProvider* Engine::services() { |
| 145 return this; |
| 146 } |
| 147 |
| 148 mojo::NavigatorHost* Engine::NavigatorHost() { |
| 149 return this; |
| 150 } |
| 151 |
| 152 void Engine::RequestNavigate(mojo::Target target, |
| 153 mojo::URLRequestPtr request) { |
| 154 // Ignoring target for now. |
| 155 base::MessageLoop::current()->PostTask(FROM_HERE, |
| 156 base::Bind(&Engine::LoadURL, GetWeakPtr(), request->url)); |
| 157 } |
| 158 |
| 159 void Engine::DidNavigateLocally(const mojo::String& url) { |
| 160 } |
| 161 |
136 } // namespace shell | 162 } // namespace shell |
137 } // namespace sky | 163 } // namespace sky |
OLD | NEW |