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 3417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3428 // The signon realm is effectively the primary key and must be included. | 3428 // The signon realm is effectively the primary key and must be included. |
3429 // Check here before calling GetPasswordFormFromDict. | 3429 // Check here before calling GetPasswordFormFromDict. |
3430 if (!password_dict->HasKey("signon_realm")) { | 3430 if (!password_dict->HasKey("signon_realm")) { |
3431 reply.SendError("Password must include signon_realm."); | 3431 reply.SendError("Password must include signon_realm."); |
3432 return; | 3432 return; |
3433 } | 3433 } |
3434 webkit_glue::PasswordForm new_password = | 3434 webkit_glue::PasswordForm new_password = |
3435 GetPasswordFormFromDict(*password_dict); | 3435 GetPasswordFormFromDict(*password_dict); |
3436 | 3436 |
3437 Profile* profile = browser->profile(); | 3437 Profile* profile = browser->profile(); |
3438 // Use IMPLICIT_ACCESS since new passwords aren't added off the record. | 3438 // Use IMPLICIT_ACCESS since new passwords aren't added incognito. |
akalin
2011/03/08 03:07:47
this becomes awkward phrasing; maybe "added in inc
| |
3439 PasswordStore* password_store = | 3439 PasswordStore* password_store = |
3440 profile->GetPasswordStore(Profile::IMPLICIT_ACCESS); | 3440 profile->GetPasswordStore(Profile::IMPLICIT_ACCESS); |
3441 | 3441 |
3442 // Set the return based on whether setting the password succeeded. | 3442 // Set the return based on whether setting the password succeeded. |
3443 scoped_ptr<DictionaryValue> return_value(new DictionaryValue); | 3443 scoped_ptr<DictionaryValue> return_value(new DictionaryValue); |
3444 | 3444 |
3445 // It will be null if it's accessed in an incognito window. | 3445 // It will be null if it's accessed in an incognito window. |
3446 if (password_store != NULL) { | 3446 if (password_store != NULL) { |
3447 password_store->AddLogin(new_password); | 3447 password_store->AddLogin(new_password); |
3448 return_value->SetBoolean("password_added", true); | 3448 return_value->SetBoolean("password_added", true); |
(...skipping 22 matching lines...) Expand all Loading... | |
3471 // The signon realm is effectively the primary key and must be included. | 3471 // The signon realm is effectively the primary key and must be included. |
3472 // Check here before calling GetPasswordFormFromDict. | 3472 // Check here before calling GetPasswordFormFromDict. |
3473 if (!password_dict->HasKey("signon_realm")) { | 3473 if (!password_dict->HasKey("signon_realm")) { |
3474 reply.SendError("Password must include signon_realm."); | 3474 reply.SendError("Password must include signon_realm."); |
3475 return; | 3475 return; |
3476 } | 3476 } |
3477 webkit_glue::PasswordForm to_remove = | 3477 webkit_glue::PasswordForm to_remove = |
3478 GetPasswordFormFromDict(*password_dict); | 3478 GetPasswordFormFromDict(*password_dict); |
3479 | 3479 |
3480 Profile* profile = browser->profile(); | 3480 Profile* profile = browser->profile(); |
3481 // Use EXPLICIT_ACCESS since passwords can be removed off the record. | 3481 // Use EXPLICIT_ACCESS since passwords can be removed incognito. |
akalin
2011/03/08 03:07:47
here, too
| |
3482 PasswordStore* password_store = | 3482 PasswordStore* password_store = |
3483 profile->GetPasswordStore(Profile::EXPLICIT_ACCESS); | 3483 profile->GetPasswordStore(Profile::EXPLICIT_ACCESS); |
3484 | 3484 |
3485 password_store->RemoveLogin(to_remove); | 3485 password_store->RemoveLogin(to_remove); |
3486 reply.SendSuccess(NULL); | 3486 reply.SendSuccess(NULL); |
3487 } | 3487 } |
3488 | 3488 |
3489 // Sample json input: { "command": "GetSavedPasswords" } | 3489 // Sample json input: { "command": "GetSavedPasswords" } |
3490 // Refer to GetSavedPasswords() in chrome/test/pyautolib/pyauto.py for sample | 3490 // Refer to GetSavedPasswords() in chrome/test/pyautolib/pyauto.py for sample |
3491 // json output. | 3491 // json output. |
3492 void TestingAutomationProvider::GetSavedPasswords( | 3492 void TestingAutomationProvider::GetSavedPasswords( |
3493 Browser* browser, | 3493 Browser* browser, |
3494 DictionaryValue* args, | 3494 DictionaryValue* args, |
3495 IPC::Message* reply_message) { | 3495 IPC::Message* reply_message) { |
3496 Profile* profile = browser->profile(); | 3496 Profile* profile = browser->profile(); |
3497 // Use EXPLICIT_ACCESS since saved passwords can be retreived off the record. | 3497 // Use EXPLICIT_ACCESS since saved passwords can be retreived incognito. |
akalin
2011/03/08 03:07:47
here, too
| |
3498 PasswordStore* password_store = | 3498 PasswordStore* password_store = |
3499 profile->GetPasswordStore(Profile::EXPLICIT_ACCESS); | 3499 profile->GetPasswordStore(Profile::EXPLICIT_ACCESS); |
3500 password_store->GetAutofillableLogins( | 3500 password_store->GetAutofillableLogins( |
3501 new AutomationProviderGetPasswordsObserver(this, reply_message)); | 3501 new AutomationProviderGetPasswordsObserver(this, reply_message)); |
3502 // Observer deletes itself after returning. | 3502 // Observer deletes itself after returning. |
3503 } | 3503 } |
3504 | 3504 |
3505 // Refer to ClearBrowsingData() in chrome/test/pyautolib/pyauto.py for sample | 3505 // Refer to ClearBrowsingData() in chrome/test/pyautolib/pyauto.py for sample |
3506 // json input. | 3506 // json input. |
3507 // Sample json output: {} | 3507 // Sample json output: {} |
(...skipping 1850 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5358 // If you change this, update Observer for NotificationType::SESSION_END | 5358 // If you change this, update Observer for NotificationType::SESSION_END |
5359 // below. | 5359 // below. |
5360 MessageLoop::current()->PostTask(FROM_HERE, | 5360 MessageLoop::current()->PostTask(FROM_HERE, |
5361 NewRunnableMethod(this, &TestingAutomationProvider::OnRemoveProvider)); | 5361 NewRunnableMethod(this, &TestingAutomationProvider::OnRemoveProvider)); |
5362 } | 5362 } |
5363 } | 5363 } |
5364 | 5364 |
5365 void TestingAutomationProvider::OnRemoveProvider() { | 5365 void TestingAutomationProvider::OnRemoveProvider() { |
5366 AutomationProviderList::GetInstance()->RemoveProvider(this); | 5366 AutomationProviderList::GetInstance()->RemoveProvider(this); |
5367 } | 5367 } |
OLD | NEW |