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/sync_setup_handler.h" | 5 #include "chrome/browser/ui/webui/sync_setup_handler.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/bind_helpers.h" | 9 #include "base/bind_helpers.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 return false; | 159 return false; |
160 } | 160 } |
161 if (!result->GetString("passphrase", &config->passphrase)) { | 161 if (!result->GetString("passphrase", &config->passphrase)) { |
162 DLOG(ERROR) << "GetConfiguration() not passed a passphrase value"; | 162 DLOG(ERROR) << "GetConfiguration() not passed a passphrase value"; |
163 return false; | 163 return false; |
164 } | 164 } |
165 } | 165 } |
166 return true; | 166 return true; |
167 } | 167 } |
168 | 168 |
169 bool GetPassphrase(const std::string& json, std::string* passphrase) { | |
170 scoped_ptr<Value> parsed_value(base::JSONReader::Read(json)); | |
171 if (!parsed_value.get() || !parsed_value->IsType(Value::TYPE_DICTIONARY)) | |
172 return false; | |
173 | |
174 DictionaryValue* result = static_cast<DictionaryValue*>(parsed_value.get()); | |
175 return result->GetString("passphrase", passphrase); | |
176 } | |
177 | |
178 string16 NormalizeUserName(const string16& user) { | 169 string16 NormalizeUserName(const string16& user) { |
179 if (user.find_first_of(ASCIIToUTF16("@")) != string16::npos) | 170 if (user.find_first_of(ASCIIToUTF16("@")) != string16::npos) |
180 return user; | 171 return user; |
181 return user + ASCIIToUTF16("@") + ASCIIToUTF16(kDefaultSigninDomain); | 172 return user + ASCIIToUTF16("@") + ASCIIToUTF16(kDefaultSigninDomain); |
182 } | 173 } |
183 | 174 |
184 bool AreUserNamesEqual(const string16& user1, const string16& user2) { | 175 bool AreUserNamesEqual(const string16& user1, const string16& user2) { |
185 return NormalizeUserName(user1) == NormalizeUserName(user2); | 176 return NormalizeUserName(user1) == NormalizeUserName(user2); |
186 } | 177 } |
187 | 178 |
(...skipping 899 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1087 if (i != current_profile_index && AreUserNamesEqual( | 1078 if (i != current_profile_index && AreUserNamesEqual( |
1088 cache.GetUserNameOfProfileAtIndex(i), username_utf16)) { | 1079 cache.GetUserNameOfProfileAtIndex(i), username_utf16)) { |
1089 *error_message = l10n_util::GetStringUTF16( | 1080 *error_message = l10n_util::GetStringUTF16( |
1090 IDS_SYNC_USER_NAME_IN_USE_ERROR); | 1081 IDS_SYNC_USER_NAME_IN_USE_ERROR); |
1091 return false; | 1082 return false; |
1092 } | 1083 } |
1093 } | 1084 } |
1094 | 1085 |
1095 return true; | 1086 return true; |
1096 } | 1087 } |
OLD | NEW |