OLD | NEW |
---|---|
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 Loading... | |
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 profiles::helper::OpenNewWindowForProfile(profile, |
221 Profile::CREATE_STATUS_INITIALIZED); | 221 Profile::CREATE_STATUS_INITIALIZED); |
Dan Beam
2016/02/29 20:25:32
nit: fix indent
Moe
2016/03/01 18:29:53
Done.
| |
222 } | 222 } |
223 profile_creation_type_ = NO_CREATION_IN_PROGRESS; | 223 profile_creation_type_ = NO_CREATION_IN_PROGRESS; |
224 } | 224 } |
225 | 225 |
226 void CreateProfileHandler::ShowProfileCreationError( | 226 void CreateProfileHandler::ShowProfileCreationError( |
227 Profile* profile, | 227 Profile* profile, |
228 const base::string16& error) { | 228 const base::string16& error) { |
229 DCHECK_NE(NO_CREATION_IN_PROGRESS, profile_creation_type_); | 229 DCHECK_NE(NO_CREATION_IN_PROGRESS, profile_creation_type_); |
230 profile_creation_type_ = NO_CREATION_IN_PROGRESS; | 230 profile_creation_type_ = NO_CREATION_IN_PROGRESS; |
231 profile_path_being_created_.clear(); | 231 profile_path_being_created_.clear(); |
232 web_ui()->CallJavascriptFunction( | 232 web_ui()->CallJavascriptFunction( |
233 GetJavascriptMethodName(PROFILE_CREATION_ERROR), | 233 GetJavascriptMethodName(PROFILE_CREATION_ERROR), |
234 base::StringValue(error)); | 234 base::StringValue(error)); |
235 // The ProfileManager calls us back with a NULL profile in some cases. | 235 // The ProfileManager calls us back with a NULL profile in some cases. |
236 if (profile) | 236 if (profile) |
237 helper::DeleteProfileAtPath(profile->GetPath(), web_ui()); | 237 profiles::helper::DeleteProfileAtPath(profile->GetPath(), web_ui()); |
238 } | 238 } |
239 | 239 |
240 void CreateProfileHandler::RecordProfileCreationMetrics( | 240 void CreateProfileHandler::RecordProfileCreationMetrics( |
241 Profile::CreateStatus status) { | 241 Profile::CreateStatus status) { |
242 UMA_HISTOGRAM_ENUMERATION("Profile.CreateResult", | 242 UMA_HISTOGRAM_ENUMERATION("Profile.CreateResult", |
243 status, | 243 status, |
244 Profile::MAX_CREATE_STATUS); | 244 Profile::MAX_CREATE_STATUS); |
245 UMA_HISTOGRAM_MEDIUM_TIMES( | 245 UMA_HISTOGRAM_MEDIUM_TIMES( |
246 "Profile.CreateTimeNoTimeout", | 246 "Profile.CreateTimeNoTimeout", |
247 base::TimeTicks::Now() - profile_creation_start_time_); | 247 base::TimeTicks::Now() - profile_creation_start_time_); |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
368 base::TimeTicks::Now() - profile_creation_start_time_); | 368 base::TimeTicks::Now() - profile_creation_start_time_); |
369 RecordProfileCreationMetrics(Profile::CREATE_STATUS_CANCELED); | 369 RecordProfileCreationMetrics(Profile::CREATE_STATUS_CANCELED); |
370 } | 370 } |
371 | 371 |
372 DCHECK_NE(NO_CREATION_IN_PROGRESS, profile_creation_type_); | 372 DCHECK_NE(NO_CREATION_IN_PROGRESS, profile_creation_type_); |
373 profile_creation_type_ = NO_CREATION_IN_PROGRESS; | 373 profile_creation_type_ = NO_CREATION_IN_PROGRESS; |
374 | 374 |
375 // Cancelling registration means the callback passed into | 375 // Cancelling registration means the callback passed into |
376 // RegisterAndInitSync() won't be called, so the cleanup must be done here. | 376 // RegisterAndInitSync() won't be called, so the cleanup must be done here. |
377 profile_path_being_created_.clear(); | 377 profile_path_being_created_.clear(); |
378 helper::DeleteProfileAtPath(new_profile->GetPath(), web_ui()); | 378 profiles::helper::DeleteProfileAtPath(new_profile->GetPath(), web_ui()); |
379 } | 379 } |
380 | 380 |
381 void CreateProfileHandler::RegisterSupervisedUser( | 381 void CreateProfileHandler::RegisterSupervisedUser( |
382 bool create_shortcut, | 382 bool create_shortcut, |
383 const std::string& supervised_user_id, | 383 const std::string& supervised_user_id, |
384 Profile* new_profile) { | 384 Profile* new_profile) { |
385 DCHECK_EQ(profile_path_being_created_.value(), | 385 DCHECK_EQ(profile_path_being_created_.value(), |
386 new_profile->GetPath().value()); | 386 new_profile->GetPath().value()); |
387 | 387 |
388 SupervisedUserService* supervised_user_service = | 388 SupervisedUserService* supervised_user_service = |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
469 GetProfileAttributesStorage().GetAllProfilesAttributes(); | 469 GetProfileAttributesStorage().GetAllProfilesAttributes(); |
470 for (const ProfileAttributesEntry* entry : entries) { | 470 for (const ProfileAttributesEntry* entry : entries) { |
471 if (existing_supervised_user_id == entry->GetSupervisedUserId()) | 471 if (existing_supervised_user_id == entry->GetSupervisedUserId()) |
472 return false; | 472 return false; |
473 } | 473 } |
474 return true; | 474 return true; |
475 } | 475 } |
476 #endif | 476 #endif |
477 | 477 |
478 } // namespace options | 478 } // namespace options |
OLD | NEW |