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

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

Issue 2020453003: Convert ViewProviderApp and ContentViewerApp to implement ApplicationImplBase instead of Applicatio… (Closed) Base URL: https://github.com/domokit/mojo.git@work796_no_run_main_app
Patch Set: Created 4 years, 6 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 | « examples/ui/tile/tile_app.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
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef MOJO_UI_CONTENT_VIEWER_APP_H_ 5 #ifndef MOJO_UI_CONTENT_VIEWER_APP_H_
6 #define MOJO_UI_CONTENT_VIEWER_APP_H_ 6 #define MOJO_UI_CONTENT_VIEWER_APP_H_
7 7
8 #include "mojo/common/strong_binding_set.h" 8 #include "mojo/common/strong_binding_set.h"
9 #include "mojo/public/cpp/application/application_impl_base.h"
10 #include "mojo/public/cpp/system/macros.h"
9 #include "mojo/services/content_handler/interfaces/content_handler.mojom.h" 11 #include "mojo/services/content_handler/interfaces/content_handler.mojom.h"
10 #include "mojo/ui/view_provider_app.h"
11 12
12 namespace mojo { 13 namespace mojo {
14
15 class ServiceProviderImpl;
16
13 namespace ui { 17 namespace ui {
14 18
19 class ViewProviderApp;
20
15 // A simple ContentHandler application implementation for rendering 21 // A simple ContentHandler application implementation for rendering
16 // content as Views. Subclasses must provide a function to create 22 // content as Views. Subclasses must provide a function to create
17 // the view provider application on demand. 23 // the view provider application on demand.
18 // 24 //
19 // TODO(jeffbrown): Support creating the view provider application in a 25 // TODO(jeffbrown): Support creating the view provider application in a
20 // separate thread if desired (often not the case). This is one reason 26 // separate thread if desired (often not the case). This is one reason
21 // we are not using the ContentHandlerFactory here. 27 // we are not using the ContentHandlerFactory here.
22 class ContentViewerApp : public ApplicationDelegate { 28 class ContentViewerApp : public ApplicationImplBase {
23 public: 29 public:
24 ContentViewerApp(); 30 ContentViewerApp();
25 ~ContentViewerApp() override; 31 ~ContentViewerApp() override;
26 32
27 ApplicationImpl* app_impl() { return app_impl_; } 33 // |ApplicationImplBase|:
28 34 void OnInitialize() override;
29 // |ApplicationDelegate|: 35 bool OnAcceptConnection(ServiceProviderImpl* service_provider_impl) override;
30 void Initialize(ApplicationImpl* app) override;
31 bool ConfigureIncomingConnection(
32 ServiceProviderImpl* service_provider_impl) override;
33 36
34 // Called to create the view provider application to view the content. 37 // Called to create the view provider application to view the content.
35 // 38 //
36 // This method may be called multiple times to load different content 39 // This method may be called multiple times to load different content
37 // into separate view providers. The view provider implementation should 40 // into separate view providers. The view provider implementation should
38 // cache the loaded content in case it is asked to create multiple instances 41 // cache the loaded content in case it is asked to create multiple instances
39 // of the view since the response can only be consumed once. 42 // of the view since the response can only be consumed once.
40 // 43 //
41 // The |content_handler_url| is the connection URL of the content handler 44 // The |content_handler_url| is the connection URL of the content handler
42 // request. 45 // request.
43 // The |response| carries the data retrieved by the content handler. 46 // The |response| carries the data retrieved by the content handler.
44 // 47 //
45 // Returns the view provider application delegate to view the content, 48 // Returns the view provider application to view the content, or nullptr if
46 // or nullptr if the content could not be loaded. 49 // the content could not be loaded.
50 //
51 // TODO(vtl): This interface is a bit broken. (What's the ownership of the
52 // returned ViewProviderApp implementation?) See my TODO in the implementation
53 // of StartViewer().
47 virtual ViewProviderApp* LoadContent(const std::string& content_handler_url, 54 virtual ViewProviderApp* LoadContent(const std::string& content_handler_url,
48 URLResponsePtr response) = 0; 55 URLResponsePtr response) = 0;
49 56
50 private: 57 private:
51 class DelegatingContentHandler; 58 class DelegatingContentHandler;
52 59
53 void StartViewer(const std::string& content_handler_url, 60 void StartViewer(const std::string& content_handler_url,
54 InterfaceRequest<Application> application_request, 61 InterfaceRequest<Application> application_request,
55 URLResponsePtr response); 62 URLResponsePtr response);
56 63
57 ApplicationImpl* app_impl_ = nullptr;
58 StrongBindingSet<ContentHandler> bindings_; 64 StrongBindingSet<ContentHandler> bindings_;
59 65
60 MOJO_DISALLOW_COPY_AND_ASSIGN(ContentViewerApp); 66 MOJO_DISALLOW_COPY_AND_ASSIGN(ContentViewerApp);
61 }; 67 };
62 68
63 } // namespace ui 69 } // namespace ui
64 } // namespace mojo 70 } // namespace mojo
65 71
66 #endif // MOJO_UI_CONTENT_VIEWER_APP_H_ 72 #endif // MOJO_UI_CONTENT_VIEWER_APP_H_
OLDNEW
« no previous file with comments | « examples/ui/tile/tile_app.cc ('k') | mojo/ui/content_viewer_app.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698