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/options2/manage_profile_handler.h" | 5 #include "chrome/browser/ui/webui/options2/manage_profile_handler.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/string_number_conversions.h" | 9 #include "base/string_number_conversions.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 profile_name_dict.SetBoolean(UTF16ToUTF8(cache.GetNameOfProfileAtIndex(i)), | 145 profile_name_dict.SetBoolean(UTF16ToUTF8(cache.GetNameOfProfileAtIndex(i)), |
146 true); | 146 true); |
147 | 147 |
148 web_ui()->CallJavascriptFunction("ManageProfileOverlay.receiveProfileNames", | 148 web_ui()->CallJavascriptFunction("ManageProfileOverlay.receiveProfileNames", |
149 profile_name_dict); | 149 profile_name_dict); |
150 } | 150 } |
151 | 151 |
152 void ManageProfileHandler::SetProfileNameAndIcon(const ListValue* args) { | 152 void ManageProfileHandler::SetProfileNameAndIcon(const ListValue* args) { |
153 DCHECK(args); | 153 DCHECK(args); |
154 | 154 |
155 Value* file_path_value; | 155 const Value* file_path_value; |
156 FilePath profile_file_path; | 156 FilePath profile_file_path; |
157 if (!args->Get(0, &file_path_value) || | 157 if (!args->Get(0, &file_path_value) || |
158 !base::GetValueAsFilePath(*file_path_value, &profile_file_path)) | 158 !base::GetValueAsFilePath(*file_path_value, &profile_file_path)) |
159 return; | 159 return; |
160 | 160 |
161 ProfileInfoCache& cache = | 161 ProfileInfoCache& cache = |
162 g_browser_process->profile_manager()->GetProfileInfoCache(); | 162 g_browser_process->profile_manager()->GetProfileInfoCache(); |
163 size_t profile_index = cache.GetIndexOfProfileWithPath(profile_file_path); | 163 size_t profile_index = cache.GetIndexOfProfileWithPath(profile_file_path); |
164 if (profile_index == std::string::npos) | 164 if (profile_index == std::string::npos) |
165 return; | 165 return; |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 | 232 |
233 void ManageProfileHandler::DeleteProfile(const ListValue* args) { | 233 void ManageProfileHandler::DeleteProfile(const ListValue* args) { |
234 DCHECK(args); | 234 DCHECK(args); |
235 // This handler could have been called in managed mode, for example because | 235 // This handler could have been called in managed mode, for example because |
236 // the user fiddled with the web inspector. Silently return in this case. | 236 // the user fiddled with the web inspector. Silently return in this case. |
237 if (!ProfileManager::IsMultipleProfilesEnabled()) | 237 if (!ProfileManager::IsMultipleProfilesEnabled()) |
238 return; | 238 return; |
239 | 239 |
240 ProfileMetrics::LogProfileDeleteUser(ProfileMetrics::PROFILE_DELETED); | 240 ProfileMetrics::LogProfileDeleteUser(ProfileMetrics::PROFILE_DELETED); |
241 | 241 |
242 Value* file_path_value; | 242 const Value* file_path_value; |
243 FilePath profile_file_path; | 243 FilePath profile_file_path; |
244 if (!args->Get(0, &file_path_value) || | 244 if (!args->Get(0, &file_path_value) || |
245 !base::GetValueAsFilePath(*file_path_value, &profile_file_path)) | 245 !base::GetValueAsFilePath(*file_path_value, &profile_file_path)) |
246 return; | 246 return; |
247 | 247 |
248 g_browser_process->profile_manager()->ScheduleProfileForDeletion( | 248 g_browser_process->profile_manager()->ScheduleProfileForDeletion( |
249 profile_file_path); | 249 profile_file_path); |
250 } | 250 } |
251 | 251 |
252 void ManageProfileHandler::ProfileIconSelectionChanged( | 252 void ManageProfileHandler::ProfileIconSelectionChanged( |
253 const base::ListValue* args) { | 253 const base::ListValue* args) { |
254 DCHECK(args); | 254 DCHECK(args); |
255 | 255 |
256 Value* file_path_value; | 256 const Value* file_path_value; |
257 FilePath file_path; | 257 FilePath file_path; |
258 if (!args->Get(0, &file_path_value) || | 258 if (!args->Get(0, &file_path_value) || |
259 !base::GetValueAsFilePath(*file_path_value, &file_path)) { | 259 !base::GetValueAsFilePath(*file_path_value, &file_path)) { |
260 return; | 260 return; |
261 } | 261 } |
262 | 262 |
263 // Currently this only supports editing the current profile's info. | 263 // Currently this only supports editing the current profile's info. |
264 if (file_path != Profile::FromWebUI(web_ui())->GetPath()) | 264 if (file_path != Profile::FromWebUI(web_ui())->GetPath()) |
265 return; | 265 return; |
266 | 266 |
(...skipping 14 matching lines...) Expand all Loading... |
281 string16 gaia_name = cache.GetGAIANameOfProfileAtIndex(i); | 281 string16 gaia_name = cache.GetGAIANameOfProfileAtIndex(i); |
282 if (gaia_name.empty()) | 282 if (gaia_name.empty()) |
283 return; | 283 return; |
284 | 284 |
285 StringValue gaia_name_value(gaia_name); | 285 StringValue gaia_name_value(gaia_name); |
286 web_ui()->CallJavascriptFunction("ManageProfileOverlay.setProfileName", | 286 web_ui()->CallJavascriptFunction("ManageProfileOverlay.setProfileName", |
287 gaia_name_value); | 287 gaia_name_value); |
288 } | 288 } |
289 | 289 |
290 } // namespace options2 | 290 } // namespace options2 |
OLD | NEW |