Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(97)

Side by Side Diff: chrome/browser/ui/webui/options/create_profile_handler.cc

Issue 1869473002: Fixed crash on double profile delete operation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Review fixes. Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/options/create_profile_handler.h" 5 #include "chrome/browser/ui/webui/options/create_profile_handler.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <vector> 9 #include <vector>
10 10
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 void CreateProfileHandler::ShowProfileCreationError( 225 void CreateProfileHandler::ShowProfileCreationError(
226 Profile* profile, 226 Profile* profile,
227 const base::string16& error) { 227 const base::string16& error) {
228 DCHECK_NE(NO_CREATION_IN_PROGRESS, profile_creation_type_); 228 DCHECK_NE(NO_CREATION_IN_PROGRESS, profile_creation_type_);
229 profile_creation_type_ = NO_CREATION_IN_PROGRESS; 229 profile_creation_type_ = NO_CREATION_IN_PROGRESS;
230 profile_path_being_created_.clear(); 230 profile_path_being_created_.clear();
231 web_ui()->CallJavascriptFunction( 231 web_ui()->CallJavascriptFunction(
232 GetJavascriptMethodName(PROFILE_CREATION_ERROR), 232 GetJavascriptMethodName(PROFILE_CREATION_ERROR),
233 base::StringValue(error)); 233 base::StringValue(error));
234 // The ProfileManager calls us back with a NULL profile in some cases. 234 // The ProfileManager calls us back with a NULL profile in some cases.
235 if (profile) 235 if (profile)
achuithb 2016/05/12 22:33:59 I believe you need {} in the multi-line case?
236 webui::DeleteProfileAtPath(profile->GetPath(), web_ui()); 236 webui::DeleteProfileAtPath(profile->GetPath(),
237 web_ui(),
238 ProfileMetrics::DELETE_PROFILE_SETTINGS);
237 } 239 }
238 240
239 void CreateProfileHandler::RecordProfileCreationMetrics( 241 void CreateProfileHandler::RecordProfileCreationMetrics(
240 Profile::CreateStatus status) { 242 Profile::CreateStatus status) {
241 UMA_HISTOGRAM_ENUMERATION("Profile.CreateResult", 243 UMA_HISTOGRAM_ENUMERATION("Profile.CreateResult",
242 status, 244 status,
243 Profile::MAX_CREATE_STATUS); 245 Profile::MAX_CREATE_STATUS);
244 UMA_HISTOGRAM_MEDIUM_TIMES( 246 UMA_HISTOGRAM_MEDIUM_TIMES(
245 "Profile.CreateTimeNoTimeout", 247 "Profile.CreateTimeNoTimeout",
246 base::TimeTicks::Now() - profile_creation_start_time_); 248 base::TimeTicks::Now() - profile_creation_start_time_);
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 base::TimeTicks::Now() - profile_creation_start_time_); 369 base::TimeTicks::Now() - profile_creation_start_time_);
368 RecordProfileCreationMetrics(Profile::CREATE_STATUS_CANCELED); 370 RecordProfileCreationMetrics(Profile::CREATE_STATUS_CANCELED);
369 } 371 }
370 372
371 DCHECK_NE(NO_CREATION_IN_PROGRESS, profile_creation_type_); 373 DCHECK_NE(NO_CREATION_IN_PROGRESS, profile_creation_type_);
372 profile_creation_type_ = NO_CREATION_IN_PROGRESS; 374 profile_creation_type_ = NO_CREATION_IN_PROGRESS;
373 375
374 // Cancelling registration means the callback passed into 376 // Cancelling registration means the callback passed into
375 // RegisterAndInitSync() won't be called, so the cleanup must be done here. 377 // RegisterAndInitSync() won't be called, so the cleanup must be done here.
376 profile_path_being_created_.clear(); 378 profile_path_being_created_.clear();
377 webui::DeleteProfileAtPath(new_profile->GetPath(), web_ui()); 379 webui::DeleteProfileAtPath(new_profile->GetPath(),
380 web_ui(),
381 ProfileMetrics::DELETE_PROFILE_SETTINGS);
378 } 382 }
379 383
380 void CreateProfileHandler::RegisterSupervisedUser( 384 void CreateProfileHandler::RegisterSupervisedUser(
381 bool create_shortcut, 385 bool create_shortcut,
382 const std::string& supervised_user_id, 386 const std::string& supervised_user_id,
383 Profile* new_profile) { 387 Profile* new_profile) {
384 DCHECK_EQ(profile_path_being_created_.value(), 388 DCHECK_EQ(profile_path_being_created_.value(),
385 new_profile->GetPath().value()); 389 new_profile->GetPath().value());
386 390
387 SupervisedUserService* supervised_user_service = 391 SupervisedUserService* supervised_user_service =
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
468 GetProfileAttributesStorage().GetAllProfilesAttributes(); 472 GetProfileAttributesStorage().GetAllProfilesAttributes();
469 for (const ProfileAttributesEntry* entry : entries) { 473 for (const ProfileAttributesEntry* entry : entries) {
470 if (existing_supervised_user_id == entry->GetSupervisedUserId()) 474 if (existing_supervised_user_id == entry->GetSupervisedUserId())
471 return false; 475 return false;
472 } 476 }
473 return true; 477 return true;
474 } 478 }
475 #endif 479 #endif
476 480
477 } // namespace options 481 } // namespace options
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698