diff options
Diffstat (limited to 'mojo/examples')
-rw-r--r-- | mojo/examples/aura_demo/aura_demo.cc | 15 | ||||
-rw-r--r-- | mojo/examples/aura_demo/view_manager_init.cc | 11 | ||||
-rw-r--r-- | mojo/examples/browser/browser.cc | 23 | ||||
-rw-r--r-- | mojo/examples/compositor_app/compositor_app.cc | 12 | ||||
-rw-r--r-- | mojo/examples/dbus_echo/dbus_echo_app.cc | 13 | ||||
-rw-r--r-- | mojo/examples/demo_launcher/demo_launcher.cc | 19 | ||||
-rw-r--r-- | mojo/examples/embedded_app/embedded_app.cc | 28 | ||||
-rw-r--r-- | mojo/examples/html_viewer/blink_platform_impl.cc | 6 | ||||
-rw-r--r-- | mojo/examples/html_viewer/blink_platform_impl.h | 4 | ||||
-rw-r--r-- | mojo/examples/html_viewer/html_viewer.cc | 25 | ||||
-rw-r--r-- | mojo/examples/keyboard/keyboard.cc | 22 | ||||
-rw-r--r-- | mojo/examples/media_viewer/media_viewer.cc | 32 | ||||
-rw-r--r-- | mojo/examples/nesting_app/nesting_app.cc | 31 | ||||
-rw-r--r-- | mojo/examples/pepper_container_app/pepper_container_app.cc | 14 | ||||
-rw-r--r-- | mojo/examples/png_viewer/png_viewer.cc | 21 | ||||
-rw-r--r-- | mojo/examples/sample_app/sample_app.cc | 12 | ||||
-rw-r--r-- | mojo/examples/wget/wget.cc | 11 | ||||
-rw-r--r-- | mojo/examples/window_manager/window_manager.cc | 45 |
18 files changed, 209 insertions, 135 deletions
diff --git a/mojo/examples/aura_demo/aura_demo.cc b/mojo/examples/aura_demo/aura_demo.cc index de005a7..4f88dfb 100644 --- a/mojo/examples/aura_demo/aura_demo.cc +++ b/mojo/examples/aura_demo/aura_demo.cc @@ -10,7 +10,7 @@ #include "mojo/aura/screen_mojo.h" #include "mojo/aura/window_tree_host_mojo.h" #include "mojo/aura/window_tree_host_mojo_delegate.h" -#include "mojo/public/cpp/application/application.h" +#include "mojo/public/cpp/application/application_delegate.h" #include "mojo/public/cpp/system/core.h" #include "mojo/public/interfaces/service_provider/service_provider.mojom.h" #include "mojo/services/public/cpp/view_manager/node.h" @@ -103,7 +103,7 @@ class DemoWindowTreeClient : public aura::client::WindowTreeClient { DISALLOW_COPY_AND_ASSIGN(DemoWindowTreeClient); }; -class AuraDemo : public Application, +class AuraDemo : public ApplicationDelegate, public WindowTreeHostMojoDelegate, public view_manager::ViewManagerDelegate { public: @@ -112,7 +112,6 @@ class AuraDemo : public Application, window2_(NULL), window21_(NULL), view_(NULL) { - view_manager::ViewManager::Create(this, this); } virtual ~AuraDemo() {} @@ -159,7 +158,7 @@ class AuraDemo : public Application, view_->SetContents(bitmap); } - virtual void Initialize() OVERRIDE { + virtual void Initialize(ApplicationImpl* app) MOJO_OVERRIDE { aura::Env::CreateInstance(true); context_factory_.reset(new ContextFactoryMojo); aura::Env::GetInstance()->set_context_factory(context_factory_.get()); @@ -167,6 +166,12 @@ class AuraDemo : public Application, gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, screen_.get()); } + virtual bool ConfigureIncomingConnection(ApplicationConnection* connection) + MOJO_OVERRIDE { + view_manager::ViewManager::ConfigureIncomingConnection(connection, this); + return true; + } + scoped_ptr<DemoWindowTreeClient> window_tree_client_; scoped_ptr<ui::ContextFactory> context_factory_; @@ -191,7 +196,7 @@ class AuraDemo : public Application, } // namespace examples // static -Application* Application::Create() { +ApplicationDelegate* ApplicationDelegate::Create() { return new examples::AuraDemo(); } diff --git a/mojo/examples/aura_demo/view_manager_init.cc b/mojo/examples/aura_demo/view_manager_init.cc index 7a558d3..4130193 100644 --- a/mojo/examples/aura_demo/view_manager_init.cc +++ b/mojo/examples/aura_demo/view_manager_init.cc @@ -4,7 +4,8 @@ #include "base/basictypes.h" #include "base/bind.h" -#include "mojo/public/cpp/application/application.h" +#include "mojo/public/cpp/application/application_delegate.h" +#include "mojo/public/cpp/application/application_impl.h" #include "mojo/services/public/interfaces/view_manager/view_manager.mojom.h" namespace mojo { @@ -12,13 +13,13 @@ namespace examples { // ViewManagerInit is responsible for establishing the initial connection to // the view manager. When established it loads |mojo_aura_demo|. -class ViewManagerInit : public Application { +class ViewManagerInit : public ApplicationDelegate { public: ViewManagerInit() {} virtual ~ViewManagerInit() {} - virtual void Initialize() OVERRIDE { - ConnectTo("mojo:mojo_view_manager", &view_manager_init_); + virtual void Initialize(ApplicationImpl* app) MOJO_OVERRIDE { + app->ConnectToService("mojo:mojo_view_manager", &view_manager_init_); view_manager_init_->EmbedRoot("mojo:mojo_aura_demo", base::Bind(&ViewManagerInit::DidConnect, base::Unretained(this))); @@ -38,7 +39,7 @@ class ViewManagerInit : public Application { } // namespace examples // static -Application* Application::Create() { +ApplicationDelegate* ApplicationDelegate::Create() { return new examples::ViewManagerInit(); } diff --git a/mojo/examples/browser/browser.cc b/mojo/examples/browser/browser.cc index fed88b5..edc565c 100644 --- a/mojo/examples/browser/browser.cc +++ b/mojo/examples/browser/browser.cc @@ -6,7 +6,9 @@ #include "base/strings/string_util.h" #include "base/strings/utf_string_conversions.h" #include "mojo/examples/window_manager/window_manager.mojom.h" -#include "mojo/public/cpp/application/application.h" +#include "mojo/public/cpp/application/application_connection.h" +#include "mojo/public/cpp/application/application_delegate.h" +#include "mojo/public/cpp/application/application_impl.h" #include "mojo/services/public/cpp/geometry/geometry_type_converters.h" #include "mojo/services/public/cpp/view_manager/node.h" #include "mojo/services/public/cpp/view_manager/view.h" @@ -112,7 +114,7 @@ class KeyboardManager : public views::FocusChangeListener, // This is the basics of creating a views widget with a textfield. // TODO: cleanup! -class Browser : public Application, +class Browser : public ApplicationDelegate, public view_manager::ViewManagerDelegate, public views::TextfieldController, public view_manager::NodeObserver { @@ -123,12 +125,17 @@ class Browser : public Application, } private: - // Overridden from Application: - virtual void Initialize() MOJO_OVERRIDE { + // Overridden from ApplicationDelegate: + virtual void Initialize(ApplicationImpl* app) MOJO_OVERRIDE { views_init_.reset(new ViewsInit); - view_manager::ViewManager::Create(this, this); - ConnectTo("mojo:mojo_window_manager", &navigator_host_); - ConnectTo("mojo:mojo_window_manager", &window_manager_); + app->ConnectToService("mojo:mojo_window_manager", &navigator_host_); + app->ConnectToService("mojo:mojo_window_manager", &window_manager_); + } + + virtual bool ConfigureIncomingConnection(ApplicationConnection* connection) + MOJO_OVERRIDE { + view_manager::ViewManager::ConfigureIncomingConnection(connection, this); + return true; } void CreateWidget(view_manager::Node* node) { @@ -206,7 +213,7 @@ class Browser : public Application, } // namespace examples // static -Application* Application::Create() { +ApplicationDelegate* ApplicationDelegate::Create() { return new examples::Browser; } diff --git a/mojo/examples/compositor_app/compositor_app.cc b/mojo/examples/compositor_app/compositor_app.cc index 31752bd..6a5a8c4 100644 --- a/mojo/examples/compositor_app/compositor_app.cc +++ b/mojo/examples/compositor_app/compositor_app.cc @@ -7,7 +7,8 @@ #include "base/macros.h" #include "mojo/examples/compositor_app/compositor_host.h" -#include "mojo/public/cpp/application/application.h" +#include "mojo/public/cpp/application/application_delegate.h" +#include "mojo/public/cpp/application/application_impl.h" #include "mojo/public/cpp/gles2/gles2.h" #include "mojo/public/cpp/system/core.h" #include "mojo/public/interfaces/service_provider/service_provider.mojom.h" @@ -18,15 +19,14 @@ namespace mojo { namespace examples { -class SampleApp : public Application, public NativeViewportClient { +class SampleApp : public ApplicationDelegate, public NativeViewportClient { public: SampleApp() {} virtual ~SampleApp() {} - virtual void Initialize() OVERRIDE { - ConnectTo("mojo:mojo_native_viewport_service", &viewport_); + virtual void Initialize(ApplicationImpl* app) OVERRIDE { + app->ConnectToService("mojo:mojo_native_viewport_service", &viewport_); viewport_.set_client(this); - viewport_->Create(Rect::From(gfx::Rect(10, 10, 800, 600))); viewport_->Show(); @@ -62,7 +62,7 @@ class SampleApp : public Application, public NativeViewportClient { } // namespace examples // static -Application* Application::Create() { +ApplicationDelegate* ApplicationDelegate::Create() { return new examples::SampleApp(); } diff --git a/mojo/examples/dbus_echo/dbus_echo_app.cc b/mojo/examples/dbus_echo/dbus_echo_app.cc index 5a9b80f..948ad8c 100644 --- a/mojo/examples/dbus_echo/dbus_echo_app.cc +++ b/mojo/examples/dbus_echo/dbus_echo_app.cc @@ -7,7 +7,8 @@ #include "base/bind.h" #include "base/logging.h" -#include "mojo/public/cpp/application/application.h" +#include "mojo/public/cpp/application/application_delegate.h" +#include "mojo/public/cpp/application/application_impl.h" #include "mojo/public/cpp/environment/environment.h" #include "mojo/public/cpp/system/core.h" #include "mojo/public/cpp/system/macros.h" @@ -17,14 +18,14 @@ namespace mojo { namespace examples { -class DBusEchoApp : public Application { +class DBusEchoApp : public ApplicationDelegate { public: DBusEchoApp() {} virtual ~DBusEchoApp() {} - virtual void Initialize() MOJO_OVERRIDE { - ConnectTo("dbus:org.chromium.EchoService/org/chromium/MojoImpl", - &echo_service_); + virtual void Initialize(ApplicationImpl* app) MOJO_OVERRIDE { + app->ConnectToService( + "dbus:org.chromium.EchoService/org/chromium/MojoImpl", &echo_service_); echo_service_->Echo( String::From("who"), @@ -44,7 +45,7 @@ class DBusEchoApp : public Application { } // namespace examples // static -Application* Application::Create() { +ApplicationDelegate* ApplicationDelegate::Create() { return new examples::DBusEchoApp(); } diff --git a/mojo/examples/demo_launcher/demo_launcher.cc b/mojo/examples/demo_launcher/demo_launcher.cc index 141a49a..d6a3712 100644 --- a/mojo/examples/demo_launcher/demo_launcher.cc +++ b/mojo/examples/demo_launcher/demo_launcher.cc @@ -5,25 +5,30 @@ #include "base/basictypes.h" #include "base/bind.h" #include "base/run_loop.h" -#include "mojo/public/cpp/application/application.h" +#include "mojo/public/cpp/application/application_connection.h" +#include "mojo/public/cpp/application/application_delegate.h" +#include "mojo/public/cpp/application/application_impl.h" #include "mojo/services/public/interfaces/view_manager/view_manager.mojom.h" namespace mojo { namespace examples { -class DemoLauncher : public Application { +class DemoLauncher : public ApplicationDelegate { public: DemoLauncher() {} virtual ~DemoLauncher() {} private: - // Overridden from Application: - virtual void Initialize() MOJO_OVERRIDE { - ConnectTo<view_manager::ViewManagerInitService>("mojo:mojo_view_manager", - &view_manager_init_); + virtual void Initialize(ApplicationImpl* app) MOJO_OVERRIDE { + app->ConnectToService("mojo:mojo_view_manager", &view_manager_init_); + } + + virtual bool ConfigureIncomingConnection(ApplicationConnection* connection) + MOJO_OVERRIDE { view_manager_init_->EmbedRoot("mojo:mojo_window_manager", base::Bind(&DemoLauncher::OnConnect, base::Unretained(this))); + return true; } void OnConnect(bool success) {} @@ -36,7 +41,7 @@ class DemoLauncher : public Application { } // namespace examples // static -Application* Application::Create() { +ApplicationDelegate* ApplicationDelegate::Create() { return new examples::DemoLauncher; } diff --git a/mojo/examples/embedded_app/embedded_app.cc b/mojo/examples/embedded_app/embedded_app.cc index de8b00b..9a0144d 100644 --- a/mojo/examples/embedded_app/embedded_app.cc +++ b/mojo/examples/embedded_app/embedded_app.cc @@ -7,7 +7,9 @@ #include "base/logging.h" #include "base/strings/string_number_conversions.h" #include "mojo/examples/window_manager/window_manager.mojom.h" -#include "mojo/public/cpp/application/application.h" +#include "mojo/public/cpp/application/application_connection.h" +#include "mojo/public/cpp/application/application_delegate.h" +#include "mojo/public/cpp/application/application_impl.h" #include "mojo/services/public/cpp/view_manager/node.h" #include "mojo/services/public/cpp/view_manager/node_observer.h" #include "mojo/services/public/cpp/view_manager/view.h" @@ -29,7 +31,7 @@ using mojo::view_manager::ViewObserver; namespace mojo { namespace examples { -class EmbeddedApp : public Application, +class EmbeddedApp : public ApplicationDelegate, public ViewManagerDelegate, public ViewObserver, public NodeObserver { @@ -47,7 +49,8 @@ class EmbeddedApp : public Application, private: class Navigator : public InterfaceImpl<navigation::Navigator> { public: - explicit Navigator(EmbeddedApp* app) : app_(app) {} + Navigator(ApplicationConnection* connection, + EmbeddedApp* app) : app_(app) {} private: virtual void Navigate( uint32 node_id, @@ -70,15 +73,20 @@ class EmbeddedApp : public Application, DISALLOW_COPY_AND_ASSIGN(Navigator); }; - // Overridden from Application: - virtual void Initialize() MOJO_OVERRIDE { - ViewManager::Create(this, this); + // Overridden from ApplicationDelegate: + virtual void Initialize(ApplicationImpl* app) MOJO_OVERRIDE { // TODO(aa): Weird for embeddee to talk to embedder by URL. Seems like // embedder should be able to specify the SP embeddee receives, then // communication can be anonymous. - ConnectTo<IWindowManager>("mojo:mojo_window_manager", &window_manager_); - ConnectTo("mojo:mojo_window_manager", &navigator_host_); - AddService<Navigator>(this); + app->ConnectToService("mojo:mojo_window_manager", &window_manager_); + app->ConnectToService("mojo:mojo_window_manager", &navigator_host_); + } + + virtual bool ConfigureIncomingConnection(ApplicationConnection* connection) + MOJO_OVERRIDE { + ViewManager::ConfigureIncomingConnection(connection, this); + connection->AddService<Navigator>(this); + return true; } // Overridden from ViewManagerDelegate: @@ -160,7 +168,7 @@ class EmbeddedApp : public Application, } // namespace examples // static -Application* Application::Create() { +ApplicationDelegate* ApplicationDelegate::Create() { return new examples::EmbeddedApp; } diff --git a/mojo/examples/html_viewer/blink_platform_impl.cc b/mojo/examples/html_viewer/blink_platform_impl.cc index 3128d43..f629b9c 100644 --- a/mojo/examples/html_viewer/blink_platform_impl.cc +++ b/mojo/examples/html_viewer/blink_platform_impl.cc @@ -12,7 +12,7 @@ #include "base/time/time.h" #include "mojo/examples/html_viewer/webthread_impl.h" #include "mojo/examples/html_viewer/weburlloader_impl.h" -#include "mojo/public/cpp/application/application.h" +#include "mojo/public/cpp/application/application_impl.h" #include "net/base/data_url.h" #include "net/base/mime_util.h" #include "net/base/net_errors.h" @@ -46,14 +46,14 @@ class WebWaitableEventImpl : public blink::WebWaitableEvent { } // namespace -BlinkPlatformImpl::BlinkPlatformImpl(Application* app) +BlinkPlatformImpl::BlinkPlatformImpl(ApplicationImpl* app) : main_loop_(base::MessageLoop::current()), shared_timer_func_(NULL), shared_timer_fire_time_(0.0), shared_timer_fire_time_was_set_while_suspended_(false), shared_timer_suspended_(0), current_thread_slot_(&DestroyCurrentThread) { - app->ConnectTo("mojo:mojo_network_service", &network_service_); + app->ConnectToService("mojo:mojo_network_service", &network_service_); } BlinkPlatformImpl::~BlinkPlatformImpl() { diff --git a/mojo/examples/html_viewer/blink_platform_impl.h b/mojo/examples/html_viewer/blink_platform_impl.h index dfe7744..e24f17e 100644 --- a/mojo/examples/html_viewer/blink_platform_impl.h +++ b/mojo/examples/html_viewer/blink_platform_impl.h @@ -14,13 +14,13 @@ #include "third_party/WebKit/public/platform/WebThemeEngine.h" namespace mojo { -class Application; +class ApplicationImpl; namespace examples { class BlinkPlatformImpl : public blink::Platform { public: - explicit BlinkPlatformImpl(Application* app); + explicit BlinkPlatformImpl(ApplicationImpl* app); virtual ~BlinkPlatformImpl(); // blink::Platform methods: diff --git a/mojo/examples/html_viewer/html_viewer.cc b/mojo/examples/html_viewer/html_viewer.cc index 05bd7b5..ad9bb8f 100644 --- a/mojo/examples/html_viewer/html_viewer.cc +++ b/mojo/examples/html_viewer/html_viewer.cc @@ -4,7 +4,9 @@ #include "mojo/examples/html_viewer/blink_platform_impl.h" #include "mojo/examples/html_viewer/html_document_view.h" -#include "mojo/public/cpp/application/application.h" +#include "mojo/public/cpp/application/application_connection.h" +#include "mojo/public/cpp/application/application_delegate.h" +#include "mojo/public/cpp/application/application_impl.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" @@ -20,7 +22,8 @@ class HTMLViewer; class NavigatorImpl : public InterfaceImpl<navigation::Navigator> { public: - explicit NavigatorImpl(HTMLViewer* viewer) : viewer_(viewer) {} + explicit NavigatorImpl(ApplicationConnection* connection, + HTMLViewer* viewer) : viewer_(viewer) {} virtual ~NavigatorImpl() {} private: @@ -35,7 +38,7 @@ class NavigatorImpl : public InterfaceImpl<navigation::Navigator> { DISALLOW_COPY_AND_ASSIGN(NavigatorImpl); }; -class HTMLViewer : public Application, +class HTMLViewer : public ApplicationDelegate, public view_manager::ViewManagerDelegate { public: HTMLViewer() : document_view_(NULL) { @@ -53,13 +56,17 @@ class HTMLViewer : public Application, } private: - // Overridden from Application: - virtual void Initialize() OVERRIDE { - blink_platform_impl_.reset(new BlinkPlatformImpl(this)); + // Overridden from ApplicationDelegate: + virtual void Initialize(ApplicationImpl* app) OVERRIDE { + blink_platform_impl_.reset(new BlinkPlatformImpl(app)); blink::initialize(blink_platform_impl_.get()); + } - AddService<NavigatorImpl>(this); - view_manager::ViewManager::Create(this, this); + virtual bool ConfigureIncomingConnection(ApplicationConnection* connection) + OVERRIDE { + connection->AddService<NavigatorImpl>(this); + view_manager::ViewManager::ConfigureIncomingConnection(connection, this); + return true; } // Overridden from view_manager::ViewManagerDelegate: @@ -98,7 +105,7 @@ void NavigatorImpl::Navigate( } // static -Application* Application::Create() { +ApplicationDelegate* ApplicationDelegate::Create() { return new examples::HTMLViewer; } diff --git a/mojo/examples/keyboard/keyboard.cc b/mojo/examples/keyboard/keyboard.cc index ae6d8c9..0941d05 100644 --- a/mojo/examples/keyboard/keyboard.cc +++ b/mojo/examples/keyboard/keyboard.cc @@ -8,7 +8,8 @@ #include "mojo/examples/keyboard/keyboard.mojom.h" #include "mojo/examples/keyboard/keyboard_delegate.h" #include "mojo/examples/keyboard/keyboard_view.h" -#include "mojo/public/cpp/application/application.h" +#include "mojo/public/cpp/application/application_connection.h" +#include "mojo/public/cpp/application/application_delegate.h" #include "mojo/services/public/cpp/view_manager/node.h" #include "mojo/services/public/cpp/view_manager/view.h" #include "mojo/services/public/cpp/view_manager/view_manager.h" @@ -32,7 +33,7 @@ class Keyboard; class KeyboardServiceImpl : public InterfaceImpl<KeyboardService> { public: - KeyboardServiceImpl(Keyboard* keyboard); + KeyboardServiceImpl(ApplicationConnection* connection, Keyboard* keyboard); virtual ~KeyboardServiceImpl() {} // KeyboardService: @@ -44,7 +45,7 @@ class KeyboardServiceImpl : public InterfaceImpl<KeyboardService> { DISALLOW_COPY_AND_ASSIGN(KeyboardServiceImpl); }; -class Keyboard : public Application, +class Keyboard : public ApplicationDelegate, public view_manager::ViewManagerDelegate, public KeyboardDelegate { public: @@ -60,11 +61,13 @@ class Keyboard : public Application, } private: - // Overridden from Application: - virtual void Initialize() MOJO_OVERRIDE { + // Overridden from ApplicationDelegate: + virtual bool ConfigureIncomingConnection(ApplicationConnection* connection) + MOJO_OVERRIDE { views_init_.reset(new ViewsInit); - view_manager::ViewManager::Create(this, this); - AddService<KeyboardServiceImpl>(this); + view_manager::ViewManager::ConfigureIncomingConnection(connection, this); + connection->AddService<KeyboardServiceImpl>(this); + return true; } void CreateWidget(view_manager::Node* node) { @@ -110,7 +113,8 @@ class Keyboard : public Application, DISALLOW_COPY_AND_ASSIGN(Keyboard); }; -KeyboardServiceImpl::KeyboardServiceImpl(Keyboard* keyboard) +KeyboardServiceImpl::KeyboardServiceImpl(ApplicationConnection* connection, + Keyboard* keyboard) : keyboard_(keyboard) { keyboard_->set_keyboard_service(this); } @@ -122,7 +126,7 @@ void KeyboardServiceImpl::SetTarget(uint32_t node_id) { } // namespace examples // static -Application* Application::Create() { +ApplicationDelegate* ApplicationDelegate::Create() { return new examples::Keyboard; } diff --git a/mojo/examples/media_viewer/media_viewer.cc b/mojo/examples/media_viewer/media_viewer.cc index 29d4b06..b727b59 100644 --- a/mojo/examples/media_viewer/media_viewer.cc +++ b/mojo/examples/media_viewer/media_viewer.cc @@ -7,7 +7,9 @@ #include "base/macros.h" #include "base/memory/scoped_ptr.h" -#include "mojo/public/cpp/application/application.h" +#include "mojo/public/cpp/application/application_connection.h" +#include "mojo/public/cpp/application/application_delegate.h" +#include "mojo/public/cpp/application/application_impl.h" #include "mojo/public/cpp/bindings/interface_impl.h" #include "mojo/services/public/cpp/view_manager/node.h" #include "mojo/services/public/cpp/view_manager/view.h" @@ -23,7 +25,8 @@ class MediaViewer; class NavigatorImpl : public InterfaceImpl<navigation::Navigator> { public: - explicit NavigatorImpl(MediaViewer* viewer) : viewer_(viewer) {} + explicit NavigatorImpl(ApplicationConnection* connection, + MediaViewer* viewer) : viewer_(viewer) {} virtual ~NavigatorImpl() {} private: @@ -38,10 +41,11 @@ class NavigatorImpl : public InterfaceImpl<navigation::Navigator> { DISALLOW_COPY_AND_ASSIGN(NavigatorImpl); }; -class MediaViewer : public Application, +class MediaViewer : public ApplicationDelegate, public view_manager::ViewManagerDelegate { public: - MediaViewer() : content_node_(NULL), + MediaViewer() : app_(NULL), + content_node_(NULL), view_manager_(NULL) { handler_map_["image/png"] = "mojo:mojo_png_viewer"; } @@ -72,7 +76,7 @@ class MediaViewer : public Application, if (navigation_details) { navigation::NavigatorPtr navigator; - ConnectTo(handler, &navigator); + app_->ConnectToService(handler, &navigator); navigator->Navigate(content_node_->id(), navigation_details.Pass(), response_details.Pass()); } @@ -87,10 +91,17 @@ class MediaViewer : public Application, navigation::ResponseDetailsPtr response_details; }; - // Overridden from Application: - virtual void Initialize() OVERRIDE { - AddService<NavigatorImpl>(this); - view_manager::ViewManager::Create(this, this); + + // Overridden from ApplicationDelegate: + virtual void Initialize(ApplicationImpl* app) OVERRIDE { + app_ = app; + } + + virtual bool ConfigureIncomingConnection(ApplicationConnection* connection) + OVERRIDE { + connection->AddService<NavigatorImpl>(this); + view_manager::ViewManager::ConfigureIncomingConnection(connection, this); + return true; } // Overridden from view_manager::ViewManagerDelegate: @@ -117,6 +128,7 @@ class MediaViewer : public Application, return it != handler_map_.end() ? it->second : std::string(); } + ApplicationImpl* app_; view_manager::Node* content_node_; view_manager::ViewManager* view_manager_; HandlerMap handler_map_; @@ -136,7 +148,7 @@ void NavigatorImpl::Navigate( } // namespace examples // static -Application* Application::Create() { +ApplicationDelegate* ApplicationDelegate::Create() { return new examples::MediaViewer; } diff --git a/mojo/examples/nesting_app/nesting_app.cc b/mojo/examples/nesting_app/nesting_app.cc index 7eccc72..8e66736 100644 --- a/mojo/examples/nesting_app/nesting_app.cc +++ b/mojo/examples/nesting_app/nesting_app.cc @@ -6,7 +6,8 @@ #include "base/bind.h" #include "base/strings/stringprintf.h" #include "mojo/examples/window_manager/window_manager.mojom.h" -#include "mojo/public/cpp/application/application.h" +#include "mojo/public/cpp/application/application_connection.h" +#include "mojo/public/cpp/application/application_delegate.h" #include "mojo/services/public/cpp/view_manager/node.h" #include "mojo/services/public/cpp/view_manager/node_observer.h" #include "mojo/services/public/cpp/view_manager/view.h" @@ -32,7 +33,8 @@ const char kEmbeddedAppURL[] = "mojo:mojo_embedded_app"; } // An app that embeds another app. -class NestingApp : public Application, +// TODO(davemoore): Is this the right name? +class NestingApp : public ApplicationDelegate, public ViewManagerDelegate, public ViewObserver, public NodeObserver { @@ -43,7 +45,8 @@ class NestingApp : public Application, private: class Navigator : public InterfaceImpl<navigation::Navigator> { public: - explicit Navigator(NestingApp* app) : app_(app) {} + explicit Navigator(ApplicationConnection* connection, + NestingApp* app) : app_(app) {} private: virtual void Navigate( uint32 node_id, @@ -61,11 +64,18 @@ class NestingApp : public Application, DISALLOW_COPY_AND_ASSIGN(Navigator); }; - // Overridden from Application: - virtual void Initialize() MOJO_OVERRIDE { - ViewManager::Create(this, this); - ConnectTo<IWindowManager>("mojo:mojo_window_manager", &window_manager_); - AddService<Navigator>(this); + // Overridden from ApplicationImpl: + virtual bool ConfigureIncomingConnection(ApplicationConnection* connection) + MOJO_OVERRIDE { + ViewManager::ConfigureIncomingConnection(connection, this); + connection->ConnectToService(&window_manager_); + connection->AddService<Navigator>(this); + // TODO(davemoore): Is this ok? + if (!navigator_.get()) { + connection->ConnectToApplication( + kEmbeddedAppURL)->ConnectToService(&navigator_); + } + return true; } // Overridden from ViewManagerDelegate: @@ -82,9 +92,6 @@ class NestingApp : public Application, nested_->SetBounds(gfx::Rect(20, 20, 50, 50)); nested_->Embed(kEmbeddedAppURL); - if (!navigator_.get()) - ConnectTo(kEmbeddedAppURL, &navigator_); - NavigateChild(); } @@ -129,7 +136,7 @@ class NestingApp : public Application, } // namespace examples // static -Application* Application::Create() { +ApplicationDelegate* ApplicationDelegate::Create() { return new examples::NestingApp; } diff --git a/mojo/examples/pepper_container_app/pepper_container_app.cc b/mojo/examples/pepper_container_app/pepper_container_app.cc index 3c6cf76..dc4a9ce 100644 --- a/mojo/examples/pepper_container_app/pepper_container_app.cc +++ b/mojo/examples/pepper_container_app/pepper_container_app.cc @@ -11,7 +11,8 @@ #include "mojo/examples/pepper_container_app/plugin_instance.h" #include "mojo/examples/pepper_container_app/plugin_module.h" #include "mojo/examples/pepper_container_app/type_converters.h" -#include "mojo/public/cpp/application/application.h" +#include "mojo/public/cpp/application/application_delegate.h" +#include "mojo/public/cpp/application/application_impl.h" #include "mojo/public/cpp/gles2/gles2.h" #include "mojo/public/cpp/system/core.h" #include "mojo/public/interfaces/service_provider/service_provider.mojom.h" @@ -22,19 +23,18 @@ namespace mojo { namespace examples { -class PepperContainerApp: public Application, +class PepperContainerApp: public ApplicationDelegate, public NativeViewportClient, public MojoPpapiGlobals::Delegate { public: explicit PepperContainerApp() - : Application(), - ppapi_globals_(this), + : ppapi_globals_(this), plugin_module_(new PluginModule) {} virtual ~PepperContainerApp() {} - virtual void Initialize() MOJO_OVERRIDE { - ConnectTo("mojo:mojo_native_viewport_service", &viewport_); + virtual void Initialize(ApplicationImpl* app) MOJO_OVERRIDE { + app->ConnectToService("mojo:mojo_native_viewport_service", &viewport_); viewport_.set_client(this); RectPtr rect(Rect::New()); @@ -103,7 +103,7 @@ class PepperContainerApp: public Application, } // namespace examples // static -Application* Application::Create() { +ApplicationDelegate* ApplicationDelegate::Create() { return new examples::PepperContainerApp(); } diff --git a/mojo/examples/png_viewer/png_viewer.cc b/mojo/examples/png_viewer/png_viewer.cc index 8faed24..6a7218a 100644 --- a/mojo/examples/png_viewer/png_viewer.cc +++ b/mojo/examples/png_viewer/png_viewer.cc @@ -5,7 +5,8 @@ #include <algorithm> #include "base/strings/string_tokenizer.h" -#include "mojo/public/cpp/application/application.h" +#include "mojo/public/cpp/application/application_connection.h" +#include "mojo/public/cpp/application/application_delegate.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" @@ -22,7 +23,8 @@ class PNGViewer; class NavigatorImpl : public InterfaceImpl<navigation::Navigator> { public: - explicit NavigatorImpl(PNGViewer* viewer) : viewer_(viewer) {} + explicit NavigatorImpl(ApplicationConnection* connection, + PNGViewer* viewer) : viewer_(viewer) {} virtual ~NavigatorImpl() {} private: @@ -84,7 +86,8 @@ class NavigatorImpl : public InterfaceImpl<navigation::Navigator> { DISALLOW_COPY_AND_ASSIGN(NavigatorImpl); }; -class PNGViewer : public Application, public view_manager::ViewManagerDelegate { +class PNGViewer : public ApplicationDelegate, + public view_manager::ViewManagerDelegate { public: PNGViewer() : content_view_(NULL) {} virtual ~PNGViewer() {} @@ -95,10 +98,12 @@ class PNGViewer : public Application, public view_manager::ViewManagerDelegate { } private: - // Overridden from Application: - virtual void Initialize() OVERRIDE { - AddService<NavigatorImpl>(this); - view_manager::ViewManager::Create(this, this); + // Overridden from ApplicationDelegate: + virtual bool ConfigureIncomingConnection(ApplicationConnection* connection) + MOJO_OVERRIDE { + connection->AddService<NavigatorImpl>(this); + view_manager::ViewManager::ConfigureIncomingConnection(connection, this); + return true; } // Overridden from view_manager::ViewManagerDelegate: @@ -130,7 +135,7 @@ void NavigatorImpl::UpdateView(view_manager::Id node_id, } // namespace examples // static -Application* Application::Create() { +ApplicationDelegate* ApplicationDelegate::Create() { return new examples::PNGViewer; } diff --git a/mojo/examples/sample_app/sample_app.cc b/mojo/examples/sample_app/sample_app.cc index b6a20b7..c5a57ab 100644 --- a/mojo/examples/sample_app/sample_app.cc +++ b/mojo/examples/sample_app/sample_app.cc @@ -6,7 +6,9 @@ #include <string> #include "mojo/examples/sample_app/gles2_client_impl.h" -#include "mojo/public/cpp/application/application.h" +#include "mojo/public/cpp/application/application_connection.h" +#include "mojo/public/cpp/application/application_delegate.h" +#include "mojo/public/cpp/application/application_impl.h" #include "mojo/public/cpp/gles2/gles2.h" #include "mojo/public/cpp/system/core.h" #include "mojo/public/cpp/system/macros.h" @@ -17,7 +19,7 @@ namespace mojo { namespace examples { -class SampleApp : public Application, public NativeViewportClient { +class SampleApp : public ApplicationDelegate, public NativeViewportClient { public: SampleApp() {} @@ -26,8 +28,8 @@ class SampleApp : public Application, public NativeViewportClient { MOJO_ALLOW_UNUSED GLES2ClientImpl* leaked = gles2_client_.release(); } - virtual void Initialize() MOJO_OVERRIDE { - ConnectTo("mojo:mojo_native_viewport_service", &viewport_); + virtual void Initialize(ApplicationImpl* app) MOJO_OVERRIDE { + app->ConnectToService("mojo:mojo_native_viewport_service", &viewport_); viewport_.set_client(this); RectPtr rect(Rect::New()); @@ -77,7 +79,7 @@ class SampleApp : public Application, public NativeViewportClient { } // namespace examples // static -Application* Application::Create() { +ApplicationDelegate* ApplicationDelegate::Create() { return new examples::SampleApp(); } diff --git a/mojo/examples/wget/wget.cc b/mojo/examples/wget/wget.cc index 8a0ad5e..8fabbe6 100644 --- a/mojo/examples/wget/wget.cc +++ b/mojo/examples/wget/wget.cc @@ -4,17 +4,18 @@ #include <stdio.h> -#include "mojo/public/cpp/application/application.h" +#include "mojo/public/cpp/application/application_delegate.h" +#include "mojo/public/cpp/application/application_impl.h" #include "mojo/services/public/interfaces/network/network_service.mojom.h" #include "mojo/services/public/interfaces/network/url_loader.mojom.h" namespace mojo { namespace examples { -class WGetApp : public Application, public URLLoaderClient { +class WGetApp : public ApplicationDelegate, public URLLoaderClient { public: - virtual void Initialize() MOJO_OVERRIDE { - ConnectTo("mojo:mojo_network_service", &network_service_); + virtual void Initialize(ApplicationImpl* app) MOJO_OVERRIDE { + app->ConnectToService("mojo:mojo_network_service", &network_service_); Start(); } @@ -109,7 +110,7 @@ class WGetApp : public Application, public URLLoaderClient { } // namespace examples // static -Application* Application::Create() { +ApplicationDelegate* ApplicationDelegate::Create() { return new examples::WGetApp(); } diff --git a/mojo/examples/window_manager/window_manager.cc b/mojo/examples/window_manager/window_manager.cc index 28178ba..d6c2082 100644 --- a/mojo/examples/window_manager/window_manager.cc +++ b/mojo/examples/window_manager/window_manager.cc @@ -7,7 +7,9 @@ #include "base/strings/stringprintf.h" #include "mojo/examples/keyboard/keyboard.mojom.h" #include "mojo/examples/window_manager/window_manager.mojom.h" -#include "mojo/public/cpp/application/application.h" +#include "mojo/public/cpp/application/application_connection.h" +#include "mojo/public/cpp/application/application_delegate.h" +#include "mojo/public/cpp/application/application_impl.h" #include "mojo/services/public/cpp/geometry/geometry_type_converters.h" #include "mojo/services/public/cpp/input_events/input_events_type_converters.h" #include "mojo/services/public/cpp/view_manager/node.h" @@ -54,7 +56,8 @@ const int kTextfieldHeight = 25; class WindowManagerConnection : public InterfaceImpl<IWindowManager> { public: - explicit WindowManagerConnection(WindowManager* window_manager) + explicit WindowManagerConnection(ApplicationConnection* connection, + WindowManager* window_manager) : window_manager_(window_manager) {} virtual ~WindowManagerConnection() {} @@ -71,7 +74,8 @@ class WindowManagerConnection : public InterfaceImpl<IWindowManager> { class NavigatorHost : public InterfaceImpl<navigation::NavigatorHost> { public: - explicit NavigatorHost(WindowManager* window_manager) + explicit NavigatorHost(ApplicationConnection* connection, + WindowManager* window_manager) : window_manager_(window_manager) { } virtual ~NavigatorHost() { @@ -96,7 +100,7 @@ class KeyboardManager : public KeyboardClient { Node* node() { return node_; } - void Init(Application* application, + void Init(ApplicationImpl* application, ViewManager* view_manager, Node* parent, const gfx::Rect& bounds) { @@ -105,7 +109,7 @@ class KeyboardManager : public KeyboardClient { parent->AddChild(node_); node_->SetBounds(bounds); node_->Embed("mojo:mojo_keyboard"); - application->ConnectTo("mojo:mojo_keyboard", &keyboard_service_); + application->ConnectToService("mojo:mojo_keyboard", &keyboard_service_); keyboard_service_.set_client(this); } @@ -151,13 +155,12 @@ class KeyboardManager : public KeyboardClient { DISALLOW_COPY_AND_ASSIGN(KeyboardManager); }; -class WindowManager : public Application, +class WindowManager : public ApplicationDelegate, public ViewObserver, public ViewManagerDelegate, public ViewEventDispatcher { public: - WindowManager() : launcher_ui_(NULL), view_manager_(NULL) { - } + WindowManager() : launcher_ui_(NULL), view_manager_(NULL), app_(NULL) {} virtual ~WindowManager() {} void CloseWindow(Id node_id) { @@ -176,7 +179,7 @@ class WindowManager : public Application, // this really owns |view_id|. if (!keyboard_manager_) { keyboard_manager_.reset(new KeyboardManager); - keyboard_manager_->Init(this, view_manager_, + keyboard_manager_->Init(app_, view_manager_, view_manager_->GetRoots().back(), gfx::Rect(0, 400, 400, 200)); } @@ -193,8 +196,6 @@ class WindowManager : public Application, uint32 source_node_id, navigation::Target target, navigation::NavigationDetailsPtr nav_details) { - if (!launcher_.get()) - ConnectTo("mojo:mojo_launcher", &launcher_); launcher_->Launch(nav_details->url, base::Bind(&WindowManager::OnLaunch, base::Unretained(this), @@ -203,11 +204,18 @@ class WindowManager : public Application, } private: - // Overridden from Application: - virtual void Initialize() MOJO_OVERRIDE { - AddService<WindowManagerConnection>(this); - AddService<NavigatorHost>(this); - ViewManager::Create(this, this); + // Overridden from ApplicationDelegate: + virtual void Initialize(ApplicationImpl* app) MOJO_OVERRIDE { + app_ = app; + app->ConnectToService("mojo:mojo_launcher", &launcher_); + } + + virtual bool ConfigureIncomingConnection(ApplicationConnection* connection) + MOJO_OVERRIDE { + connection->AddService<WindowManagerConnection>(this); + connection->AddService<NavigatorHost>(this); + ViewManager::ConfigureIncomingConnection(connection, this); + return true; } // Overridden from ViewObserver: @@ -328,7 +336,7 @@ class WindowManager : public Application, node->Embed(app_url); if (nav_details.get()) { navigation::NavigatorPtr navigator; - ConnectTo(app_url, &navigator); + app_->ConnectToService(app_url, &navigator); navigator->Navigate(node->id(), nav_details.Pass(), response.Pass()); } } @@ -347,6 +355,7 @@ class WindowManager : public Application, Id content_node_id_; scoped_ptr<KeyboardManager> keyboard_manager_; + ApplicationImpl* app_; DISALLOW_COPY_AND_ASSIGN(WindowManager); }; @@ -373,7 +382,7 @@ void NavigatorHost::RequestNavigate( } // namespace examples // static -Application* Application::Create() { +ApplicationDelegate* ApplicationDelegate::Create() { return new examples::WindowManager; } |