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

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

Issue 1556803002: Add helpers for creating UI components. (Closed) Base URL: git@github.com:domokit/mojo.git@moz-13
Patch Set: address feedback 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
« no previous file with comments | « mojo/ui/choreographer.cc ('k') | mojo/ui/content_viewer_app.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_CONTENT_VIEWER_APP_H_
6 #define MOJO_UI_CONTENT_VIEWER_APP_H_
7
8 #include "mojo/common/strong_binding_set.h"
9 #include "mojo/services/content_handler/interfaces/content_handler.mojom.h"
10 #include "mojo/ui/view_provider_app.h"
11
12 namespace mojo {
13 namespace ui {
14
15 // A simple ContentHandler application implementation for rendering
16 // content as Views. Subclasses must provide a function to create
17 // the view provider application on demand.
18 //
19 // TODO(jeffbrown): Support creating the view provider application in a
20 // separate thread if desired (often not the case). This is one reason
21 // we are not using the ContentHandlerFactory here.
22 class ContentViewerApp : public mojo::ApplicationDelegate,
23 public mojo::InterfaceFactory<mojo::ContentHandler> {
24 public:
25 ContentViewerApp();
26 ~ContentViewerApp() override;
27
28 mojo::ApplicationImpl* app_impl() { return app_impl_; }
29
30 // |ApplicationDelegate|:
31 void Initialize(mojo::ApplicationImpl* app) override;
32 bool ConfigureIncomingConnection(
33 mojo::ApplicationConnection* connection) override;
34
35 // Called to create the view provider application to view the content.
36 //
37 // This method may be called multiple times to load different content
38 // into separate view providers. The view provider implementation should
39 // cache the loaded content in case it is asked to create multiple instances
40 // of the view since the response can only be consumed once.
41 //
42 // The |content_handler_url| is the connection URL of the content handler
43 // request.
44 // The |response| carries the data retrieved by the content handler.
45 //
46 // Returns the view provider application delegate to view the content,
47 // or nullptr if the content could not be loaded.
48 virtual ViewProviderApp* LoadContent(const std::string& content_handler_url,
49 mojo::URLResponsePtr response) = 0;
50
51 private:
52 class DelegatingContentHandler;
53
54 // |InterfaceFactory<ContentHandler>|:
55 void Create(mojo::ApplicationConnection* connection,
56 mojo::InterfaceRequest<mojo::ContentHandler> request) override;
57
58 void StartViewer(
59 const std::string& content_handler_url,
60 mojo::InterfaceRequest<mojo::Application> application_request,
61 mojo::URLResponsePtr response);
62
63 mojo::ApplicationImpl* app_impl_ = nullptr;
64 mojo::StrongBindingSet<mojo::ContentHandler> bindings_;
65
66 MOJO_DISALLOW_COPY_AND_ASSIGN(ContentViewerApp);
67 };
68
69 } // namespace ui
70 } // namespace mojo
71
72 #endif // MOJO_UI_CONTENT_VIEWER_APP_H_
OLDNEW
« no previous file with comments | « mojo/ui/choreographer.cc ('k') | mojo/ui/content_viewer_app.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698