| 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/password_manager_handler.h" | 5 #include "chrome/browser/ui/webui/options/password_manager_handler.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" |
| 9 #include "base/debug/leak_annotations.h" |
| 8 #include "base/feature_list.h" | 10 #include "base/feature_list.h" |
| 11 #include "base/files/file_path.h" |
| 9 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "base/metrics/field_trial.h" |
| 14 #include "base/metrics/histogram.h" |
| 10 #include "base/strings/string_number_conversions.h" | 15 #include "base/strings/string_number_conversions.h" |
| 11 #include "base/strings/string_split.h" | 16 #include "base/strings/string_split.h" |
| 12 #include "base/strings/utf_string_conversions.h" | 17 #include "base/strings/utf_string_conversions.h" |
| 13 #include "base/values.h" | 18 #include "base/values.h" |
| 14 #include "build/build_config.h" | 19 #include "build/build_config.h" |
| 15 #include "chrome/browser/chrome_notification_types.h" | 20 #include "chrome/browser/chrome_notification_types.h" |
| 21 #include "chrome/browser/password_manager/password_store_factory.h" |
| 16 #include "chrome/browser/profiles/profile.h" | 22 #include "chrome/browser/profiles/profile.h" |
| 17 #include "chrome/browser/sync/profile_sync_service_factory.h" | 23 #include "chrome/browser/sync/profile_sync_service_factory.h" |
| 24 #include "chrome/browser/ui/chrome_select_file_policy.h" |
| 18 #include "chrome/common/pref_names.h" | 25 #include "chrome/common/pref_names.h" |
| 19 #include "chrome/common/url_constants.h" | 26 #include "chrome/common/url_constants.h" |
| 20 #include "chrome/grit/generated_resources.h" | 27 #include "chrome/grit/generated_resources.h" |
| 21 #include "components/autofill/core/common/password_form.h" | 28 #include "components/autofill/core/common/password_form.h" |
| 22 #include "components/browser_sync/browser/profile_sync_service.h" | 29 #include "components/browser_sync/browser/profile_sync_service.h" |
| 30 #include "components/password_manager/core/browser/export/password_exporter.h" |
| 23 #include "components/password_manager/core/browser/password_bubble_experiment.h" | 31 #include "components/password_manager/core/browser/password_bubble_experiment.h" |
| 24 #include "components/password_manager/core/browser/password_manager_constants.h" | 32 #include "components/password_manager/core/browser/password_manager_constants.h" |
| 33 #include "components/password_manager/core/browser/password_store.h" |
| 25 #include "components/password_manager/core/browser/password_ui_utils.h" | 34 #include "components/password_manager/core/browser/password_ui_utils.h" |
| 26 #include "components/password_manager/core/common/experiments.h" | 35 #include "components/password_manager/core/common/experiments.h" |
| 36 #include "components/password_manager/core/common/password_manager_features.h" |
| 27 #include "components/prefs/pref_service.h" | 37 #include "components/prefs/pref_service.h" |
| 28 #include "components/strings/grit/components_strings.h" | 38 #include "components/strings/grit/components_strings.h" |
| 29 #include "components/url_formatter/url_formatter.h" | 39 #include "components/url_formatter/url_formatter.h" |
| 40 #include "content/public/browser/browser_thread.h" |
| 30 #include "content/public/browser/notification_details.h" | 41 #include "content/public/browser/notification_details.h" |
| 31 #include "content/public/browser/notification_source.h" | 42 #include "content/public/browser/notification_source.h" |
| 32 #include "content/public/browser/user_metrics.h" | 43 #include "content/public/browser/user_metrics.h" |
| 33 #include "content/public/browser/web_contents.h" | 44 #include "content/public/browser/web_contents.h" |
| 34 #include "content/public/browser/web_ui.h" | 45 #include "content/public/browser/web_ui.h" |
| 35 #include "content/public/common/content_features.h" | 46 #include "content/public/common/content_features.h" |
| 36 #include "content/public/common/origin_util.h" | 47 #include "content/public/common/origin_util.h" |
| 37 #include "ui/base/l10n/l10n_util.h" | 48 #include "ui/base/l10n/l10n_util.h" |
| 38 | 49 |
| 39 #if defined(OS_WIN) && defined(USE_ASH) | 50 #if defined(OS_WIN) && defined(USE_ASH) |
| (...skipping 28 matching lines...) Expand all Loading... |
| 68 DCHECK(link_url.is_valid()); | 79 DCHECK(link_url.is_valid()); |
| 69 entry->SetString( | 80 entry->SetString( |
| 70 kUrlField, url_formatter::FormatUrl( | 81 kUrlField, url_formatter::FormatUrl( |
| 71 link_url, url_formatter::kFormatUrlOmitNothing, | 82 link_url, url_formatter::kFormatUrlOmitNothing, |
| 72 net::UnescapeRule::SPACES, nullptr, nullptr, nullptr)); | 83 net::UnescapeRule::SPACES, nullptr, nullptr, nullptr)); |
| 73 entry->SetBoolean(kIsAndroidUriField, is_android_uri); | 84 entry->SetBoolean(kIsAndroidUriField, is_android_uri); |
| 74 entry->SetBoolean(kIsClickable, origin_is_clickable); | 85 entry->SetBoolean(kIsClickable, origin_is_clickable); |
| 75 entry->SetBoolean(kIsSecureField, content::IsOriginSecure(link_url)); | 86 entry->SetBoolean(kIsSecureField, content::IsOriginSecure(link_url)); |
| 76 } | 87 } |
| 77 | 88 |
| 89 // Enumeration of different callers of SelectFile. Starting count at 1 so |
| 90 // accidental call of SelectFile with params=NULL will error out. |
| 91 enum FileSelectorCaller { |
| 92 IMPORT_FILE_SELECTED = 1, |
| 93 EXPORT_FILE_SELECTED, |
| 94 }; |
| 95 |
| 78 } // namespace | 96 } // namespace |
| 79 | 97 |
| 80 PasswordManagerHandler::PasswordManagerHandler() | 98 PasswordManagerHandler::PasswordManagerHandler() { |
| 81 : password_manager_presenter_(this) {} | 99 password_manager_presenter_.reset(new PasswordManagerPresenter(this)); |
| 100 } |
| 101 |
| 102 PasswordManagerHandler::PasswordManagerHandler( |
| 103 scoped_ptr<PasswordManagerPresenter> presenter) |
| 104 : password_manager_presenter_(std::move(presenter)) {} |
| 82 | 105 |
| 83 PasswordManagerHandler::~PasswordManagerHandler() {} | 106 PasswordManagerHandler::~PasswordManagerHandler() {} |
| 84 | 107 |
| 85 Profile* PasswordManagerHandler::GetProfile() { | 108 Profile* PasswordManagerHandler::GetProfile() { |
| 86 return Profile::FromWebUI(web_ui()); | 109 return Profile::FromWebUI(web_ui()); |
| 87 } | 110 } |
| 88 | 111 |
| 89 #if !defined(OS_ANDROID) | 112 #if !defined(OS_ANDROID) |
| 90 gfx::NativeWindow PasswordManagerHandler::GetNativeWindow() const { | 113 gfx::NativeWindow PasswordManagerHandler::GetNativeWindow() const { |
| 91 return web_ui()->GetWebContents()->GetTopLevelNativeWindow(); | 114 return web_ui()->GetWebContents()->GetTopLevelNativeWindow(); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 102 {"autoSigninDescription", IDS_PASSWORDS_AUTO_SIGNIN_DESCRIPTION}, | 125 {"autoSigninDescription", IDS_PASSWORDS_AUTO_SIGNIN_DESCRIPTION}, |
| 103 {"savedPasswordsTitle", IDS_PASSWORD_MANAGER_SHOW_PASSWORDS_TAB_TITLE}, | 126 {"savedPasswordsTitle", IDS_PASSWORD_MANAGER_SHOW_PASSWORDS_TAB_TITLE}, |
| 104 {"passwordExceptionsTitle", IDS_PASSWORD_MANAGER_EXCEPTIONS_TAB_TITLE}, | 127 {"passwordExceptionsTitle", IDS_PASSWORD_MANAGER_EXCEPTIONS_TAB_TITLE}, |
| 105 {"passwordSearchPlaceholder", IDS_PASSWORDS_PAGE_SEARCH_PASSWORDS}, | 128 {"passwordSearchPlaceholder", IDS_PASSWORDS_PAGE_SEARCH_PASSWORDS}, |
| 106 {"passwordShowButton", IDS_PASSWORDS_PAGE_VIEW_SHOW_BUTTON}, | 129 {"passwordShowButton", IDS_PASSWORDS_PAGE_VIEW_SHOW_BUTTON}, |
| 107 {"passwordHideButton", IDS_PASSWORDS_PAGE_VIEW_HIDE_BUTTON}, | 130 {"passwordHideButton", IDS_PASSWORDS_PAGE_VIEW_HIDE_BUTTON}, |
| 108 {"passwordsNoPasswordsDescription", | 131 {"passwordsNoPasswordsDescription", |
| 109 IDS_PASSWORDS_PAGE_VIEW_NO_PASSWORDS_DESCRIPTION}, | 132 IDS_PASSWORDS_PAGE_VIEW_NO_PASSWORDS_DESCRIPTION}, |
| 110 {"passwordsNoExceptionsDescription", | 133 {"passwordsNoExceptionsDescription", |
| 111 IDS_PASSWORDS_PAGE_VIEW_NO_EXCEPTIONS_DESCRIPTION}, | 134 IDS_PASSWORDS_PAGE_VIEW_NO_EXCEPTIONS_DESCRIPTION}, |
| 135 {"passwordManagerImportPasswordButtonText", |
| 136 IDS_PASSWORD_MANAGER_IMPORT_BUTTON}, |
| 137 {"passwordManagerExportPasswordButtonText", |
| 138 IDS_PASSWORD_MANAGER_EXPORT_BUTTON}, |
| 112 }; | 139 }; |
| 113 | 140 |
| 114 RegisterStrings(localized_strings, resources, arraysize(resources)); | 141 RegisterStrings(localized_strings, resources, arraysize(resources)); |
| 115 | 142 |
| 116 const ProfileSyncService* sync_service = | 143 const ProfileSyncService* sync_service = |
| 117 ProfileSyncServiceFactory::GetForProfile(GetProfile()); | 144 ProfileSyncServiceFactory::GetForProfile(GetProfile()); |
| 118 int title_id = | 145 int title_id = |
| 119 password_bubble_experiment::IsSmartLockBrandingEnabled(sync_service) | 146 password_bubble_experiment::IsSmartLockBrandingEnabled(sync_service) |
| 120 ? IDS_PASSWORD_MANAGER_SMART_LOCK_FOR_PASSWORDS | 147 ? IDS_PASSWORD_MANAGER_SMART_LOCK_FOR_PASSWORDS |
| 121 : IDS_PASSWORDS_EXCEPTIONS_WINDOW_TITLE; | 148 : IDS_PASSWORDS_EXCEPTIONS_WINDOW_TITLE; |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 base::Bind(&PasswordManagerHandler::HandleRemoveSavedPassword, | 195 base::Bind(&PasswordManagerHandler::HandleRemoveSavedPassword, |
| 169 base::Unretained(this))); | 196 base::Unretained(this))); |
| 170 web_ui()->RegisterMessageCallback( | 197 web_ui()->RegisterMessageCallback( |
| 171 "removePasswordException", | 198 "removePasswordException", |
| 172 base::Bind(&PasswordManagerHandler::HandleRemovePasswordException, | 199 base::Bind(&PasswordManagerHandler::HandleRemovePasswordException, |
| 173 base::Unretained(this))); | 200 base::Unretained(this))); |
| 174 web_ui()->RegisterMessageCallback( | 201 web_ui()->RegisterMessageCallback( |
| 175 "requestShowPassword", | 202 "requestShowPassword", |
| 176 base::Bind(&PasswordManagerHandler::HandleRequestShowPassword, | 203 base::Bind(&PasswordManagerHandler::HandleRequestShowPassword, |
| 177 base::Unretained(this))); | 204 base::Unretained(this))); |
| 205 web_ui()->RegisterMessageCallback( |
| 206 "importPassword", |
| 207 base::Bind(&PasswordManagerHandler::HandlePasswordImport, |
| 208 base::Unretained(this))); |
| 209 web_ui()->RegisterMessageCallback( |
| 210 "exportPassword", |
| 211 base::Bind(&PasswordManagerHandler::HandlePasswordExport, |
| 212 base::Unretained(this))); |
| 178 } | 213 } |
| 179 | 214 |
| 180 void PasswordManagerHandler::InitializeHandler() { | 215 void PasswordManagerHandler::InitializeHandler() { |
| 181 password_manager_presenter_.Initialize(); | 216 password_manager_presenter_->Initialize(); |
| 217 } |
| 218 |
| 219 void PasswordManagerHandler::InitializePage() { |
| 220 if (base::FeatureList::IsEnabled( |
| 221 password_manager::features::kPasswordImportExport)) { |
| 222 web_ui()->CallJavascriptFunction("PasswordManager.showImportExportButton"); |
| 223 } |
| 182 } | 224 } |
| 183 | 225 |
| 184 void PasswordManagerHandler::HandleRemoveSavedPassword( | 226 void PasswordManagerHandler::HandleRemoveSavedPassword( |
| 185 const base::ListValue* args) { | 227 const base::ListValue* args) { |
| 186 std::string string_value = base::UTF16ToUTF8(ExtractStringValue(args)); | 228 std::string string_value = base::UTF16ToUTF8(ExtractStringValue(args)); |
| 187 int index; | 229 int index; |
| 188 if (base::StringToInt(string_value, &index) && index >= 0) { | 230 if (base::StringToInt(string_value, &index) && index >= 0) { |
| 189 password_manager_presenter_.RemoveSavedPassword(static_cast<size_t>(index)); | 231 password_manager_presenter_->RemoveSavedPassword( |
| 232 static_cast<size_t>(index)); |
| 190 } | 233 } |
| 191 } | 234 } |
| 192 | 235 |
| 193 void PasswordManagerHandler::HandleRemovePasswordException( | 236 void PasswordManagerHandler::HandleRemovePasswordException( |
| 194 const base::ListValue* args) { | 237 const base::ListValue* args) { |
| 195 std::string string_value = base::UTF16ToUTF8(ExtractStringValue(args)); | 238 std::string string_value = base::UTF16ToUTF8(ExtractStringValue(args)); |
| 196 int index; | 239 int index; |
| 197 if (base::StringToInt(string_value, &index) && index >= 0) { | 240 if (base::StringToInt(string_value, &index) && index >= 0) { |
| 198 password_manager_presenter_.RemovePasswordException( | 241 password_manager_presenter_->RemovePasswordException( |
| 199 static_cast<size_t>(index)); | 242 static_cast<size_t>(index)); |
| 200 } | 243 } |
| 201 } | 244 } |
| 202 | 245 |
| 203 void PasswordManagerHandler::HandleRequestShowPassword( | 246 void PasswordManagerHandler::HandleRequestShowPassword( |
| 204 const base::ListValue* args) { | 247 const base::ListValue* args) { |
| 205 int index; | 248 int index; |
| 206 if (!ExtractIntegerValue(args, &index)) | 249 if (!ExtractIntegerValue(args, &index)) |
| 207 NOTREACHED(); | 250 NOTREACHED(); |
| 208 | 251 |
| 209 password_manager_presenter_.RequestShowPassword(static_cast<size_t>(index)); | 252 password_manager_presenter_->RequestShowPassword(static_cast<size_t>(index)); |
| 210 } | 253 } |
| 211 | 254 |
| 212 void PasswordManagerHandler::ShowPassword( | 255 void PasswordManagerHandler::ShowPassword( |
| 213 size_t index, | 256 size_t index, |
| 214 const std::string& origin_url, | 257 const std::string& origin_url, |
| 215 const std::string& username, | 258 const std::string& username, |
| 216 const base::string16& password_value) { | 259 const base::string16& password_value) { |
| 217 // Call back the front end to reveal the password. | 260 // Call back the front end to reveal the password. |
| 218 web_ui()->CallJavascriptFunction( | 261 web_ui()->CallJavascriptFunction( |
| 219 "PasswordManager.showPassword", | 262 "PasswordManager.showPassword", |
| 220 base::FundamentalValue(static_cast<int>(index)), | 263 base::FundamentalValue(static_cast<int>(index)), |
| 221 base::StringValue(password_value)); | 264 base::StringValue(password_value)); |
| 222 } | 265 } |
| 223 | 266 |
| 224 void PasswordManagerHandler::HandleUpdatePasswordLists( | 267 void PasswordManagerHandler::HandleUpdatePasswordLists( |
| 225 const base::ListValue* args) { | 268 const base::ListValue* args) { |
| 226 password_manager_presenter_.UpdatePasswordLists(); | 269 password_manager_presenter_->UpdatePasswordLists(); |
| 227 } | 270 } |
| 228 | 271 |
| 229 void PasswordManagerHandler::SetPasswordList( | 272 void PasswordManagerHandler::SetPasswordList( |
| 230 const std::vector<std::unique_ptr<autofill::PasswordForm>>& password_list) { | 273 const std::vector<std::unique_ptr<autofill::PasswordForm>>& password_list) { |
| 231 base::ListValue entries; | 274 base::ListValue entries; |
| 232 base::string16 placeholder(base::ASCIIToUTF16(" ")); | 275 base::string16 placeholder(base::ASCIIToUTF16(" ")); |
| 233 for (const auto& saved_password : password_list) { | 276 for (const auto& saved_password : password_list) { |
| 234 std::unique_ptr<base::DictionaryValue> entry(new base::DictionaryValue); | 277 std::unique_ptr<base::DictionaryValue> entry(new base::DictionaryValue); |
| 235 CopyOriginInfoOfPasswordForm(*saved_password, entry.get()); | 278 CopyOriginInfoOfPasswordForm(*saved_password, entry.get()); |
| 236 | 279 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 261 for (const auto& exception : password_exception_list) { | 304 for (const auto& exception : password_exception_list) { |
| 262 std::unique_ptr<base::DictionaryValue> entry(new base::DictionaryValue); | 305 std::unique_ptr<base::DictionaryValue> entry(new base::DictionaryValue); |
| 263 CopyOriginInfoOfPasswordForm(*exception, entry.get()); | 306 CopyOriginInfoOfPasswordForm(*exception, entry.get()); |
| 264 entries.Append(entry.release()); | 307 entries.Append(entry.release()); |
| 265 } | 308 } |
| 266 | 309 |
| 267 web_ui()->CallJavascriptFunction("PasswordManager.setPasswordExceptionsList", | 310 web_ui()->CallJavascriptFunction("PasswordManager.setPasswordExceptionsList", |
| 268 entries); | 311 entries); |
| 269 } | 312 } |
| 270 | 313 |
| 314 void PasswordManagerHandler::FileSelected(const base::FilePath& path, |
| 315 int index, |
| 316 void* params) { |
| 317 switch (reinterpret_cast<intptr_t>(params)) { |
| 318 case IMPORT_FILE_SELECTED: |
| 319 ImportPasswordFileSelected(path); |
| 320 break; |
| 321 case EXPORT_FILE_SELECTED: |
| 322 ExportPasswordFileSelected(path); |
| 323 break; |
| 324 default: |
| 325 NOTREACHED(); |
| 326 } |
| 327 } |
| 328 |
| 329 void PasswordManagerHandler::HandlePasswordImport(const base::ListValue* args) { |
| 330 #if !defined(OS_ANDROID) // This is never called on Android. |
| 331 ui::SelectFileDialog::FileTypeInfo file_type_info; |
| 332 |
| 333 file_type_info.extensions = |
| 334 password_manager::PasswordImporter::GetSupportedFileExtensions(); |
| 335 DCHECK(!file_type_info.extensions.empty() && |
| 336 !file_type_info.extensions[0].empty()); |
| 337 file_type_info.include_all_files = true; |
| 338 ChromeSelectFilePolicy* select_file_policy = |
| 339 new ChromeSelectFilePolicy(web_ui()->GetWebContents()); |
| 340 ANNOTATE_LEAKING_OBJECT_PTR(select_file_policy); |
| 341 selected_file_dialog_ = |
| 342 ui::SelectFileDialog::Create(this, select_file_policy); |
| 343 selected_file_dialog_->SelectFile( |
| 344 ui::SelectFileDialog::SELECT_OPEN_FILE, |
| 345 l10n_util::GetStringUTF16(IDS_PASSWORD_MANAGER_IMPORT_DIALOG_TITLE), |
| 346 base::FilePath(), &file_type_info, 1, file_type_info.extensions[0][0], |
| 347 web_ui()->GetWebContents()->GetTopLevelNativeWindow(), |
| 348 reinterpret_cast<void*>(IMPORT_FILE_SELECTED)); |
| 349 #endif |
| 350 } |
| 351 |
| 352 void PasswordManagerHandler::ImportPasswordFileSelected( |
| 353 const base::FilePath& path) { |
| 354 scoped_refptr<ImportPasswordResultConsumer> form_consumer( |
| 355 new ImportPasswordResultConsumer(GetProfile())); |
| 356 |
| 357 password_manager::PasswordImporter::Import( |
| 358 path, content::BrowserThread::GetMessageLoopProxyForThread( |
| 359 content::BrowserThread::FILE) |
| 360 .get(), |
| 361 base::Bind(&ImportPasswordResultConsumer::ConsumePassword, |
| 362 form_consumer)); |
| 363 } |
| 364 |
| 365 PasswordManagerHandler::ImportPasswordResultConsumer:: |
| 366 ImportPasswordResultConsumer(Profile* profile) |
| 367 : profile_(profile) {} |
| 368 |
| 369 void PasswordManagerHandler::ImportPasswordResultConsumer::ConsumePassword( |
| 370 password_manager::PasswordImporter::Result result, |
| 371 const std::vector<autofill::PasswordForm>& forms) { |
| 372 UMA_HISTOGRAM_ENUMERATION( |
| 373 "PasswordManager.ImportPasswordFromCSVResult", result, |
| 374 password_manager::PasswordImporter::NUM_IMPORT_RESULTS); |
| 375 if (result != password_manager::PasswordImporter::SUCCESS) |
| 376 return; |
| 377 |
| 378 UMA_HISTOGRAM_COUNTS("PasswordManager.ImportedPasswordsPerUserInCSV", |
| 379 forms.size()); |
| 380 |
| 381 scoped_refptr<password_manager::PasswordStore> store( |
| 382 PasswordStoreFactory::GetForProfile(profile_, |
| 383 ServiceAccessType::EXPLICIT_ACCESS)); |
| 384 if (store) { |
| 385 for (const autofill::PasswordForm& form : forms) { |
| 386 store->AddLogin(form); |
| 387 } |
| 388 } |
| 389 UMA_HISTOGRAM_BOOLEAN("PasswordManager.StorePasswordImportedFromCSVResult", |
| 390 store); |
| 391 } |
| 392 |
| 393 void PasswordManagerHandler::HandlePasswordExport(const base::ListValue* args) { |
| 394 #if !defined(OS_ANDROID) // This is never called on Android. |
| 395 if (!password_manager_presenter_->IsUserAuthenticated()) { |
| 396 return; |
| 397 } |
| 398 ui::SelectFileDialog::FileTypeInfo file_type_info; |
| 399 file_type_info.extensions = |
| 400 password_manager::PasswordExporter::GetSupportedFileExtensions(); |
| 401 DCHECK(!file_type_info.extensions.empty() && |
| 402 !file_type_info.extensions[0].empty()); |
| 403 file_type_info.include_all_files = true; |
| 404 ChromeSelectFilePolicy* select_file_policy = |
| 405 new ChromeSelectFilePolicy(web_ui()->GetWebContents()); |
| 406 ANNOTATE_LEAKING_OBJECT_PTR(select_file_policy); |
| 407 selected_file_dialog_ = |
| 408 ui::SelectFileDialog::Create(this, select_file_policy); |
| 409 selected_file_dialog_->SelectFile( |
| 410 ui::SelectFileDialog::SELECT_SAVEAS_FILE, |
| 411 l10n_util::GetStringUTF16(IDS_PASSWORD_MANAGER_EXPORT_DIALOG_TITLE), |
| 412 base::FilePath(), &file_type_info, 1, file_type_info.extensions[0][0], |
| 413 GetNativeWindow(), reinterpret_cast<void*>(EXPORT_FILE_SELECTED)); |
| 414 #endif |
| 415 } |
| 416 |
| 417 void PasswordManagerHandler::ExportPasswordFileSelected( |
| 418 const base::FilePath& path) { |
| 419 std::vector<scoped_ptr<autofill::PasswordForm>> password_list = |
| 420 password_manager_presenter_->GetAllPasswords(); |
| 421 UMA_HISTOGRAM_COUNTS("PasswordManager.ExportedPasswordsPerUserInCSV", |
| 422 password_list.size()); |
| 423 password_manager::PasswordExporter::Export( |
| 424 path, std::move(password_list), |
| 425 content::BrowserThread::GetMessageLoopProxyForThread( |
| 426 content::BrowserThread::FILE) |
| 427 .get()); |
| 428 } |
| 429 |
| 271 } // namespace options | 430 } // namespace options |
| OLD | NEW |