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

Side by Side Diff: services/authentication/main.cc

Issue 1466733002: Google OAuth Device Flow support for FNL (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Removed data_unittest.py Created 4 years, 9 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 2016 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 "mojo/application/application_runner_chromium.h"
6 #include "mojo/common/binding_set.h"
7 #include "mojo/public/c/system/main.h"
8 #include "mojo/public/cpp/application/application_connection.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/interface_factory.h"
12 #include "mojo/public/cpp/bindings/strong_binding.h"
13 #include "mojo/public/cpp/system/macros.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"
17
18 namespace authentication {
19
20 class GoogleAccountManagerApp
21 : public mojo::ApplicationDelegate,
22 public mojo::InterfaceFactory<AuthenticationService> {
23 public:
24 GoogleAccountManagerApp() {}
25 ~GoogleAccountManagerApp() override {}
26
27 void Initialize(mojo::ApplicationImpl* app) override {
28 app->ConnectToService("mojo:network_service", &network_service_);
29 app->ConnectToService("mojo:files", &files_);
30
31 app_url_ = app->url();
32 }
33
34 bool ConfigureIncomingConnection(
35 mojo::ApplicationConnection* connection) override {
36 connection->AddService<AuthenticationService>(this);
37 return true;
38 }
39
40 void Create(mojo::ApplicationConnection* connection,
41 mojo::InterfaceRequest<AuthenticationService> request) override {
42 mojo::files::Error error = mojo::files::Error::INTERNAL;
43 mojo::files::DirectoryPtr directory;
44 files_->OpenFileSystem("app_persistent_cache", GetProxy(&directory),
45 [&error](mojo::files::Error e) { error = e; });
46 CHECK(files_.WaitForIncomingResponse());
47 if (mojo::files::Error::OK != error) {
48 LOG(FATAL) << "Unable to initialize accounts DB";
49 }
50 new authentication::GoogleAuthenticationServiceImpl(
51 request.Pass(), app_url_, network_service_, directory);
52 }
53
54 private:
55 mojo::NetworkServicePtr network_service_;
56 mojo::files::FilesPtr files_;
57 std::string app_url_;
58
59 DISALLOW_COPY_AND_ASSIGN(GoogleAccountManagerApp);
60 };
61
62 } // namespace authentication
63
64 MojoResult MojoMain(MojoHandle application_request) {
65 mojo::ApplicationRunnerChromium runner(
66 new authentication::GoogleAccountManagerApp());
67 return runner.Run(application_request);
68 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698