| OLD | NEW |
| 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/automation/testing_automation_provider.h" | 5 #include "chrome/browser/automation/testing_automation_provider.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <set> | 8 #include <set> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 #include "chrome/browser/importer/importer_host.h" | 62 #include "chrome/browser/importer/importer_host.h" |
| 63 #include "chrome/browser/importer/importer_list.h" | 63 #include "chrome/browser/importer/importer_list.h" |
| 64 #include "chrome/browser/infobars/infobar_tab_helper.h" | 64 #include "chrome/browser/infobars/infobar_tab_helper.h" |
| 65 #include "chrome/browser/instant/instant_controller.h" | 65 #include "chrome/browser/instant/instant_controller.h" |
| 66 #include "chrome/browser/notifications/balloon.h" | 66 #include "chrome/browser/notifications/balloon.h" |
| 67 #include "chrome/browser/notifications/balloon_collection.h" | 67 #include "chrome/browser/notifications/balloon_collection.h" |
| 68 #include "chrome/browser/notifications/notification.h" | 68 #include "chrome/browser/notifications/notification.h" |
| 69 #include "chrome/browser/notifications/notification_ui_manager.h" | 69 #include "chrome/browser/notifications/notification_ui_manager.h" |
| 70 #include "chrome/browser/password_manager/password_store.h" | 70 #include "chrome/browser/password_manager/password_store.h" |
| 71 #include "chrome/browser/password_manager/password_store_change.h" | 71 #include "chrome/browser/password_manager/password_store_change.h" |
| 72 #include "chrome/browser/password_manager/password_store_factory.h" |
| 72 #include "chrome/browser/platform_util.h" | 73 #include "chrome/browser/platform_util.h" |
| 73 #include "chrome/browser/plugin_prefs.h" | 74 #include "chrome/browser/plugin_prefs.h" |
| 74 #include "chrome/browser/prefs/pref_service.h" | 75 #include "chrome/browser/prefs/pref_service.h" |
| 75 #include "chrome/browser/printing/print_view_manager.h" | 76 #include "chrome/browser/printing/print_view_manager.h" |
| 76 #include "chrome/browser/profiles/profile.h" | 77 #include "chrome/browser/profiles/profile.h" |
| 77 #include "chrome/browser/profiles/profile_info_cache.h" | 78 #include "chrome/browser/profiles/profile_info_cache.h" |
| 78 #include "chrome/browser/profiles/profile_manager.h" | 79 #include "chrome/browser/profiles/profile_manager.h" |
| 79 #include "chrome/browser/protector/protector_service.h" | 80 #include "chrome/browser/protector/protector_service.h" |
| 80 #include "chrome/browser/protector/protector_service_factory.h" | 81 #include "chrome/browser/protector/protector_service_factory.h" |
| 81 #include "chrome/browser/search_engines/template_url.h" | 82 #include "chrome/browser/search_engines/template_url.h" |
| (...skipping 3893 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3975 if (!password_dict->HasKey("signon_realm")) { | 3976 if (!password_dict->HasKey("signon_realm")) { |
| 3976 AutomationJSONReply(this, reply_message).SendError( | 3977 AutomationJSONReply(this, reply_message).SendError( |
| 3977 "Password must include a value for 'signon_realm.'"); | 3978 "Password must include a value for 'signon_realm.'"); |
| 3978 return; | 3979 return; |
| 3979 } | 3980 } |
| 3980 | 3981 |
| 3981 webkit::forms::PasswordForm new_password = | 3982 webkit::forms::PasswordForm new_password = |
| 3982 GetPasswordFormFromDict(*password_dict); | 3983 GetPasswordFormFromDict(*password_dict); |
| 3983 | 3984 |
| 3984 // Use IMPLICIT_ACCESS since new passwords aren't added in incognito mode. | 3985 // Use IMPLICIT_ACCESS since new passwords aren't added in incognito mode. |
| 3985 PasswordStore* password_store = | 3986 PasswordStore* password_store = PasswordStoreFactory::GetForProfile( |
| 3986 browser->profile()->GetPasswordStore(Profile::IMPLICIT_ACCESS); | 3987 browser->profile(), Profile::IMPLICIT_ACCESS); |
| 3987 | 3988 |
| 3988 // The password store does not exist for an incognito window. | 3989 // The password store does not exist for an incognito window. |
| 3989 if (password_store == NULL) { | 3990 if (password_store == NULL) { |
| 3990 scoped_ptr<DictionaryValue> return_value(new DictionaryValue); | 3991 scoped_ptr<DictionaryValue> return_value(new DictionaryValue); |
| 3991 return_value->SetBoolean("password_added", false); | 3992 return_value->SetBoolean("password_added", false); |
| 3992 AutomationJSONReply(this, reply_message).SendSuccess(return_value.get()); | 3993 AutomationJSONReply(this, reply_message).SendSuccess(return_value.get()); |
| 3993 return; | 3994 return; |
| 3994 } | 3995 } |
| 3995 | 3996 |
| 3996 // This observer will delete itself. | 3997 // This observer will delete itself. |
| (...skipping 24 matching lines...) Expand all Loading... |
| 4021 // Check here before calling GetPasswordFormFromDict. | 4022 // Check here before calling GetPasswordFormFromDict. |
| 4022 if (!password_dict->HasKey("signon_realm")) { | 4023 if (!password_dict->HasKey("signon_realm")) { |
| 4023 AutomationJSONReply(this, reply_message).SendError( | 4024 AutomationJSONReply(this, reply_message).SendError( |
| 4024 "Password must include a value for 'signon_realm.'"); | 4025 "Password must include a value for 'signon_realm.'"); |
| 4025 return; | 4026 return; |
| 4026 } | 4027 } |
| 4027 webkit::forms::PasswordForm to_remove = | 4028 webkit::forms::PasswordForm to_remove = |
| 4028 GetPasswordFormFromDict(*password_dict); | 4029 GetPasswordFormFromDict(*password_dict); |
| 4029 | 4030 |
| 4030 // Use EXPLICIT_ACCESS since passwords can be removed in incognito mode. | 4031 // Use EXPLICIT_ACCESS since passwords can be removed in incognito mode. |
| 4031 PasswordStore* password_store = | 4032 PasswordStore* password_store = PasswordStoreFactory::GetForProfile( |
| 4032 browser->profile()->GetPasswordStore(Profile::EXPLICIT_ACCESS); | 4033 browser->profile(), Profile::EXPLICIT_ACCESS); |
| 4033 if (password_store == NULL) { | 4034 if (password_store == NULL) { |
| 4034 AutomationJSONReply(this, reply_message).SendError( | 4035 AutomationJSONReply(this, reply_message).SendError( |
| 4035 "Unable to get password store."); | 4036 "Unable to get password store."); |
| 4036 return; | 4037 return; |
| 4037 } | 4038 } |
| 4038 | 4039 |
| 4039 // This observer will delete itself. | 4040 // This observer will delete itself. |
| 4040 PasswordStoreLoginsChangedObserver* observer = | 4041 PasswordStoreLoginsChangedObserver* observer = |
| 4041 new PasswordStoreLoginsChangedObserver( | 4042 new PasswordStoreLoginsChangedObserver( |
| 4042 this, reply_message, PasswordStoreChange::REMOVE, ""); | 4043 this, reply_message, PasswordStoreChange::REMOVE, ""); |
| 4043 observer->Init(); | 4044 observer->Init(); |
| 4044 | 4045 |
| 4045 password_store->RemoveLogin(to_remove); | 4046 password_store->RemoveLogin(to_remove); |
| 4046 } | 4047 } |
| 4047 | 4048 |
| 4048 // Sample json input: { "command": "GetSavedPasswords" } | 4049 // Sample json input: { "command": "GetSavedPasswords" } |
| 4049 // Refer to GetSavedPasswords() in chrome/test/pyautolib/pyauto.py for sample | 4050 // Refer to GetSavedPasswords() in chrome/test/pyautolib/pyauto.py for sample |
| 4050 // json output. | 4051 // json output. |
| 4051 void TestingAutomationProvider::GetSavedPasswords( | 4052 void TestingAutomationProvider::GetSavedPasswords( |
| 4052 Browser* browser, | 4053 Browser* browser, |
| 4053 DictionaryValue* args, | 4054 DictionaryValue* args, |
| 4054 IPC::Message* reply_message) { | 4055 IPC::Message* reply_message) { |
| 4055 // Use EXPLICIT_ACCESS since saved passwords can be retrieved in | 4056 // Use EXPLICIT_ACCESS since saved passwords can be retrieved in |
| 4056 // incognito mode. | 4057 // incognito mode. |
| 4057 PasswordStore* password_store = | 4058 PasswordStore* password_store = PasswordStoreFactory::GetForProfile( |
| 4058 browser->profile()->GetPasswordStore(Profile::EXPLICIT_ACCESS); | 4059 browser->profile(), Profile::EXPLICIT_ACCESS); |
| 4059 | 4060 |
| 4060 if (password_store == NULL) { | 4061 if (password_store == NULL) { |
| 4061 AutomationJSONReply reply(this, reply_message); | 4062 AutomationJSONReply reply(this, reply_message); |
| 4062 reply.SendError("Unable to get password store."); | 4063 reply.SendError("Unable to get password store."); |
| 4063 return; | 4064 return; |
| 4064 } | 4065 } |
| 4065 password_store->GetAutofillableLogins( | 4066 password_store->GetAutofillableLogins( |
| 4066 new AutomationProviderGetPasswordsObserver(this, reply_message)); | 4067 new AutomationProviderGetPasswordsObserver(this, reply_message)); |
| 4067 // Observer deletes itself after sending the result. | 4068 // Observer deletes itself after sending the result. |
| 4068 } | 4069 } |
| (...skipping 2987 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7056 | 7057 |
| 7057 Send(reply_message_); | 7058 Send(reply_message_); |
| 7058 redirect_query_ = 0; | 7059 redirect_query_ = 0; |
| 7059 reply_message_ = NULL; | 7060 reply_message_ = NULL; |
| 7060 } | 7061 } |
| 7061 | 7062 |
| 7062 void TestingAutomationProvider::OnRemoveProvider() { | 7063 void TestingAutomationProvider::OnRemoveProvider() { |
| 7063 if (g_browser_process) | 7064 if (g_browser_process) |
| 7064 g_browser_process->GetAutomationProviderList()->RemoveProvider(this); | 7065 g_browser_process->GetAutomationProviderList()->RemoveProvider(this); |
| 7065 } | 7066 } |
| OLD | NEW |