OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/automation/testing_automation_provider.h" | 5 #include "chrome/browser/automation/testing_automation_provider.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 3402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3413 // The signon realm is effectively the primary key and must be included. | 3413 // The signon realm is effectively the primary key and must be included. |
3414 // Check here before calling GetPasswordFormFromDict. | 3414 // Check here before calling GetPasswordFormFromDict. |
3415 if (!password_dict->HasKey("signon_realm")) { | 3415 if (!password_dict->HasKey("signon_realm")) { |
3416 reply.SendError("Password must include signon_realm."); | 3416 reply.SendError("Password must include signon_realm."); |
3417 return; | 3417 return; |
3418 } | 3418 } |
3419 webkit_glue::PasswordForm new_password = | 3419 webkit_glue::PasswordForm new_password = |
3420 GetPasswordFormFromDict(*password_dict); | 3420 GetPasswordFormFromDict(*password_dict); |
3421 | 3421 |
3422 Profile* profile = browser->profile(); | 3422 Profile* profile = browser->profile(); |
3423 // Use IMPLICIT_ACCESS since new passwords aren't added off the record. | 3423 // Use IMPLICIT_ACCESS since new passwords aren't added in incognito mode. |
3424 PasswordStore* password_store = | 3424 PasswordStore* password_store = |
3425 profile->GetPasswordStore(Profile::IMPLICIT_ACCESS); | 3425 profile->GetPasswordStore(Profile::IMPLICIT_ACCESS); |
3426 | 3426 |
3427 // Set the return based on whether setting the password succeeded. | 3427 // Set the return based on whether setting the password succeeded. |
3428 scoped_ptr<DictionaryValue> return_value(new DictionaryValue); | 3428 scoped_ptr<DictionaryValue> return_value(new DictionaryValue); |
3429 | 3429 |
3430 // It will be null if it's accessed in an incognito window. | 3430 // It will be null if it's accessed in an incognito window. |
3431 if (password_store != NULL) { | 3431 if (password_store != NULL) { |
3432 password_store->AddLogin(new_password); | 3432 password_store->AddLogin(new_password); |
3433 return_value->SetBoolean("password_added", true); | 3433 return_value->SetBoolean("password_added", true); |
(...skipping 22 matching lines...) Expand all Loading... |
3456 // The signon realm is effectively the primary key and must be included. | 3456 // The signon realm is effectively the primary key and must be included. |
3457 // Check here before calling GetPasswordFormFromDict. | 3457 // Check here before calling GetPasswordFormFromDict. |
3458 if (!password_dict->HasKey("signon_realm")) { | 3458 if (!password_dict->HasKey("signon_realm")) { |
3459 reply.SendError("Password must include signon_realm."); | 3459 reply.SendError("Password must include signon_realm."); |
3460 return; | 3460 return; |
3461 } | 3461 } |
3462 webkit_glue::PasswordForm to_remove = | 3462 webkit_glue::PasswordForm to_remove = |
3463 GetPasswordFormFromDict(*password_dict); | 3463 GetPasswordFormFromDict(*password_dict); |
3464 | 3464 |
3465 Profile* profile = browser->profile(); | 3465 Profile* profile = browser->profile(); |
3466 // Use EXPLICIT_ACCESS since passwords can be removed off the record. | 3466 // Use EXPLICIT_ACCESS since passwords can be removed in incognito mode. |
3467 PasswordStore* password_store = | 3467 PasswordStore* password_store = |
3468 profile->GetPasswordStore(Profile::EXPLICIT_ACCESS); | 3468 profile->GetPasswordStore(Profile::EXPLICIT_ACCESS); |
3469 | 3469 |
3470 password_store->RemoveLogin(to_remove); | 3470 password_store->RemoveLogin(to_remove); |
3471 reply.SendSuccess(NULL); | 3471 reply.SendSuccess(NULL); |
3472 } | 3472 } |
3473 | 3473 |
3474 // Sample json input: { "command": "GetSavedPasswords" } | 3474 // Sample json input: { "command": "GetSavedPasswords" } |
3475 // Refer to GetSavedPasswords() in chrome/test/pyautolib/pyauto.py for sample | 3475 // Refer to GetSavedPasswords() in chrome/test/pyautolib/pyauto.py for sample |
3476 // json output. | 3476 // json output. |
3477 void TestingAutomationProvider::GetSavedPasswords( | 3477 void TestingAutomationProvider::GetSavedPasswords( |
3478 Browser* browser, | 3478 Browser* browser, |
3479 DictionaryValue* args, | 3479 DictionaryValue* args, |
3480 IPC::Message* reply_message) { | 3480 IPC::Message* reply_message) { |
3481 Profile* profile = browser->profile(); | 3481 Profile* profile = browser->profile(); |
3482 // Use EXPLICIT_ACCESS since saved passwords can be retreived off the record. | 3482 // Use EXPLICIT_ACCESS since saved passwords can be retreived in incognito mod
e. |
3483 PasswordStore* password_store = | 3483 PasswordStore* password_store = |
3484 profile->GetPasswordStore(Profile::EXPLICIT_ACCESS); | 3484 profile->GetPasswordStore(Profile::EXPLICIT_ACCESS); |
3485 password_store->GetAutofillableLogins( | 3485 password_store->GetAutofillableLogins( |
3486 new AutomationProviderGetPasswordsObserver(this, reply_message)); | 3486 new AutomationProviderGetPasswordsObserver(this, reply_message)); |
3487 // Observer deletes itself after returning. | 3487 // Observer deletes itself after returning. |
3488 } | 3488 } |
3489 | 3489 |
3490 // Refer to ClearBrowsingData() in chrome/test/pyautolib/pyauto.py for sample | 3490 // Refer to ClearBrowsingData() in chrome/test/pyautolib/pyauto.py for sample |
3491 // json input. | 3491 // json input. |
3492 // Sample json output: {} | 3492 // Sample json output: {} |
(...skipping 1530 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5023 // If you change this, update Observer for NotificationType::SESSION_END | 5023 // If you change this, update Observer for NotificationType::SESSION_END |
5024 // below. | 5024 // below. |
5025 MessageLoop::current()->PostTask(FROM_HERE, | 5025 MessageLoop::current()->PostTask(FROM_HERE, |
5026 NewRunnableMethod(this, &TestingAutomationProvider::OnRemoveProvider)); | 5026 NewRunnableMethod(this, &TestingAutomationProvider::OnRemoveProvider)); |
5027 } | 5027 } |
5028 } | 5028 } |
5029 | 5029 |
5030 void TestingAutomationProvider::OnRemoveProvider() { | 5030 void TestingAutomationProvider::OnRemoveProvider() { |
5031 AutomationProviderList::GetInstance()->RemoveProvider(this); | 5031 AutomationProviderList::GetInstance()->RemoveProvider(this); |
5032 } | 5032 } |
OLD | NEW |