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

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

Issue 2946693002: Use GN buildflags and features to configure account consistency (Closed)
Patch Set: fix Created 3 years, 6 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/logging.h" 7 #include "base/logging.h"
8 #include "base/strings/string_util.h" 8 #include "base/strings/string_util.h"
9 #include "build/build_config.h" 9 #include "build/build_config.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/signin/account_reconcilor_factory.h" 12 #include "chrome/browser/signin/account_reconcilor_factory.h"
13 #include "chrome/browser/signin/chrome_signin_client.h" 13 #include "chrome/browser/signin/chrome_signin_client.h"
14 #include "chrome/browser/signin/chrome_signin_client_factory.h" 14 #include "chrome/browser/signin/chrome_signin_client_factory.h"
15 #include "chrome/browser/signin/dice_response_handler.h" 15 #include "chrome/browser/signin/dice_response_handler.h"
16 #include "chrome/browser/tab_contents/tab_util.h" 16 #include "chrome/browser/tab_contents/tab_util.h"
17 #include "chrome/browser/ui/browser_window.h" 17 #include "chrome/browser/ui/browser_window.h"
18 #include "chrome/common/url_constants.h" 18 #include "chrome/common/url_constants.h"
19 #include "components/signin/core/browser/account_reconcilor.h" 19 #include "components/signin/core/browser/account_reconcilor.h"
20 #include "components/signin/core/browser/chrome_connected_header_helper.h" 20 #include "components/signin/core/browser/chrome_connected_header_helper.h"
21 #include "components/signin/core/browser/signin_header_helper.h" 21 #include "components/signin/core/browser/signin_header_helper.h"
22 #include "components/signin/core/common/profile_management_switches.h" 22 #include "components/signin/core/common/profile_management_switches.h"
23 #include "components/signin/core/common/signin_features.h"
23 #include "content/public/browser/browser_thread.h" 24 #include "content/public/browser/browser_thread.h"
24 #include "content/public/browser/web_contents.h" 25 #include "content/public/browser/web_contents.h"
25 #include "google_apis/gaia/gaia_auth_util.h" 26 #include "google_apis/gaia/gaia_auth_util.h"
26 #include "net/http/http_response_headers.h" 27 #include "net/http/http_response_headers.h"
27 #include "net/url_request/url_request.h" 28 #include "net/url_request/url_request.h"
28 29
29 #if defined(OS_ANDROID) 30 #if defined(OS_ANDROID)
30 #include "chrome/browser/android/signin/account_management_screen_helper.h" 31 #include "chrome/browser/android/signin/account_management_screen_helper.h"
31 #else 32 #else
32 #include "chrome/browser/ui/browser_commands.h" 33 #include "chrome/browser/ui/browser_commands.h"
33 #include "chrome/browser/ui/browser_finder.h" 34 #include "chrome/browser/ui/browser_finder.h"
34 #include "extensions/browser/guest_view/web_view/web_view_renderer_state.h" 35 #include "extensions/browser/guest_view/web_view/web_view_renderer_state.h"
35 #endif // defined(OS_ANDROID) 36 #endif // defined(OS_ANDROID)
36 37
37 namespace signin { 38 namespace signin {
38 39
39 namespace { 40 namespace {
40 41
41 const char kChromeManageAccountsHeader[] = "X-Chrome-Manage-Accounts"; 42 const char kChromeManageAccountsHeader[] = "X-Chrome-Manage-Accounts";
42 43
43 #if !defined(OS_ANDROID) 44 #if BUILDFLAG(ENABLE_DICE_SUPPORT)
44 const char kDiceResponseHeader[] = "X-Chrome-ID-Consistency-Response"; 45 const char kDiceResponseHeader[] = "X-Chrome-ID-Consistency-Response";
45 #endif 46 #endif
46 47
47 // Processes the mirror response header on the UI thread. Currently depending 48 // Processes the mirror response header on the UI thread. Currently depending
48 // on the value of |header_value|, it either shows the profile avatar menu, or 49 // on the value of |header_value|, it either shows the profile avatar menu, or
49 // opens an incognito window/tab. 50 // opens an incognito window/tab.
50 void ProcessMirrorHeaderUIThread( 51 void ProcessMirrorHeaderUIThread(
51 ManageAccountsParams manage_accounts_params, 52 ManageAccountsParams manage_accounts_params,
52 const content::ResourceRequestInfo::WebContentsGetter& 53 const content::ResourceRequestInfo::WebContentsGetter&
53 web_contents_getter) { 54 web_contents_getter) {
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 ui::PAGE_TRANSITION_AUTO_TOPLEVEL, false)); 101 ui::PAGE_TRANSITION_AUTO_TOPLEVEL, false));
101 } else { 102 } else {
102 signin_metrics::LogAccountReconcilorStateOnGaiaResponse( 103 signin_metrics::LogAccountReconcilorStateOnGaiaResponse(
103 account_reconcilor->GetState()); 104 account_reconcilor->GetState());
104 AccountManagementScreenHelper::OpenAccountManagementScreen(profile, 105 AccountManagementScreenHelper::OpenAccountManagementScreen(profile,
105 service_type); 106 service_type);
106 } 107 }
107 #endif // !defined(OS_ANDROID) 108 #endif // !defined(OS_ANDROID)
108 } 109 }
109 110
110 #if !defined(OS_ANDROID) 111 #if BUILDFLAG(ENABLE_DICE_SUPPORT)
111 void ProcessDiceHeaderUIThread( 112 void ProcessDiceHeaderUIThread(
112 const DiceResponseParams& dice_params, 113 const DiceResponseParams& dice_params,
113 const content::ResourceRequestInfo::WebContentsGetter& 114 const content::ResourceRequestInfo::WebContentsGetter&
114 web_contents_getter) { 115 web_contents_getter) {
115 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 116 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
116 DCHECK_EQ(switches::AccountConsistencyMethod::kDice, 117 DCHECK_EQ(switches::AccountConsistencyMethod::kDice,
117 switches::GetAccountConsistencyMethod()); 118 switches::GetAccountConsistencyMethod());
118 119
119 content::WebContents* web_contents = web_contents_getter.Run(); 120 content::WebContents* web_contents = web_contents_getter.Run();
120 if (!web_contents) 121 if (!web_contents)
121 return; 122 return;
122 123
123 Profile* profile = 124 Profile* profile =
124 Profile::FromBrowserContext(web_contents->GetBrowserContext()); 125 Profile::FromBrowserContext(web_contents->GetBrowserContext());
125 DCHECK(!profile->IsOffTheRecord()); 126 DCHECK(!profile->IsOffTheRecord());
126 127
127 DiceResponseHandler* dice_response_handler = 128 DiceResponseHandler* dice_response_handler =
128 DiceResponseHandler::GetForProfile(profile); 129 DiceResponseHandler::GetForProfile(profile);
129 dice_response_handler->ProcessDiceHeader(dice_params); 130 dice_response_handler->ProcessDiceHeader(dice_params);
130 } 131 }
131 #endif // !defined(OS_ANDROID) 132 #endif // BUILDFLAG(ENABLE_DICE_SUPPORT)
132 133
133 // Looks for the X-Chrome-Manage-Accounts response header, and if found, 134 // Looks for the X-Chrome-Manage-Accounts response header, and if found,
134 // tries to show the avatar bubble in the browser identified by the 135 // tries to show the avatar bubble in the browser identified by the
135 // child/route id. Must be called on IO thread. 136 // child/route id. Must be called on IO thread.
136 void ProcessMirrorResponseHeaderIfExists( 137 void ProcessMirrorResponseHeaderIfExists(
137 net::URLRequest* request, 138 net::URLRequest* request,
138 ProfileIOData* io_data, 139 ProfileIOData* io_data,
139 const content::ResourceRequestInfo::WebContentsGetter& 140 const content::ResourceRequestInfo::WebContentsGetter&
140 web_contents_getter) { 141 web_contents_getter) {
141 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); 142 DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 // If the request does not have a response header or if the header contains 176 // If the request does not have a response header or if the header contains
176 // garbage, then |service_type| is set to |GAIA_SERVICE_TYPE_NONE|. 177 // garbage, then |service_type| is set to |GAIA_SERVICE_TYPE_NONE|.
177 if (params.service_type == GAIA_SERVICE_TYPE_NONE) 178 if (params.service_type == GAIA_SERVICE_TYPE_NONE)
178 return; 179 return;
179 180
180 content::BrowserThread::PostTask( 181 content::BrowserThread::PostTask(
181 content::BrowserThread::UI, FROM_HERE, 182 content::BrowserThread::UI, FROM_HERE,
182 base::Bind(ProcessMirrorHeaderUIThread, params, web_contents_getter)); 183 base::Bind(ProcessMirrorHeaderUIThread, params, web_contents_getter));
183 } 184 }
184 185
185 #if !defined(OS_ANDROID) 186 #if BUILDFLAG(ENABLE_DICE_SUPPORT)
186 void ProcessDiceResponseHeaderIfExists( 187 void ProcessDiceResponseHeaderIfExists(
187 net::URLRequest* request, 188 net::URLRequest* request,
188 ProfileIOData* io_data, 189 ProfileIOData* io_data,
189 const content::ResourceRequestInfo::WebContentsGetter& 190 const content::ResourceRequestInfo::WebContentsGetter&
190 web_contents_getter) { 191 web_contents_getter) {
191 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); 192 DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
192 193
193 if (io_data->IsOffTheRecord()) 194 if (io_data->IsOffTheRecord())
194 return; 195 return;
195 196
(...skipping 23 matching lines...) Expand all
219 DiceResponseParams params = BuildDiceResponseParams(header_value); 220 DiceResponseParams params = BuildDiceResponseParams(header_value);
220 // If the request does not have a response header or if the header contains 221 // If the request does not have a response header or if the header contains
221 // garbage, then |user_intention| is set to |NONE|. 222 // garbage, then |user_intention| is set to |NONE|.
222 if (params.user_intention == DiceAction::NONE) 223 if (params.user_intention == DiceAction::NONE)
223 return; 224 return;
224 225
225 content::BrowserThread::PostTask( 226 content::BrowserThread::PostTask(
226 content::BrowserThread::UI, FROM_HERE, 227 content::BrowserThread::UI, FROM_HERE,
227 base::Bind(ProcessDiceHeaderUIThread, params, web_contents_getter)); 228 base::Bind(ProcessDiceHeaderUIThread, params, web_contents_getter));
228 } 229 }
229 #endif // !defined(OS_ANDROID) 230 #endif // BUILDFLAG(ENABLE_DICE_SUPPORT)
230 231
231 } // namespace 232 } // namespace
232 233
233 void FixAccountConsistencyRequestHeader(net::URLRequest* request, 234 void FixAccountConsistencyRequestHeader(net::URLRequest* request,
234 const GURL& redirect_url, 235 const GURL& redirect_url,
235 ProfileIOData* io_data, 236 ProfileIOData* io_data,
236 int child_id, 237 int child_id,
237 int route_id) { 238 int route_id) {
238 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); 239 DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
239 240
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 if (redirect_url.is_empty()) { 278 if (redirect_url.is_empty()) {
278 // This is not a redirect. 279 // This is not a redirect.
279 280
280 // See if the response contains the X-Chrome-Manage-Accounts header. If so 281 // See if the response contains the X-Chrome-Manage-Accounts header. If so
281 // show the profile avatar bubble so that user can complete signin/out 282 // show the profile avatar bubble so that user can complete signin/out
282 // action the native UI. 283 // action the native UI.
283 ProcessMirrorResponseHeaderIfExists(request, io_data, web_contents_getter); 284 ProcessMirrorResponseHeaderIfExists(request, io_data, web_contents_getter);
284 } else { 285 } else {
285 // This is a redirect. 286 // This is a redirect.
286 287
287 #if !defined(OS_ANDROID) 288 #if BUILDFLAG(ENABLE_DICE_SUPPORT)
288 // Process the Dice header: on sign-in, exchange the authorization code for 289 // Process the Dice header: on sign-in, exchange the authorization code for
289 // a refresh token, on sign-out just follow the sign-out URL. 290 // a refresh token, on sign-out just follow the sign-out URL.
290 ProcessDiceResponseHeaderIfExists(request, io_data, web_contents_getter); 291 ProcessDiceResponseHeaderIfExists(request, io_data, web_contents_getter);
291 #endif 292 #endif // BUILDFLAG(ENABLE_DICE_SUPPORT)
292 } 293 }
293 } 294 }
294 295
295 } // namespace signin 296 } // namespace signin
OLDNEW
« no previous file with comments | « chrome/browser/about_flags.cc ('k') | chrome/browser/signin/mutable_profile_oauth2_token_service_delegate_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698