OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/ui/chrome_pages.h" | 5 #include "chrome/browser/ui/chrome_pages.h" |
6 | 6 |
7 #include "base/command_line.h" | |
8 #include "base/logging.h" | 7 #include "base/logging.h" |
9 #include "base/string_number_conversions.h" | 8 #include "base/string_number_conversions.h" |
10 #include "base/stringprintf.h" | 9 #include "base/stringprintf.h" |
11 #include "chrome/browser/download/download_shelf.h" | 10 #include "chrome/browser/download/download_shelf.h" |
12 #include "chrome/browser/profiles/profile.h" | 11 #include "chrome/browser/profiles/profile.h" |
13 #include "chrome/browser/sync/profile_sync_service.h" | 12 #include "chrome/browser/sync/profile_sync_service.h" |
14 #include "chrome/browser/sync/profile_sync_service_factory.h" | 13 #include "chrome/browser/sync/profile_sync_service_factory.h" |
15 #include "chrome/browser/ui/browser.h" | 14 #include "chrome/browser/ui/browser.h" |
16 #include "chrome/browser/ui/browser_navigator.h" | 15 #include "chrome/browser/ui/browser_navigator.h" |
17 #include "chrome/browser/ui/browser_window.h" | 16 #include "chrome/browser/ui/browser_window.h" |
18 #include "chrome/browser/ui/singleton_tabs.h" | 17 #include "chrome/browser/ui/singleton_tabs.h" |
19 #include "chrome/browser/ui/webui/options/content_settings_handler.h" | 18 #include "chrome/browser/ui/webui/options/content_settings_handler.h" |
20 #include "chrome/browser/ui/webui/signin/login_ui_service.h" | 19 #include "chrome/browser/ui/webui/signin/login_ui_service.h" |
21 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h" | 20 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h" |
22 #include "chrome/common/chrome_switches.h" | 21 #include "chrome/browser/ui/webui/sync_promo/sync_promo_ui.h" |
23 #include "chrome/common/net/url_util.h" | 22 #include "chrome/common/net/url_util.h" |
24 #include "chrome/common/url_constants.h" | 23 #include "chrome/common/url_constants.h" |
25 #include "content/public/browser/user_metrics.h" | 24 #include "content/public/browser/user_metrics.h" |
26 #include "google_apis/gaia/gaia_urls.h" | 25 #include "google_apis/gaia/gaia_urls.h" |
27 #include "googleurl/src/gurl.h" | 26 #include "googleurl/src/gurl.h" |
28 | 27 |
29 using content::UserMetricsAction; | 28 using content::UserMetricsAction; |
30 | 29 |
31 namespace chrome { | 30 namespace chrome { |
32 namespace { | 31 namespace { |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 } | 180 } |
182 | 181 |
183 void ShowSyncSetup(Browser* browser, SyncPromoUI::Source source) { | 182 void ShowSyncSetup(Browser* browser, SyncPromoUI::Source source) { |
184 Profile* original_profile = browser->profile()->GetOriginalProfile(); | 183 Profile* original_profile = browser->profile()->GetOriginalProfile(); |
185 ProfileSyncService* service = | 184 ProfileSyncService* service = |
186 ProfileSyncServiceFactory::GetInstance()->GetForProfile( | 185 ProfileSyncServiceFactory::GetInstance()->GetForProfile( |
187 original_profile); | 186 original_profile); |
188 if (service->HasSyncSetupCompleted()) { | 187 if (service->HasSyncSetupCompleted()) { |
189 ShowSettings(browser); | 188 ShowSettings(browser); |
190 } else { | 189 } else { |
191 const bool use_web_flow = CommandLine::ForCurrentProcess()->HasSwitch( | 190 const bool use_web_flow = SyncPromoUI::UseWebBasedSigninFlow(); |
192 switches::kUseWebBasedSigninFlow); | |
193 const bool show_promo = | 191 const bool show_promo = |
194 SyncPromoUI::ShouldShowSyncPromo(browser->profile()); | 192 SyncPromoUI::ShouldShowSyncPromo(browser->profile()); |
195 | 193 |
196 LoginUIService* login = LoginUIServiceFactory::GetForProfile( | 194 LoginUIService* login = LoginUIServiceFactory::GetForProfile( |
197 original_profile); | 195 original_profile); |
198 if (use_web_flow || (show_promo && login->current_login_ui() == NULL)) { | 196 if (use_web_flow || (show_promo && login->current_login_ui() == NULL)) { |
199 NavigateToSingletonTab(browser, GURL(SyncPromoUI::GetSyncPromoURL(GURL(), | 197 NavigateToSingletonTab(browser, GURL(SyncPromoUI::GetSyncPromoURL(GURL(), |
200 source, | 198 source, |
201 false))); | 199 false))); |
202 } else { | 200 } else { |
203 login->ShowLoginUI(browser); | 201 login->ShowLoginUI(browser); |
204 } | 202 } |
205 } | 203 } |
206 } | 204 } |
207 | 205 |
208 void ShowGaiaSignin(Browser* browser, | 206 void ShowGaiaSignin(Browser* browser, |
209 const std::string& service, | 207 const std::string& service, |
210 const GURL& continue_url) { | 208 const GURL& continue_url) { |
211 GURL url(GaiaUrls::GetInstance()->service_login_url()); | 209 GURL url(GaiaUrls::GetInstance()->service_login_url()); |
212 url = chrome_common_net::AppendQueryParameter(url, "service", service); | 210 url = chrome_common_net::AppendQueryParameter(url, "service", service); |
213 if (continue_url.is_valid()) | 211 if (continue_url.is_valid()) |
214 url = chrome_common_net::AppendQueryParameter(url, | 212 url = chrome_common_net::AppendQueryParameter(url, |
215 "continue", | 213 "continue", |
216 continue_url.spec()); | 214 continue_url.spec()); |
217 NavigateToSingletonTab(browser, url); | 215 NavigateToSingletonTab(browser, url); |
218 } | 216 } |
219 | 217 |
220 } // namespace chrome | 218 } // namespace chrome |
OLD | NEW |