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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
95 // the respective types in ModelType | 95 // the respective types in ModelType |
96 const char* kDataTypeNames[] = { | 96 const char* kDataTypeNames[] = { |
97 "bookmarks", | 97 "bookmarks", |
98 "preferences", | 98 "preferences", |
99 "passwords", | 99 "passwords", |
100 "autofill", | 100 "autofill", |
101 "themes", | 101 "themes", |
102 "typedUrls", | 102 "typedUrls", |
103 "extensions", | 103 "extensions", |
104 "apps", | 104 "apps", |
105 "tabs" | 105 "wifiCredentials", |
106 "tabs", | |
106 }; | 107 }; |
107 | 108 |
108 COMPILE_ASSERT(32 == syncer::MODEL_TYPE_COUNT, | 109 COMPILE_ASSERT(33 == syncer::MODEL_TYPE_COUNT, |
109 update_kDataTypeNames_to_match_UserSelectableTypes); | 110 update_kDataTypeNames_to_match_UserSelectableTypes); |
110 | 111 |
111 typedef std::map<syncer::ModelType, const char*> ModelTypeNameMap; | 112 typedef std::map<syncer::ModelType, const char*> ModelTypeNameMap; |
112 | 113 |
113 ModelTypeNameMap GetSelectableTypeNameMap() { | 114 ModelTypeNameMap GetSelectableTypeNameMap() { |
114 ModelTypeNameMap type_names; | 115 ModelTypeNameMap type_names; |
115 syncer::ModelTypeSet type_set = syncer::UserSelectableTypes(); | 116 syncer::ModelTypeSet type_set = syncer::UserSelectableTypes(); |
116 syncer::ModelTypeSet::Iterator it = type_set.First(); | 117 syncer::ModelTypeSet::Iterator it = type_set.First(); |
117 DCHECK_EQ(arraysize(kDataTypeNames), type_set.Size()); | 118 DCHECK_EQ(arraysize(kDataTypeNames), type_set.Size()); |
118 for (size_t i = 0; i < arraysize(kDataTypeNames) && it.Good(); | 119 for (size_t i = 0; i < arraysize(kDataTypeNames) && it.Good(); |
119 ++i, it.Inc()) { | 120 ++i, it.Inc()) { |
120 type_names[it.Get()] = kDataTypeNames[i]; | 121 type_names[it.Get()] = kDataTypeNames[i]; |
121 } | 122 } |
122 return type_names; | 123 return type_names; |
123 } | 124 } |
Roger Tawa OOO till Jul 10th
2014/10/29 13:55:03
Seems like this function should be moved to model_
mukesh agrawal
2014/10/29 18:17:11
Done.
| |
124 | 125 |
125 bool GetConfiguration(const std::string& json, SyncConfigInfo* config) { | 126 bool GetConfiguration(const std::string& json, SyncConfigInfo* config) { |
126 scoped_ptr<base::Value> parsed_value(base::JSONReader::Read(json)); | 127 scoped_ptr<base::Value> parsed_value(base::JSONReader::Read(json)); |
127 base::DictionaryValue* result; | 128 base::DictionaryValue* result; |
128 if (!parsed_value || !parsed_value->GetAsDictionary(&result)) { | 129 if (!parsed_value || !parsed_value->GetAsDictionary(&result)) { |
129 DLOG(ERROR) << "GetConfiguration() not passed a Dictionary"; | 130 DLOG(ERROR) << "GetConfiguration() not passed a Dictionary"; |
130 return false; | 131 return false; |
131 } | 132 } |
132 | 133 |
133 if (!result->GetBoolean("syncAllDataTypes", &config->sync_everything)) { | 134 if (!result->GetBoolean("syncAllDataTypes", &config->sync_everything)) { |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
264 { "chooseDataTypes", IDS_SYNC_CHOOSE_DATATYPES }, | 265 { "chooseDataTypes", IDS_SYNC_CHOOSE_DATATYPES }, |
265 { "syncNothing", IDS_SYNC_NOTHING }, | 266 { "syncNothing", IDS_SYNC_NOTHING }, |
266 { "bookmarks", IDS_SYNC_DATATYPE_BOOKMARKS }, | 267 { "bookmarks", IDS_SYNC_DATATYPE_BOOKMARKS }, |
267 { "preferences", IDS_SYNC_DATATYPE_PREFERENCES }, | 268 { "preferences", IDS_SYNC_DATATYPE_PREFERENCES }, |
268 { "autofill", IDS_SYNC_DATATYPE_AUTOFILL }, | 269 { "autofill", IDS_SYNC_DATATYPE_AUTOFILL }, |
269 { "themes", IDS_SYNC_DATATYPE_THEMES }, | 270 { "themes", IDS_SYNC_DATATYPE_THEMES }, |
270 { "passwords", IDS_SYNC_DATATYPE_PASSWORDS }, | 271 { "passwords", IDS_SYNC_DATATYPE_PASSWORDS }, |
271 { "extensions", IDS_SYNC_DATATYPE_EXTENSIONS }, | 272 { "extensions", IDS_SYNC_DATATYPE_EXTENSIONS }, |
272 { "typedURLs", IDS_SYNC_DATATYPE_TYPED_URLS }, | 273 { "typedURLs", IDS_SYNC_DATATYPE_TYPED_URLS }, |
273 { "apps", IDS_SYNC_DATATYPE_APPS }, | 274 { "apps", IDS_SYNC_DATATYPE_APPS }, |
275 { "wifiCredentials", IDS_SYNC_DATATYPE_WIFI_CREDENTIALS }, | |
274 { "openTabs", IDS_SYNC_DATATYPE_TABS }, | 276 { "openTabs", IDS_SYNC_DATATYPE_TABS }, |
275 { "serviceUnavailableError", IDS_SYNC_SETUP_ABORTED_BY_PENDING_CLEAR }, | 277 { "serviceUnavailableError", IDS_SYNC_SETUP_ABORTED_BY_PENDING_CLEAR }, |
276 { "confirmLabel", IDS_SYNC_CONFIRM_PASSPHRASE_LABEL }, | 278 { "confirmLabel", IDS_SYNC_CONFIRM_PASSPHRASE_LABEL }, |
277 { "emptyErrorMessage", IDS_SYNC_EMPTY_PASSPHRASE_ERROR }, | 279 { "emptyErrorMessage", IDS_SYNC_EMPTY_PASSPHRASE_ERROR }, |
278 { "mismatchErrorMessage", IDS_SYNC_PASSPHRASE_MISMATCH_ERROR }, | 280 { "mismatchErrorMessage", IDS_SYNC_PASSPHRASE_MISMATCH_ERROR }, |
279 { "customizeLinkLabel", IDS_SYNC_CUSTOMIZE_LINK_LABEL }, | 281 { "customizeLinkLabel", IDS_SYNC_CUSTOMIZE_LINK_LABEL }, |
280 { "confirmSyncPreferences", IDS_SYNC_CONFIRM_SYNC_PREFERENCES }, | 282 { "confirmSyncPreferences", IDS_SYNC_CONFIRM_SYNC_PREFERENCES }, |
281 { "syncEverything", IDS_SYNC_SYNC_EVERYTHING }, | 283 { "syncEverything", IDS_SYNC_SYNC_EVERYTHING }, |
282 { "useDefaultSettings", IDS_SYNC_USE_DEFAULT_SETTINGS }, | 284 { "useDefaultSettings", IDS_SYNC_USE_DEFAULT_SETTINGS }, |
283 { "enterPassphraseBody", IDS_SYNC_ENTER_PASSPHRASE_BODY }, | 285 { "enterPassphraseBody", IDS_SYNC_ENTER_PASSPHRASE_BODY }, |
(...skipping 674 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
958 | 960 |
959 LoginUIService* service = GetLoginUIService(); | 961 LoginUIService* service = GetLoginUIService(); |
960 DCHECK(service); | 962 DCHECK(service); |
961 service->current_login_ui()->FocusUI(); | 963 service->current_login_ui()->FocusUI(); |
962 return true; | 964 return true; |
963 } | 965 } |
964 | 966 |
965 LoginUIService* SyncSetupHandler::GetLoginUIService() const { | 967 LoginUIService* SyncSetupHandler::GetLoginUIService() const { |
966 return LoginUIServiceFactory::GetForProfile(GetProfile()); | 968 return LoginUIServiceFactory::GetForProfile(GetProfile()); |
967 } | 969 } |
OLD | NEW |