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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 | 47 |
48 // Responsible for managing a particlar view displaying a PDF document. | 48 // Responsible for managing a particlar view displaying a PDF document. |
49 class PDFView : public mus::WindowTreeDelegate, | 49 class PDFView : public mus::WindowTreeDelegate, |
50 public mus::WindowObserver, | 50 public mus::WindowObserver, |
51 public mus::InputEventHandler, | 51 public mus::InputEventHandler, |
52 public web_view::mojom::FrameClient, | 52 public web_view::mojom::FrameClient, |
53 public mojo::InterfaceFactory<web_view::mojom::FrameClient> { | 53 public mojo::InterfaceFactory<web_view::mojom::FrameClient> { |
54 public: | 54 public: |
55 using DeleteCallback = base::Callback<void(PDFView*)>; | 55 using DeleteCallback = base::Callback<void(PDFView*)>; |
56 | 56 |
57 PDFView(mojo::ApplicationImpl* app, | 57 PDFView(mojo::Shell* shell, |
58 mojo::ApplicationConnection* connection, | 58 mojo::ApplicationConnection* connection, |
59 FPDF_DOCUMENT doc, | 59 FPDF_DOCUMENT doc, |
60 const DeleteCallback& delete_callback) | 60 const DeleteCallback& delete_callback) |
61 : app_ref_(app->app_lifetime_helper()->CreateAppRefCount()), | 61 : app_ref_(shell->CreateAppRefCount()), |
62 doc_(doc), | 62 doc_(doc), |
63 current_page_(0), | 63 current_page_(0), |
64 page_count_(FPDF_GetPageCount(doc_)), | 64 page_count_(FPDF_GetPageCount(doc_)), |
65 shell_(app->shell()), | 65 shell_(shell), |
66 root_(nullptr), | 66 root_(nullptr), |
67 frame_client_binding_(this), | 67 frame_client_binding_(this), |
68 delete_callback_(delete_callback) { | 68 delete_callback_(delete_callback) { |
69 connection->AddService(this); | 69 connection->AddService(this); |
70 } | 70 } |
71 | 71 |
72 void Close() { | 72 void Close() { |
73 if (root_) | 73 if (root_) |
74 mus::ScopedWindowPtr::DeleteWindowOrWindowManager(root_); | 74 mus::ScopedWindowPtr::DeleteWindowOrWindowManager(root_); |
75 else | 75 else |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 frame_client_binding_.Bind(std::move(request)); | 221 frame_client_binding_.Bind(std::move(request)); |
222 } | 222 } |
223 | 223 |
224 scoped_ptr<mojo::AppRefCount> app_ref_; | 224 scoped_ptr<mojo::AppRefCount> app_ref_; |
225 FPDF_DOCUMENT doc_; | 225 FPDF_DOCUMENT doc_; |
226 int current_page_; | 226 int current_page_; |
227 int page_count_; | 227 int page_count_; |
228 | 228 |
229 scoped_ptr<bitmap_uploader::BitmapUploader> bitmap_uploader_; | 229 scoped_ptr<bitmap_uploader::BitmapUploader> bitmap_uploader_; |
230 | 230 |
231 mojo::shell::mojom::Shell* shell_; | 231 mojo::Shell* shell_; |
232 mus::Window* root_; | 232 mus::Window* root_; |
233 | 233 |
234 web_view::mojom::FramePtr frame_; | 234 web_view::mojom::FramePtr frame_; |
235 mojo::Binding<web_view::mojom::FrameClient> frame_client_binding_; | 235 mojo::Binding<web_view::mojom::FrameClient> frame_client_binding_; |
236 DeleteCallback delete_callback_; | 236 DeleteCallback delete_callback_; |
237 | 237 |
238 DISALLOW_COPY_AND_ASSIGN(PDFView); | 238 DISALLOW_COPY_AND_ASSIGN(PDFView); |
239 }; | 239 }; |
240 | 240 |
241 // Responsible for managing all the views for displaying a PDF document. | 241 // Responsible for managing all the views for displaying a PDF document. |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
346 public: | 346 public: |
347 PDFViewer() { | 347 PDFViewer() { |
348 v8::V8::InitializeICU(); | 348 v8::V8::InitializeICU(); |
349 FPDF_InitLibrary(); | 349 FPDF_InitLibrary(); |
350 } | 350 } |
351 | 351 |
352 ~PDFViewer() override { FPDF_DestroyLibrary(); } | 352 ~PDFViewer() override { FPDF_DestroyLibrary(); } |
353 | 353 |
354 private: | 354 private: |
355 // ApplicationDelegate: | 355 // ApplicationDelegate: |
356 void Initialize(mojo::ApplicationImpl* app) override { | 356 void Initialize(mojo::Shell* shell, const std::string& url, |
357 tracing_.Initialize(app); | 357 uint32_t id) override { |
| 358 tracing_.Initialize(shell, url); |
358 } | 359 } |
359 | 360 |
360 bool AcceptConnection( | 361 bool AcceptConnection( |
361 mojo::ApplicationConnection* connection) override { | 362 mojo::ApplicationConnection* connection) override { |
362 connection->AddService(this); | 363 connection->AddService(this); |
363 return true; | 364 return true; |
364 } | 365 } |
365 | 366 |
366 // InterfaceFactory<ContentHandler>: | 367 // InterfaceFactory<ContentHandler>: |
367 void Create(mojo::ApplicationConnection* connection, | 368 void Create(mojo::ApplicationConnection* connection, |
368 mojo::InterfaceRequest<mojo::shell::mojom::ContentHandler> | 369 mojo::InterfaceRequest<mojo::shell::mojom::ContentHandler> |
369 request) override { | 370 request) override { |
370 new ContentHandlerImpl(std::move(request)); | 371 new ContentHandlerImpl(std::move(request)); |
371 } | 372 } |
372 | 373 |
373 mojo::TracingImpl tracing_; | 374 mojo::TracingImpl tracing_; |
374 | 375 |
375 DISALLOW_COPY_AND_ASSIGN(PDFViewer); | 376 DISALLOW_COPY_AND_ASSIGN(PDFViewer); |
376 }; | 377 }; |
377 } // namespace | 378 } // namespace |
378 } // namespace pdf_viewer | 379 } // namespace pdf_viewer |
379 | 380 |
380 MojoResult MojoMain(MojoHandle application_request) { | 381 MojoResult MojoMain(MojoHandle application_request) { |
381 mojo::ApplicationRunner runner(new pdf_viewer::PDFViewer()); | 382 mojo::ApplicationRunner runner(new pdf_viewer::PDFViewer()); |
382 return runner.Run(application_request); | 383 return runner.Run(application_request); |
383 } | 384 } |
OLD | NEW |