| 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/signin_header_helper.h" | 5 #include "chrome/browser/signin/signin_header_helper.h" |
| 6 | 6 |
| 7 #include "base/strings/string_number_conversions.h" | 7 #include "base/strings/string_number_conversions.h" |
| 8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
| 9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
| 10 #include "chrome/browser/prefs/incognito_mode_prefs.h" | 10 #include "chrome/browser/prefs/incognito_mode_prefs.h" |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 route_id(0) {} | 195 route_id(0) {} |
| 196 | 196 |
| 197 bool AppendMirrorRequestHeaderIfPossible( | 197 bool AppendMirrorRequestHeaderIfPossible( |
| 198 net::URLRequest* request, | 198 net::URLRequest* request, |
| 199 const GURL& redirect_url, | 199 const GURL& redirect_url, |
| 200 ProfileIOData* io_data, | 200 ProfileIOData* io_data, |
| 201 int child_id, | 201 int child_id, |
| 202 int route_id) { | 202 int route_id) { |
| 203 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); | 203 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); |
| 204 | 204 |
| 205 if (io_data->IsOffTheRecord() || | 205 if (io_data->IsOffTheRecord()) |
| 206 io_data->google_services_username()->GetValue().empty()) { | |
| 207 return false; | 206 return false; |
| 208 } | 207 |
| 208 std::string account_id(io_data->google_services_account_id()->GetValue()); |
| 209 |
| 210 if (account_id.empty()) |
| 211 return false; |
| 209 | 212 |
| 210 // If signin cookies are not allowed, don't add the header. | 213 // If signin cookies are not allowed, don't add the header. |
| 211 if (!ChromeSigninClient::SettingsAllowSigninCookies( | 214 if (!ChromeSigninClient::SettingsAllowSigninCookies( |
| 212 io_data->GetCookieSettings())) { | 215 io_data->GetCookieSettings())) { |
| 213 return false; | 216 return false; |
| 214 } | 217 } |
| 215 | 218 |
| 216 // Only set the header for Drive and Gaia always, and other Google properties | 219 // Only set the header for Drive and Gaia always, and other Google properties |
| 217 // if account consistency is enabled. | 220 // if account consistency is enabled. |
| 218 // Vasquette, which is integrated with most Google properties, needs the | 221 // Vasquette, which is integrated with most Google properties, needs the |
| (...skipping 25 matching lines...) Expand all Loading... |
| 244 child_id, route_id, &webview_info); | 247 child_id, route_id, &webview_info); |
| 245 // Do not set the x-chrome-connected header on requests from a native signin | 248 // Do not set the x-chrome-connected header on requests from a native signin |
| 246 // webview, as identified by an empty extension id which means the webview is | 249 // webview, as identified by an empty extension id which means the webview is |
| 247 // embedded in a webui page, otherwise user may end up with a blank page as | 250 // embedded in a webui page, otherwise user may end up with a blank page as |
| 248 // gaia uses the header to decide whether it returns 204 for certain end | 251 // gaia uses the header to decide whether it returns 204 for certain end |
| 249 // points. | 252 // points. |
| 250 if (is_guest && webview_info.owner_extension_id.empty()) | 253 if (is_guest && webview_info.owner_extension_id.empty()) |
| 251 return false; | 254 return false; |
| 252 #endif // !OS_ANDROID && !OS_IOS | 255 #endif // !OS_ANDROID && !OS_IOS |
| 253 | 256 |
| 254 std::string account_id(io_data->google_services_account_id()->GetValue()); | |
| 255 | |
| 256 int profile_mode_mask = PROFILE_MODE_DEFAULT; | 257 int profile_mode_mask = PROFILE_MODE_DEFAULT; |
| 257 if (io_data->incognito_availibility()->GetValue() == | 258 if (io_data->incognito_availibility()->GetValue() == |
| 258 IncognitoModePrefs::DISABLED || | 259 IncognitoModePrefs::DISABLED || |
| 259 IncognitoModePrefs::ArePlatformParentalControlsEnabled()) { | 260 IncognitoModePrefs::ArePlatformParentalControlsEnabled()) { |
| 260 profile_mode_mask |= PROFILE_MODE_INCOGNITO_DISABLED; | 261 profile_mode_mask |= PROFILE_MODE_INCOGNITO_DISABLED; |
| 261 } | 262 } |
| 262 | 263 |
| 263 std::string header_value(base::StringPrintf("%s=%s,%s=%s,%s=%s", | 264 std::string header_value(base::StringPrintf("%s=%s,%s=%s,%s=%s", |
| 264 kGaiaIdAttrName, account_id.c_str(), | 265 kGaiaIdAttrName, account_id.c_str(), |
| 265 kProfileModeAttrName, base::IntToString(profile_mode_mask).c_str(), | 266 kProfileModeAttrName, base::IntToString(profile_mode_mask).c_str(), |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 300 | 301 |
| 301 params.child_id = child_id; | 302 params.child_id = child_id; |
| 302 params.route_id = route_id; | 303 params.route_id = route_id; |
| 303 content::BrowserThread::PostTask( | 304 content::BrowserThread::PostTask( |
| 304 content::BrowserThread::UI, FROM_HERE, | 305 content::BrowserThread::UI, FROM_HERE, |
| 305 base::Bind(ProcessMirrorHeaderUIThread, child_id, route_id, params)); | 306 base::Bind(ProcessMirrorHeaderUIThread, child_id, route_id, params)); |
| 306 #endif // defined(OS_IOS) | 307 #endif // defined(OS_IOS) |
| 307 } | 308 } |
| 308 | 309 |
| 309 } // namespace signin | 310 } // namespace signin |
| OLD | NEW |