| 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/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/string_number_conversions.h" | 8 #include "base/string_number_conversions.h" |
| 9 #include "base/stringprintf.h" | 9 #include "base/stringprintf.h" |
| 10 #include "chrome/browser/download/download_shelf.h" | 10 #include "chrome/browser/download/download_shelf.h" |
| 11 #include "chrome/browser/profiles/profile.h" | 11 #include "chrome/browser/profiles/profile.h" |
| 12 #include "chrome/browser/signin/signin_manager.h" |
| 12 #include "chrome/browser/sync/profile_sync_service.h" | 13 #include "chrome/browser/sync/profile_sync_service.h" |
| 13 #include "chrome/browser/sync/profile_sync_service_factory.h" | 14 #include "chrome/browser/sync/profile_sync_service_factory.h" |
| 14 #include "chrome/browser/ui/browser.h" | 15 #include "chrome/browser/ui/browser.h" |
| 15 #include "chrome/browser/ui/browser_finder.h" | 16 #include "chrome/browser/ui/browser_finder.h" |
| 16 #include "chrome/browser/ui/browser_navigator.h" | 17 #include "chrome/browser/ui/browser_navigator.h" |
| 17 #include "chrome/browser/ui/browser_window.h" | 18 #include "chrome/browser/ui/browser_window.h" |
| 18 #include "chrome/browser/ui/singleton_tabs.h" | 19 #include "chrome/browser/ui/singleton_tabs.h" |
| 19 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 20 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 20 #include "chrome/browser/ui/webui/options/content_settings_handler.h" | 21 #include "chrome/browser/ui/webui/options/content_settings_handler.h" |
| 21 #include "chrome/browser/ui/webui/signin/login_ui_service.h" | 22 #include "chrome/browser/ui/webui/signin/login_ui_service.h" |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 GetSingletonTabNavigateParams(browser, GURL(kChromeUIUberURL))); | 175 GetSingletonTabNavigateParams(browser, GURL(kChromeUIUberURL))); |
| 175 params.path_behavior = NavigateParams::IGNORE_AND_NAVIGATE; | 176 params.path_behavior = NavigateParams::IGNORE_AND_NAVIGATE; |
| 176 ShowSingletonTabOverwritingNTP(browser, params); | 177 ShowSingletonTabOverwritingNTP(browser, params); |
| 177 } | 178 } |
| 178 | 179 |
| 179 void ShowSearchEngineSettings(Browser* browser) { | 180 void ShowSearchEngineSettings(Browser* browser) { |
| 180 content::RecordAction(UserMetricsAction("EditSearchEngines")); | 181 content::RecordAction(UserMetricsAction("EditSearchEngines")); |
| 181 ShowSettingsSubPage(browser, kSearchEnginesSubPage); | 182 ShowSettingsSubPage(browser, kSearchEnginesSubPage); |
| 182 } | 183 } |
| 183 | 184 |
| 184 void ShowSyncSetup(Browser* browser, SyncPromoUI::Source source) { | 185 void ShowBrowserSignin(Browser* browser, SyncPromoUI::Source source) { |
| 185 Profile* original_profile = browser->profile()->GetOriginalProfile(); | 186 Profile* original_profile = browser->profile()->GetOriginalProfile(); |
| 186 ProfileSyncService* service = | 187 ProfileSyncService* service = |
| 187 ProfileSyncServiceFactory::GetInstance()->GetForProfile( | 188 ProfileSyncServiceFactory::GetInstance()->GetForProfile( |
| 188 original_profile); | 189 original_profile); |
| 189 if (service->HasSyncSetupCompleted()) { | 190 // If we're signed in, just show settings. |
| 191 if (!service->signin()->GetAuthenticatedUsername().empty()) { |
| 190 ShowSettings(browser); | 192 ShowSettings(browser); |
| 191 } else { | 193 } else { |
| 192 // If the browser's profile is an incognito profile, make sure to use | 194 // If the browser's profile is an incognito profile, make sure to use |
| 193 // a browser window from the original profile. The user cannot sign in | 195 // a browser window from the original profile. The user cannot sign in |
| 194 // from an incognito window. | 196 // from an incognito window. |
| 195 if (browser->profile()->IsOffTheRecord()) { | 197 if (browser->profile()->IsOffTheRecord()) { |
| 196 browser = | 198 browser = |
| 197 chrome::FindOrCreateTabbedBrowser(original_profile, | 199 chrome::FindOrCreateTabbedBrowser(original_profile, |
| 198 chrome::HOST_DESKTOP_TYPE_NATIVE); | 200 chrome::HOST_DESKTOP_TYPE_NATIVE); |
| 199 } | 201 } |
| (...skipping 28 matching lines...) Expand all Loading... |
| 228 GURL url(GaiaUrls::GetInstance()->service_login_url()); | 230 GURL url(GaiaUrls::GetInstance()->service_login_url()); |
| 229 url = chrome_common_net::AppendQueryParameter(url, "service", service); | 231 url = chrome_common_net::AppendQueryParameter(url, "service", service); |
| 230 if (continue_url.is_valid()) | 232 if (continue_url.is_valid()) |
| 231 url = chrome_common_net::AppendQueryParameter(url, | 233 url = chrome_common_net::AppendQueryParameter(url, |
| 232 "continue", | 234 "continue", |
| 233 continue_url.spec()); | 235 continue_url.spec()); |
| 234 NavigateToSingletonTab(browser, url); | 236 NavigateToSingletonTab(browser, url); |
| 235 } | 237 } |
| 236 | 238 |
| 237 } // namespace chrome | 239 } // namespace chrome |
| OLD | NEW |