OLD | NEW |
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 <algorithm> | 5 #include <algorithm> |
6 | 6 |
7 #include "base/macros.h" | 7 #include "base/macros.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/strings/string_tokenizer.h" | 10 #include "base/strings/string_tokenizer.h" |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 | 77 |
78 // Overridden from ApplicationDelegate: | 78 // Overridden from ApplicationDelegate: |
79 virtual void Initialize(ApplicationImpl* app) override { | 79 virtual void Initialize(ApplicationImpl* app) override { |
80 app_ = app; | 80 app_ = app; |
81 view_manager_client_factory_.reset( | 81 view_manager_client_factory_.reset( |
82 new ViewManagerClientFactory(app->shell(), this)); | 82 new ViewManagerClientFactory(app->shell(), this)); |
83 } | 83 } |
84 | 84 |
85 // Overridden from ApplicationDelegate: | 85 // Overridden from ApplicationDelegate: |
86 virtual bool ConfigureIncomingConnection( | 86 virtual bool ConfigureIncomingConnection( |
87 ApplicationConnection* connection) override { | 87 ApplicationConnection* connection, const std::string& url) override { |
88 connection->AddService(view_manager_client_factory_.get()); | 88 connection->AddService(view_manager_client_factory_.get()); |
89 return true; | 89 return true; |
90 } | 90 } |
91 | 91 |
92 // Overridden from ViewManagerDelegate: | 92 // Overridden from ViewManagerDelegate: |
93 virtual void OnEmbed(View* root, | 93 virtual void OnEmbed(View* root, |
94 InterfaceRequest<ServiceProvider> services, | 94 InterfaceRequest<ServiceProvider> services, |
95 ServiceProviderPtr exposed_services) override { | 95 ServiceProviderPtr exposed_services) override { |
96 // TODO(qsr): The same view should be embeddable on multiple views. | 96 // TODO(qsr): The same view should be embeddable on multiple views. |
97 DCHECK(embedder_for_roots_.find(root) == embedder_for_roots_.end()); | 97 DCHECK(embedder_for_roots_.find(root) == embedder_for_roots_.end()); |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 }; | 196 }; |
197 | 197 |
198 class PNGViewer : public ApplicationDelegate, | 198 class PNGViewer : public ApplicationDelegate, |
199 public ContentHandlerFactory::ManagedDelegate { | 199 public ContentHandlerFactory::ManagedDelegate { |
200 public: | 200 public: |
201 PNGViewer() : content_handler_factory_(this) {} | 201 PNGViewer() : content_handler_factory_(this) {} |
202 | 202 |
203 private: | 203 private: |
204 // Overridden from ApplicationDelegate: | 204 // Overridden from ApplicationDelegate: |
205 virtual bool ConfigureIncomingConnection( | 205 virtual bool ConfigureIncomingConnection( |
206 ApplicationConnection* connection) override { | 206 ApplicationConnection* connection, const std::string& url) override { |
207 connection->AddService(&content_handler_factory_); | 207 connection->AddService(&content_handler_factory_); |
208 return true; | 208 return true; |
209 } | 209 } |
210 | 210 |
211 // Overridden from ContentHandlerFactory::ManagedDelegate: | 211 // Overridden from ContentHandlerFactory::ManagedDelegate: |
212 virtual scoped_ptr<ContentHandlerFactory::HandledApplicationHolder> | 212 virtual scoped_ptr<ContentHandlerFactory::HandledApplicationHolder> |
213 CreateApplication(InterfaceRequest<Application> application_request, | 213 CreateApplication(InterfaceRequest<Application> application_request, |
214 URLResponsePtr response) override { | 214 URLResponsePtr response) override { |
215 return make_handled_factory_holder(new mojo::ApplicationImpl( | 215 return make_handled_factory_holder(new mojo::ApplicationImpl( |
216 new PNGView(response.Pass()), application_request.Pass())); | 216 new PNGView(response.Pass()), application_request.Pass())); |
217 } | 217 } |
218 | 218 |
219 ContentHandlerFactory content_handler_factory_; | 219 ContentHandlerFactory content_handler_factory_; |
220 | 220 |
221 DISALLOW_COPY_AND_ASSIGN(PNGViewer); | 221 DISALLOW_COPY_AND_ASSIGN(PNGViewer); |
222 }; | 222 }; |
223 | 223 |
224 } // namespace examples | 224 } // namespace examples |
225 } // namespace mojo | 225 } // namespace mojo |
226 | 226 |
227 MojoResult MojoMain(MojoHandle shell_handle) { | 227 MojoResult MojoMain(MojoHandle shell_handle) { |
228 mojo::ApplicationRunnerChromium runner(new mojo::examples::PNGViewer()); | 228 mojo::ApplicationRunnerChromium runner(new mojo::examples::PNGViewer()); |
229 return runner.Run(shell_handle); | 229 return runner.Run(shell_handle); |
230 } | 230 } |
OLD | NEW |