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

Side by Side Diff: chrome/browser/signin/chrome_signin_helper.cc

Issue 2258483002: X-Chrome-Connected is stripped when it should not be in headers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed comments Created 4 years, 3 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/signin/chrome_signin_helper.h" 5 #include "chrome/browser/signin/chrome_signin_helper.h"
6 6
7 #include "base/strings/string_util.h" 7 #include "base/strings/string_util.h"
8 #include "build/build_config.h" 8 #include "build/build_config.h"
9 #include "chrome/browser/prefs/incognito_mode_prefs.h" 9 #include "chrome/browser/prefs/incognito_mode_prefs.h"
10 #include "chrome/browser/profiles/profile_io_data.h" 10 #include "chrome/browser/profiles/profile_io_data.h"
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 ManageAccountsParams empty_params; 111 ManageAccountsParams empty_params;
112 empty_params.service_type = GAIA_SERVICE_TYPE_NONE; 112 empty_params.service_type = GAIA_SERVICE_TYPE_NONE;
113 return empty_params; 113 return empty_params;
114 } 114 }
115 115
116 return BuildManageAccountsParamsIfExists(request, io_data->IsOffTheRecord()); 116 return BuildManageAccountsParamsIfExists(request, io_data->IsOffTheRecord());
117 } 117 }
118 118
119 } // namespace 119 } // namespace
120 120
121 bool AppendMirrorRequestHeaderHelper(net::URLRequest* request, 121 void FixMirrorRequestHeaderHelper(net::URLRequest* request,
122 const GURL& redirect_url, 122 const GURL& redirect_url,
123 ProfileIOData* io_data, 123 ProfileIOData* io_data,
124 int child_id, 124 int child_id,
125 int route_id) { 125 int route_id) {
126 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); 126 DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
127 127
128 if (io_data->IsOffTheRecord()) 128 if (io_data->IsOffTheRecord())
129 return false; 129 return;
130 130
131 #if !defined(OS_ANDROID) 131 #if !defined(OS_ANDROID)
132 extensions::WebViewRendererState::WebViewInfo webview_info; 132 extensions::WebViewRendererState::WebViewInfo webview_info;
133 bool is_guest = extensions::WebViewRendererState::GetInstance()->GetInfo( 133 bool is_guest = extensions::WebViewRendererState::GetInstance()->GetInfo(
134 child_id, route_id, &webview_info); 134 child_id, route_id, &webview_info);
135 // Do not set the x-chrome-connected header on requests from a native signin 135 // Do not set the x-chrome-connected header on requests from a native signin
136 // webview, as identified by an empty extension id which means the webview is 136 // webview, as identified by an empty extension id which means the webview is
137 // embedded in a webui page, otherwise user may end up with a blank page as 137 // embedded in a webui page, otherwise user may end up with a blank page as
138 // gaia uses the header to decide whether it returns 204 for certain end 138 // gaia uses the header to decide whether it returns 204 for certain end
139 // points. 139 // points.
140 if (is_guest && webview_info.owner_host.empty()) 140 if (is_guest && webview_info.owner_host.empty())
141 return false; 141 return;
142 #endif // !defined(OS_ANDROID) 142 #endif // !defined(OS_ANDROID)
143 143
144 int profile_mode_mask = PROFILE_MODE_DEFAULT; 144 int profile_mode_mask = PROFILE_MODE_DEFAULT;
145 if (io_data->incognito_availibility()->GetValue() == 145 if (io_data->incognito_availibility()->GetValue() ==
146 IncognitoModePrefs::DISABLED || 146 IncognitoModePrefs::DISABLED ||
147 IncognitoModePrefs::ArePlatformParentalControlsEnabled()) { 147 IncognitoModePrefs::ArePlatformParentalControlsEnabled()) {
148 profile_mode_mask |= PROFILE_MODE_INCOGNITO_DISABLED; 148 profile_mode_mask |= PROFILE_MODE_INCOGNITO_DISABLED;
149 } 149 }
150 150
151 return AppendMirrorRequestHeaderIfPossible( 151 // If new url is eligible to have the header, add it, otherwise remove it.
152 AppendOrRemoveMirrorRequestHeaderIfPossible(
152 request, redirect_url, io_data->google_services_account_id()->GetValue(), 153 request, redirect_url, io_data->google_services_account_id()->GetValue(),
153 io_data->GetCookieSettings(), profile_mode_mask); 154 io_data->GetCookieSettings(), profile_mode_mask);
154 } 155 }
155 156
156 void ProcessMirrorResponseHeaderIfExists(net::URLRequest* request, 157 void ProcessMirrorResponseHeaderIfExists(net::URLRequest* request,
157 ProfileIOData* io_data, 158 ProfileIOData* io_data,
158 int child_id, 159 int child_id,
159 int route_id) { 160 int route_id) {
160 ManageAccountsParams params = 161 ManageAccountsParams params =
161 BuildManageAccountsParamsHelper(request, io_data); 162 BuildManageAccountsParamsHelper(request, io_data);
162 if (params.service_type == GAIA_SERVICE_TYPE_NONE) 163 if (params.service_type == GAIA_SERVICE_TYPE_NONE)
163 return; 164 return;
164 165
165 params.child_id = child_id; 166 params.child_id = child_id;
166 params.route_id = route_id; 167 params.route_id = route_id;
167 content::BrowserThread::PostTask( 168 content::BrowserThread::PostTask(
168 content::BrowserThread::UI, FROM_HERE, 169 content::BrowserThread::UI, FROM_HERE,
169 base::Bind(ProcessMirrorHeaderUIThread, child_id, route_id, params)); 170 base::Bind(ProcessMirrorHeaderUIThread, child_id, route_id, params));
170 } 171 }
171 172
172 } // namespace signin 173 } // namespace signin
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698