| 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 "base/strings/string_tokenizer.h" | 5 #include "base/strings/string_tokenizer.h" |
| 6 #include "examples/bitmap_uploader/bitmap_uploader.h" | 6 #include "examples/bitmap_uploader/bitmap_uploader.h" |
| 7 #include "mojo/application/application_runner_chromium.h" | 7 #include "mojo/application/application_runner_chromium.h" |
| 8 #include "mojo/application/content_handler.h" | 8 #include "mojo/application/content_handler.h" |
| 9 #include "mojo/public/c/system/main.h" | 9 #include "mojo/public/c/system/main.h" |
| 10 #include "mojo/public/cpp/application/application_connection.h" | 10 #include "mojo/public/cpp/application/application_connection.h" |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 int page_count_; | 185 int page_count_; |
| 186 FPDF_DOCUMENT doc_; | 186 FPDF_DOCUMENT doc_; |
| 187 ApplicationImpl* app_; | 187 ApplicationImpl* app_; |
| 188 View* root_; | 188 View* root_; |
| 189 scoped_ptr<ViewManagerClientFactory> view_manager_client_factory_; | 189 scoped_ptr<ViewManagerClientFactory> view_manager_client_factory_; |
| 190 scoped_ptr<BitmapUploader> bitmap_uploader_; | 190 scoped_ptr<BitmapUploader> bitmap_uploader_; |
| 191 | 191 |
| 192 DISALLOW_COPY_AND_ASSIGN(PDFView); | 192 DISALLOW_COPY_AND_ASSIGN(PDFView); |
| 193 }; | 193 }; |
| 194 | 194 |
| 195 class PDFViewer : public ContentHandlerDelegate { | 195 class PDFViewer : public ApplicationDelegate, ContentHandlerFactory::Delegate { |
| 196 public: | 196 public: |
| 197 PDFViewer() { | 197 PDFViewer() : content_handler_factory_(this) { |
| 198 v8::V8::InitializeICU(); | 198 v8::V8::InitializeICU(); |
| 199 FPDF_InitLibrary(NULL); | 199 FPDF_InitLibrary(NULL); |
| 200 } | 200 } |
| 201 | 201 |
| 202 virtual ~PDFViewer() { | 202 virtual ~PDFViewer() { |
| 203 FPDF_DestroyLibrary(); | 203 FPDF_DestroyLibrary(); |
| 204 } | 204 } |
| 205 private: | 205 private: |
| 206 // Overridden from ContentHandlerDelegate: | 206 // Overridden from ApplicationDelegate: |
| 207 virtual scoped_ptr<mojo::InterfaceImpl<mojo::Application>> CreateApplication( | 207 virtual bool ConfigureIncomingConnection( |
| 208 ShellPtr shell, | 208 ApplicationConnection* connection) override { |
| 209 connection->AddService(&content_handler_factory_); |
| 210 return true; |
| 211 } |
| 212 |
| 213 // Overridden from ContentHandlerFactory::Delegate: |
| 214 virtual ApplicationDelegate* CreateApplication( |
| 209 URLResponsePtr response) override { | 215 URLResponsePtr response) override { |
| 210 return make_scoped_ptr(new mojo::ApplicationImpl( | 216 return new PDFView(response.Pass()); |
| 211 new PDFView(response.Pass()), shell.PassMessagePipe())); | |
| 212 } | 217 } |
| 213 | 218 |
| 219 ContentHandlerFactory content_handler_factory_; |
| 220 |
| 214 DISALLOW_COPY_AND_ASSIGN(PDFViewer); | 221 DISALLOW_COPY_AND_ASSIGN(PDFViewer); |
| 215 }; | 222 }; |
| 216 | 223 |
| 217 } // namespace examples | 224 } // namespace examples |
| 218 } // namespace mojo | 225 } // namespace mojo |
| 219 | 226 |
| 220 MojoResult MojoMain(MojoHandle shell_handle) { | 227 MojoResult MojoMain(MojoHandle shell_handle) { |
| 221 return mojo::ContentHandlerRunner::Run( | 228 mojo::ApplicationRunnerChromium runner(new mojo::examples::PDFViewer()); |
| 222 shell_handle, make_scoped_ptr(new mojo::examples::PDFViewer)); | 229 return runner.Run(shell_handle); |
| 223 } | 230 } |
| OLD | NEW |