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 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/pdf_viewer/pdf_viewer.cc ('k') | examples/ui/shapes/main.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"
11 #include "mojo/data_pipe_utils/data_pipe_utils.h" 10 #include "mojo/data_pipe_utils/data_pipe_utils.h"
11 #include "mojo/environment/scoped_chromium_init.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/public/cpp/application/connect.h"
14 #include "mojo/public/cpp/application/run_application.h"
14 #include "mojo/ui/content_viewer_app.h" 15 #include "mojo/ui/content_viewer_app.h"
15 #include "mojo/ui/ganesh_view.h" 16 #include "mojo/ui/ganesh_view.h"
17 #include "mojo/ui/view_provider_app.h"
16 #include "third_party/skia/include/core/SkBitmap.h" 18 #include "third_party/skia/include/core/SkBitmap.h"
17 #include "third_party/skia/include/core/SkCanvas.h" 19 #include "third_party/skia/include/core/SkCanvas.h"
18 #include "third_party/skia/include/core/SkImage.h" 20 #include "third_party/skia/include/core/SkImage.h"
19 #include "third_party/skia/include/core/SkSurface.h" 21 #include "third_party/skia/include/core/SkSurface.h"
20 #include "ui/gfx/codec/png_codec.h" 22 #include "ui/gfx/codec/png_codec.h"
21 23
22 namespace examples { 24 namespace examples {
23 25
24 namespace { 26 namespace {
25 constexpr uint32_t kContentImageResourceId = 1; 27 constexpr uint32_t kContentImageResourceId = 1;
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 PNGContentViewProviderApp(sk_sp<SkImage> image) : image_(image) { 116 PNGContentViewProviderApp(sk_sp<SkImage> image) : image_(image) {
115 DCHECK(image_); 117 DCHECK(image_);
116 } 118 }
117 119
118 ~PNGContentViewProviderApp() override {} 120 ~PNGContentViewProviderApp() override {}
119 121
120 void CreateView( 122 void CreateView(
121 const std::string& connection_url, 123 const std::string& connection_url,
122 mojo::InterfaceRequest<mojo::ui::ViewOwner> view_owner_request, 124 mojo::InterfaceRequest<mojo::ui::ViewOwner> view_owner_request,
123 mojo::InterfaceRequest<mojo::ServiceProvider> services) override { 125 mojo::InterfaceRequest<mojo::ServiceProvider> services) override {
124 new PNGView(mojo::CreateApplicationConnector(app_impl()->shell()), 126 new PNGView(mojo::CreateApplicationConnector(shell()),
125 view_owner_request.Pass(), image_); 127 view_owner_request.Pass(), image_);
126 } 128 }
127 129
128 private: 130 private:
129 sk_sp<SkImage> image_; 131 sk_sp<SkImage> image_;
130 132
131 DISALLOW_COPY_AND_ASSIGN(PNGContentViewProviderApp); 133 DISALLOW_COPY_AND_ASSIGN(PNGContentViewProviderApp);
132 }; 134 };
133 135
134 class PNGContentViewerApp : public mojo::ui::ContentViewerApp { 136 class PNGContentViewerApp : public mojo::ui::ContentViewerApp {
(...skipping 19 matching lines...) Expand all
154 return new PNGContentViewProviderApp(SkImage::MakeFromBitmap(bitmap)); 156 return new PNGContentViewProviderApp(SkImage::MakeFromBitmap(bitmap));
155 } 157 }
156 158
157 private: 159 private:
158 DISALLOW_COPY_AND_ASSIGN(PNGContentViewerApp); 160 DISALLOW_COPY_AND_ASSIGN(PNGContentViewerApp);
159 }; 161 };
160 162
161 } // namespace examples 163 } // namespace examples
162 164
163 MojoResult MojoMain(MojoHandle application_request) { 165 MojoResult MojoMain(MojoHandle application_request) {
164 mojo::ApplicationRunnerChromium runner(new examples::PNGContentViewerApp()); 166 mojo::ScopedChromiumInit init;
165 return runner.Run(application_request); 167 examples::PNGContentViewerApp png_content_viewer_app;
168 return mojo::RunApplication(application_request, &png_content_viewer_app);
166 } 169 }
OLDNEW
« no previous file with comments | « examples/ui/pdf_viewer/pdf_viewer.cc ('k') | examples/ui/shapes/main.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698