Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(80)

Side by Side Diff: examples/bank_app/customer.cc

Issue 1261403003: Initial skeletal implementation of the PrincipalService. Also, use the Login()/GetUserBlessing() (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Add a new example for user authorization Created 5 years, 4 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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include <stdio.h>
6
7 #include "examples/bank_app/bank.mojom.h"
8 #include "mojo/public/c/system/main.h"
9 #include "mojo/public/cpp/application/application_delegate.h"
10 #include "mojo/public/cpp/application/application_impl.h"
11 #include "mojo/public/cpp/application/application_runner.h"
12 #include "mojo/public/cpp/utility/run_loop.h"
13 #include "mojo/services/vanadium/security/public/interfaces/principal.mojom.h"
14
15 namespace mojo {
16 namespace examples {
17
18 class BankCustomer : public ApplicationDelegate {
19 public:
20 void Initialize(ApplicationImpl* app) override {
21 // Get user login credentials
22 app->ConnectToService("mojo:principal_service", &login_service_);
23 login_service_->Login(PrincipalService::LoginCallback());
24
25 // Deposit some money and check the balance
26 app->ConnectToService("mojo:bank", &bank_);
27 bank_->Deposit(500/*usd*/);
28 bank_->Withdraw(100/*usd*/);
29 bank_->GetBalance(Bank::GetBalanceCallback());
30 }
31
32 void Quit() override {
33 login_service_->Logout();
34 }
35
36 private:
37 BankPtr bank_;
38 PrincipalServicePtr login_service_;
39 };
40
41 } // namespace examples
42 } // namespace mojo
43
44 MojoResult MojoMain(MojoHandle application_request) {
45 mojo::ApplicationRunner runner(new mojo::examples::BankCustomer);
46 return runner.Run(application_request);
47 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698