Chromium Code Reviews| 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 | 165 // If we're not being connected to from the browser assume we're being |
| 166 // run in tests, or a headless environment, in which case we'll never get a | 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. | 167 // ui and there is no point in waiting for it. |
| 168 if (connection->GetRemoteApplicationURL() != "mojo://view_manager/" && | 168 if (!setup_->did_init() && |
| 169 !setup_->did_init()) { | 169 connection->GetRemoteApplicationURL() != "mojo://browser/") { |
|
Ben Goodger (Google)
2015/06/09 20:27:27
oof this feels like a layering violation.
seems l
sky
2015/06/09 21:35:31
It's more subtle than that. But, we have a switch
| |
| 170 setup_->InitHeadless(); | 170 setup_->InitHeadless(); |
| 171 } | 171 } |
| 172 connection->AddService(this); | 172 connection->AddService(this); |
| 173 return true; | 173 return true; |
| 174 } | 174 } |
| 175 | 175 |
| 176 // Overridden from InterfaceFactory<ContentHandler> | 176 // Overridden from InterfaceFactory<ContentHandler> |
| 177 void Create(ApplicationConnection* connection, | 177 void Create(ApplicationConnection* connection, |
| 178 mojo::InterfaceRequest<ContentHandler> request) override { | 178 mojo::InterfaceRequest<ContentHandler> request) override { |
| 179 new ContentHandlerImpl(setup_.get(), app_, request.Pass()); | 179 new ContentHandlerImpl(setup_.get(), app_, request.Pass()); |
| 180 } | 180 } |
| 181 | 181 |
| 182 scoped_ptr<Setup> setup_; | 182 scoped_ptr<Setup> setup_; |
| 183 mojo::ApplicationImpl* app_; | 183 mojo::ApplicationImpl* app_; |
| 184 | 184 |
| 185 DISALLOW_COPY_AND_ASSIGN(HTMLViewer); | 185 DISALLOW_COPY_AND_ASSIGN(HTMLViewer); |
| 186 }; | 186 }; |
| 187 | 187 |
| 188 } // namespace html_viewer | 188 } // namespace html_viewer |
| 189 | 189 |
| 190 MojoResult MojoMain(MojoHandle shell_handle) { | 190 MojoResult MojoMain(MojoHandle shell_handle) { |
| 191 mojo::ApplicationRunner runner(new html_viewer::HTMLViewer); | 191 mojo::ApplicationRunner runner(new html_viewer::HTMLViewer); |
| 192 return runner.Run(shell_handle); | 192 return runner.Run(shell_handle); |
| 193 } | 193 } |
| OLD | NEW |