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

Unified Diff: examples/pdf_viewer/pdf_viewer.cc

Issue 688693004: alternate shape for content handler boilerplate (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: 80 cols Created 6 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | mojo/application/content_handler.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: examples/pdf_viewer/pdf_viewer.cc
diff --git a/examples/pdf_viewer/pdf_viewer.cc b/examples/pdf_viewer/pdf_viewer.cc
index ed60a55bf09d646a8bcfd3bb9c30829d05957070..ed81932fd92d5f56c14cd36919b4a519b44a357e 100644
--- a/examples/pdf_viewer/pdf_viewer.cc
+++ b/examples/pdf_viewer/pdf_viewer.cc
@@ -192,9 +192,9 @@ class PDFView : public ApplicationDelegate,
DISALLOW_COPY_AND_ASSIGN(PDFView);
};
-class PDFViewer : public ContentHandlerDelegate {
+class PDFViewer : public ApplicationDelegate, ContentHandlerFactory::Delegate {
public:
- PDFViewer() {
+ PDFViewer() : content_handler_factory_(this) {
v8::V8::InitializeICU();
FPDF_InitLibrary(NULL);
}
@@ -203,14 +203,21 @@ class PDFViewer : public ContentHandlerDelegate {
FPDF_DestroyLibrary();
}
private:
- // Overridden from ContentHandlerDelegate:
- virtual scoped_ptr<mojo::InterfaceImpl<mojo::Application>> CreateApplication(
- ShellPtr shell,
+ // Overridden from ApplicationDelegate:
+ virtual bool ConfigureIncomingConnection(
+ ApplicationConnection* connection) override {
+ connection->AddService(&content_handler_factory_);
+ return true;
+ }
+
+ // Overridden from ContentHandlerFactory::Delegate:
+ virtual ApplicationDelegate* CreateApplication(
URLResponsePtr response) override {
- return make_scoped_ptr(new mojo::ApplicationImpl(
- new PDFView(response.Pass()), shell.PassMessagePipe()));
+ return new PDFView(response.Pass());
}
+ ContentHandlerFactory content_handler_factory_;
+
DISALLOW_COPY_AND_ASSIGN(PDFViewer);
};
@@ -218,6 +225,6 @@ class PDFViewer : public ContentHandlerDelegate {
} // namespace mojo
MojoResult MojoMain(MojoHandle shell_handle) {
- return mojo::ContentHandlerRunner::Run(
- shell_handle, make_scoped_ptr(new mojo::examples::PDFViewer));
+ mojo::ApplicationRunnerChromium runner(new mojo::examples::PDFViewer());
+ return runner.Run(shell_handle);
}
« no previous file with comments | « no previous file | mojo/application/content_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698