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" |
11 #include "chrome/browser/profiles/profile_io_data.h" | 11 #include "chrome/browser/profiles/profile_io_data.h" |
12 #include "chrome/browser/tab_contents/tab_util.h" | 12 #include "chrome/browser/tab_contents/tab_util.h" |
13 #include "chrome/browser/ui/browser_window.h" | 13 #include "chrome/browser/ui/browser_window.h" |
14 #include "chrome/common/url_constants.h" | 14 #include "chrome/common/url_constants.h" |
15 #include "components/google/core/browser/google_util.h" | 15 #include "components/google/core/browser/google_util.h" |
16 #include "components/signin/core/common/profile_management_switches.h" | 16 #include "components/signin/core/common/profile_management_switches.h" |
17 #include "content/public/browser/browser_thread.h" | 17 #include "content/public/browser/browser_thread.h" |
| 18 #include "content/public/browser/resource_request_info.h" |
18 #include "content/public/browser/web_contents.h" | 19 #include "content/public/browser/web_contents.h" |
19 #include "google_apis/gaia/gaia_auth_util.h" | 20 #include "google_apis/gaia/gaia_auth_util.h" |
20 #include "net/http/http_response_headers.h" | 21 #include "net/http/http_response_headers.h" |
21 #include "net/url_request/url_request.h" | 22 #include "net/url_request/url_request.h" |
22 | 23 |
23 #if defined(OS_ANDROID) | 24 #if defined(OS_ANDROID) |
24 #include "chrome/browser/android/signin/account_management_screen_helper.h" | 25 #include "chrome/browser/android/signin/account_management_screen_helper.h" |
25 #else | 26 #else |
26 #include "chrome/browser/ui/browser_commands.h" | 27 #include "chrome/browser/ui/browser_commands.h" |
27 #include "chrome/browser/ui/browser_finder.h" | 28 #include "chrome/browser/ui/browser_finder.h" |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
246 ProfileIOData* io_data, | 247 ProfileIOData* io_data, |
247 int child_id, | 248 int child_id, |
248 int route_id) { | 249 int route_id) { |
249 #if defined(OS_IOS) | 250 #if defined(OS_IOS) |
250 NOTREACHED(); | 251 NOTREACHED(); |
251 #else | 252 #else |
252 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); | 253 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); |
253 if (!gaia::IsGaiaSignonRealm(request->url().GetOrigin())) | 254 if (!gaia::IsGaiaSignonRealm(request->url().GetOrigin())) |
254 return; | 255 return; |
255 | 256 |
| 257 const content::ResourceRequestInfo* info = |
| 258 content::ResourceRequestInfo::ForRequest(request); |
| 259 if (!(info && info->IsMainFrame() && info->HasUserGesture())) |
| 260 return; |
| 261 |
256 std::string header_value; | 262 std::string header_value; |
257 if (!request->response_headers()->GetNormalizedHeader( | 263 if (!request->response_headers()->GetNormalizedHeader( |
258 kChromeManageAccountsHeader, &header_value)) { | 264 kChromeManageAccountsHeader, &header_value)) { |
259 return; | 265 return; |
260 } | 266 } |
261 | 267 |
262 DCHECK(switches::IsEnableAccountConsistency() && !io_data->IsOffTheRecord()); | 268 DCHECK(switches::IsEnableAccountConsistency() && !io_data->IsOffTheRecord()); |
263 ManageAccountsParams params(BuildManageAccountsParams(header_value)); | 269 ManageAccountsParams params(BuildManageAccountsParams(header_value)); |
264 if (params.service_type == GAIA_SERVICE_TYPE_NONE) | 270 if (params.service_type == GAIA_SERVICE_TYPE_NONE) |
265 return; | 271 return; |
266 | 272 |
267 params.child_id = child_id; | 273 params.child_id = child_id; |
268 params.route_id = route_id; | 274 params.route_id = route_id; |
269 content::BrowserThread::PostTask( | 275 content::BrowserThread::PostTask( |
270 content::BrowserThread::UI, FROM_HERE, | 276 content::BrowserThread::UI, FROM_HERE, |
271 base::Bind(ProcessMirrorHeaderUIThread, child_id, route_id, params)); | 277 base::Bind(ProcessMirrorHeaderUIThread, child_id, route_id, params)); |
272 #endif // defined(OS_IOS) | 278 #endif // defined(OS_IOS) |
273 } | 279 } |
274 | 280 |
275 } // namespace signin | 281 } // namespace signin |
OLD | NEW |