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/new_tab_sync_setup_handler.h" | 5 #include "chrome/browser/ui/webui/ntp/new_tab_sync_setup_handler.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/values.h" | 8 #include "base/values.h" |
9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
10 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 string16 short_product_name = | 135 string16 short_product_name = |
136 l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME); | 136 l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME); |
137 status_msg = l10n_util::GetStringFUTF16(IDS_SYNC_STATUS_CONNECTED, | 137 status_msg = l10n_util::GetStringFUTF16(IDS_SYNC_STATUS_CONNECTED, |
138 short_product_name, | 138 short_product_name, |
139 UTF8ToUTF16(username)); | 139 UTF8ToUTF16(username)); |
140 } | 140 } |
141 StringValue status_msg_value(status_msg); | 141 StringValue status_msg_value(status_msg); |
142 | 142 |
143 std::string icon_url; | 143 std::string icon_url; |
144 ProfileInfoCache& cache = | 144 ProfileInfoCache& cache = |
145 g_browser_process->profile_manager()->GetMutableProfileInfo(); | 145 g_browser_process->profile_manager()->GetProfileInfoCache(); |
146 if (cache.GetNumberOfProfiles() > 1) { | 146 if (cache.GetNumberOfProfiles() > 1) { |
147 size_t index = cache.GetIndexOfProfileWithPath( | 147 size_t index = cache.GetIndexOfProfileWithPath( |
148 Profile::FromWebUI(web_ui_)->GetPath()); | 148 Profile::FromWebUI(web_ui_)->GetPath()); |
149 if (index != std::string::npos) { | 149 if (index != std::string::npos) { |
150 size_t icon_index = cache.GetAvatarIconIndexOfProfileAtIndex(index); | 150 size_t icon_index = cache.GetAvatarIconIndexOfProfileAtIndex(index); |
151 icon_url = ProfileInfoCache::GetDefaultAvatarIconUrl(icon_index); | 151 icon_url = ProfileInfoCache::GetDefaultAvatarIconUrl(icon_index); |
152 } | 152 } |
153 } | 153 } |
154 StringValue icon_url_value(icon_url); | 154 StringValue icon_url_value(icon_url); |
155 | 155 |
156 // If the user isn't signed in then make the login text clickable so that | 156 // If the user isn't signed in then make the login text clickable so that |
157 // users can click on it to expand the sync promo. Otherwise, if the user | 157 // users can click on it to expand the sync promo. Otherwise, if the user |
158 // has multiple profiles then clicking on it should show the profiles menu. | 158 // has multiple profiles then clicking on it should show the profiles menu. |
159 base::FundamentalValue is_clickable_value( | 159 base::FundamentalValue is_clickable_value( |
160 username.empty() || cache.GetNumberOfProfiles() > 1); | 160 username.empty() || cache.GetNumberOfProfiles() > 1); |
161 | 161 |
162 base::FundamentalValue is_signed_in_value(!username.empty()); | 162 base::FundamentalValue is_signed_in_value(!username.empty()); |
163 web_ui_->CallJavascriptFunction("new_tab.NewTabSyncPromo.updateLogin", | 163 web_ui_->CallJavascriptFunction("new_tab.NewTabSyncPromo.updateLogin", |
164 status_msg_value, icon_url_value, | 164 status_msg_value, icon_url_value, |
165 is_signed_in_value, is_clickable_value); | 165 is_signed_in_value, is_clickable_value); |
166 } | 166 } |
167 | 167 |
168 void NewTabSyncSetupHandler::SaveExpandedPreference(bool is_expanded) { | 168 void NewTabSyncSetupHandler::SaveExpandedPreference(bool is_expanded) { |
169 Profile* profile = Profile::FromWebUI(web_ui_); | 169 Profile* profile = Profile::FromWebUI(web_ui_); |
170 profile->GetPrefs()->SetBoolean(prefs::kSyncPromoExpanded, is_expanded); | 170 profile->GetPrefs()->SetBoolean(prefs::kSyncPromoExpanded, is_expanded); |
171 profile->GetPrefs()->ScheduleSavePersistentPrefs(); | 171 profile->GetPrefs()->ScheduleSavePersistentPrefs(); |
172 } | 172 } |
OLD | NEW |