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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: services/authentication/main.cc
diff --git a/services/authentication/main.cc b/services/authentication/main.cc
new file mode 100644
index 0000000000000000000000000000000000000000..a40d9658729e4962e6ca806293efcb5f561b115b
--- /dev/null
+++ b/services/authentication/main.cc
@@ -0,0 +1,68 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "mojo/application/application_runner_chromium.h"
+#include "mojo/common/binding_set.h"
+#include "mojo/public/c/system/main.h"
+#include "mojo/public/cpp/application/application_connection.h"
+#include "mojo/public/cpp/application/application_delegate.h"
+#include "mojo/public/cpp/application/application_impl.h"
+#include "mojo/public/cpp/application/interface_factory.h"
+#include "mojo/public/cpp/bindings/strong_binding.h"
+#include "mojo/public/cpp/system/macros.h"
+#include "mojo/services/authentication/interfaces/authentication.mojom.h"
+#include "mojo/services/network/interfaces/network_service.mojom.h"
+#include "services/authentication/google_authentication_impl.h"
+
+namespace authentication {
+
+class GoogleAccountManagerApp
+ : public mojo::ApplicationDelegate,
+ public mojo::InterfaceFactory<AuthenticationService> {
+ public:
+ GoogleAccountManagerApp() {}
+ ~GoogleAccountManagerApp() override {}
+
+ void Initialize(mojo::ApplicationImpl* app) override {
+ app->ConnectToService("mojo:network_service", &network_service_);
+ app->ConnectToService("mojo:files", &files_);
+
+ app_url_ = app->url();
+ }
+
+ bool ConfigureIncomingConnection(
+ mojo::ApplicationConnection* connection) override {
+ connection->AddService<AuthenticationService>(this);
+ return true;
+ }
+
+ void Create(mojo::ApplicationConnection* connection,
+ mojo::InterfaceRequest<AuthenticationService> request) override {
+ mojo::files::Error error = mojo::files::Error::INTERNAL;
+ mojo::files::DirectoryPtr directory;
+ files_->OpenFileSystem("app_persistent_cache", GetProxy(&directory),
+ [&error](mojo::files::Error e) { error = e; });
+ CHECK(files_.WaitForIncomingResponse());
+ if (mojo::files::Error::OK != error) {
+ LOG(FATAL) << "Unable to initialize accounts DB";
+ }
+ new authentication::GoogleAuthenticationServiceImpl(
+ request.Pass(), app_url_, network_service_, directory);
+ }
+
+ private:
+ mojo::NetworkServicePtr network_service_;
+ mojo::files::FilesPtr files_;
+ std::string app_url_;
+
+ DISALLOW_COPY_AND_ASSIGN(GoogleAccountManagerApp);
+};
+
+} // namespace authentication
+
+MojoResult MojoMain(MojoHandle application_request) {
+ mojo::ApplicationRunnerChromium runner(
+ new authentication::GoogleAccountManagerApp());
+ return runner.Run(application_request);
+}

Powered by Google App Engine
This is Rietveld 408576698