| 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 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 // TODO(abarth): We should ask the view whether it is focused instead of | 151 // TODO(abarth): We should ask the view whether it is focused instead of |
| 152 // assuming that we're focused. | 152 // assuming that we're focused. |
| 153 if (web_view_) | 153 if (web_view_) |
| 154 web_view_->setFocus(true); | 154 web_view_->setFocus(true); |
| 155 root_->AddObserver(this); | 155 root_->AddObserver(this); |
| 156 } | 156 } |
| 157 | 157 |
| 158 void DocumentView::OnViewManagerDisconnected(mojo::ViewManager* view_manager) { | 158 void DocumentView::OnViewManagerDisconnected(mojo::ViewManager* view_manager) { |
| 159 // TODO(aa): Need to figure out how shutdown works. | 159 // TODO(aa): Need to figure out how shutdown works. |
| 160 } | 160 } |
| 161 void DocumentView::Load(mojo::URLResponsePtr response) { |
| 162 GURL responseURL(response->url); |
| 161 | 163 |
| 162 void DocumentView::Load(mojo::URLResponsePtr response) { | 164 if (!blink::WebView::shouldUseWebView(responseURL)) { |
| 163 // Enable SkyView here. | |
| 164 if (false) { | |
| 165 sky_view_ = blink::SkyView::Create(this); | 165 sky_view_ = blink::SkyView::Create(this); |
| 166 initializeLayerTreeView(); | 166 initializeLayerTreeView(); |
| 167 sky_view_->Load(GURL(response->url), response.Pass()); | 167 sky_view_->Load(responseURL, response.Pass()); |
| 168 return; | 168 return; |
| 169 } | 169 } |
| 170 | 170 |
| 171 if (!RuntimeFlags::Get().testing()) |
| 172 LOG(WARNING) << ".sky support is deprecated, please use .dart for main()"; |
| 173 |
| 171 web_view_ = blink::WebView::create(this); | 174 web_view_ = blink::WebView::create(this); |
| 172 ConfigureSettings(web_view_->settings()); | 175 ConfigureSettings(web_view_->settings()); |
| 173 web_view_->setMainFrame(blink::WebLocalFrame::create(this)); | 176 web_view_->setMainFrame(blink::WebLocalFrame::create(this)); |
| 174 web_view_->mainFrame()->loadFromDataPipeWithURL( | 177 web_view_->mainFrame()->loadFromDataPipeWithURL( |
| 175 response->body.Pass(), GURL(response->url)); | 178 response->body.Pass(), responseURL); |
| 176 } | 179 } |
| 177 | 180 |
| 178 void DocumentView::initializeLayerTreeView() { | 181 void DocumentView::initializeLayerTreeView() { |
| 179 layer_host_.reset(new LayerHost(this)); | 182 layer_host_.reset(new LayerHost(this)); |
| 180 root_layer_ = make_scoped_refptr(new Layer(this)); | 183 root_layer_ = make_scoped_refptr(new Layer(this)); |
| 181 root_layer_->set_rasterizer(CreateRasterizer()); | 184 root_layer_->set_rasterizer(CreateRasterizer()); |
| 182 layer_host_->SetRootLayer(root_layer_); | 185 layer_host_->SetRootLayer(root_layer_); |
| 183 } | 186 } |
| 184 | 187 |
| 185 scoped_ptr<Rasterizer> DocumentView::CreateRasterizer() { | 188 scoped_ptr<Rasterizer> DocumentView::CreateRasterizer() { |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 430 new mojo::StrongBinding<mojo::ServiceProvider>(sp_impl, &sp)); | 433 new mojo::StrongBinding<mojo::ServiceProvider>(sp_impl, &sp)); |
| 431 service_registry_->AddServices(interface_names.Pass(), sp.Pass()); | 434 service_registry_->AddServices(interface_names.Pass(), sp.Pass()); |
| 432 } | 435 } |
| 433 | 436 |
| 434 void DocumentView::ScheduleFrame() { | 437 void DocumentView::ScheduleFrame() { |
| 435 DCHECK(sky_view_); | 438 DCHECK(sky_view_); |
| 436 layer_host_->SetNeedsAnimate(); | 439 layer_host_->SetNeedsAnimate(); |
| 437 } | 440 } |
| 438 | 441 |
| 439 } // namespace sky | 442 } // namespace sky |
| OLD | NEW |