| 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 <stddef.h> | 5 #include <stddef.h> |
| 6 #include <stdint.h> | 6 #include <stdint.h> |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 FPDF_DOCUMENT doc, | 57 FPDF_DOCUMENT doc, |
| 58 const DeleteCallback& delete_callback) | 58 const DeleteCallback& delete_callback) |
| 59 : app_ref_(shell->CreateAppRefCount()), | 59 : app_ref_(shell->CreateAppRefCount()), |
| 60 doc_(doc), | 60 doc_(doc), |
| 61 current_page_(0), | 61 current_page_(0), |
| 62 page_count_(FPDF_GetPageCount(doc_)), | 62 page_count_(FPDF_GetPageCount(doc_)), |
| 63 shell_(shell), | 63 shell_(shell), |
| 64 root_(nullptr), | 64 root_(nullptr), |
| 65 frame_client_binding_(this), | 65 frame_client_binding_(this), |
| 66 delete_callback_(delete_callback) { | 66 delete_callback_(delete_callback) { |
| 67 connection->AddService(this); | 67 connection->AddInterface(this); |
| 68 } | 68 } |
| 69 | 69 |
| 70 void Close() { | 70 void Close() { |
| 71 if (root_) | 71 if (root_) |
| 72 mus::ScopedWindowPtr::DeleteWindowOrWindowManager(root_); | 72 mus::ScopedWindowPtr::DeleteWindowOrWindowManager(root_); |
| 73 else | 73 else |
| 74 delete this; | 74 delete this; |
| 75 } | 75 } |
| 76 | 76 |
| 77 private: | 77 private: |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 280 void OnTerminate() { delete this; } | 280 void OnTerminate() { delete this; } |
| 281 | 281 |
| 282 void OnPDFViewDestroyed(PDFView* pdf_view) { | 282 void OnPDFViewDestroyed(PDFView* pdf_view) { |
| 283 DCHECK(std::find(pdf_views_.begin(), pdf_views_.end(), pdf_view) != | 283 DCHECK(std::find(pdf_views_.begin(), pdf_views_.end(), pdf_view) != |
| 284 pdf_views_.end()); | 284 pdf_views_.end()); |
| 285 pdf_views_.erase(std::find(pdf_views_.begin(), pdf_views_.end(), pdf_view)); | 285 pdf_views_.erase(std::find(pdf_views_.begin(), pdf_views_.end(), pdf_view)); |
| 286 } | 286 } |
| 287 | 287 |
| 288 // mojo::ShellClient: | 288 // mojo::ShellClient: |
| 289 bool AcceptConnection(mojo::Connection* connection) override { | 289 bool AcceptConnection(mojo::Connection* connection) override { |
| 290 connection->AddService<mus::mojom::WindowTreeClient>(this); | 290 connection->AddInterface<mus::mojom::WindowTreeClient>(this); |
| 291 return true; | 291 return true; |
| 292 } | 292 } |
| 293 | 293 |
| 294 // mojo::InterfaceFactory<mus::mojom::WindowTreeClient>: | 294 // mojo::InterfaceFactory<mus::mojom::WindowTreeClient>: |
| 295 void Create( | 295 void Create( |
| 296 mojo::Connection* connection, | 296 mojo::Connection* connection, |
| 297 mojo::InterfaceRequest<mus::mojom::WindowTreeClient> request) override { | 297 mojo::InterfaceRequest<mus::mojom::WindowTreeClient> request) override { |
| 298 PDFView* pdf_view = new PDFView( | 298 PDFView* pdf_view = new PDFView( |
| 299 &app_, connection, doc_, | 299 &app_, connection, doc_, |
| 300 base::Bind(&PDFViewerApplicationDelegate::OnPDFViewDestroyed, | 300 base::Bind(&PDFViewerApplicationDelegate::OnPDFViewDestroyed, |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 349 ~PDFViewer() override { FPDF_DestroyLibrary(); } | 349 ~PDFViewer() override { FPDF_DestroyLibrary(); } |
| 350 | 350 |
| 351 private: | 351 private: |
| 352 // mojo::ShellClient: | 352 // mojo::ShellClient: |
| 353 void Initialize(mojo::Shell* shell, const std::string& url, | 353 void Initialize(mojo::Shell* shell, const std::string& url, |
| 354 uint32_t id) override { | 354 uint32_t id) override { |
| 355 tracing_.Initialize(shell, url); | 355 tracing_.Initialize(shell, url); |
| 356 } | 356 } |
| 357 | 357 |
| 358 bool AcceptConnection(mojo::Connection* connection) override { | 358 bool AcceptConnection(mojo::Connection* connection) override { |
| 359 connection->AddService(this); | 359 connection->AddInterface(this); |
| 360 return true; | 360 return true; |
| 361 } | 361 } |
| 362 | 362 |
| 363 // InterfaceFactory<ContentHandler>: | 363 // InterfaceFactory<ContentHandler>: |
| 364 void Create(mojo::Connection* connection, | 364 void Create(mojo::Connection* connection, |
| 365 mojo::InterfaceRequest<mojo::shell::mojom::ContentHandler> | 365 mojo::InterfaceRequest<mojo::shell::mojom::ContentHandler> |
| 366 request) override { | 366 request) override { |
| 367 new ContentHandlerImpl(std::move(request)); | 367 new ContentHandlerImpl(std::move(request)); |
| 368 } | 368 } |
| 369 | 369 |
| 370 mojo::TracingImpl tracing_; | 370 mojo::TracingImpl tracing_; |
| 371 | 371 |
| 372 DISALLOW_COPY_AND_ASSIGN(PDFViewer); | 372 DISALLOW_COPY_AND_ASSIGN(PDFViewer); |
| 373 }; | 373 }; |
| 374 } // namespace | 374 } // namespace |
| 375 } // namespace pdf_viewer | 375 } // namespace pdf_viewer |
| 376 | 376 |
| 377 MojoResult MojoMain(MojoHandle request) { | 377 MojoResult MojoMain(MojoHandle request) { |
| 378 mojo::ApplicationRunner runner(new pdf_viewer::PDFViewer()); | 378 mojo::ApplicationRunner runner(new pdf_viewer::PDFViewer()); |
| 379 return runner.Run(request); | 379 return runner.Run(request); |
| 380 } | 380 } |
| OLD | NEW |