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

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

Issue 2925083002: [signin] Move Mirror code to ChromeConnectedHeaderHelper (Closed)
Patch Set: 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
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 3fc64bb20a600dd5674294f801429cf10f4330ba..2e48bc6276f89c7e2292b2de2364c1a886053ca5 100644
--- a/chrome/browser/signin/chrome_signin_helper.cc
+++ b/chrome/browser/signin/chrome_signin_helper.cc
@@ -14,11 +14,14 @@
#include "chrome/browser/ui/browser_window.h"
#include "chrome/common/url_constants.h"
#include "components/signin/core/browser/account_reconcilor.h"
+#include "components/signin/core/browser/chrome_connected_header_helper.h"
#include "components/signin/core/browser/signin_header_helper.h"
+#include "components/signin/core/common/profile_management_switches.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/resource_request_info.h"
#include "content/public/browser/web_contents.h"
#include "google_apis/gaia/gaia_auth_util.h"
+#include "net/http/http_response_headers.h"
#include "net/url_request/url_request.h"
#if defined(OS_ANDROID)
@@ -33,6 +36,8 @@ namespace signin {
namespace {
+const char kChromeManageAccountsHeader[] = "X-Chrome-Manage-Accounts";
+
// Processes the mirror response header on the UI thread. Currently depending
// on the value of |header_value|, it either shows the profile avatar menu, or
// opens an incognito window/tab.
@@ -41,6 +46,11 @@ void ProcessMirrorHeaderUIThread(int child_id,
ManageAccountsParams manage_accounts_params) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
+ if (switches::GetAccountConsistencyMethod() !=
+ switches::AccountConsistencyMethod::kMirror) {
droger 2017/06/09 12:06:55 Note: this was a DCHECK but I think a if is more c
msarda 2017/06/12 12:21:14 I'm afraid I do not understand this comment - I do
+ return;
+ }
+
GAIAServiceType service_type = manage_accounts_params.service_type;
DCHECK_NE(GAIA_SERVICE_TYPE_NONE, service_type);
@@ -95,26 +105,6 @@ void ProcessMirrorHeaderUIThread(int child_id,
#endif // !defined(OS_ANDROID)
}
-// Returns the parameters contained in the X-Chrome-Manage-Accounts response
-// header.
-// If the request does not have a response header or if the header contains
-// garbage, then |service_type| is set to |GAIA_SERVICE_TYPE_NONE|.
-// Must be called on IO thread.
-ManageAccountsParams BuildManageAccountsParamsHelper(net::URLRequest* request,
- ProfileIOData* io_data) {
- DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
-
- const content::ResourceRequestInfo* info =
- content::ResourceRequestInfo::ForRequest(request);
- if (!(info && info->GetResourceType() == content::RESOURCE_TYPE_MAIN_FRAME)) {
- ManageAccountsParams empty_params;
- empty_params.service_type = GAIA_SERVICE_TYPE_NONE;
- return empty_params;
- }
-
- return BuildManageAccountsParamsIfExists(request, io_data->IsOffTheRecord());
-}
-
} // namespace
void FixAccountConsistencyRequestHeader(net::URLRequest* request,
@@ -157,8 +147,33 @@ void ProcessMirrorResponseHeaderIfExists(net::URLRequest* request,
ProfileIOData* io_data,
int child_id,
int route_id) {
+ DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
+
+ if (io_data->IsOffTheRecord())
droger 2017/06/09 12:06:55 Note: this was a DCHECK but I think a if is more c
msarda 2017/06/12 12:21:14 Same here - what DCHECK are you referring to?
+ return;
+
+ const content::ResourceRequestInfo* info =
+ content::ResourceRequestInfo::ForRequest(request);
+ if (!(info && info->GetResourceType() == content::RESOURCE_TYPE_MAIN_FRAME))
+ return;
+
+ if (!gaia::IsGaiaSignonRealm(request->url().GetOrigin()))
+ return;
+
+ net::HttpResponseHeaders* response_headers = request->response_headers();
+ if (!response_headers)
+ return;
+
+ std::string header_value;
+ if (!response_headers->GetNormalizedHeader(kChromeManageAccountsHeader,
+ &header_value)) {
+ return;
+ }
+
ManageAccountsParams params =
- BuildManageAccountsParamsHelper(request, io_data);
+ ChromeConnectedHeaderHelper::BuildManageAccountsParams(header_value);
+ // If the request does not have a response header or if the header contains
+ // garbage, then |service_type| is set to |GAIA_SERVICE_TYPE_NONE|.
if (params.service_type == GAIA_SERVICE_TYPE_NONE)
return;

Powered by Google App Engine
This is Rietveld 408576698