| 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/webui/ntp/ntp_login_handler.h" | 5 #include "chrome/browser/ui/webui/ntp/ntp_login_handler.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 void NTPLoginHandler::HandleShowSyncLoginUI(const base::ListValue* args) { | 125 void NTPLoginHandler::HandleShowSyncLoginUI(const base::ListValue* args) { |
| 126 Profile* profile = Profile::FromWebUI(web_ui()); | 126 Profile* profile = Profile::FromWebUI(web_ui()); |
| 127 std::string username = profile->GetPrefs()->GetString( | 127 std::string username = profile->GetPrefs()->GetString( |
| 128 prefs::kGoogleServicesUsername); | 128 prefs::kGoogleServicesUsername); |
| 129 content::WebContents* web_contents = web_ui()->GetWebContents(); | 129 content::WebContents* web_contents = web_ui()->GetWebContents(); |
| 130 Browser* browser = chrome::FindBrowserWithWebContents(web_contents); | 130 Browser* browser = chrome::FindBrowserWithWebContents(web_contents); |
| 131 if (!browser) | 131 if (!browser) |
| 132 return; | 132 return; |
| 133 | 133 |
| 134 if (username.empty()) { | 134 if (username.empty()) { |
| 135 #if !defined(OS_ANDROID) |
| 135 // The user isn't signed in, show the sign in promo. | 136 // The user isn't signed in, show the sign in promo. |
| 136 if (signin::ShouldShowPromo(profile)) { | 137 if (signin::ShouldShowPromo(profile)) { |
| 137 signin::Source source = | 138 signin::Source source = |
| 138 (web_contents->GetURL().spec() == chrome::kChromeUIAppsURL) ? | 139 (web_contents->GetURL().spec() == chrome::kChromeUIAppsURL) ? |
| 139 signin::SOURCE_APPS_PAGE_LINK : | 140 signin::SOURCE_APPS_PAGE_LINK : |
| 140 signin::SOURCE_NTP_LINK; | 141 signin::SOURCE_NTP_LINK; |
| 141 chrome::ShowBrowserSignin(browser, source); | 142 chrome::ShowBrowserSignin(browser, source); |
| 142 RecordInHistogram(NTP_SIGN_IN_PROMO_CLICKED); | 143 RecordInHistogram(NTP_SIGN_IN_PROMO_CLICKED); |
| 143 } | 144 } |
| 145 #endif |
| 144 } else if (args->GetSize() == 4) { | 146 } else if (args->GetSize() == 4) { |
| 145 // The user is signed in, show the profiles menu. | 147 // The user is signed in, show the profiles menu. |
| 146 double x = 0; | 148 double x = 0; |
| 147 double y = 0; | 149 double y = 0; |
| 148 double width = 0; | 150 double width = 0; |
| 149 double height = 0; | 151 double height = 0; |
| 150 bool success = args->GetDouble(0, &x); | 152 bool success = args->GetDouble(0, &x); |
| 151 DCHECK(success); | 153 DCHECK(success); |
| 152 success = args->GetDouble(1, &y); | 154 success = args->GetDouble(1, &y); |
| 153 DCHECK(success); | 155 DCHECK(success); |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 cache.GetGAIAPictureOfProfileAtIndex(profile_index); | 216 cache.GetGAIAPictureOfProfileAtIndex(profile_index); |
| 215 if (image) | 217 if (image) |
| 216 icon_url = webui::GetBitmapDataUrl(GetGAIAPictureForNTP(*image)); | 218 icon_url = webui::GetBitmapDataUrl(GetGAIAPictureForNTP(*image)); |
| 217 } | 219 } |
| 218 if (header.empty()) { | 220 if (header.empty()) { |
| 219 header = CreateSpanWithClass(base::UTF8ToUTF16(username), | 221 header = CreateSpanWithClass(base::UTF8ToUTF16(username), |
| 220 "profile-name"); | 222 "profile-name"); |
| 221 } | 223 } |
| 222 } | 224 } |
| 223 } else { | 225 } else { |
| 224 #if !defined(OS_CHROMEOS) | 226 #if !defined(OS_ANDROID) && !defined(OS_CHROMEOS) |
| 225 // Chromeos does not show this status header. | 227 // Android uses a custom sign in promo. Don't call the function |
| 228 // signin::ShouldShowPromo() since it does a bunch of checks that are not |
| 229 // required here. We only want to suppress this login status for users that |
| 230 // are not allowed to sign in. Chromeos does not show this status header |
| 231 // at all. |
| 226 SigninManager* signin = SigninManagerFactory::GetForProfile( | 232 SigninManager* signin = SigninManagerFactory::GetForProfile( |
| 227 profile->GetOriginalProfile()); | 233 profile->GetOriginalProfile()); |
| 228 if (!profile->IsManaged() && signin->IsSigninAllowed()) { | 234 if (!profile->IsManaged() && signin->IsSigninAllowed()) { |
| 229 base::string16 signed_in_link = l10n_util::GetStringUTF16( | 235 base::string16 signed_in_link = l10n_util::GetStringUTF16( |
| 230 IDS_SYNC_PROMO_NOT_SIGNED_IN_STATUS_LINK); | 236 IDS_SYNC_PROMO_NOT_SIGNED_IN_STATUS_LINK); |
| 231 signed_in_link = CreateSpanWithClass(signed_in_link, "link-span"); | 237 signed_in_link = CreateSpanWithClass(signed_in_link, "link-span"); |
| 232 header = l10n_util::GetStringFUTF16( | 238 header = l10n_util::GetStringFUTF16( |
| 233 IDS_SYNC_PROMO_NOT_SIGNED_IN_STATUS_HEADER, | 239 IDS_SYNC_PROMO_NOT_SIGNED_IN_STATUS_HEADER, |
| 234 l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME)); | 240 l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME)); |
| 235 sub_header = l10n_util::GetStringFUTF16( | 241 sub_header = l10n_util::GetStringFUTF16( |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 273 values->SetString("login_status_message", message); | 279 values->SetString("login_status_message", message); |
| 274 values->SetString("login_status_url", | 280 values->SetString("login_status_url", |
| 275 hide_sync ? std::string() : chrome::kSyncLearnMoreURL); | 281 hide_sync ? std::string() : chrome::kSyncLearnMoreURL); |
| 276 values->SetString("login_status_advanced", | 282 values->SetString("login_status_advanced", |
| 277 hide_sync ? base::string16() : | 283 hide_sync ? base::string16() : |
| 278 l10n_util::GetStringUTF16(IDS_SYNC_PROMO_NTP_BUBBLE_ADVANCED)); | 284 l10n_util::GetStringUTF16(IDS_SYNC_PROMO_NTP_BUBBLE_ADVANCED)); |
| 279 values->SetString("login_status_dismiss", | 285 values->SetString("login_status_dismiss", |
| 280 hide_sync ? base::string16() : | 286 hide_sync ? base::string16() : |
| 281 l10n_util::GetStringUTF16(IDS_SYNC_PROMO_NTP_BUBBLE_OK)); | 287 l10n_util::GetStringUTF16(IDS_SYNC_PROMO_NTP_BUBBLE_OK)); |
| 282 } | 288 } |
| OLD | NEW |