OLD | NEW |
---|---|
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 Loading... | |
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 bool 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 false; |
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 false; |
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 |
mmenke
2016/08/30 19:12:26
Think everything below this point may belong in a
Ramin Halavati
2016/09/01 10:41:44
Done.
The removed part is now moved to signin_hea
| |
151 return AppendMirrorRequestHeaderIfPossible( | 151 // If new url is eligible to have the header, return true, otherwise if |
152 request, redirect_url, io_data->google_services_account_id()->GetValue(), | 152 // redirecting to another site and x-chrome-header exists, and the redirected |
mmenke
2016/08/30 19:12:26
x-chrome-header -> x-chrome-connected header (Or x
Ramin Halavati
2016/09/01 10:41:44
Done.
| |
153 io_data->GetCookieSettings(), profile_mode_mask); | 153 // site is not illigible and current site was illigible, remove it. |
mmenke
2016/08/30 19:12:27
illigible -> eligible (x2)
Ramin Halavati
2016/09/01 10:41:44
Done.
| |
154 if (AppendMirrorRequestHeaderIfPossible( | |
155 request, redirect_url, | |
156 io_data->google_services_account_id()->GetValue(), | |
157 io_data->GetCookieSettings(), profile_mode_mask)) { | |
158 return true; | |
mmenke
2016/08/30 19:12:27
The return value isn't used, and it isn't clear wh
Ramin Halavati
2016/09/01 10:41:44
Done.
| |
159 } else { | |
mmenke
2016/08/30 19:12:27
Since you have the early return, this else isn't n
Ramin Halavati
2016/09/01 10:41:44
Done.
| |
160 if (!redirect_url.is_empty() && // redirecting | |
161 request->extra_request_headers().HasHeader( | |
162 signin::kChromeConnectedHeader) && // x-chrome-header exists | |
mmenke
2016/08/30 19:12:27
Rather than inline comments, suggest writing out d
Ramin Halavati
2016/09/01 10:41:44
Done.
| |
163 signin::IsUrlElligibleForXChromeConnectedHeader(request->url()) && | |
164 !signin::IsUrlElligibleForXChromeConnectedHeader(redirect_url)) | |
165 request->RemoveRequestHeaderByName(signin::kChromeConnectedHeader); | |
mmenke
2016/08/30 19:12:27
Use braces when an if condition takes multiple lin
Ramin Halavati
2016/09/01 10:41:44
Done.
| |
166 } | |
167 return false; | |
154 } | 168 } |
155 | 169 |
156 void ProcessMirrorResponseHeaderIfExists(net::URLRequest* request, | 170 void ProcessMirrorResponseHeaderIfExists(net::URLRequest* request, |
157 ProfileIOData* io_data, | 171 ProfileIOData* io_data, |
158 int child_id, | 172 int child_id, |
159 int route_id) { | 173 int route_id) { |
160 ManageAccountsParams params = | 174 ManageAccountsParams params = |
161 BuildManageAccountsParamsHelper(request, io_data); | 175 BuildManageAccountsParamsHelper(request, io_data); |
162 if (params.service_type == GAIA_SERVICE_TYPE_NONE) | 176 if (params.service_type == GAIA_SERVICE_TYPE_NONE) |
163 return; | 177 return; |
164 | 178 |
165 params.child_id = child_id; | 179 params.child_id = child_id; |
166 params.route_id = route_id; | 180 params.route_id = route_id; |
167 content::BrowserThread::PostTask( | 181 content::BrowserThread::PostTask( |
168 content::BrowserThread::UI, FROM_HERE, | 182 content::BrowserThread::UI, FROM_HERE, |
169 base::Bind(ProcessMirrorHeaderUIThread, child_id, route_id, params)); | 183 base::Bind(ProcessMirrorHeaderUIThread, child_id, route_id, params)); |
170 } | 184 } |
171 | 185 |
172 } // namespace signin | 186 } // namespace signin |
OLD | NEW |