Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(854)

Side by Side Diff: components/pdf_viewer/pdf_viewer.cc

Issue 1679573002: Move shell interfaces into the shell.mojom namespace. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@delegate
Patch Set: . Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « components/mus/android_loader.cc ('k') | components/web_view/frame_connection.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
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* shell_; 231 mojo::shell::mojom::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.
242 class PDFViewerApplicationDelegate 242 class PDFViewerApplicationDelegate
243 : public mojo::ApplicationDelegate, 243 : public mojo::ApplicationDelegate,
244 public mojo::InterfaceFactory<mus::mojom::WindowTreeClient> { 244 public mojo::InterfaceFactory<mus::mojom::WindowTreeClient> {
245 public: 245 public:
246 PDFViewerApplicationDelegate( 246 PDFViewerApplicationDelegate(
247 mojo::InterfaceRequest<mojo::Application> request, 247 mojo::ApplicationRequest request,
248 mojo::URLResponsePtr response, 248 mojo::URLResponsePtr response,
249 const mojo::Callback<void()>& destruct_callback) 249 const mojo::Callback<void()>& destruct_callback)
250 : app_(this, 250 : app_(this,
251 std::move(request), 251 std::move(request),
252 base::Bind(&PDFViewerApplicationDelegate::OnTerminate, 252 base::Bind(&PDFViewerApplicationDelegate::OnTerminate,
253 base::Unretained(this))), 253 base::Unretained(this))),
254 doc_(nullptr), 254 doc_(nullptr),
255 is_destroying_(false), 255 is_destroying_(false),
256 destruct_callback_(destruct_callback) { 256 destruct_callback_(destruct_callback) {
257 FetchPDF(std::move(response)); 257 FetchPDF(std::move(response));
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 mojo::ApplicationImpl app_; 311 mojo::ApplicationImpl app_;
312 std::string data_; 312 std::string data_;
313 std::vector<PDFView*> pdf_views_; 313 std::vector<PDFView*> pdf_views_;
314 FPDF_DOCUMENT doc_; 314 FPDF_DOCUMENT doc_;
315 bool is_destroying_; 315 bool is_destroying_;
316 mojo::Callback<void()> destruct_callback_; 316 mojo::Callback<void()> destruct_callback_;
317 317
318 DISALLOW_COPY_AND_ASSIGN(PDFViewerApplicationDelegate); 318 DISALLOW_COPY_AND_ASSIGN(PDFViewerApplicationDelegate);
319 }; 319 };
320 320
321 class ContentHandlerImpl : public mojo::ContentHandler { 321 class ContentHandlerImpl : public mojo::shell::mojom::ContentHandler {
322 public: 322 public:
323 ContentHandlerImpl(mojo::InterfaceRequest<ContentHandler> request) 323 ContentHandlerImpl(
324 mojo::InterfaceRequest<mojo::shell::mojom::ContentHandler> request)
324 : binding_(this, std::move(request)) {} 325 : binding_(this, std::move(request)) {}
325 ~ContentHandlerImpl() override {} 326 ~ContentHandlerImpl() override {}
326 327
327 private: 328 private:
328 // ContentHandler: 329 // mojo::shell::mojom::ContentHandler:
329 void StartApplication( 330 void StartApplication(
330 mojo::InterfaceRequest<mojo::Application> request, 331 mojo::ApplicationRequest request,
331 mojo::URLResponsePtr response, 332 mojo::URLResponsePtr response,
332 const mojo::Callback<void()>& destruct_callback) override { 333 const mojo::Callback<void()>& destruct_callback) override {
333 new PDFViewerApplicationDelegate(std::move(request), std::move(response), 334 new PDFViewerApplicationDelegate(std::move(request), std::move(response),
334 destruct_callback); 335 destruct_callback);
335 } 336 }
336 337
337 mojo::StrongBinding<mojo::ContentHandler> binding_; 338 mojo::StrongBinding<mojo::shell::mojom::ContentHandler> binding_;
338 339
339 DISALLOW_COPY_AND_ASSIGN(ContentHandlerImpl); 340 DISALLOW_COPY_AND_ASSIGN(ContentHandlerImpl);
340 }; 341 };
341 342
342 class PDFViewer : public mojo::ApplicationDelegate, 343 class PDFViewer
343 public mojo::InterfaceFactory<mojo::ContentHandler> { 344 : public mojo::ApplicationDelegate,
345 public mojo::InterfaceFactory<mojo::shell::mojom::ContentHandler> {
344 public: 346 public:
345 PDFViewer() { 347 PDFViewer() {
346 v8::V8::InitializeICU(); 348 v8::V8::InitializeICU();
347 FPDF_InitLibrary(); 349 FPDF_InitLibrary();
348 } 350 }
349 351
350 ~PDFViewer() override { FPDF_DestroyLibrary(); } 352 ~PDFViewer() override { FPDF_DestroyLibrary(); }
351 353
352 private: 354 private:
353 // ApplicationDelegate: 355 // ApplicationDelegate:
354 void Initialize(mojo::ApplicationImpl* app) override { 356 void Initialize(mojo::ApplicationImpl* app) override {
355 tracing_.Initialize(app); 357 tracing_.Initialize(app);
356 } 358 }
357 359
358 bool AcceptConnection( 360 bool AcceptConnection(
359 mojo::ApplicationConnection* connection) override { 361 mojo::ApplicationConnection* connection) override {
360 connection->AddService(this); 362 connection->AddService(this);
361 return true; 363 return true;
362 } 364 }
363 365
364 // InterfaceFactory<ContentHandler>: 366 // InterfaceFactory<ContentHandler>:
365 void Create(mojo::ApplicationConnection* connection, 367 void Create(mojo::ApplicationConnection* connection,
366 mojo::InterfaceRequest<mojo::ContentHandler> request) override { 368 mojo::InterfaceRequest<mojo::shell::mojom::ContentHandler>
369 request) override {
367 new ContentHandlerImpl(std::move(request)); 370 new ContentHandlerImpl(std::move(request));
368 } 371 }
369 372
370 mojo::TracingImpl tracing_; 373 mojo::TracingImpl tracing_;
371 374
372 DISALLOW_COPY_AND_ASSIGN(PDFViewer); 375 DISALLOW_COPY_AND_ASSIGN(PDFViewer);
373 }; 376 };
374 } // namespace 377 } // namespace
375 } // namespace pdf_viewer 378 } // namespace pdf_viewer
376 379
377 MojoResult MojoMain(MojoHandle application_request) { 380 MojoResult MojoMain(MojoHandle application_request) {
378 mojo::ApplicationRunner runner(new pdf_viewer::PDFViewer()); 381 mojo::ApplicationRunner runner(new pdf_viewer::PDFViewer());
379 return runner.Run(application_request); 382 return runner.Run(application_request);
380 } 383 }
OLDNEW
« no previous file with comments | « components/mus/android_loader.cc ('k') | components/web_view/frame_connection.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698