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

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

Issue 1459793002: Android: Allow compiling browser without Java UI (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years 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/strings/string_util.h" 7 #include "base/strings/string_util.h"
8 #include "chrome/browser/prefs/incognito_mode_prefs.h" 8 #include "chrome/browser/prefs/incognito_mode_prefs.h"
9 #include "chrome/browser/profiles/profile_io_data.h" 9 #include "chrome/browser/profiles/profile_io_data.h"
10 #include "chrome/browser/signin/account_reconcilor_factory.h" 10 #include "chrome/browser/signin/account_reconcilor_factory.h"
11 #include "chrome/browser/signin/chrome_signin_client.h" 11 #include "chrome/browser/signin/chrome_signin_client.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/signin/core/browser/account_reconcilor.h" 15 #include "components/signin/core/browser/account_reconcilor.h"
16 #include "components/signin/core/browser/signin_header_helper.h" 16 #include "components/signin/core/browser/signin_header_helper.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/resource_request_info.h"
19 #include "content/public/browser/web_contents.h" 19 #include "content/public/browser/web_contents.h"
20 #include "google_apis/gaia/gaia_auth_util.h" 20 #include "google_apis/gaia/gaia_auth_util.h"
21 #include "net/url_request/url_request.h" 21 #include "net/url_request/url_request.h"
22 22
23 #if defined(OS_ANDROID) 23 #if defined(ANDROID_JAVA_UI)
24 #include "chrome/browser/android/signin/account_management_screen_helper.h" 24 #include "chrome/browser/android/signin/account_management_screen_helper.h"
25 #else 25 #else
26 #include "chrome/browser/ui/browser_commands.h" 26 #include "chrome/browser/ui/browser_commands.h"
27 #include "chrome/browser/ui/browser_finder.h" 27 #include "chrome/browser/ui/browser_finder.h"
28 #include "extensions/browser/guest_view/web_view/web_view_renderer_state.h" 28 #include "extensions/browser/guest_view/web_view/web_view_renderer_state.h"
29 #endif // defined(OS_ANDROID) 29 #endif // defined(ANDROID_JAVA_UI)
30 30
31 namespace signin { 31 namespace signin {
32 32
33 namespace { 33 namespace {
34 34
35 // Processes the mirror response header on the UI thread. Currently depending 35 // Processes the mirror response header on the UI thread. Currently depending
36 // on the value of |header_value|, it either shows the profile avatar menu, or 36 // on the value of |header_value|, it either shows the profile avatar menu, or
37 // opens an incognito window/tab. 37 // opens an incognito window/tab.
38 void ProcessMirrorHeaderUIThread(int child_id, 38 void ProcessMirrorHeaderUIThread(int child_id,
39 int route_id, 39 int route_id,
40 ManageAccountsParams manage_accounts_params) { 40 ManageAccountsParams manage_accounts_params) {
41 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 41 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
42 42
43 GAIAServiceType service_type = manage_accounts_params.service_type; 43 GAIAServiceType service_type = manage_accounts_params.service_type;
44 DCHECK_NE(GAIA_SERVICE_TYPE_NONE, service_type); 44 DCHECK_NE(GAIA_SERVICE_TYPE_NONE, service_type);
45 45
46 content::WebContents* web_contents = 46 content::WebContents* web_contents =
47 tab_util::GetWebContentsByID(child_id, route_id); 47 tab_util::GetWebContentsByID(child_id, route_id);
48 if (!web_contents) 48 if (!web_contents)
49 return; 49 return;
50 50
51 Profile* profile = 51 Profile* profile =
52 Profile::FromBrowserContext(web_contents->GetBrowserContext()); 52 Profile::FromBrowserContext(web_contents->GetBrowserContext());
53 AccountReconcilor* account_reconcilor = 53 AccountReconcilor* account_reconcilor =
54 AccountReconcilorFactory::GetForProfile(profile); 54 AccountReconcilorFactory::GetForProfile(profile);
55 account_reconcilor->OnReceivedManageAccountsResponse( 55 account_reconcilor->OnReceivedManageAccountsResponse(
56 manage_accounts_params.service_type); 56 manage_accounts_params.service_type);
57 #if !defined(OS_ANDROID) 57 #if !defined(ANDROID_JAVA_UI)
58 Browser* browser = chrome::FindBrowserWithWebContents(web_contents); 58 Browser* browser = chrome::FindBrowserWithWebContents(web_contents);
59 if (browser) { 59 if (browser) {
60 BrowserWindow::AvatarBubbleMode bubble_mode; 60 BrowserWindow::AvatarBubbleMode bubble_mode;
61 switch (service_type) { 61 switch (service_type) {
62 case GAIA_SERVICE_TYPE_INCOGNITO: 62 case GAIA_SERVICE_TYPE_INCOGNITO:
63 chrome::NewIncognitoWindow(browser); 63 chrome::NewIncognitoWindow(browser);
64 return; 64 return;
65 case GAIA_SERVICE_TYPE_ADDSESSION: 65 case GAIA_SERVICE_TYPE_ADDSESSION:
66 bubble_mode = BrowserWindow::AVATAR_BUBBLE_MODE_ADD_ACCOUNT; 66 bubble_mode = BrowserWindow::AVATAR_BUBBLE_MODE_ADD_ACCOUNT;
67 break; 67 break;
68 case GAIA_SERVICE_TYPE_REAUTH: 68 case GAIA_SERVICE_TYPE_REAUTH:
69 bubble_mode = BrowserWindow::AVATAR_BUBBLE_MODE_REAUTH; 69 bubble_mode = BrowserWindow::AVATAR_BUBBLE_MODE_REAUTH;
70 break; 70 break;
71 default: 71 default:
72 bubble_mode = BrowserWindow::AVATAR_BUBBLE_MODE_ACCOUNT_MANAGEMENT; 72 bubble_mode = BrowserWindow::AVATAR_BUBBLE_MODE_ACCOUNT_MANAGEMENT;
73 } 73 }
74 signin_metrics::LogAccountReconcilorStateOnGaiaResponse( 74 signin_metrics::LogAccountReconcilorStateOnGaiaResponse(
75 account_reconcilor->GetState()); 75 account_reconcilor->GetState());
76 browser->window()->ShowAvatarBubbleFromAvatarButton(bubble_mode, 76 browser->window()->ShowAvatarBubbleFromAvatarButton(bubble_mode,
77 manage_accounts_params); 77 manage_accounts_params);
78 } 78 }
79 #else // defined(OS_ANDROID) 79 #else // defined(ANDROID_JAVA_UI)
80 if (service_type == signin::GAIA_SERVICE_TYPE_INCOGNITO) { 80 if (service_type == signin::GAIA_SERVICE_TYPE_INCOGNITO) {
81 GURL url(manage_accounts_params.continue_url.empty() 81 GURL url(manage_accounts_params.continue_url.empty()
82 ? chrome::kChromeUINativeNewTabURL 82 ? chrome::kChromeUINativeNewTabURL
83 : manage_accounts_params.continue_url); 83 : manage_accounts_params.continue_url);
84 web_contents->OpenURL( 84 web_contents->OpenURL(
85 content::OpenURLParams(url, content::Referrer(), OFF_THE_RECORD, 85 content::OpenURLParams(url, content::Referrer(), OFF_THE_RECORD,
86 ui::PAGE_TRANSITION_AUTO_TOPLEVEL, false)); 86 ui::PAGE_TRANSITION_AUTO_TOPLEVEL, false));
87 } else { 87 } else {
88 signin_metrics::LogAccountReconcilorStateOnGaiaResponse( 88 signin_metrics::LogAccountReconcilorStateOnGaiaResponse(
89 account_reconcilor->GetState()); 89 account_reconcilor->GetState());
90 AccountManagementScreenHelper::OpenAccountManagementScreen(profile, 90 AccountManagementScreenHelper::OpenAccountManagementScreen(profile,
91 service_type); 91 service_type);
92 } 92 }
93 #endif // !defined(OS_ANDROID) 93 #endif // !defined(ANDROID_JAVA_UI)
94 } 94 }
95 95
96 // Returns the parameters contained in the X-Chrome-Manage-Accounts response 96 // Returns the parameters contained in the X-Chrome-Manage-Accounts response
97 // header. 97 // header.
98 // If the request does not have a response header or if the header contains 98 // If the request does not have a response header or if the header contains
99 // garbage, then |service_type| is set to |GAIA_SERVICE_TYPE_NONE|. 99 // garbage, then |service_type| is set to |GAIA_SERVICE_TYPE_NONE|.
100 // Must be called on IO thread. 100 // Must be called on IO thread.
101 ManageAccountsParams BuildManageAccountsParamsHelper(net::URLRequest* request, 101 ManageAccountsParams BuildManageAccountsParamsHelper(net::URLRequest* request,
102 ProfileIOData* io_data) { 102 ProfileIOData* io_data) {
103 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); 103 DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 return; 160 return;
161 161
162 params.child_id = child_id; 162 params.child_id = child_id;
163 params.route_id = route_id; 163 params.route_id = route_id;
164 content::BrowserThread::PostTask( 164 content::BrowserThread::PostTask(
165 content::BrowserThread::UI, FROM_HERE, 165 content::BrowserThread::UI, FROM_HERE,
166 base::Bind(ProcessMirrorHeaderUIThread, child_id, route_id, params)); 166 base::Bind(ProcessMirrorHeaderUIThread, child_id, route_id, params));
167 } 167 }
168 168
169 } // namespace signin 169 } // namespace signin
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698