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/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
9 #include "chrome/browser/google/google_util.h" | 9 #include "chrome/browser/google/google_util.h" |
10 #include "chrome/browser/prefs/incognito_mode_prefs.h" | 10 #include "chrome/browser/prefs/incognito_mode_prefs.h" |
(...skipping 21 matching lines...) Expand all Loading... |
32 const char kChromeManageAccountsHeader[] = "X-Chrome-Manage-Accounts"; | 32 const char kChromeManageAccountsHeader[] = "X-Chrome-Manage-Accounts"; |
33 const char kGaiaIdAttrName[] = "id"; | 33 const char kGaiaIdAttrName[] = "id"; |
34 const char kProfileModeAttrName[] = "mode"; | 34 const char kProfileModeAttrName[] = "mode"; |
35 const char kEnableAccountConsistencyAttrName[] = "enable_account_consistency"; | 35 const char kEnableAccountConsistencyAttrName[] = "enable_account_consistency"; |
36 | 36 |
37 // Determine the service type that has been passed from GAIA in the header. | 37 // Determine the service type that has been passed from GAIA in the header. |
38 signin::GAIAServiceType GetGAIAServiceTypeFromHeader( | 38 signin::GAIAServiceType GetGAIAServiceTypeFromHeader( |
39 const std::string& header_value) { | 39 const std::string& header_value) { |
40 if (header_value == "SIGNOUT") | 40 if (header_value == "SIGNOUT") |
41 return signin::GAIA_SERVICE_TYPE_SIGNOUT; | 41 return signin::GAIA_SERVICE_TYPE_SIGNOUT; |
42 else if (header_value == "SIGNOUTOPTIONS_INCOGNITO") | 42 else if (header_value == "INCOGNITO") |
43 return signin::GAIA_SERVICE_TYPE_SIGNOUTOPTIONS_INCOGNITO; | 43 return signin::GAIA_SERVICE_TYPE_INCOGNITO; |
44 else if (header_value == "ADDSESSION") | 44 else if (header_value == "ADDSESSION") |
45 return signin::GAIA_SERVICE_TYPE_ADDSESSION; | 45 return signin::GAIA_SERVICE_TYPE_ADDSESSION; |
46 else if (header_value == "REAUTH") | 46 else if (header_value == "REAUTH") |
47 return signin::GAIA_SERVICE_TYPE_REAUTH; | 47 return signin::GAIA_SERVICE_TYPE_REAUTH; |
48 else if (header_value == "DEFAULT") | 48 else if (header_value == "DEFAULT") |
49 return signin::GAIA_SERVICE_TYPE_DEFAULT; | 49 return signin::GAIA_SERVICE_TYPE_DEFAULT; |
50 else | 50 else |
51 return signin::GAIA_SERVICE_TYPE_NONE; | 51 return signin::GAIA_SERVICE_TYPE_NONE; |
52 } | 52 } |
53 | 53 |
54 // Processes the mirror response header on the UI thread. Currently depending | 54 // Processes the mirror response header on the UI thread. Currently depending |
55 // on the value of |header_value|, it either shows the profile avatar menu, or | 55 // on the value of |header_value|, it either shows the profile avatar menu, or |
56 // opens an incognito window/tab. | 56 // opens an incognito window/tab. |
57 void ProcessMirrorHeaderUIThread( | 57 void ProcessMirrorHeaderUIThread( |
58 int child_id, int route_id, const std::string& header_value) { | 58 int child_id, int route_id, const std::string& header_value) { |
59 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 59 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
60 | 60 |
61 content::WebContents* web_contents = | 61 content::WebContents* web_contents = |
62 tab_util::GetWebContentsByID(child_id, route_id); | 62 tab_util::GetWebContentsByID(child_id, route_id); |
63 if (!web_contents) | 63 if (!web_contents) |
64 return; | 64 return; |
65 | 65 |
66 signin::GAIAServiceType service_type = | 66 signin::GAIAServiceType service_type = |
67 GetGAIAServiceTypeFromHeader(header_value); | 67 GetGAIAServiceTypeFromHeader(header_value); |
68 | 68 |
69 #if !defined(OS_ANDROID) | 69 #if !defined(OS_ANDROID) |
70 Browser* browser = chrome::FindBrowserWithWebContents(web_contents); | 70 Browser* browser = chrome::FindBrowserWithWebContents(web_contents); |
71 if (browser) { | 71 if (browser) { |
72 if (service_type == signin::GAIA_SERVICE_TYPE_SIGNOUTOPTIONS_INCOGNITO) { | 72 if (service_type == signin::GAIA_SERVICE_TYPE_INCOGNITO) { |
73 chrome::NewIncognitoWindow(browser); | 73 chrome::NewIncognitoWindow(browser); |
74 } else { | 74 } else { |
75 browser->window()->ShowAvatarBubbleFromAvatarButton( | 75 browser->window()->ShowAvatarBubbleFromAvatarButton( |
76 BrowserWindow::AVATAR_BUBBLE_MODE_ACCOUNT_MANAGEMENT, | 76 BrowserWindow::AVATAR_BUBBLE_MODE_ACCOUNT_MANAGEMENT, |
77 service_type); | 77 service_type); |
78 } | 78 } |
79 } | 79 } |
80 #else // defined(OS_ANDROID) | 80 #else // defined(OS_ANDROID) |
81 if (service_type == signin::GAIA_SERVICE_TYPE_SIGNOUTOPTIONS_INCOGNITO) { | 81 if (service_type == signin::GAIA_SERVICE_TYPE_INCOGNITO) { |
82 web_contents->OpenURL(content::OpenURLParams( | 82 web_contents->OpenURL(content::OpenURLParams( |
83 GURL(chrome::kChromeUINativeNewTabURL), content::Referrer(), | 83 GURL(chrome::kChromeUINativeNewTabURL), content::Referrer(), |
84 OFF_THE_RECORD, content::PAGE_TRANSITION_AUTO_TOPLEVEL, false)); | 84 OFF_THE_RECORD, content::PAGE_TRANSITION_AUTO_TOPLEVEL, false)); |
85 } else { | 85 } else { |
86 // TODO(mlerman): pass service_type to android logic for UMA metrics | 86 // TODO(mlerman): pass service_type to android logic for UMA metrics |
87 // that will eventually be installed there. | 87 // that will eventually be installed there. |
88 AccountManagementScreenHelper::OpenAccountManagementScreen( | 88 AccountManagementScreenHelper::OpenAccountManagementScreen( |
89 Profile::FromBrowserContext(web_contents->GetBrowserContext())); | 89 Profile::FromBrowserContext(web_contents->GetBrowserContext())); |
90 } | 90 } |
91 #endif // OS_ANDROID | 91 #endif // OS_ANDROID |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 DCHECK(switches::IsNewProfileManagement() && | 170 DCHECK(switches::IsNewProfileManagement() && |
171 !io_data->IsOffTheRecord()); | 171 !io_data->IsOffTheRecord()); |
172 content::BrowserThread::PostTask( | 172 content::BrowserThread::PostTask( |
173 content::BrowserThread::UI, FROM_HERE, | 173 content::BrowserThread::UI, FROM_HERE, |
174 base::Bind(ProcessMirrorHeaderUIThread, child_id, route_id, | 174 base::Bind(ProcessMirrorHeaderUIThread, child_id, route_id, |
175 header_value)); | 175 header_value)); |
176 } | 176 } |
177 } | 177 } |
178 | 178 |
179 } // namespace signin | 179 } // namespace signin |
OLD | NEW |