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

Unified Diff: chrome/browser/chromeos/arc/arc_auth_fetcher.h

Issue 1618193003: arc: Pass auth token from Chrome to ARC instance. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Refactored. Added LSO UI Created 4 years, 11 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: chrome/browser/chromeos/arc/arc_auth_fetcher.h
diff --git a/chrome/browser/chromeos/arc/arc_auth_fetcher.h b/chrome/browser/chromeos/arc/arc_auth_fetcher.h
new file mode 100644
index 0000000000000000000000000000000000000000..0e2db3e8682f89b1a8131517034c0844bdc7f269
--- /dev/null
+++ b/chrome/browser/chromeos/arc/arc_auth_fetcher.h
@@ -0,0 +1,62 @@
+// 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.
+
+#ifndef CHROME_BROWSER_CHROMEOS_ARC_ARC_AUTH_FETCHER_H_
+#define CHROME_BROWSER_CHROMEOS_ARC_ARC_AUTH_FETCHER_H_
+
+#include <string>
+
+#include "base/macros.h"
+#include "base/memory/scoped_ptr.h"
+#include "net/url_request/url_fetcher_delegate.h"
+
+class GURL;
+class Profile;
+
+namespace net {
+class URLFetcher;
+} // namespace net
+
+namespace arc {
+
+// Fetches ARC auth code. Fetching process starts automatically on creation.
+class ArcAuthFetcher : public net::URLFetcherDelegate {
xiyuan 2016/01/26 23:37:05 Is it possible to extend GaiaAuthFetcher to suppor
khmel 2016/01/27 22:36:21 Honestly speaking I was thinking about this possib
+ public:
+ // Returns a result of ARC auth code fetching.
+ class Delegate {
+ public:
+ // Called when code was fetched.
+ virtual void OnAuthCodeFetched(const std::string& code) = 0;
+ // Called when additional UI authorization is required.
+ virtual void OnAuthCodeNeedUI() = 0;
+ // Called when auth code cannot be received.
+ virtual void OnAuthCodeFailed() = 0;
+ };
+
+ ArcAuthFetcher(Profile* profile, Delegate* delegate);
+ ~ArcAuthFetcher() override;
+
+ // net::URLFetcherDelegate overrides.
+ void OnURLFetchComplete(const net::URLFetcher* source) override;
+
+ // Helper function to compose target URL, also is used in test.
+ static GURL CreateURL(Profile* profile);
+
+ private:
+ void FetchAuthCode();
+ // Finds auth code in cookies.
+ static bool ParseAuthCode(const net::URLFetcher* source, std::string* code);
+
+ // Unowned pointers.
+ Profile* profile_;
+ Delegate* delegate_;
+
+ scoped_ptr<net::URLFetcher> auth_fetcher_;
+
+ DISALLOW_COPY_AND_ASSIGN(ArcAuthFetcher);
+};
+
+} // namespace arc
+
+#endif // CHROME_BROWSER_CHROMEOS_ARC_ARC_AUTH_FETCHER_H_
« no previous file with comments | « no previous file | chrome/browser/chromeos/arc/arc_auth_fetcher.cc » ('j') | chrome/browser/chromeos/arc/arc_auth_fetcher.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698