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

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

Issue 1716163005: MD user manager (C++ for create profile flow) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 9 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
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/files/file_path.h" 12 #include "base/files/file_path.h"
13 #include "base/metrics/histogram.h" 13 #include "base/metrics/histogram.h"
14 #include "base/strings/string_util.h" 14 #include "base/strings/string_util.h"
15 #include "base/value_conversions.h" 15 #include "base/value_conversions.h"
16 #include "base/values.h" 16 #include "base/values.h"
17 #include "chrome/browser/browser_process.h" 17 #include "chrome/browser/browser_process.h"
18 #include "chrome/browser/profiles/profile_attributes_entry.h" 18 #include "chrome/browser/profiles/profile_attributes_entry.h"
19 #include "chrome/browser/profiles/profile_attributes_storage.h" 19 #include "chrome/browser/profiles/profile_attributes_storage.h"
20 #include "chrome/browser/profiles/profile_avatar_icon_util.h" 20 #include "chrome/browser/profiles/profile_avatar_icon_util.h"
21 #include "chrome/browser/profiles/profile_manager.h" 21 #include "chrome/browser/profiles/profile_manager.h"
22 #include "chrome/browser/profiles/profile_metrics.h" 22 #include "chrome/browser/profiles/profile_metrics.h"
23 #include "chrome/browser/profiles/profiles_state.h" 23 #include "chrome/browser/profiles/profiles_state.h"
24 #include "chrome/browser/sync/profile_sync_service_factory.h" 24 #include "chrome/browser/sync/profile_sync_service_factory.h"
25 #include "chrome/browser/ui/webui/options/options_handlers_helper.h" 25 #include "chrome/browser/ui/webui/profile_helper.h"
26 #include "chrome/common/pref_names.h" 26 #include "chrome/common/pref_names.h"
27 #include "chrome/grit/generated_resources.h" 27 #include "chrome/grit/generated_resources.h"
28 #include "components/browser_sync/browser/profile_sync_service.h" 28 #include "components/browser_sync/browser/profile_sync_service.h"
29 #include "components/prefs/pref_service.h" 29 #include "components/prefs/pref_service.h"
30 #include "content/public/browser/web_ui.h" 30 #include "content/public/browser/web_ui.h"
31 #include "ui/base/l10n/l10n_util.h" 31 #include "ui/base/l10n/l10n_util.h"
32 32
33 #if defined(ENABLE_SUPERVISED_USERS) 33 #if defined(ENABLE_SUPERVISED_USERS)
34 #include "chrome/browser/supervised_user/legacy/supervised_user_registration_uti lity.h" 34 #include "chrome/browser/supervised_user/legacy/supervised_user_registration_uti lity.h"
35 #include "chrome/browser/supervised_user/legacy/supervised_user_sync_service.h" 35 #include "chrome/browser/supervised_user/legacy/supervised_user_sync_service.h"
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 // the new window now. 210 // the new window now.
211 bool should_open_new_window = true; 211 bool should_open_new_window = true;
212 #if defined(ENABLE_SUPERVISED_USERS) 212 #if defined(ENABLE_SUPERVISED_USERS)
213 if (profile_creation_type_ == SUPERVISED_PROFILE_CREATION) 213 if (profile_creation_type_ == SUPERVISED_PROFILE_CREATION)
214 should_open_new_window = false; 214 should_open_new_window = false;
215 #endif 215 #endif
216 216
217 if (should_open_new_window) { 217 if (should_open_new_window) {
218 // Opening the new window must be the last action, after all callbacks 218 // Opening the new window must be the last action, after all callbacks
219 // have been run, to give them a chance to initialize the profile. 219 // have been run, to give them a chance to initialize the profile.
220 helper::OpenNewWindowForProfile(profile, 220 webui::OpenNewWindowForProfile(profile, Profile::CREATE_STATUS_INITIALIZED);
221 Profile::CREATE_STATUS_INITIALIZED);
222 } 221 }
223 profile_creation_type_ = NO_CREATION_IN_PROGRESS; 222 profile_creation_type_ = NO_CREATION_IN_PROGRESS;
224 } 223 }
225 224
226 void CreateProfileHandler::ShowProfileCreationError( 225 void CreateProfileHandler::ShowProfileCreationError(
227 Profile* profile, 226 Profile* profile,
228 const base::string16& error) { 227 const base::string16& error) {
229 DCHECK_NE(NO_CREATION_IN_PROGRESS, profile_creation_type_); 228 DCHECK_NE(NO_CREATION_IN_PROGRESS, profile_creation_type_);
230 profile_creation_type_ = NO_CREATION_IN_PROGRESS; 229 profile_creation_type_ = NO_CREATION_IN_PROGRESS;
231 profile_path_being_created_.clear(); 230 profile_path_being_created_.clear();
232 web_ui()->CallJavascriptFunction( 231 web_ui()->CallJavascriptFunction(
233 GetJavascriptMethodName(PROFILE_CREATION_ERROR), 232 GetJavascriptMethodName(PROFILE_CREATION_ERROR),
234 base::StringValue(error)); 233 base::StringValue(error));
235 // 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.
236 if (profile) 235 if (profile)
237 helper::DeleteProfileAtPath(profile->GetPath(), web_ui()); 236 webui::DeleteProfileAtPath(profile->GetPath(), web_ui());
238 } 237 }
239 238
240 void CreateProfileHandler::RecordProfileCreationMetrics( 239 void CreateProfileHandler::RecordProfileCreationMetrics(
241 Profile::CreateStatus status) { 240 Profile::CreateStatus status) {
242 UMA_HISTOGRAM_ENUMERATION("Profile.CreateResult", 241 UMA_HISTOGRAM_ENUMERATION("Profile.CreateResult",
243 status, 242 status,
244 Profile::MAX_CREATE_STATUS); 243 Profile::MAX_CREATE_STATUS);
245 UMA_HISTOGRAM_MEDIUM_TIMES( 244 UMA_HISTOGRAM_MEDIUM_TIMES(
246 "Profile.CreateTimeNoTimeout", 245 "Profile.CreateTimeNoTimeout",
247 base::TimeTicks::Now() - profile_creation_start_time_); 246 base::TimeTicks::Now() - profile_creation_start_time_);
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 base::TimeTicks::Now() - profile_creation_start_time_); 367 base::TimeTicks::Now() - profile_creation_start_time_);
369 RecordProfileCreationMetrics(Profile::CREATE_STATUS_CANCELED); 368 RecordProfileCreationMetrics(Profile::CREATE_STATUS_CANCELED);
370 } 369 }
371 370
372 DCHECK_NE(NO_CREATION_IN_PROGRESS, profile_creation_type_); 371 DCHECK_NE(NO_CREATION_IN_PROGRESS, profile_creation_type_);
373 profile_creation_type_ = NO_CREATION_IN_PROGRESS; 372 profile_creation_type_ = NO_CREATION_IN_PROGRESS;
374 373
375 // Cancelling registration means the callback passed into 374 // Cancelling registration means the callback passed into
376 // RegisterAndInitSync() won't be called, so the cleanup must be done here. 375 // RegisterAndInitSync() won't be called, so the cleanup must be done here.
377 profile_path_being_created_.clear(); 376 profile_path_being_created_.clear();
378 helper::DeleteProfileAtPath(new_profile->GetPath(), web_ui()); 377 webui::DeleteProfileAtPath(new_profile->GetPath(), web_ui());
379 } 378 }
380 379
381 void CreateProfileHandler::RegisterSupervisedUser( 380 void CreateProfileHandler::RegisterSupervisedUser(
382 bool create_shortcut, 381 bool create_shortcut,
383 const std::string& supervised_user_id, 382 const std::string& supervised_user_id,
384 Profile* new_profile) { 383 Profile* new_profile) {
385 DCHECK_EQ(profile_path_being_created_.value(), 384 DCHECK_EQ(profile_path_being_created_.value(),
386 new_profile->GetPath().value()); 385 new_profile->GetPath().value());
387 386
388 SupervisedUserService* supervised_user_service = 387 SupervisedUserService* supervised_user_service =
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
469 GetProfileAttributesStorage().GetAllProfilesAttributes(); 468 GetProfileAttributesStorage().GetAllProfilesAttributes();
470 for (const ProfileAttributesEntry* entry : entries) { 469 for (const ProfileAttributesEntry* entry : entries) {
471 if (existing_supervised_user_id == entry->GetSupervisedUserId()) 470 if (existing_supervised_user_id == entry->GetSupervisedUserId())
472 return false; 471 return false;
473 } 472 }
474 return true; 473 return true;
475 } 474 }
476 #endif 475 #endif
477 476
478 } // namespace options 477 } // namespace options
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/options/browser_options_handler.cc ('k') | chrome/browser/ui/webui/options/manage_profile_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698