OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 <memory> | 5 #include <memory> |
6 | 6 |
7 #include "examples/bank_app/bank.mojom.h" | 7 #include "examples/bank_app/bank.mojom.h" |
8 #include "mojo/common/binding_set.h" | 8 #include "mojo/common/binding_set.h" |
9 #include "mojo/public/c/system/main.h" | 9 #include "mojo/public/c/system/main.h" |
10 #include "mojo/public/cpp/application/application_connection.h" | 10 #include "mojo/public/cpp/application/application_connection.h" |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 BankApp() {} | 52 BankApp() {} |
53 | 53 |
54 void Initialize(mojo::ApplicationImpl* app) override { | 54 void Initialize(mojo::ApplicationImpl* app) override { |
55 mojo::ConnectToService(app->shell(), "mojo:principal_service", | 55 mojo::ConnectToService(app->shell(), "mojo:principal_service", |
56 GetProxy(&login_service_)); | 56 GetProxy(&login_service_)); |
57 } | 57 } |
58 | 58 |
59 // From ApplicationDelegate | 59 // From ApplicationDelegate |
60 bool ConfigureIncomingConnection( | 60 bool ConfigureIncomingConnection( |
61 mojo::ApplicationConnection* connection) override { | 61 mojo::ApplicationConnection* connection) override { |
62 std::string url = connection->GetRemoteApplicationURL(); | 62 std::string url = |
| 63 connection->GetServiceProviderImpl().connection_context().remote_url; |
63 if (url.length() > 0) { | 64 if (url.length() > 0) { |
64 vanadium::AppInstanceNamePtr app(vanadium::AppInstanceName::New()); | 65 vanadium::AppInstanceNamePtr app(vanadium::AppInstanceName::New()); |
65 app->url = url; | 66 app->url = url; |
66 std::string user; | 67 std::string user; |
67 login_service_->GetUser(app.Pass(), BankUser(&user)); | 68 login_service_->GetUser(app.Pass(), BankUser(&user)); |
68 // Check and see whether we got a valid user blessing. | 69 // Check and see whether we got a valid user blessing. |
69 if (!login_service_.WaitForIncomingResponse()) { | 70 if (!login_service_.WaitForIncomingResponse()) { |
70 MOJO_LOG(INFO) << "Failed to get a valid user blessing"; | 71 MOJO_LOG(INFO) << "Failed to get a valid user blessing"; |
71 return false; | 72 return false; |
72 } | 73 } |
(...skipping 20 matching lines...) Expand all Loading... |
93 vanadium::PrincipalServicePtr login_service_; | 94 vanadium::PrincipalServicePtr login_service_; |
94 }; | 95 }; |
95 | 96 |
96 } // namespace examples | 97 } // namespace examples |
97 | 98 |
98 MojoResult MojoMain(MojoHandle application_request) { | 99 MojoResult MojoMain(MojoHandle application_request) { |
99 mojo::ApplicationRunner runner( | 100 mojo::ApplicationRunner runner( |
100 std::unique_ptr<examples::BankApp>(new examples::BankApp())); | 101 std::unique_ptr<examples::BankApp>(new examples::BankApp())); |
101 return runner.Run(application_request); | 102 return runner.Run(application_request); |
102 } | 103 } |
OLD | NEW |