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 "base/bind.h" | 5 #include "base/bind.h" |
6 #include "base/command_line.h" | 6 #include "base/command_line.h" |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 ~HTMLViewer() override {} | 155 ~HTMLViewer() override {} |
156 | 156 |
157 private: | 157 private: |
158 // Overridden from ApplicationDelegate: | 158 // Overridden from ApplicationDelegate: |
159 void Initialize(mojo::ApplicationImpl* app) override { | 159 void Initialize(mojo::ApplicationImpl* app) override { |
160 app_ = app; | 160 app_ = app; |
161 setup_.reset(new Setup(app)); | 161 setup_.reset(new Setup(app)); |
162 } | 162 } |
163 | 163 |
164 bool ConfigureIncomingConnection(ApplicationConnection* connection) override { | 164 bool ConfigureIncomingConnection(ApplicationConnection* connection) override { |
165 // If we're not being connected to from the view manager assume we're being | |
166 // run in tests, or a headless environment, in which case we'll never get a | |
167 // ui and there is no point in waiting for it. | |
168 if (connection->GetRemoteApplicationURL() != "mojo://view_manager/" && | |
169 !setup_->did_init()) { | |
170 setup_->InitHeadless(); | |
171 } | |
172 connection->AddService(this); | 165 connection->AddService(this); |
173 return true; | 166 return true; |
174 } | 167 } |
175 | 168 |
176 // Overridden from InterfaceFactory<ContentHandler> | 169 // Overridden from InterfaceFactory<ContentHandler> |
177 void Create(ApplicationConnection* connection, | 170 void Create(ApplicationConnection* connection, |
178 mojo::InterfaceRequest<ContentHandler> request) override { | 171 mojo::InterfaceRequest<ContentHandler> request) override { |
179 new ContentHandlerImpl(setup_.get(), app_, request.Pass()); | 172 new ContentHandlerImpl(setup_.get(), app_, request.Pass()); |
180 } | 173 } |
181 | 174 |
182 scoped_ptr<Setup> setup_; | 175 scoped_ptr<Setup> setup_; |
183 mojo::ApplicationImpl* app_; | 176 mojo::ApplicationImpl* app_; |
184 | 177 |
185 DISALLOW_COPY_AND_ASSIGN(HTMLViewer); | 178 DISALLOW_COPY_AND_ASSIGN(HTMLViewer); |
186 }; | 179 }; |
187 | 180 |
188 } // namespace html_viewer | 181 } // namespace html_viewer |
189 | 182 |
190 MojoResult MojoMain(MojoHandle shell_handle) { | 183 MojoResult MojoMain(MojoHandle shell_handle) { |
191 mojo::ApplicationRunner runner(new html_viewer::HTMLViewer); | 184 mojo::ApplicationRunner runner(new html_viewer::HTMLViewer); |
192 return runner.Run(shell_handle); | 185 return runner.Run(shell_handle); |
193 } | 186 } |
OLD | NEW |