summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbzanotti <bzanotti@chromium.org>2015-06-01 11:10:36 -0700
committerCommit bot <commit-bot@chromium.org>2015-06-01 18:12:16 +0000
commit4aafe7e05b5684fc990f9202b0e6ced03edac87d (patch)
treeaf0eee90d2b6e924a3d2febdc1e123f93eb2ad2a
parente0a63cd567c39f93c18d37467cb4d65abb8f51fb (diff)
downloadchromium_src-4aafe7e05b5684fc990f9202b0e6ced03edac87d.zip
chromium_src-4aafe7e05b5684fc990f9202b0e6ced03edac87d.tar.gz
chromium_src-4aafe7e05b5684fc990f9202b0e6ced03edac87d.tar.bz2
Refactor ManageAccountsParams construction.
This CL extracts the validation done before creating a ManageAccountsParams into a new GetManageAccountsParams function. This allows the logic to be used on platform now using the ProcessMirrorResponseHeaderIfExists function. BUG= Review URL: https://codereview.chromium.org/1152083005 Cr-Commit-Position: refs/heads/master@{#332216}
-rw-r--r--chrome/browser/signin/signin_header_helper.cc34
-rw-r--r--chrome/browser/signin/signin_header_helper.h8
2 files changed, 30 insertions, 12 deletions
diff --git a/chrome/browser/signin/signin_header_helper.cc b/chrome/browser/signin/signin_header_helper.cc
index 187a6c3..99241bb 100644
--- a/chrome/browser/signin/signin_header_helper.cc
+++ b/chrome/browser/signin/signin_header_helper.cc
@@ -271,31 +271,41 @@ bool AppendMirrorRequestHeaderIfPossible(
return true;
}
-void ProcessMirrorResponseHeaderIfExists(
- net::URLRequest* request,
- ProfileIOData* io_data,
- int child_id,
- int route_id) {
-#if defined(OS_IOS)
- NOTREACHED();
-#else
+ManageAccountsParams BuildManageAccountsParamsIfValid(net::URLRequest* request,
+ ProfileIOData* io_data) {
DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
+
+ ManageAccountsParams empty_params;
+ empty_params.service_type = GAIA_SERVICE_TYPE_NONE;
if (!gaia::IsGaiaSignonRealm(request->url().GetOrigin()))
- return;
+ return empty_params;
+#if !defined(OS_IOS)
const content::ResourceRequestInfo* info =
content::ResourceRequestInfo::ForRequest(request);
if (!(info && info->GetResourceType() == content::RESOURCE_TYPE_MAIN_FRAME))
- return;
+ return empty_params;
+#endif
std::string header_value;
if (!request->response_headers()->GetNormalizedHeader(
kChromeManageAccountsHeader, &header_value)) {
- return;
+ return empty_params;
}
DCHECK(switches::IsEnableAccountConsistency() && !io_data->IsOffTheRecord());
- ManageAccountsParams params(BuildManageAccountsParams(header_value));
+ return BuildManageAccountsParams(header_value);
+}
+
+void ProcessMirrorResponseHeaderIfExists(net::URLRequest* request,
+ ProfileIOData* io_data,
+ int child_id,
+ int route_id) {
+#if defined(OS_IOS)
+ NOTREACHED();
+#else
+ ManageAccountsParams params =
+ BuildManageAccountsParamsIfValid(request, io_data);
if (params.service_type == GAIA_SERVICE_TYPE_NONE)
return;
diff --git a/chrome/browser/signin/signin_header_helper.h b/chrome/browser/signin/signin_header_helper.h
index 8ca99b3..b89913c 100644
--- a/chrome/browser/signin/signin_header_helper.h
+++ b/chrome/browser/signin/signin_header_helper.h
@@ -74,6 +74,14 @@ bool AppendMirrorRequestHeaderIfPossible(
int child_id,
int route_id);
+// 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 BuildManageAccountsParamsIfValid(net::URLRequest* request,
+ ProfileIOData* io_data);
+
// 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.