Chromium Code Reviews| 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" | |
| 9 #include "chrome/browser/prefs/incognito_mode_prefs.h" | 8 #include "chrome/browser/prefs/incognito_mode_prefs.h" |
| 10 #include "chrome/browser/profiles/profile_io_data.h" | 9 #include "chrome/browser/profiles/profile_io_data.h" |
| 11 #include "chrome/browser/signin/account_reconcilor_factory.h" | 10 #include "chrome/browser/signin/account_reconcilor_factory.h" |
| 12 #include "chrome/browser/signin/chrome_signin_client.h" | 11 #include "chrome/browser/signin/chrome_signin_client.h" |
| 13 #include "chrome/browser/tab_contents/tab_util.h" | 12 #include "chrome/browser/tab_contents/tab_util.h" |
| 14 #include "chrome/browser/ui/browser_window.h" | 13 #include "chrome/browser/ui/browser_window.h" |
| 15 #include "chrome/common/url_constants.h" | 14 #include "chrome/common/url_constants.h" |
| 16 #include "components/signin/core/browser/account_reconcilor.h" | 15 #include "components/signin/core/browser/account_reconcilor.h" |
| 17 #include "components/signin/core/browser/chrome_connected_header_helper.h" | 16 #include "components/signin/core/browser/chrome_connected_header_helper.h" |
| 18 #include "components/signin/core/browser/signin_header_helper.h" | 17 #include "components/signin/core/browser/signin_header_helper.h" |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 30 #include "chrome/browser/ui/browser_commands.h" | 29 #include "chrome/browser/ui/browser_commands.h" |
| 31 #include "chrome/browser/ui/browser_finder.h" | 30 #include "chrome/browser/ui/browser_finder.h" |
| 32 #include "extensions/browser/guest_view/web_view/web_view_renderer_state.h" | 31 #include "extensions/browser/guest_view/web_view/web_view_renderer_state.h" |
| 33 #endif // defined(OS_ANDROID) | 32 #endif // defined(OS_ANDROID) |
| 34 | 33 |
| 35 namespace signin { | 34 namespace signin { |
| 36 | 35 |
| 37 namespace { | 36 namespace { |
| 38 | 37 |
| 39 const char kChromeManageAccountsHeader[] = "X-Chrome-Manage-Accounts"; | 38 const char kChromeManageAccountsHeader[] = "X-Chrome-Manage-Accounts"; |
| 39 const char kDiceResponseHeader[] = "X-Chrome-ID-Consistency-Response"; | |
| 40 | 40 |
| 41 // Processes the mirror response header on the UI thread. Currently depending | 41 // Processes the mirror response header on the UI thread. Currently depending |
| 42 // on the value of |header_value|, it either shows the profile avatar menu, or | 42 // on the value of |header_value|, it either shows the profile avatar menu, or |
| 43 // opens an incognito window/tab. | 43 // opens an incognito window/tab. |
| 44 void ProcessMirrorHeaderUIThread(int child_id, | 44 void ProcessMirrorHeaderUIThread(int child_id, |
| 45 int route_id, | 45 int route_id, |
| 46 ManageAccountsParams manage_accounts_params) { | 46 ManageAccountsParams manage_accounts_params) { |
| 47 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 47 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 48 | 48 |
| 49 if (switches::GetAccountConsistencyMethod() != | 49 if (switches::GetAccountConsistencyMethod() != |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 136 IncognitoModePrefs::ArePlatformParentalControlsEnabled()) { | 136 IncognitoModePrefs::ArePlatformParentalControlsEnabled()) { |
| 137 profile_mode_mask |= PROFILE_MODE_INCOGNITO_DISABLED; | 137 profile_mode_mask |= PROFILE_MODE_INCOGNITO_DISABLED; |
| 138 } | 138 } |
| 139 | 139 |
| 140 // If new url is eligible to have the header, add it, otherwise remove it. | 140 // If new url is eligible to have the header, add it, otherwise remove it. |
| 141 AppendOrRemoveAccountConsistentyRequestHeader( | 141 AppendOrRemoveAccountConsistentyRequestHeader( |
| 142 request, redirect_url, io_data->google_services_account_id()->GetValue(), | 142 request, redirect_url, io_data->google_services_account_id()->GetValue(), |
| 143 io_data->GetCookieSettings(), profile_mode_mask); | 143 io_data->GetCookieSettings(), profile_mode_mask); |
| 144 } | 144 } |
| 145 | 145 |
| 146 void ProcessMirrorResponseHeaderIfExists(net::URLRequest* request, | 146 void ProcessMirrorResponseHeaderIfExists(net::URLRequest* request, |
|
msarda
2017/06/12 11:52:21
Could we replace this with a similar strategy as f
droger
2017/06/12 12:39:14
They are done at different times currently.
It pro
msarda
2017/06/12 14:03:42
This was one of the reasons why I wanted to get a
droger
2017/06/12 16:12:58
Ok. I'm going to ask them.
I think in the meantim
| |
| 147 ProfileIOData* io_data, | 147 ProfileIOData* io_data, |
| 148 int child_id, | 148 int child_id, |
| 149 int route_id) { | 149 int route_id) { |
| 150 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); | 150 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); |
| 151 | 151 |
| 152 if (io_data->IsOffTheRecord()) | 152 if (io_data->IsOffTheRecord()) |
| 153 return; | 153 return; |
| 154 | 154 |
| 155 const content::ResourceRequestInfo* info = | 155 const content::ResourceRequestInfo* info = |
| 156 content::ResourceRequestInfo::ForRequest(request); | 156 content::ResourceRequestInfo::ForRequest(request); |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 176 if (params.service_type == GAIA_SERVICE_TYPE_NONE) | 176 if (params.service_type == GAIA_SERVICE_TYPE_NONE) |
| 177 return; | 177 return; |
| 178 | 178 |
| 179 params.child_id = child_id; | 179 params.child_id = child_id; |
| 180 params.route_id = route_id; | 180 params.route_id = route_id; |
| 181 content::BrowserThread::PostTask( | 181 content::BrowserThread::PostTask( |
| 182 content::BrowserThread::UI, FROM_HERE, | 182 content::BrowserThread::UI, FROM_HERE, |
| 183 base::Bind(ProcessMirrorHeaderUIThread, child_id, route_id, params)); | 183 base::Bind(ProcessMirrorHeaderUIThread, child_id, route_id, params)); |
| 184 } | 184 } |
| 185 | 185 |
| 186 #if !defined(OS_IOS) && !defined(OS_ANDROID) | |
| 187 void ProcessDiceResponseHeaderIfExists(net::URLRequest* request, | |
| 188 ProfileIOData* io_data) { | |
| 189 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); | |
| 190 | |
| 191 if (io_data->IsOffTheRecord()) | |
| 192 return; | |
| 193 | |
| 194 const content::ResourceRequestInfo* info = | |
| 195 content::ResourceRequestInfo::ForRequest(request); | |
| 196 if (!(info && info->GetResourceType() == content::RESOURCE_TYPE_MAIN_FRAME)) | |
| 197 return; | |
| 198 | |
| 199 if (!gaia::IsGaiaSignonRealm(request->url().GetOrigin())) | |
| 200 return; | |
| 201 | |
| 202 if (switches::GetAccountConsistencyMethod() != | |
| 203 switches::AccountConsistencyMethod::kDice) { | |
| 204 return; | |
| 205 } | |
| 206 | |
| 207 net::HttpResponseHeaders* response_headers = request->response_headers(); | |
| 208 if (!response_headers) | |
| 209 return; | |
| 210 | |
| 211 std::string header_value; | |
| 212 if (!response_headers->GetNormalizedHeader(kDiceResponseHeader, | |
| 213 &header_value)) { | |
| 214 return; | |
| 215 } | |
| 216 | |
| 217 DiceResponseParams params = BuildDiceResponseParams(header_value); | |
| 218 // If the request does not have a response header or if the header contains | |
| 219 // garbage, then |user_intention| is set to |NONE|. | |
| 220 if (params.user_intention == DiceAction::NONE) | |
| 221 return; | |
| 222 | |
| 223 // TODO(droger): Start the Chrome authentication flow. | |
|
msarda
2017/06/12 11:52:21
This TODO is wrong as we do not plan to start an a
droger
2017/06/12 12:39:14
Done.
| |
| 224 } | |
| 225 #endif // !defined(OS_IOS) && !defined(OS_ANDROID) | |
| 226 | |
| 186 } // namespace signin | 227 } // namespace signin |
| OLD | NEW |