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

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

Issue 1995113002: Rename WebUI::CallJavascriptFunction to WebUI::CallJavascriptFunctionUnsafe (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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/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" 8 #include "base/command_line.h"
9 #include "base/feature_list.h" 9 #include "base/feature_list.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 base::Unretained(this))); 204 base::Unretained(this)));
205 } 205 }
206 206
207 void PasswordManagerHandler::InitializeHandler() { 207 void PasswordManagerHandler::InitializeHandler() {
208 password_manager_presenter_->Initialize(); 208 password_manager_presenter_->Initialize();
209 } 209 }
210 210
211 void PasswordManagerHandler::InitializePage() { 211 void PasswordManagerHandler::InitializePage() {
212 if (base::FeatureList::IsEnabled( 212 if (base::FeatureList::IsEnabled(
213 password_manager::features::kPasswordImportExport)) { 213 password_manager::features::kPasswordImportExport)) {
214 web_ui()->CallJavascriptFunction("PasswordManager.showImportExportButton"); 214 web_ui()->CallJavascriptFunctionUnsafe(
215 "PasswordManager.showImportExportButton");
215 } 216 }
216 } 217 }
217 218
218 void PasswordManagerHandler::HandleRemoveSavedPassword( 219 void PasswordManagerHandler::HandleRemoveSavedPassword(
219 const base::ListValue* args) { 220 const base::ListValue* args) {
220 std::string string_value = base::UTF16ToUTF8(ExtractStringValue(args)); 221 std::string string_value = base::UTF16ToUTF8(ExtractStringValue(args));
221 int index; 222 int index;
222 if (base::StringToInt(string_value, &index) && index >= 0) { 223 if (base::StringToInt(string_value, &index) && index >= 0) {
223 password_manager_presenter_->RemoveSavedPassword( 224 password_manager_presenter_->RemoveSavedPassword(
224 static_cast<size_t>(index)); 225 static_cast<size_t>(index));
(...skipping 18 matching lines...) Expand all
243 244
244 password_manager_presenter_->RequestShowPassword(static_cast<size_t>(index)); 245 password_manager_presenter_->RequestShowPassword(static_cast<size_t>(index));
245 } 246 }
246 247
247 void PasswordManagerHandler::ShowPassword( 248 void PasswordManagerHandler::ShowPassword(
248 size_t index, 249 size_t index,
249 const std::string& origin_url, 250 const std::string& origin_url,
250 const std::string& username, 251 const std::string& username,
251 const base::string16& password_value) { 252 const base::string16& password_value) {
252 // Call back the front end to reveal the password. 253 // Call back the front end to reveal the password.
253 web_ui()->CallJavascriptFunction( 254 web_ui()->CallJavascriptFunctionUnsafe(
254 "PasswordManager.showPassword", 255 "PasswordManager.showPassword",
255 base::FundamentalValue(static_cast<int>(index)), 256 base::FundamentalValue(static_cast<int>(index)),
256 base::StringValue(password_value)); 257 base::StringValue(password_value));
257 } 258 }
258 259
259 void PasswordManagerHandler::HandleUpdatePasswordLists( 260 void PasswordManagerHandler::HandleUpdatePasswordLists(
260 const base::ListValue* args) { 261 const base::ListValue* args) {
261 password_manager_presenter_->UpdatePasswordLists(); 262 password_manager_presenter_->UpdatePasswordLists();
262 } 263 }
263 264
(...skipping 14 matching lines...) Expand all
278 entry->SetString( 279 entry->SetString(
279 kFederationField, 280 kFederationField,
280 l10n_util::GetStringFUTF16( 281 l10n_util::GetStringFUTF16(
281 IDS_PASSWORDS_VIA_FEDERATION, 282 IDS_PASSWORDS_VIA_FEDERATION,
282 base::UTF8ToUTF16(saved_password->federation_origin.host()))); 283 base::UTF8ToUTF16(saved_password->federation_origin.host())));
283 } 284 }
284 285
285 entries.Append(entry.release()); 286 entries.Append(entry.release());
286 } 287 }
287 288
288 web_ui()->CallJavascriptFunction("PasswordManager.setSavedPasswordsList", 289 web_ui()->CallJavascriptFunctionUnsafe(
289 entries); 290 "PasswordManager.setSavedPasswordsList", entries);
290 } 291 }
291 292
292 void PasswordManagerHandler::SetPasswordExceptionList( 293 void PasswordManagerHandler::SetPasswordExceptionList(
293 const std::vector<std::unique_ptr<autofill::PasswordForm>>& 294 const std::vector<std::unique_ptr<autofill::PasswordForm>>&
294 password_exception_list) { 295 password_exception_list) {
295 base::ListValue entries; 296 base::ListValue entries;
296 for (const auto& exception : password_exception_list) { 297 for (const auto& exception : password_exception_list) {
297 std::unique_ptr<base::DictionaryValue> entry(new base::DictionaryValue); 298 std::unique_ptr<base::DictionaryValue> entry(new base::DictionaryValue);
298 CopyOriginInfoOfPasswordForm(*exception, entry.get()); 299 CopyOriginInfoOfPasswordForm(*exception, entry.get());
299 entries.Append(entry.release()); 300 entries.Append(entry.release());
300 } 301 }
301 302
302 web_ui()->CallJavascriptFunction("PasswordManager.setPasswordExceptionsList", 303 web_ui()->CallJavascriptFunctionUnsafe(
303 entries); 304 "PasswordManager.setPasswordExceptionsList", entries);
304 } 305 }
305 306
306 void PasswordManagerHandler::FileSelected(const base::FilePath& path, 307 void PasswordManagerHandler::FileSelected(const base::FilePath& path,
307 int index, 308 int index,
308 void* params) { 309 void* params) {
309 switch (static_cast<FileSelectorCaller>(reinterpret_cast<intptr_t>(params))) { 310 switch (static_cast<FileSelectorCaller>(reinterpret_cast<intptr_t>(params))) {
310 case IMPORT_FILE_SELECTED: 311 case IMPORT_FILE_SELECTED:
311 ImportPasswordFileSelected(path); 312 ImportPasswordFileSelected(path);
312 break; 313 break;
313 case EXPORT_FILE_SELECTED: 314 case EXPORT_FILE_SELECTED:
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
404 password_manager_presenter_->GetAllPasswords(); 405 password_manager_presenter_->GetAllPasswords();
405 UMA_HISTOGRAM_COUNTS("PasswordManager.ExportedPasswordsPerUserInCSV", 406 UMA_HISTOGRAM_COUNTS("PasswordManager.ExportedPasswordsPerUserInCSV",
406 password_list.size()); 407 password_list.size());
407 password_manager::PasswordExporter::Export( 408 password_manager::PasswordExporter::Export(
408 path, password_list, content::BrowserThread::GetMessageLoopProxyForThread( 409 path, password_list, content::BrowserThread::GetMessageLoopProxyForThread(
409 content::BrowserThread::FILE) 410 content::BrowserThread::FILE)
410 .get()); 411 .get());
411 } 412 }
412 413
413 } // namespace options 414 } // namespace options
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/options/options_ui.cc ('k') | chrome/browser/ui/webui/options/reset_profile_settings_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698