| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 11 matching lines...) Expand all Loading... |
| 22 #include "chrome/browser/ui/browser_list.h" | 22 #include "chrome/browser/ui/browser_list.h" |
| 23 #include "chrome/browser/ui/browser_window.h" | 23 #include "chrome/browser/ui/browser_window.h" |
| 24 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 24 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
| 25 #include "chrome/browser/ui/webui/sync_promo_ui.h" | 25 #include "chrome/browser/ui/webui/sync_promo_ui.h" |
| 26 #include "chrome/browser/web_resource/promo_resource_service.h" | 26 #include "chrome/browser/web_resource/promo_resource_service.h" |
| 27 #include "chrome/common/chrome_notification_types.h" | 27 #include "chrome/common/chrome_notification_types.h" |
| 28 #include "chrome/common/pref_names.h" | 28 #include "chrome/common/pref_names.h" |
| 29 #include "chrome/common/url_constants.h" | 29 #include "chrome/common/url_constants.h" |
| 30 #include "content/browser/tab_contents/tab_contents.h" | 30 #include "content/browser/tab_contents/tab_contents.h" |
| 31 #include "content/public/browser/notification_details.h" | 31 #include "content/public/browser/notification_details.h" |
| 32 #include "content/public/browser/notification_service.h" |
| 32 #include "grit/chromium_strings.h" | 33 #include "grit/chromium_strings.h" |
| 33 #include "grit/generated_resources.h" | 34 #include "grit/generated_resources.h" |
| 34 #include "ui/base/l10n/l10n_util.h" | 35 #include "ui/base/l10n/l10n_util.h" |
| 35 | 36 |
| 36 NTPLoginHandler::NTPLoginHandler() { | 37 NTPLoginHandler::NTPLoginHandler() { |
| 37 } | 38 } |
| 38 | 39 |
| 39 NTPLoginHandler::~NTPLoginHandler() { | 40 NTPLoginHandler::~NTPLoginHandler() { |
| 40 } | 41 } |
| 41 | 42 |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 NOTREACHED(); | 119 NOTREACHED(); |
| 119 } else { | 120 } else { |
| 120 UMA_HISTOGRAM_ENUMERATION("SyncPromo.NTPPromo", type, | 121 UMA_HISTOGRAM_ENUMERATION("SyncPromo.NTPPromo", type, |
| 121 NTP_SIGN_IN_PROMO_BUCKET_BOUNDARY); | 122 NTP_SIGN_IN_PROMO_BUCKET_BOUNDARY); |
| 122 } | 123 } |
| 123 } | 124 } |
| 124 | 125 |
| 125 void NTPLoginHandler::HandleLoginMessageSeen(const ListValue* args) { | 126 void NTPLoginHandler::HandleLoginMessageSeen(const ListValue* args) { |
| 126 Profile::FromWebUI(web_ui_)->GetPrefs()->SetBoolean( | 127 Profile::FromWebUI(web_ui_)->GetPrefs()->SetBoolean( |
| 127 prefs::kSyncPromoShowNTPBubble, false); | 128 prefs::kSyncPromoShowNTPBubble, false); |
| 129 |
| 130 content::NotificationService* service = |
| 131 content::NotificationService::current(); |
| 132 service->Notify(chrome::NTP4_SYNC_PROMO_SHOW_NTP_BUBBLE_CHANGED, |
| 133 content::Source<NTPLoginHandler>(this), |
| 134 content::NotificationService::NoDetails()); |
| 128 } | 135 } |
| 129 | 136 |
| 130 void NTPLoginHandler::HandleShowAdvancedLoginUI(const ListValue* args) { | 137 void NTPLoginHandler::HandleShowAdvancedLoginUI(const ListValue* args) { |
| 131 Profile::FromWebUI(web_ui_)->GetProfileSyncService()->ShowConfigure(false); | 138 Profile::FromWebUI(web_ui_)->GetProfileSyncService()->ShowConfigure(false); |
| 132 } | 139 } |
| 133 | 140 |
| 134 void NTPLoginHandler::UpdateLogin() { | 141 void NTPLoginHandler::UpdateLogin() { |
| 135 Profile* profile = Profile::FromWebUI(web_ui_); | 142 Profile* profile = Profile::FromWebUI(web_ui_); |
| 136 std::string username = profile->GetPrefs()->GetString( | 143 std::string username = profile->GetPrefs()->GetString( |
| 137 prefs::kGoogleServicesUsername); | 144 prefs::kGoogleServicesUsername); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 if (profile->IsOffTheRecord()) | 178 if (profile->IsOffTheRecord()) |
| 172 return false; | 179 return false; |
| 173 | 180 |
| 174 return profile->GetOriginalProfile()->IsSyncAccessible(); | 181 return profile->GetOriginalProfile()->IsSyncAccessible(); |
| 175 #endif | 182 #endif |
| 176 } | 183 } |
| 177 | 184 |
| 178 // static | 185 // static |
| 179 void NTPLoginHandler::GetLocalizedValues(Profile* profile, | 186 void NTPLoginHandler::GetLocalizedValues(Profile* profile, |
| 180 DictionaryValue* values) { | 187 DictionaryValue* values) { |
| 188 // Always set the URL to prevent i18n missing value errors. |
| 189 values->SetString("login_status_url", |
| 190 google_util::StringAppendGoogleLocaleParam(chrome::kSyncLearnMoreURL)); |
| 191 |
| 181 PrefService* prefs = profile->GetPrefs(); | 192 PrefService* prefs = profile->GetPrefs(); |
| 182 if (prefs->GetString(prefs::kGoogleServicesUsername).empty() || | 193 if (prefs->GetString(prefs::kGoogleServicesUsername).empty() || |
| 183 !prefs->GetBoolean(prefs::kSyncPromoShowNTPBubble)) { | 194 !prefs->GetBoolean(prefs::kSyncPromoShowNTPBubble)) { |
| 184 return; | 195 return; |
| 185 } | 196 } |
| 186 | 197 |
| 187 values->SetString("login_status_message", | 198 values->SetString("login_status_message", |
| 188 l10n_util::GetStringFUTF16(IDS_SYNC_PROMO_NTP_BUBBLE_MESSAGE, | 199 l10n_util::GetStringFUTF16(IDS_SYNC_PROMO_NTP_BUBBLE_MESSAGE, |
| 189 l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME))); | 200 l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME))); |
| 190 values->SetString("login_status_url", | |
| 191 google_util::StringAppendGoogleLocaleParam(chrome::kSyncLearnMoreURL)); | |
| 192 values->SetString("login_status_learn_more", | 201 values->SetString("login_status_learn_more", |
| 193 l10n_util::GetStringUTF16(IDS_LEARN_MORE)); | 202 l10n_util::GetStringUTF16(IDS_LEARN_MORE)); |
| 194 values->SetString("login_status_advanced", | 203 values->SetString("login_status_advanced", |
| 195 l10n_util::GetStringUTF16(IDS_SYNC_PROMO_NTP_BUBBLE_ADVANCED)); | 204 l10n_util::GetStringUTF16(IDS_SYNC_PROMO_NTP_BUBBLE_ADVANCED)); |
| 196 values->SetString("login_status_dismiss", | 205 values->SetString("login_status_dismiss", |
| 197 l10n_util::GetStringUTF16(IDS_SYNC_PROMO_NTP_BUBBLE_OK)); | 206 l10n_util::GetStringUTF16(IDS_SYNC_PROMO_NTP_BUBBLE_OK)); |
| 198 } | 207 } |
| OLD | NEW |