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

Side by Side Diff: examples/ui/png_viewer/png_viewer.cc

Issue 1991853003: Make BaseView et al. take an ApplicationConnector instead of an ApplicationImpl. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: doh Created 4 years, 7 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/pdf_viewer/pdf_viewer.cc ('k') | examples/ui/shapes/shapes_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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #include <string> 5 #include <string>
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "mojo/application/application_runner_chromium.h" 10 #include "mojo/application/application_runner_chromium.h"
11 #include "mojo/data_pipe_utils/data_pipe_utils.h" 11 #include "mojo/data_pipe_utils/data_pipe_utils.h"
12 #include "mojo/public/c/system/main.h" 12 #include "mojo/public/c/system/main.h"
13 #include "mojo/public/cpp/application/connect.h"
13 #include "mojo/ui/content_viewer_app.h" 14 #include "mojo/ui/content_viewer_app.h"
14 #include "mojo/ui/ganesh_view.h" 15 #include "mojo/ui/ganesh_view.h"
15 #include "third_party/skia/include/core/SkBitmap.h" 16 #include "third_party/skia/include/core/SkBitmap.h"
16 #include "third_party/skia/include/core/SkCanvas.h" 17 #include "third_party/skia/include/core/SkCanvas.h"
17 #include "third_party/skia/include/core/SkImage.h" 18 #include "third_party/skia/include/core/SkImage.h"
18 #include "third_party/skia/include/core/SkSurface.h" 19 #include "third_party/skia/include/core/SkSurface.h"
19 #include "ui/gfx/codec/png_codec.h" 20 #include "ui/gfx/codec/png_codec.h"
20 21
21 namespace examples { 22 namespace examples {
22 23
23 namespace { 24 namespace {
24 constexpr uint32_t kContentImageResourceId = 1; 25 constexpr uint32_t kContentImageResourceId = 1;
25 constexpr uint32_t kRootNodeId = mojo::gfx::composition::kSceneRootNodeId; 26 constexpr uint32_t kRootNodeId = mojo::gfx::composition::kSceneRootNodeId;
26 } // namespace 27 } // namespace
27 28
28 class PNGView : public mojo::ui::GaneshView { 29 class PNGView : public mojo::ui::GaneshView {
29 public: 30 public:
30 PNGView(mojo::ApplicationImpl* app_impl, 31 PNGView(mojo::InterfaceHandle<mojo::ApplicationConnector> app_connector,
31 mojo::InterfaceRequest<mojo::ui::ViewOwner> view_owner_request, 32 mojo::InterfaceRequest<mojo::ui::ViewOwner> view_owner_request,
32 const skia::RefPtr<SkImage>& image) 33 const skia::RefPtr<SkImage>& image)
33 : GaneshView(app_impl, view_owner_request.Pass(), "PNGViewer"), 34 : GaneshView(app_connector.Pass(),
35 view_owner_request.Pass(),
36 "PNGViewer"),
34 image_(image) { 37 image_(image) {
35 DCHECK(image_); 38 DCHECK(image_);
36 } 39 }
37 40
38 ~PNGView() override {} 41 ~PNGView() override {}
39 42
40 private: 43 private:
41 // |GaneshView|: 44 // |GaneshView|:
42 void OnPropertiesChanged( 45 void OnPropertiesChanged(
43 uint32_t old_scene_version, 46 uint32_t old_scene_version,
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 DCHECK(image_); 115 DCHECK(image_);
113 } 116 }
114 117
115 ~PNGContentViewProviderApp() override {} 118 ~PNGContentViewProviderApp() override {}
116 119
117 void CreateView( 120 void CreateView(
118 const std::string& connection_url, 121 const std::string& connection_url,
119 mojo::InterfaceRequest<mojo::ui::ViewOwner> view_owner_request, 122 mojo::InterfaceRequest<mojo::ui::ViewOwner> view_owner_request,
120 mojo::InterfaceRequest<mojo::ServiceProvider> services, 123 mojo::InterfaceRequest<mojo::ServiceProvider> services,
121 mojo::InterfaceHandle<mojo::ServiceProvider> exposed_services) override { 124 mojo::InterfaceHandle<mojo::ServiceProvider> exposed_services) override {
122 new PNGView(app_impl(), view_owner_request.Pass(), image_); 125 new PNGView(mojo::CreateApplicationConnector(app_impl()->shell()),
126 view_owner_request.Pass(), image_);
123 } 127 }
124 128
125 private: 129 private:
126 skia::RefPtr<SkImage> image_; 130 skia::RefPtr<SkImage> image_;
127 131
128 DISALLOW_COPY_AND_ASSIGN(PNGContentViewProviderApp); 132 DISALLOW_COPY_AND_ASSIGN(PNGContentViewProviderApp);
129 }; 133 };
130 134
131 class PNGContentViewerApp : public mojo::ui::ContentViewerApp { 135 class PNGContentViewerApp : public mojo::ui::ContentViewerApp {
132 public: 136 public:
(...skipping 22 matching lines...) Expand all
155 private: 159 private:
156 DISALLOW_COPY_AND_ASSIGN(PNGContentViewerApp); 160 DISALLOW_COPY_AND_ASSIGN(PNGContentViewerApp);
157 }; 161 };
158 162
159 } // namespace examples 163 } // namespace examples
160 164
161 MojoResult MojoMain(MojoHandle application_request) { 165 MojoResult MojoMain(MojoHandle application_request) {
162 mojo::ApplicationRunnerChromium runner(new examples::PNGContentViewerApp()); 166 mojo::ApplicationRunnerChromium runner(new examples::PNGContentViewerApp());
163 return runner.Run(application_request); 167 return runner.Run(application_request);
164 } 168 }
OLDNEW
« no previous file with comments | « examples/ui/pdf_viewer/pdf_viewer.cc ('k') | examples/ui/shapes/shapes_app.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698