| 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" |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 return std::make_shared<PDFDocument>(shared_from_this(), doc, data); | 110 return std::make_shared<PDFDocument>(shared_from_this(), doc, data); |
| 111 } | 111 } |
| 112 }; | 112 }; |
| 113 | 113 |
| 114 class PDFDocumentView : public mojo::ui::GaneshView, | 114 class PDFDocumentView : public mojo::ui::GaneshView, |
| 115 public mojo::ui::ChoreographerDelegate, | 115 public mojo::ui::ChoreographerDelegate, |
| 116 public mojo::ui::InputListener { | 116 public mojo::ui::InputListener { |
| 117 public: | 117 public: |
| 118 PDFDocumentView( | 118 PDFDocumentView( |
| 119 mojo::ApplicationImpl* app_impl, | 119 mojo::ApplicationImpl* app_impl, |
| 120 const std::shared_ptr<PDFDocument>& pdf_document, | 120 mojo::InterfaceRequest<mojo::ui::ViewOwner> view_owner_request, |
| 121 const mojo::ui::ViewProvider::CreateViewCallback& create_view_callback) | 121 const std::shared_ptr<PDFDocument>& pdf_document) |
| 122 : GaneshView(app_impl, "PDFDocumentViewer", create_view_callback), | 122 : GaneshView(app_impl, view_owner_request.Pass(), "PDFDocumentViewer"), |
| 123 pdf_document_(pdf_document), | 123 pdf_document_(pdf_document), |
| 124 choreographer_(scene(), this), | 124 choreographer_(scene(), this), |
| 125 input_handler_(view_service_provider(), this) { | 125 input_handler_(view_service_provider(), this) { |
| 126 DCHECK(pdf_document_); | 126 DCHECK(pdf_document_); |
| 127 } | 127 } |
| 128 | 128 |
| 129 ~PDFDocumentView() override {} | 129 ~PDFDocumentView() override {} |
| 130 | 130 |
| 131 private: | 131 private: |
| 132 // |GaneshView|: | 132 // |GaneshView|: |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 public: | 249 public: |
| 250 PDFContentViewProviderApp(const std::shared_ptr<PDFLibrary>& pdf_library, | 250 PDFContentViewProviderApp(const std::shared_ptr<PDFLibrary>& pdf_library, |
| 251 const std::shared_ptr<PDFDocument>& pdf_document) | 251 const std::shared_ptr<PDFDocument>& pdf_document) |
| 252 : pdf_library_(pdf_library), pdf_document_(pdf_document) { | 252 : pdf_library_(pdf_library), pdf_document_(pdf_document) { |
| 253 DCHECK(pdf_library_); | 253 DCHECK(pdf_library_); |
| 254 DCHECK(pdf_document_); | 254 DCHECK(pdf_document_); |
| 255 } | 255 } |
| 256 | 256 |
| 257 ~PDFContentViewProviderApp() override {} | 257 ~PDFContentViewProviderApp() override {} |
| 258 | 258 |
| 259 bool CreateView( | 259 void CreateView( |
| 260 const std::string& connection_url, | 260 const std::string& connection_url, |
| 261 mojo::InterfaceRequest<mojo::ui::ViewOwner> view_owner_request, |
| 261 mojo::InterfaceRequest<mojo::ServiceProvider> services, | 262 mojo::InterfaceRequest<mojo::ServiceProvider> services, |
| 262 mojo::ServiceProviderPtr exposed_services, | 263 mojo::ServiceProviderPtr exposed_services) override { |
| 263 const mojo::ui::ViewProvider::CreateViewCallback& callback) override { | 264 new PDFDocumentView(app_impl(), view_owner_request.Pass(), pdf_document_); |
| 264 new PDFDocumentView(app_impl(), pdf_document_, callback); | |
| 265 return true; | |
| 266 } | 265 } |
| 267 | 266 |
| 268 private: | 267 private: |
| 269 std::shared_ptr<PDFLibrary> pdf_library_; | 268 std::shared_ptr<PDFLibrary> pdf_library_; |
| 270 std::shared_ptr<PDFDocument> pdf_document_; | 269 std::shared_ptr<PDFDocument> pdf_document_; |
| 271 | 270 |
| 272 DISALLOW_COPY_AND_ASSIGN(PDFContentViewProviderApp); | 271 DISALLOW_COPY_AND_ASSIGN(PDFContentViewProviderApp); |
| 273 }; | 272 }; |
| 274 | 273 |
| 275 class PDFContentViewerApp : public mojo::ui::ContentViewerApp { | 274 class PDFContentViewerApp : public mojo::ui::ContentViewerApp { |
| (...skipping 20 matching lines...) Expand all Loading... |
| 296 | 295 |
| 297 DISALLOW_COPY_AND_ASSIGN(PDFContentViewerApp); | 296 DISALLOW_COPY_AND_ASSIGN(PDFContentViewerApp); |
| 298 }; | 297 }; |
| 299 | 298 |
| 300 } // namespace examples | 299 } // namespace examples |
| 301 | 300 |
| 302 MojoResult MojoMain(MojoHandle application_request) { | 301 MojoResult MojoMain(MojoHandle application_request) { |
| 303 mojo::ApplicationRunnerChromium runner(new examples::PDFContentViewerApp()); | 302 mojo::ApplicationRunnerChromium runner(new examples::PDFContentViewerApp()); |
| 304 return runner.Run(application_request); | 303 return runner.Run(application_request); |
| 305 } | 304 } |
| OLD | NEW |