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

Side by Side Diff: examples/authentication_demo/google_authentication_demo.cc

Issue 2015643002: Add (optional) options to Run[Main]Application(). (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: doh Created 4 years, 6 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
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/logging.h" 6 #include "base/logging.h"
7 #include "mojo/public/c/system/main.h" 7 #include "mojo/public/c/system/main.h"
8 #include "mojo/public/cpp/application/application_delegate.h" 8 #include "mojo/public/cpp/application/application_impl_base.h"
9 #include "mojo/public/cpp/application/application_impl.h"
10 #include "mojo/public/cpp/application/application_runner.h"
11 #include "mojo/public/cpp/application/connect.h" 9 #include "mojo/public/cpp/application/connect.h"
10 #include "mojo/public/cpp/application/run_application.h"
12 #include "mojo/public/cpp/utility/run_loop.h" 11 #include "mojo/public/cpp/utility/run_loop.h"
13 #include "mojo/services/authentication/interfaces/authentication.mojom.h" 12 #include "mojo/services/authentication/interfaces/authentication.mojom.h"
14 13
15 namespace examples { 14 namespace examples {
16 namespace authentication { 15 namespace authentication {
17 16
18 class GoogleAuthApp : public mojo::ApplicationDelegate { 17 class GoogleAuthApp : public mojo::ApplicationImplBase {
19 public: 18 public:
20 GoogleAuthApp() {} 19 GoogleAuthApp() {}
21 20
22 ~GoogleAuthApp() override {} 21 ~GoogleAuthApp() override {}
23 22
24 void Initialize(mojo::ApplicationImpl* app) override { 23 void OnInitialize() override {
25 DLOG(INFO) << "Connecting to authentication service..."; 24 DLOG(INFO) << "Connecting to authentication service...";
26 mojo::ConnectToService(app->shell(), "mojo:authentication", 25 mojo::ConnectToService(shell(), "mojo:authentication",
27 GetProxy(&authentication_service_)); 26 GetProxy(&authentication_service_));
28 27
29 mojo::Array<mojo::String> scopes; 28 mojo::Array<mojo::String> scopes;
30 scopes.push_back("profile"); 29 scopes.push_back("profile");
31 scopes.push_back("email"); 30 scopes.push_back("email");
32 31
33 DLOG(INFO) << "Starting the device flow handshake..."; 32 DLOG(INFO) << "Starting the device flow handshake...";
34 authentication_service_->GetOAuth2DeviceCode( 33 authentication_service_->GetOAuth2DeviceCode(
35 scopes.Pass(), 34 scopes.Pass(),
36 base::Bind(&GoogleAuthApp::OnDeviceCode, base::Unretained(this))); 35 base::Bind(&GoogleAuthApp::OnDeviceCode, base::Unretained(this)));
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 return; 120 return;
122 } 121 }
123 122
124 ::authentication::AuthenticationServicePtr authentication_service_; 123 ::authentication::AuthenticationServicePtr authentication_service_;
125 }; 124 };
126 125
127 } // namespace authentication 126 } // namespace authentication
128 } // namespace examples 127 } // namespace examples
129 128
130 MojoResult MojoMain(MojoHandle application_request) { 129 MojoResult MojoMain(MojoHandle application_request) {
131 mojo::ApplicationRunner runner( 130 examples::authentication::GoogleAuthApp google_auth_app;
132 std::unique_ptr<examples::authentication::GoogleAuthApp>( 131 return mojo::RunMainApplication(application_request, &google_auth_app);
133 new examples::authentication::GoogleAuthApp()));
134 return runner.Run(application_request);
135 } 132 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698