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 <memory> | 5 #include <memory> |
6 #include <string> | 6 #include <string> |
7 | 7 |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
11 #include "mojo/application/application_runner_chromium.h" | 11 #include "mojo/application/application_runner_chromium.h" |
12 #include "mojo/data_pipe_utils/data_pipe_utils.h" | 12 #include "mojo/data_pipe_utils/data_pipe_utils.h" |
13 #include "mojo/public/c/system/main.h" | 13 #include "mojo/public/c/system/main.h" |
| 14 #include "mojo/public/cpp/application/connect.h" |
14 #include "mojo/ui/choreographer.h" | 15 #include "mojo/ui/choreographer.h" |
15 #include "mojo/ui/content_viewer_app.h" | 16 #include "mojo/ui/content_viewer_app.h" |
16 #include "mojo/ui/ganesh_view.h" | 17 #include "mojo/ui/ganesh_view.h" |
17 #include "mojo/ui/input_handler.h" | 18 #include "mojo/ui/input_handler.h" |
18 #include "third_party/pdfium/fpdfsdk/include/fpdf_ext.h" | 19 #include "third_party/pdfium/fpdfsdk/include/fpdf_ext.h" |
19 #include "third_party/pdfium/fpdfsdk/include/fpdfview.h" | 20 #include "third_party/pdfium/fpdfsdk/include/fpdfview.h" |
20 #include "third_party/skia/include/core/SkCanvas.h" | 21 #include "third_party/skia/include/core/SkCanvas.h" |
21 #include "third_party/skia/include/core/SkData.h" | 22 #include "third_party/skia/include/core/SkData.h" |
22 #include "third_party/skia/include/core/SkImage.h" | 23 #include "third_party/skia/include/core/SkImage.h" |
23 #include "third_party/skia/include/core/SkImageInfo.h" | 24 #include "third_party/skia/include/core/SkImageInfo.h" |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 | 110 |
110 return std::make_shared<PDFDocument>(shared_from_this(), doc, data); | 111 return std::make_shared<PDFDocument>(shared_from_this(), doc, data); |
111 } | 112 } |
112 }; | 113 }; |
113 | 114 |
114 class PDFDocumentView : public mojo::ui::GaneshView, | 115 class PDFDocumentView : public mojo::ui::GaneshView, |
115 public mojo::ui::ChoreographerDelegate, | 116 public mojo::ui::ChoreographerDelegate, |
116 public mojo::ui::InputListener { | 117 public mojo::ui::InputListener { |
117 public: | 118 public: |
118 PDFDocumentView( | 119 PDFDocumentView( |
119 mojo::ApplicationImpl* app_impl, | 120 mojo::InterfaceHandle<mojo::ApplicationConnector> app_connector, |
120 mojo::InterfaceRequest<mojo::ui::ViewOwner> view_owner_request, | 121 mojo::InterfaceRequest<mojo::ui::ViewOwner> view_owner_request, |
121 const std::shared_ptr<PDFDocument>& pdf_document) | 122 const std::shared_ptr<PDFDocument>& pdf_document) |
122 : GaneshView(app_impl, view_owner_request.Pass(), "PDFDocumentViewer"), | 123 : GaneshView(app_connector.Pass(), |
| 124 view_owner_request.Pass(), |
| 125 "PDFDocumentViewer"), |
123 pdf_document_(pdf_document), | 126 pdf_document_(pdf_document), |
124 choreographer_(scene(), this), | 127 choreographer_(scene(), this), |
125 input_handler_(GetViewServiceProvider(), this) { | 128 input_handler_(GetViewServiceProvider(), this) { |
126 DCHECK(pdf_document_); | 129 DCHECK(pdf_document_); |
127 } | 130 } |
128 | 131 |
129 ~PDFDocumentView() override {} | 132 ~PDFDocumentView() override {} |
130 | 133 |
131 private: | 134 private: |
132 // |GaneshView|: | 135 // |GaneshView|: |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 DCHECK(pdf_document_); | 267 DCHECK(pdf_document_); |
265 } | 268 } |
266 | 269 |
267 ~PDFContentViewProviderApp() override {} | 270 ~PDFContentViewProviderApp() override {} |
268 | 271 |
269 void CreateView( | 272 void CreateView( |
270 const std::string& connection_url, | 273 const std::string& connection_url, |
271 mojo::InterfaceRequest<mojo::ui::ViewOwner> view_owner_request, | 274 mojo::InterfaceRequest<mojo::ui::ViewOwner> view_owner_request, |
272 mojo::InterfaceRequest<mojo::ServiceProvider> services, | 275 mojo::InterfaceRequest<mojo::ServiceProvider> services, |
273 mojo::InterfaceHandle<mojo::ServiceProvider> exposed_services) override { | 276 mojo::InterfaceHandle<mojo::ServiceProvider> exposed_services) override { |
274 new PDFDocumentView(app_impl(), view_owner_request.Pass(), pdf_document_); | 277 new PDFDocumentView(mojo::CreateApplicationConnector(app_impl()->shell()), |
| 278 view_owner_request.Pass(), pdf_document_); |
275 } | 279 } |
276 | 280 |
277 private: | 281 private: |
278 std::shared_ptr<PDFLibrary> pdf_library_; | 282 std::shared_ptr<PDFLibrary> pdf_library_; |
279 std::shared_ptr<PDFDocument> pdf_document_; | 283 std::shared_ptr<PDFDocument> pdf_document_; |
280 | 284 |
281 DISALLOW_COPY_AND_ASSIGN(PDFContentViewProviderApp); | 285 DISALLOW_COPY_AND_ASSIGN(PDFContentViewProviderApp); |
282 }; | 286 }; |
283 | 287 |
284 class PDFContentViewerApp : public mojo::ui::ContentViewerApp { | 288 class PDFContentViewerApp : public mojo::ui::ContentViewerApp { |
(...skipping 20 matching lines...) Expand all Loading... |
305 | 309 |
306 DISALLOW_COPY_AND_ASSIGN(PDFContentViewerApp); | 310 DISALLOW_COPY_AND_ASSIGN(PDFContentViewerApp); |
307 }; | 311 }; |
308 | 312 |
309 } // namespace examples | 313 } // namespace examples |
310 | 314 |
311 MojoResult MojoMain(MojoHandle application_request) { | 315 MojoResult MojoMain(MojoHandle application_request) { |
312 mojo::ApplicationRunnerChromium runner(new examples::PDFContentViewerApp()); | 316 mojo::ApplicationRunnerChromium runner(new examples::PDFContentViewerApp()); |
313 return runner.Run(application_request); | 317 return runner.Run(application_request); |
314 } | 318 } |
OLD | NEW |