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

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

Issue 480953002: Implement "Autofill form data" import for Firefox (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Review feedback (simplify Read method) 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
« no previous file with comments | « chrome/browser/ui/browser_ui_prefs.cc ('k') | chrome/chrome_common.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/options/import_data_handler.h" 5 #include "chrome/browser/ui/webui/options/import_data_handler.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 if (select_file_dialog_.get()) 48 if (select_file_dialog_.get())
49 select_file_dialog_->ListenerDestroyed(); 49 select_file_dialog_->ListenerDestroyed();
50 } 50 }
51 51
52 void ImportDataHandler::GetLocalizedValues( 52 void ImportDataHandler::GetLocalizedValues(
53 base::DictionaryValue* localized_strings) { 53 base::DictionaryValue* localized_strings) {
54 DCHECK_CURRENTLY_ON(BrowserThread::UI); 54 DCHECK_CURRENTLY_ON(BrowserThread::UI);
55 DCHECK(localized_strings); 55 DCHECK(localized_strings);
56 56
57 static OptionsStringResource resources[] = { 57 static OptionsStringResource resources[] = {
58 { "importFromLabel", IDS_IMPORT_FROM_LABEL }, 58 {"importFromLabel", IDS_IMPORT_FROM_LABEL},
59 { "importLoading", IDS_IMPORT_LOADING_PROFILES }, 59 {"importLoading", IDS_IMPORT_LOADING_PROFILES},
60 { "importDescription", IDS_IMPORT_ITEMS_LABEL }, 60 {"importDescription", IDS_IMPORT_ITEMS_LABEL},
61 { "importHistory", IDS_IMPORT_HISTORY_CHKBOX }, 61 {"importHistory", IDS_IMPORT_HISTORY_CHKBOX},
62 { "importFavorites", IDS_IMPORT_FAVORITES_CHKBOX }, 62 {"importFavorites", IDS_IMPORT_FAVORITES_CHKBOX},
63 { "importSearch", IDS_IMPORT_SEARCH_ENGINES_CHKBOX }, 63 {"importSearch", IDS_IMPORT_SEARCH_ENGINES_CHKBOX},
64 { "importPasswords", IDS_IMPORT_PASSWORDS_CHKBOX }, 64 {"importPasswords", IDS_IMPORT_PASSWORDS_CHKBOX},
65 { "importChooseFile", IDS_IMPORT_CHOOSE_FILE }, 65 {"importAutofillFormData", IDS_IMPORT_AUTOFILL_FORM_DATA_CHKBOX},
66 { "importCommit", IDS_IMPORT_COMMIT }, 66 {"importChooseFile", IDS_IMPORT_CHOOSE_FILE},
67 { "noProfileFound", IDS_IMPORT_NO_PROFILE_FOUND }, 67 {"importCommit", IDS_IMPORT_COMMIT},
68 { "importSucceeded", IDS_IMPORT_SUCCEEDED }, 68 {"noProfileFound", IDS_IMPORT_NO_PROFILE_FOUND},
69 { "findYourImportedBookmarks", IDS_IMPORT_FIND_YOUR_BOOKMARKS }, 69 {"importSucceeded", IDS_IMPORT_SUCCEEDED},
70 {"findYourImportedBookmarks", IDS_IMPORT_FIND_YOUR_BOOKMARKS},
70 #if defined(OS_MACOSX) 71 #if defined(OS_MACOSX)
71 { "macPasswordKeychain", IDS_IMPORT_PASSWORD_KEYCHAIN_WARNING }, 72 {"macPasswordKeychain", IDS_IMPORT_PASSWORD_KEYCHAIN_WARNING},
72 #endif 73 #endif
73 }; 74 };
74 75
75 RegisterStrings(localized_strings, resources, arraysize(resources)); 76 RegisterStrings(localized_strings, resources, arraysize(resources));
76 RegisterTitle(localized_strings, "importDataOverlay", 77 RegisterTitle(localized_strings, "importDataOverlay",
77 IDS_IMPORT_SETTINGS_TITLE); 78 IDS_IMPORT_SETTINGS_TITLE);
78 } 79 }
79 80
80 void ImportDataHandler::InitializeHandler() { 81 void ImportDataHandler::InitializeHandler() {
81 DCHECK_CURRENTLY_ON(BrowserThread::UI); 82 DCHECK_CURRENTLY_ON(BrowserThread::UI);
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 } 146 }
146 if (args->GetString(2, &string_value) && string_value == "true") { 147 if (args->GetString(2, &string_value) && string_value == "true") {
147 selected_items |= importer::FAVORITES; 148 selected_items |= importer::FAVORITES;
148 } 149 }
149 if (args->GetString(3, &string_value) && string_value == "true") { 150 if (args->GetString(3, &string_value) && string_value == "true") {
150 selected_items |= importer::PASSWORDS; 151 selected_items |= importer::PASSWORDS;
151 } 152 }
152 if (args->GetString(4, &string_value) && string_value == "true") { 153 if (args->GetString(4, &string_value) && string_value == "true") {
153 selected_items |= importer::SEARCH_ENGINES; 154 selected_items |= importer::SEARCH_ENGINES;
154 } 155 }
156 if (args->GetString(5, &string_value) && string_value == "true") {
157 selected_items |= importer::AUTOFILL_FORM_DATA;
158 }
155 159
156 const importer::SourceProfile& source_profile = 160 const importer::SourceProfile& source_profile =
157 importer_list_->GetSourceProfileAt(browser_index); 161 importer_list_->GetSourceProfileAt(browser_index);
158 uint16 supported_items = source_profile.services_supported; 162 uint16 supported_items = source_profile.services_supported;
159 163
160 uint16 imported_items = (selected_items & supported_items); 164 uint16 imported_items = (selected_items & supported_items);
161 if (imported_items) { 165 if (imported_items) {
162 StartImport(source_profile, imported_items); 166 StartImport(source_profile, imported_items);
163 } else { 167 } else {
164 LOG(WARNING) << "There were no settings to import from '" 168 LOG(WARNING) << "There were no settings to import from '"
(...skipping 14 matching lines...) Expand all
179 browser_profile->SetString("name", source_profile.importer_name); 183 browser_profile->SetString("name", source_profile.importer_name);
180 browser_profile->SetInteger("index", i); 184 browser_profile->SetInteger("index", i);
181 browser_profile->SetBoolean("history", 185 browser_profile->SetBoolean("history",
182 (browser_services & importer::HISTORY) != 0); 186 (browser_services & importer::HISTORY) != 0);
183 browser_profile->SetBoolean("favorites", 187 browser_profile->SetBoolean("favorites",
184 (browser_services & importer::FAVORITES) != 0); 188 (browser_services & importer::FAVORITES) != 0);
185 browser_profile->SetBoolean("passwords", 189 browser_profile->SetBoolean("passwords",
186 (browser_services & importer::PASSWORDS) != 0); 190 (browser_services & importer::PASSWORDS) != 0);
187 browser_profile->SetBoolean("search", 191 browser_profile->SetBoolean("search",
188 (browser_services & importer::SEARCH_ENGINES) != 0); 192 (browser_services & importer::SEARCH_ENGINES) != 0);
193 browser_profile->SetBoolean("autofill-form-data",
194 (browser_services & importer::AUTOFILL_FORM_DATA) != 0);
189 195
190 browser_profile->SetBoolean("show_bottom_bar", 196 browser_profile->SetBoolean("show_bottom_bar",
191 #if defined(OS_MACOSX) 197 #if defined(OS_MACOSX)
192 source_profile.importer_type == importer::TYPE_SAFARI); 198 source_profile.importer_type == importer::TYPE_SAFARI);
193 #else 199 #else
194 false); 200 false);
195 #endif 201 #endif
196 202
197 browser_profiles.Append(browser_profile); 203 browser_profiles.Append(browser_profile);
198 } 204 }
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 base::string16(), 270 base::string16(),
265 base::FilePath(), 271 base::FilePath(),
266 &file_type_info, 272 &file_type_info,
267 0, 273 0,
268 base::FilePath::StringType(), 274 base::FilePath::StringType(),
269 browser->window()->GetNativeWindow(), 275 browser->window()->GetNativeWindow(),
270 NULL); 276 NULL);
271 } 277 }
272 278
273 } // namespace options 279 } // namespace options
OLDNEW
« no previous file with comments | « chrome/browser/ui/browser_ui_prefs.cc ('k') | chrome/chrome_common.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698