OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/settings/settings_manage_profile_handler.h" | 5 #include "chrome/browser/ui/webui/settings/settings_manage_profile_handler.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 } | 85 } |
86 | 86 |
87 void ManageProfileHandler::OnJavascriptDisallowed() { | 87 void ManageProfileHandler::OnJavascriptDisallowed() { |
88 observer_.RemoveAll(); | 88 observer_.RemoveAll(); |
89 } | 89 } |
90 | 90 |
91 void ManageProfileHandler::OnProfileAvatarChanged( | 91 void ManageProfileHandler::OnProfileAvatarChanged( |
92 const base::FilePath& profile_path) { | 92 const base::FilePath& profile_path) { |
93 // This is necessary to send the potentially updated GAIA photo. | 93 // This is necessary to send the potentially updated GAIA photo. |
94 CallJavascriptFunction("cr.webUIListenerCallback", | 94 CallJavascriptFunction("cr.webUIListenerCallback", |
95 base::StringValue("available-icons-changed"), | 95 base::Value("available-icons-changed"), |
96 *GetAvailableIcons()); | 96 *GetAvailableIcons()); |
97 } | 97 } |
98 | 98 |
99 void ManageProfileHandler::HandleGetAvailableIcons( | 99 void ManageProfileHandler::HandleGetAvailableIcons( |
100 const base::ListValue* args) { | 100 const base::ListValue* args) { |
101 AllowJavascript(); | 101 AllowJavascript(); |
102 | 102 |
103 profiles::UpdateGaiaProfileInfoIfNeeded(profile_); | 103 profiles::UpdateGaiaProfileInfoIfNeeded(profile_); |
104 | 104 |
105 CHECK_EQ(1U, args->GetSize()); | 105 CHECK_EQ(1U, args->GetSize()); |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 DCHECK(ProfileShortcutManager::IsFeatureEnabled()); | 187 DCHECK(ProfileShortcutManager::IsFeatureEnabled()); |
188 | 188 |
189 CHECK_EQ(1U, args->GetSize()); | 189 CHECK_EQ(1U, args->GetSize()); |
190 std::string callback_id; | 190 std::string callback_id; |
191 CHECK(args->GetString(0, &callback_id)); | 191 CHECK(args->GetString(0, &callback_id)); |
192 | 192 |
193 // Don't show the add/remove desktop shortcut button in the single user case. | 193 // Don't show the add/remove desktop shortcut button in the single user case. |
194 ProfileAttributesStorage& storage = | 194 ProfileAttributesStorage& storage = |
195 g_browser_process->profile_manager()->GetProfileAttributesStorage(); | 195 g_browser_process->profile_manager()->GetProfileAttributesStorage(); |
196 if (storage.GetNumberOfProfiles() <= 1u) { | 196 if (storage.GetNumberOfProfiles() <= 1u) { |
197 ResolveJavascriptCallback(base::StringValue(callback_id), | 197 ResolveJavascriptCallback(base::Value(callback_id), |
198 base::StringValue(kProfileShortcutSettingHidden)); | 198 base::Value(kProfileShortcutSettingHidden)); |
199 return; | 199 return; |
200 } | 200 } |
201 | 201 |
202 ProfileShortcutManager* shortcut_manager = | 202 ProfileShortcutManager* shortcut_manager = |
203 g_browser_process->profile_manager()->profile_shortcut_manager(); | 203 g_browser_process->profile_manager()->profile_shortcut_manager(); |
204 DCHECK(shortcut_manager); | 204 DCHECK(shortcut_manager); |
205 shortcut_manager->HasProfileShortcuts( | 205 shortcut_manager->HasProfileShortcuts( |
206 profile_->GetPath(), | 206 profile_->GetPath(), |
207 base::Bind(&ManageProfileHandler::OnHasProfileShortcuts, | 207 base::Bind(&ManageProfileHandler::OnHasProfileShortcuts, |
208 weak_factory_.GetWeakPtr(), callback_id)); | 208 weak_factory_.GetWeakPtr(), callback_id)); |
209 } | 209 } |
210 | 210 |
211 void ManageProfileHandler::OnHasProfileShortcuts( | 211 void ManageProfileHandler::OnHasProfileShortcuts( |
212 const std::string& callback_id, bool has_shortcuts) { | 212 const std::string& callback_id, bool has_shortcuts) { |
213 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 213 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
214 ResolveJavascriptCallback( | 214 ResolveJavascriptCallback( |
215 base::StringValue(callback_id), | 215 base::Value(callback_id), |
216 base::StringValue(has_shortcuts ? kProfileShortcutFound | 216 base::Value(has_shortcuts ? kProfileShortcutFound |
217 : kProfileShortcutNotFound)); | 217 : kProfileShortcutNotFound)); |
218 } | 218 } |
219 | 219 |
220 void ManageProfileHandler::HandleAddProfileShortcut( | 220 void ManageProfileHandler::HandleAddProfileShortcut( |
221 const base::ListValue* args) { | 221 const base::ListValue* args) { |
222 DCHECK(ProfileShortcutManager::IsFeatureEnabled()); | 222 DCHECK(ProfileShortcutManager::IsFeatureEnabled()); |
223 ProfileShortcutManager* shortcut_manager = | 223 ProfileShortcutManager* shortcut_manager = |
224 g_browser_process->profile_manager()->profile_shortcut_manager(); | 224 g_browser_process->profile_manager()->profile_shortcut_manager(); |
225 DCHECK(shortcut_manager); | 225 DCHECK(shortcut_manager); |
226 | 226 |
227 shortcut_manager->CreateProfileShortcut(profile_->GetPath()); | 227 shortcut_manager->CreateProfileShortcut(profile_->GetPath()); |
228 } | 228 } |
229 | 229 |
230 void ManageProfileHandler::HandleRemoveProfileShortcut( | 230 void ManageProfileHandler::HandleRemoveProfileShortcut( |
231 const base::ListValue* args) { | 231 const base::ListValue* args) { |
232 DCHECK(ProfileShortcutManager::IsFeatureEnabled()); | 232 DCHECK(ProfileShortcutManager::IsFeatureEnabled()); |
233 ProfileShortcutManager* shortcut_manager = | 233 ProfileShortcutManager* shortcut_manager = |
234 g_browser_process->profile_manager()->profile_shortcut_manager(); | 234 g_browser_process->profile_manager()->profile_shortcut_manager(); |
235 DCHECK(shortcut_manager); | 235 DCHECK(shortcut_manager); |
236 | 236 |
237 shortcut_manager->RemoveProfileShortcuts(profile_->GetPath()); | 237 shortcut_manager->RemoveProfileShortcuts(profile_->GetPath()); |
238 } | 238 } |
239 | 239 |
240 } // namespace settings | 240 } // namespace settings |
OLD | NEW |