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

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

Issue 943053003: Simple multi-url support for mojo apps (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: hate Created 5 years, 9 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
OLDNEW
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_factory.h" 8 #include "mojo/application/content_handler_factory.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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 69
70 private: 70 private:
71 // Overridden from ApplicationDelegate: 71 // Overridden from ApplicationDelegate:
72 virtual void Initialize(ApplicationImpl* app) override { 72 virtual void Initialize(ApplicationImpl* app) override {
73 app_ = app; 73 app_ = app;
74 view_manager_client_factory_.reset( 74 view_manager_client_factory_.reset(
75 new ViewManagerClientFactory(app->shell(), this)); 75 new ViewManagerClientFactory(app->shell(), this));
76 } 76 }
77 77
78 virtual bool ConfigureIncomingConnection( 78 virtual bool ConfigureIncomingConnection(
79 ApplicationConnection* connection) override { 79 ApplicationConnection* connection, const std::string& url) override {
80 connection->AddService(view_manager_client_factory_.get()); 80 connection->AddService(view_manager_client_factory_.get());
81 return true; 81 return true;
82 } 82 }
83 83
84 // Overridden from ViewManagerDelegate: 84 // Overridden from ViewManagerDelegate:
85 virtual void OnEmbed(View* root, 85 virtual void OnEmbed(View* root,
86 InterfaceRequest<ServiceProvider> services, 86 InterfaceRequest<ServiceProvider> services,
87 ServiceProviderPtr exposed_services) override { 87 ServiceProviderPtr exposed_services) override {
88 DCHECK(embedder_for_roots_.find(root) == embedder_for_roots_.end()); 88 DCHECK(embedder_for_roots_.find(root) == embedder_for_roots_.end());
89 root->AddObserver(this); 89 root->AddObserver(this);
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 PDFViewer() : content_handler_factory_(this) { 216 PDFViewer() : content_handler_factory_(this) {
217 v8::V8::InitializeICU(); 217 v8::V8::InitializeICU();
218 FPDF_InitLibrary(); 218 FPDF_InitLibrary();
219 } 219 }
220 220
221 virtual ~PDFViewer() { FPDF_DestroyLibrary(); } 221 virtual ~PDFViewer() { FPDF_DestroyLibrary(); }
222 222
223 private: 223 private:
224 // Overridden from ApplicationDelegate: 224 // Overridden from ApplicationDelegate:
225 virtual bool ConfigureIncomingConnection( 225 virtual bool ConfigureIncomingConnection(
226 ApplicationConnection* connection) override { 226 ApplicationConnection* connection, const std::string& url) override {
227 connection->AddService(&content_handler_factory_); 227 connection->AddService(&content_handler_factory_);
228 return true; 228 return true;
229 } 229 }
230 230
231 // Overridden from ContentHandlerFactory::ManagedDelegate: 231 // Overridden from ContentHandlerFactory::ManagedDelegate:
232 virtual scoped_ptr<ContentHandlerFactory::HandledApplicationHolder> 232 virtual scoped_ptr<ContentHandlerFactory::HandledApplicationHolder>
233 CreateApplication(InterfaceRequest<Application> application_request, 233 CreateApplication(InterfaceRequest<Application> application_request,
234 URLResponsePtr response) override { 234 URLResponsePtr response) override {
235 return make_handled_factory_holder(new mojo::ApplicationImpl( 235 return make_handled_factory_holder(new mojo::ApplicationImpl(
236 new PDFView(response.Pass()), application_request.Pass())); 236 new PDFView(response.Pass()), application_request.Pass()));
237 } 237 }
238 238
239 ContentHandlerFactory content_handler_factory_; 239 ContentHandlerFactory content_handler_factory_;
240 240
241 DISALLOW_COPY_AND_ASSIGN(PDFViewer); 241 DISALLOW_COPY_AND_ASSIGN(PDFViewer);
242 }; 242 };
243 243
244 } // namespace examples 244 } // namespace examples
245 } // namespace mojo 245 } // namespace mojo
246 246
247 MojoResult MojoMain(MojoHandle shell_handle) { 247 MojoResult MojoMain(MojoHandle shell_handle) {
248 mojo::ApplicationRunnerChromium runner(new mojo::examples::PDFViewer()); 248 mojo::ApplicationRunnerChromium runner(new mojo::examples::PDFViewer());
249 return runner.Run(shell_handle); 249 return runner.Run(shell_handle);
250 } 250 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698