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

Side by Side Diff: mojo/ui/view_provider_app.h

Issue 1556803002: Add helpers for creating UI components. (Closed) Base URL: git@github.com:domokit/mojo.git@moz-13
Patch Set: Created 4 years, 11 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
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef MOJO_UI_VIEW_PROVIDER_APP_H_
6 #define MOJO_UI_VIEW_PROVIDER_APP_H_
7
8 #include <string>
9
10 #include "mojo/common/strong_binding_set.h"
11 #include "mojo/public/c/system/main.h"
12 #include "mojo/public/cpp/application/application_connection.h"
13 #include "mojo/public/cpp/application/application_impl.h"
14 #include "mojo/public/cpp/system/core.h"
15 #include "mojo/public/cpp/system/macros.h"
16 #include "mojo/services/ui/views/interfaces/view_provider.mojom.h"
17
18 namespace mojo {
19 namespace ui {
20
21 // Abstract implementation of a simple application that offers a ViewProvider.
22 // Subclasses must provide a function to create the necessary Views.
23 //
24 // It is not necessary to use this class to implement all ViewProviders.
25 // This class is merely intended to make the simple apps easier to write.
26 class ViewProviderApp : public mojo::ApplicationDelegate,
27 public mojo::InterfaceFactory<mojo::ui::ViewProvider> {
28 public:
29 ViewProviderApp();
30 ~ViewProviderApp() override;
31
32 mojo::ApplicationImpl* app_impl() { return app_impl_; }
33
34 // |ApplicationDelegate|:
35 void Initialize(mojo::ApplicationImpl* app) override;
36 bool ConfigureIncomingConnection(
37 mojo::ApplicationConnection* connection) override;
38
39 // Called by the ViewProvider to create a view.
40 // This method may be called multiple times in the case where the
41 // view provider is asked to create multiple view instances.
42 //
43 // The |view_provider_url| is the connection URL of the view provider request.
44 //
45 // Returns true if successful, false if the view could not be created.
46 virtual bool CreateView(
47 const std::string& view_provider_url,
48 mojo::InterfaceRequest<mojo::ServiceProvider> services,
49 mojo::ServiceProviderPtr exposed_services,
50 const mojo::ui::ViewProvider::CreateViewCallback& callback) = 0;
51
52 private:
53 class DelegatingViewProvider;
54
55 // |InterfaceFactory<mojo::ui::ViewProvider>|:
56 void Create(mojo::ApplicationConnection* connection,
57 mojo::InterfaceRequest<mojo::ui::ViewProvider> request) override;
58
59 void CreateView(DelegatingViewProvider* provider,
60 const std::string& view_provider_url,
61 mojo::InterfaceRequest<mojo::ServiceProvider> services,
62 mojo::ServiceProviderPtr exposed_services,
63 const mojo::ui::ViewProvider::CreateViewCallback& callback);
64
65 mojo::ApplicationImpl* app_impl_ = nullptr;
66 mojo::StrongBindingSet<mojo::ui::ViewProvider> bindings_;
67
68 MOJO_DISALLOW_COPY_AND_ASSIGN(ViewProviderApp);
69 };
70
71 } // namespace ui
72 } // namespace mojo
73
74 #endif // MOJO_UI_VIEW_PROVIDER_APP_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698