| OLD | NEW |
| 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_connection.h" | 8 #include "mojo/public/cpp/application/application_connection.h" |
| 9 #include "mojo/public/cpp/application/application_delegate.h" | 9 #include "mojo/public/cpp/application/application_delegate.h" |
| 10 #include "mojo/public/cpp/application/application_impl.h" | 10 #include "mojo/public/cpp/application/application_impl.h" |
| 11 #include "mojo/public/cpp/application/application_runner.h" | 11 #include "mojo/public/cpp/application/application_runner.h" |
| 12 #include "mojo/public/cpp/utility/run_loop.h" | 12 #include "mojo/public/cpp/utility/run_loop.h" |
| 13 #include "mojo/services/authentication/interfaces/authentication.mojom.h" | 13 #include "mojo/services/authentication/interfaces/authentication.mojom.h" |
| 14 | 14 |
| 15 namespace examples { | 15 namespace examples { |
| 16 namespace authentication { | 16 namespace authentication { |
| 17 | 17 |
| 18 class GoogleAuthApp : public mojo::ApplicationDelegate { | 18 class GoogleAuthApp : public mojo::ApplicationDelegate { |
| 19 public: | 19 public: |
| 20 GoogleAuthApp() {} | 20 GoogleAuthApp() {} |
| 21 | 21 |
| 22 ~GoogleAuthApp() override {} | 22 ~GoogleAuthApp() override {} |
| 23 | 23 |
| 24 void Initialize(mojo::ApplicationImpl* app) override { | 24 void Initialize(mojo::ApplicationImpl* app) override { |
| 25 DLOG(INFO) << "Connecting to authentication service..."; | 25 DLOG(INFO) << "Connecting to authentication service..."; |
| 26 app->ConnectToService("mojo:authentication", &authentication_service_); | 26 app->ConnectToServiceDeprecated("mojo:authentication", |
| 27 &authentication_service_); |
| 27 | 28 |
| 28 mojo::Array<mojo::String> scopes; | 29 mojo::Array<mojo::String> scopes; |
| 29 scopes.push_back("profile"); | 30 scopes.push_back("profile"); |
| 30 scopes.push_back("email"); | 31 scopes.push_back("email"); |
| 31 | 32 |
| 32 DLOG(INFO) << "Starting the device flow handshake..."; | 33 DLOG(INFO) << "Starting the device flow handshake..."; |
| 33 authentication_service_->GetOAuth2DeviceCode( | 34 authentication_service_->GetOAuth2DeviceCode( |
| 34 scopes.Pass(), | 35 scopes.Pass(), |
| 35 base::Bind(&GoogleAuthApp::OnDeviceCode, base::Unretained(this))); | 36 base::Bind(&GoogleAuthApp::OnDeviceCode, base::Unretained(this))); |
| 36 } | 37 } |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 | 126 |
| 126 } // namespace authentication | 127 } // namespace authentication |
| 127 } // namespace examples | 128 } // namespace examples |
| 128 | 129 |
| 129 MojoResult MojoMain(MojoHandle application_request) { | 130 MojoResult MojoMain(MojoHandle application_request) { |
| 130 mojo::ApplicationRunner runner( | 131 mojo::ApplicationRunner runner( |
| 131 std::unique_ptr<examples::authentication::GoogleAuthApp>( | 132 std::unique_ptr<examples::authentication::GoogleAuthApp>( |
| 132 new examples::authentication::GoogleAuthApp())); | 133 new examples::authentication::GoogleAuthApp())); |
| 133 return runner.Run(application_request); | 134 return runner.Run(application_request); |
| 134 } | 135 } |
| OLD | NEW |