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

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

Issue 562233002: Don't allow creating a profile with an empty name in chrome://settings (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: added empty string checks Created 6 years, 3 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 "base/bind.h" 7 #include "base/bind.h"
8 #include "base/files/file_path.h" 8 #include "base/files/file_path.h"
9 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
10 #include "base/prefs/pref_service.h" 10 #include "base/prefs/pref_service.h"
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 DCHECK(profile_path_being_created_.empty()); 75 DCHECK(profile_path_being_created_.empty());
76 profile_creation_start_time_ = base::TimeTicks::Now(); 76 profile_creation_start_time_ = base::TimeTicks::Now();
77 77
78 base::string16 name; 78 base::string16 name;
79 base::string16 icon; 79 base::string16 icon;
80 std::string supervised_user_id; 80 std::string supervised_user_id;
81 bool create_shortcut = false; 81 bool create_shortcut = false;
82 bool supervised_user = false; 82 bool supervised_user = false;
83 if (args->GetString(0, &name) && args->GetString(1, &icon)) { 83 if (args->GetString(0, &name) && args->GetString(1, &icon)) {
84 base::TrimWhitespace(name, base::TRIM_ALL, &name); 84 base::TrimWhitespace(name, base::TRIM_ALL, &name);
85 CHECK(!name.empty());
85 if (args->GetBoolean(2, &create_shortcut)) { 86 if (args->GetBoolean(2, &create_shortcut)) {
86 bool success = args->GetBoolean(3, &supervised_user); 87 bool success = args->GetBoolean(3, &supervised_user);
87 DCHECK(success); 88 DCHECK(success);
88 success = args->GetString(4, &supervised_user_id); 89 success = args->GetString(4, &supervised_user_id);
89 DCHECK(success); 90 DCHECK(success);
90 } 91 }
91 } 92 }
92 93
93 if (supervised_user) { 94 if (supervised_user) {
94 if (!IsValidExistingSupervisedUserId(supervised_user_id)) 95 if (!IsValidExistingSupervisedUserId(supervised_user_id))
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after
427 g_browser_process->profile_manager()->GetProfileInfoCache(); 428 g_browser_process->profile_manager()->GetProfileInfoCache();
428 for (size_t i = 0; i < cache.GetNumberOfProfiles(); ++i) { 429 for (size_t i = 0; i < cache.GetNumberOfProfiles(); ++i) {
429 if (existing_supervised_user_id == 430 if (existing_supervised_user_id ==
430 cache.GetSupervisedUserIdOfProfileAtIndex(i)) 431 cache.GetSupervisedUserIdOfProfileAtIndex(i))
431 return false; 432 return false;
432 } 433 }
433 return true; 434 return true;
434 } 435 }
435 436
436 } // namespace options 437 } // namespace options
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698