Index: mojo/examples/png_viewer/png_viewer.cc |
diff --git a/mojo/examples/png_viewer/png_viewer.cc b/mojo/examples/png_viewer/png_viewer.cc |
index a6f87417bad4f50a075919dd017923d6c46363a3..0eaa11856cd1dd7051810a0cbcddc31de4ab64c1 100644 |
--- a/mojo/examples/png_viewer/png_viewer.cc |
+++ b/mojo/examples/png_viewer/png_viewer.cc |
@@ -9,10 +9,12 @@ |
#include "mojo/examples/media_viewer/media_viewer.mojom.h" |
#include "mojo/public/cpp/application/application_connection.h" |
#include "mojo/public/cpp/application/application_delegate.h" |
+#include "mojo/public/cpp/application/interface_factory_with_context.h" |
#include "mojo/services/public/cpp/view_manager/node.h" |
#include "mojo/services/public/cpp/view_manager/types.h" |
#include "mojo/services/public/cpp/view_manager/view.h" |
#include "mojo/services/public/cpp/view_manager/view_manager.h" |
+#include "mojo/services/public/cpp/view_manager/view_manager_client_factory.h" |
#include "mojo/services/public/cpp/view_manager/view_manager_delegate.h" |
#include "mojo/services/public/interfaces/navigation/navigation.mojom.h" |
#include "skia/ext/platform_canvas.h" |
@@ -30,8 +32,7 @@ class PNGViewer; |
class ZoomableMediaImpl : public InterfaceImpl<ZoomableMedia> { |
public: |
- ZoomableMediaImpl(ApplicationConnection* connection, |
- PNGViewer* viewer) : viewer_(viewer) {} |
+ explicit ZoomableMediaImpl(PNGViewer* viewer) : viewer_(viewer) {} |
virtual ~ZoomableMediaImpl() {} |
private: |
@@ -47,8 +48,7 @@ class ZoomableMediaImpl : public InterfaceImpl<ZoomableMedia> { |
class NavigatorImpl : public InterfaceImpl<navigation::Navigator> { |
public: |
- NavigatorImpl(ApplicationConnection* connection, |
- PNGViewer* viewer) : viewer_(viewer) {} |
+ explicit NavigatorImpl(PNGViewer* viewer) : viewer_(viewer) {} |
virtual ~NavigatorImpl() {} |
private: |
@@ -110,10 +110,18 @@ class NavigatorImpl : public InterfaceImpl<navigation::Navigator> { |
DISALLOW_COPY_AND_ASSIGN(NavigatorImpl); |
}; |
-class PNGViewer : public ApplicationDelegate, |
- public view_manager::ViewManagerDelegate { |
+class PNGViewer |
+ : public ApplicationDelegate, |
+ public view_manager::ViewManagerDelegate, |
+ public InterfaceFactoryWithContext<NavigatorImpl, PNGViewer>, |
+ public InterfaceFactoryWithContext<ZoomableMediaImpl, PNGViewer> { |
public: |
- PNGViewer() : content_view_(NULL), zoom_percentage_(kDefaultZoomPercentage) {} |
+ PNGViewer() |
+ : InterfaceFactoryWithContext<NavigatorImpl, PNGViewer>(this), |
+ InterfaceFactoryWithContext<ZoomableMediaImpl, PNGViewer>(this), |
+ content_view_(NULL), |
+ zoom_percentage_(kDefaultZoomPercentage), |
+ view_manager_client_factory_(this) {} |
virtual ~PNGViewer() {} |
void UpdateView(view_manager::Id node_id, const SkBitmap& bitmap) { |
@@ -152,9 +160,9 @@ class PNGViewer : public ApplicationDelegate, |
// Overridden from ApplicationDelegate: |
virtual bool ConfigureIncomingConnection(ApplicationConnection* connection) |
MOJO_OVERRIDE { |
- connection->AddService<NavigatorImpl>(this); |
- connection->AddService<ZoomableMediaImpl>(this); |
- view_manager::ViewManager::ConfigureIncomingConnection(connection, this); |
+ connection->AddServiceFactory<navigation::Navigator>(this); |
+ connection->AddServiceFactory<ZoomableMedia>(this); |
+ connection->AddServiceFactory(&view_manager_client_factory_); |
return true; |
} |
@@ -192,6 +200,7 @@ class PNGViewer : public ApplicationDelegate, |
view_manager::View* content_view_; |
SkBitmap bitmap_; |
uint16_t zoom_percentage_; |
+ view_manager::ViewManagerClientFactory view_manager_client_factory_; |
DISALLOW_COPY_AND_ASSIGN(PNGViewer); |
}; |