| 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> | |
| 6 | |
| 7 #include "mojo/common/binding_set.h" | 5 #include "mojo/common/binding_set.h" |
| 8 #include "mojo/public/c/system/main.h" | 6 #include "mojo/public/c/system/main.h" |
| 9 #include "mojo/public/cpp/application/application_connection.h" | 7 #include "mojo/public/cpp/application/application_connection.h" |
| 10 #include "mojo/public/cpp/application/application_delegate.h" | 8 #include "mojo/public/cpp/application/application_delegate.h" |
| 9 #include "mojo/public/cpp/application/application_impl.h" |
| 11 #include "mojo/public/cpp/application/application_runner.h" | 10 #include "mojo/public/cpp/application/application_runner.h" |
| 12 #include "mojo/public/cpp/application/interface_factory.h" | 11 #include "mojo/public/cpp/application/interface_factory.h" |
| 12 #include "mojo/public/cpp/bindings/strong_binding.h" |
| 13 #include "mojo/public/cpp/system/macros.h" | 13 #include "mojo/public/cpp/system/macros.h" |
| 14 #include "mojo/services/authentication/interfaces/authentication.mojom.h" | 14 #include "mojo/services/authentication/interfaces/authentication.mojom.h" |
| 15 #include "mojo/services/network/interfaces/network_service.mojom.h" |
| 16 #include "services/authentication/google_authentication_impl.h" |
| 15 | 17 |
| 16 namespace authentication { | 18 namespace authentication { |
| 17 namespace { | |
| 18 | 19 |
| 19 class DummyAuthenticationApplication | 20 class GoogleAccountManagerApp |
| 20 : public mojo::ApplicationDelegate, | 21 : public mojo::ApplicationDelegate, |
| 21 public mojo::InterfaceFactory<AuthenticationService>, | 22 public mojo::InterfaceFactory<AuthenticationService> { |
| 22 public AuthenticationService { | |
| 23 public: | 23 public: |
| 24 DummyAuthenticationApplication() {} | 24 GoogleAccountManagerApp() {} |
| 25 ~DummyAuthenticationApplication() override {} | 25 ~GoogleAccountManagerApp() override {} |
| 26 | 26 |
| 27 private: | 27 void Initialize(mojo::ApplicationImpl* app) override { |
| 28 // ApplicationDelegate implementation. | 28 app->ConnectToService("mojo:network_service", &network_service_); |
| 29 void Initialize(mojo::ApplicationImpl* app) override{}; | 29 app->ConnectToService("mojo:files", &files_); |
| 30 } |
| 31 |
| 30 bool ConfigureIncomingConnection( | 32 bool ConfigureIncomingConnection( |
| 31 mojo::ApplicationConnection* connection) override { | 33 mojo::ApplicationConnection* connection) override { |
| 32 connection->AddService<AuthenticationService>(this); | 34 connection->AddService<AuthenticationService>(this); |
| 33 return true; | 35 return true; |
| 34 } | 36 } |
| 35 | 37 |
| 36 // InterfaceFactory<AuthenticationService> implementation. | |
| 37 void Create(mojo::ApplicationConnection* connection, | 38 void Create(mojo::ApplicationConnection* connection, |
| 38 mojo::InterfaceRequest<AuthenticationService> request) override { | 39 mojo::InterfaceRequest<AuthenticationService> request) override { |
| 39 bindings_.AddBinding(this, request.Pass()); | 40 new authentication::GoogleAuthenticationServiceImpl( |
| 41 request.Pass(), network_service_, files_); |
| 40 } | 42 } |
| 41 | 43 |
| 42 // AuthenticationService implementation | 44 private: |
| 43 void SelectAccount(bool return_last_selected, | 45 mojo::NetworkServicePtr network_service_; |
| 44 const SelectAccountCallback& callback) override { | 46 mojo::files::FilesPtr files_; |
| 45 callback.Run(nullptr, "Not implemented"); | |
| 46 } | |
| 47 void GetOAuth2Token(const mojo::String& username, | |
| 48 mojo::Array<mojo::String> scopes, | |
| 49 const GetOAuth2TokenCallback& callback) override { | |
| 50 callback.Run(nullptr, "Not implemented"); | |
| 51 } | |
| 52 void ClearOAuth2Token(const mojo::String& token) override {} | |
| 53 | 47 |
| 54 mojo::BindingSet<AuthenticationService> bindings_; | 48 DISALLOW_COPY_AND_ASSIGN(GoogleAccountManagerApp); |
| 55 }; | 49 }; |
| 56 | 50 |
| 57 } // namespace | |
| 58 } // namespace authentication | 51 } // namespace authentication |
| 59 | 52 |
| 60 MojoResult MojoMain(MojoHandle application_request) { | 53 MojoResult MojoMain(MojoHandle application_request) { |
| 61 mojo::ApplicationRunner runner( | 54 mojo::ApplicationRunner runner( |
| 62 std::unique_ptr<authentication::DummyAuthenticationApplication>( | 55 std::unique_ptr<authentication::GoogleAccountManagerApp>( |
| 63 new authentication::DummyAuthenticationApplication())); | 56 new authentication::GoogleAccountManagerApp())); |
| 64 return runner.Run(application_request); | 57 return runner.Run(application_request); |
| 65 } | 58 } |
| OLD | NEW |