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

Unified Diff: chrome/browser/signin/chrome_signin_helper.cc

Issue 2942193002: [signin] Generate OAuth token on Dice Signin responses (Closed)
Patch Set: Review comments Created 3 years, 6 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
« no previous file with comments | « chrome/browser/BUILD.gn ('k') | chrome/browser/signin/dice_response_handler.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/signin/chrome_signin_helper.cc
diff --git a/chrome/browser/signin/chrome_signin_helper.cc b/chrome/browser/signin/chrome_signin_helper.cc
index a0b599cb28aa166529a06e5ae147e18faf419f18..c7639a5191f9d1546a5121321ed057c5706e76fb 100644
--- a/chrome/browser/signin/chrome_signin_helper.cc
+++ b/chrome/browser/signin/chrome_signin_helper.cc
@@ -11,6 +11,8 @@
#include "chrome/browser/profiles/profile_io_data.h"
#include "chrome/browser/signin/account_reconcilor_factory.h"
#include "chrome/browser/signin/chrome_signin_client.h"
+#include "chrome/browser/signin/chrome_signin_client_factory.h"
+#include "chrome/browser/signin/dice_response_handler.h"
#include "chrome/browser/tab_contents/tab_util.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/common/url_constants.h"
@@ -105,6 +107,29 @@ void ProcessMirrorHeaderUIThread(
#endif // !defined(OS_ANDROID)
}
+#if !defined(OS_ANDROID)
+void ProcessDiceHeaderUIThread(
+ const DiceResponseParams& dice_params,
+ const content::ResourceRequestInfo::WebContentsGetter&
+ web_contents_getter) {
+ DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
+ DCHECK_EQ(switches::AccountConsistencyMethod::kDice,
+ switches::GetAccountConsistencyMethod());
+
+ content::WebContents* web_contents = web_contents_getter.Run();
+ if (!web_contents)
+ return;
+
+ Profile* profile =
+ Profile::FromBrowserContext(web_contents->GetBrowserContext());
+ DCHECK(!profile->IsOffTheRecord());
+
+ DiceResponseHandler* dice_response_handler =
+ DiceResponseHandler::GetForProfile(profile);
+ dice_response_handler->ProcessDiceHeader(dice_params);
+}
+#endif // !defined(OS_ANDROID)
+
// Looks for the X-Chrome-Manage-Accounts response header, and if found,
// tries to show the avatar bubble in the browser identified by the
// child/route id. Must be called on IO thread.
@@ -158,8 +183,11 @@ void ProcessMirrorResponseHeaderIfExists(
}
#if !defined(OS_ANDROID)
-void ProcessDiceResponseHeaderIfExists(net::URLRequest* request,
- ProfileIOData* io_data) {
+void ProcessDiceResponseHeaderIfExists(
+ net::URLRequest* request,
+ ProfileIOData* io_data,
+ const content::ResourceRequestInfo::WebContentsGetter&
+ web_contents_getter) {
DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
if (io_data->IsOffTheRecord())
@@ -194,9 +222,9 @@ void ProcessDiceResponseHeaderIfExists(net::URLRequest* request,
if (params.user_intention == DiceAction::NONE)
return;
- // TODO(droger): Process the Dice header: on sign-in, exchange the
- // authorization code for a refresh token, on sign-out just follow the
- // sign-out URL.
+ content::BrowserThread::PostTask(
+ content::BrowserThread::UI, FROM_HERE,
+ base::Bind(ProcessDiceHeaderUIThread, params, web_contents_getter));
}
#endif // !defined(OS_ANDROID)
@@ -252,15 +280,14 @@ void ProcessAccountConsistencyResponseHeaders(
// See if the response contains the X-Chrome-Manage-Accounts header. If so
// show the profile avatar bubble so that user can complete signin/out
// action the native UI.
- signin::ProcessMirrorResponseHeaderIfExists(request, io_data,
- web_contents_getter);
+ ProcessMirrorResponseHeaderIfExists(request, io_data, web_contents_getter);
} else {
-// This is a redirect.
+ // This is a redirect.
#if !defined(OS_ANDROID)
// Process the Dice header: on sign-in, exchange the authorization code for
// a refresh token, on sign-out just follow the sign-out URL.
- signin::ProcessDiceResponseHeaderIfExists(request, io_data);
+ ProcessDiceResponseHeaderIfExists(request, io_data, web_contents_getter);
#endif
}
}
« no previous file with comments | « chrome/browser/BUILD.gn ('k') | chrome/browser/signin/dice_response_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698