| 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 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 profile_name_dict.SetBoolean(UTF16ToUTF8(cache.GetNameOfProfileAtIndex(i)), | 134 profile_name_dict.SetBoolean(UTF16ToUTF8(cache.GetNameOfProfileAtIndex(i)), |
| 135 true); | 135 true); |
| 136 | 136 |
| 137 web_ui()->CallJavascriptFunction("ManageProfileOverlay.receiveProfileNames", | 137 web_ui()->CallJavascriptFunction("ManageProfileOverlay.receiveProfileNames", |
| 138 profile_name_dict); | 138 profile_name_dict); |
| 139 } | 139 } |
| 140 | 140 |
| 141 void ManageProfileHandler::SetProfileNameAndIcon(const ListValue* args) { | 141 void ManageProfileHandler::SetProfileNameAndIcon(const ListValue* args) { |
| 142 DCHECK(args); | 142 DCHECK(args); |
| 143 | 143 |
| 144 Value* file_path_value; | 144 const Value* file_path_value; |
| 145 FilePath profile_file_path; | 145 FilePath profile_file_path; |
| 146 if (!args->Get(0, &file_path_value) || | 146 if (!args->Get(0, &file_path_value) || |
| 147 !base::GetValueAsFilePath(*file_path_value, &profile_file_path)) | 147 !base::GetValueAsFilePath(*file_path_value, &profile_file_path)) |
| 148 return; | 148 return; |
| 149 | 149 |
| 150 ProfileInfoCache& cache = | 150 ProfileInfoCache& cache = |
| 151 g_browser_process->profile_manager()->GetProfileInfoCache(); | 151 g_browser_process->profile_manager()->GetProfileInfoCache(); |
| 152 size_t profile_index = cache.GetIndexOfProfileWithPath(profile_file_path); | 152 size_t profile_index = cache.GetIndexOfProfileWithPath(profile_file_path); |
| 153 if (profile_index == std::string::npos) | 153 if (profile_index == std::string::npos) |
| 154 return; | 154 return; |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 | 221 |
| 222 void ManageProfileHandler::DeleteProfile(const ListValue* args) { | 222 void ManageProfileHandler::DeleteProfile(const ListValue* args) { |
| 223 DCHECK(args); | 223 DCHECK(args); |
| 224 // This handler could have been called in managed mode, for example because | 224 // This handler could have been called in managed mode, for example because |
| 225 // the user fiddled with the web inspector. Silently return in this case. | 225 // the user fiddled with the web inspector. Silently return in this case. |
| 226 if (!ProfileManager::IsMultipleProfilesEnabled()) | 226 if (!ProfileManager::IsMultipleProfilesEnabled()) |
| 227 return; | 227 return; |
| 228 | 228 |
| 229 ProfileMetrics::LogProfileDeleteUser(ProfileMetrics::PROFILE_DELETED); | 229 ProfileMetrics::LogProfileDeleteUser(ProfileMetrics::PROFILE_DELETED); |
| 230 | 230 |
| 231 Value* file_path_value; | 231 const Value* file_path_value; |
| 232 FilePath profile_file_path; | 232 FilePath profile_file_path; |
| 233 if (!args->Get(0, &file_path_value) || | 233 if (!args->Get(0, &file_path_value) || |
| 234 !base::GetValueAsFilePath(*file_path_value, &profile_file_path)) | 234 !base::GetValueAsFilePath(*file_path_value, &profile_file_path)) |
| 235 return; | 235 return; |
| 236 | 236 |
| 237 g_browser_process->profile_manager()->ScheduleProfileForDeletion( | 237 g_browser_process->profile_manager()->ScheduleProfileForDeletion( |
| 238 profile_file_path); | 238 profile_file_path); |
| 239 } | 239 } |
| 240 | 240 |
| 241 void ManageProfileHandler::ProfileIconSelectionChanged( | 241 void ManageProfileHandler::ProfileIconSelectionChanged( |
| 242 const base::ListValue* args) { | 242 const base::ListValue* args) { |
| 243 DCHECK(args); | 243 DCHECK(args); |
| 244 | 244 |
| 245 Value* file_path_value; | 245 const Value* file_path_value; |
| 246 FilePath file_path; | 246 FilePath file_path; |
| 247 if (!args->Get(0, &file_path_value) || | 247 if (!args->Get(0, &file_path_value) || |
| 248 !base::GetValueAsFilePath(*file_path_value, &file_path)) { | 248 !base::GetValueAsFilePath(*file_path_value, &file_path)) { |
| 249 return; | 249 return; |
| 250 } | 250 } |
| 251 | 251 |
| 252 // Currently this only supports editing the current profile's info. | 252 // Currently this only supports editing the current profile's info. |
| 253 if (file_path != Profile::FromWebUI(web_ui())->GetPath()) | 253 if (file_path != Profile::FromWebUI(web_ui())->GetPath()) |
| 254 return; | 254 return; |
| 255 | 255 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 270 string16 gaia_name = cache.GetGAIANameOfProfileAtIndex(i); | 270 string16 gaia_name = cache.GetGAIANameOfProfileAtIndex(i); |
| 271 if (gaia_name.empty()) | 271 if (gaia_name.empty()) |
| 272 return; | 272 return; |
| 273 | 273 |
| 274 StringValue gaia_name_value(gaia_name); | 274 StringValue gaia_name_value(gaia_name); |
| 275 web_ui()->CallJavascriptFunction("ManageProfileOverlay.setProfileName", | 275 web_ui()->CallJavascriptFunction("ManageProfileOverlay.setProfileName", |
| 276 gaia_name_value); | 276 gaia_name_value); |
| 277 } | 277 } |
| 278 | 278 |
| 279 } // namespace options2 | 279 } // namespace options2 |
| OLD | NEW |