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 "chrome/browser/extensions/extension_renderer_state.h" | 7 #include "chrome/browser/extensions/extension_renderer_state.h" |
8 #include "chrome/browser/profiles/profile_io_data.h" | 8 #include "chrome/browser/profiles/profile_io_data.h" |
9 #include "chrome/browser/tab_contents/tab_util.h" | 9 #include "chrome/browser/tab_contents/tab_util.h" |
10 #include "chrome/browser/ui/browser_finder.h" | 10 #include "chrome/browser/ui/browser_finder.h" |
11 #include "chrome/browser/ui/browser_window.h" | 11 #include "chrome/browser/ui/browser_window.h" |
12 #include "chrome/common/profile_management_switches.h" | 12 #include "chrome/common/profile_management_switches.h" |
13 #include "content/public/browser/browser_thread.h" | 13 #include "content/public/browser/browser_thread.h" |
14 #include "content/public/browser/web_contents.h" | 14 #include "content/public/browser/web_contents.h" |
15 #include "google_apis/gaia/gaia_auth_util.h" | 15 #include "google_apis/gaia/gaia_auth_util.h" |
16 #include "net/http/http_response_headers.h" | 16 #include "net/http/http_response_headers.h" |
17 #include "net/url_request/url_request.h" | 17 #include "net/url_request/url_request.h" |
18 | 18 |
19 #if defined(OS_ANDROID) | |
20 #include "chrome/browser/android/signin/account_management_screen_helper.h" | |
21 #endif // defined(OS_ANDROID) | |
22 | |
19 namespace { | 23 namespace { |
20 | 24 |
21 const char kChromeConnectedHeader[] = "X-Chrome-Connected"; | 25 const char kChromeConnectedHeader[] = "X-Chrome-Connected"; |
22 const char kChromeManageAccountsHeader[] = "X-Chrome-Manage-Accounts"; | 26 const char kChromeManageAccountsHeader[] = "X-Chrome-Manage-Accounts"; |
23 const char kGaiaAuthExtensionID[] = "mfffpogegjflfpflabcdkioaeobkgjik"; | 27 const char kGaiaAuthExtensionID[] = "mfffpogegjflfpflabcdkioaeobkgjik"; |
24 | 28 |
25 // Show profile avatar bubble on UI thread. Must be called on the UI thread. | 29 // Show profile avatar bubble on UI thread. Must be called on the UI thread. |
26 void ShowAvatarBubbleUIThread(int child_id, int route_id) { | 30 void ShowAvatarBubbleUIThread(int child_id, int route_id) { |
27 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 31 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
28 | 32 |
29 #if !defined(OS_ANDROID) | 33 #if !defined(OS_ANDROID) |
30 content::WebContents* web_contents = | 34 content::WebContents* web_contents = |
31 tab_util::GetWebContentsByID(child_id, route_id); | 35 tab_util::GetWebContentsByID(child_id, route_id); |
32 if (!web_contents) | 36 if (!web_contents) |
33 return; | 37 return; |
34 | 38 |
35 Browser* browser = chrome::FindBrowserWithWebContents(web_contents); | 39 Browser* browser = chrome::FindBrowserWithWebContents(web_contents); |
36 if (browser) | 40 if (browser) |
37 browser->window()->ShowAvatarBubbleFromAvatarButton(); | 41 browser->window()->ShowAvatarBubbleFromAvatarButton(); |
38 // TODO(guohui): need to handle the case when avatar button is not available. | 42 // TODO(guohui): need to handle the case when avatar button is not available. |
43 #else // defined(OS_ANDROID) | |
44 AccountManagementScreenHelper::OpenAccountManagementScreen(); | |
Andrew T Wilson (Slow)
2014/01/16 10:00:45
Seems like a better way to do this is to define Si
aruslan
2014/01/16 15:26:13
I have contemplated converting the code in this fi
guohui
2014/01/16 19:11:01
I don't have a strong preference myself, it really
aruslan
2014/01/16 19:24:57
Currently that "dozen lines" of Android-specific c
guohui
2014/01/16 19:48:37
if you are confident that this single line is the
| |
39 #endif // OS_ANDROID | 45 #endif // OS_ANDROID |
40 } | 46 } |
41 | 47 |
42 bool IsDriveOrigin(const GURL& url) { | 48 bool IsDriveOrigin(const GURL& url) { |
43 if (!url.SchemeIsSecure()) | 49 if (!url.SchemeIsSecure()) |
44 return false; | 50 return false; |
45 | 51 |
46 const GURL kGoogleDriveURL("https://drive.google.com"); | 52 const GURL kGoogleDriveURL("https://drive.google.com"); |
47 const GURL kGoogleDocsURL("https://docs.google.com"); | 53 const GURL kGoogleDocsURL("https://docs.google.com"); |
48 return url == kGoogleDriveURL || url == kGoogleDocsURL; | 54 return url == kGoogleDriveURL || url == kGoogleDocsURL; |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
106 request->response_headers()->HasHeader(kChromeManageAccountsHeader)) { | 112 request->response_headers()->HasHeader(kChromeManageAccountsHeader)) { |
107 DCHECK(switches::IsNewProfileManagement() && | 113 DCHECK(switches::IsNewProfileManagement() && |
108 !io_data->is_incognito()); | 114 !io_data->is_incognito()); |
109 content::BrowserThread::PostTask( | 115 content::BrowserThread::PostTask( |
110 content::BrowserThread::UI, FROM_HERE, | 116 content::BrowserThread::UI, FROM_HERE, |
111 base::Bind(ShowAvatarBubbleUIThread, child_id, route_id)); | 117 base::Bind(ShowAvatarBubbleUIThread, child_id, route_id)); |
112 } | 118 } |
113 } | 119 } |
114 | 120 |
115 } // namespace signin | 121 } // namespace signin |
OLD | NEW |