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 <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 3739 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3750 import_settings_data_.browser = browser; | 3750 import_settings_data_.browser = browser; |
3751 import_settings_data_.reply_message = reply_message; | 3751 import_settings_data_.reply_message = reply_message; |
3752 | 3752 |
3753 importer_list_ = new ImporterList(NULL); | 3753 importer_list_ = new ImporterList(NULL); |
3754 importer_list_->DetectSourceProfiles(this); | 3754 importer_list_->DetectSourceProfiles(this); |
3755 } | 3755 } |
3756 | 3756 |
3757 namespace { | 3757 namespace { |
3758 | 3758 |
3759 // Translates a dictionary password to a PasswordForm struct. | 3759 // Translates a dictionary password to a PasswordForm struct. |
3760 webkit_glue::PasswordForm GetPasswordFormFromDict( | 3760 webkit::forms::PasswordForm GetPasswordFormFromDict( |
3761 const DictionaryValue& password_dict) { | 3761 const DictionaryValue& password_dict) { |
3762 | 3762 |
3763 // If the time is specified, change time to the specified time. | 3763 // If the time is specified, change time to the specified time. |
3764 base::Time time = base::Time::Now(); | 3764 base::Time time = base::Time::Now(); |
3765 int it; | 3765 int it; |
3766 double dt; | 3766 double dt; |
3767 if (password_dict.GetInteger("time", &it)) | 3767 if (password_dict.GetInteger("time", &it)) |
3768 time = base::Time::FromTimeT(it); | 3768 time = base::Time::FromTimeT(it); |
3769 else if (password_dict.GetDouble("time", &dt)) | 3769 else if (password_dict.GetDouble("time", &dt)) |
3770 time = base::Time::FromDoubleT(dt); | 3770 time = base::Time::FromDoubleT(dt); |
(...skipping 19 matching lines...) Expand all Loading... |
3790 password_dict.GetString("username_element", &username_element); | 3790 password_dict.GetString("username_element", &username_element); |
3791 password_dict.GetString("password_element", &password_element); | 3791 password_dict.GetString("password_element", &password_element); |
3792 password_dict.GetString("submit_element", &submit_element); | 3792 password_dict.GetString("submit_element", &submit_element); |
3793 password_dict.GetString("action_target", &action_target_text); | 3793 password_dict.GetString("action_target", &action_target_text); |
3794 if (!password_dict.GetBoolean("blacklist", &blacklist)) | 3794 if (!password_dict.GetBoolean("blacklist", &blacklist)) |
3795 blacklist = false; | 3795 blacklist = false; |
3796 | 3796 |
3797 GURL origin_gurl(origin_url_text); | 3797 GURL origin_gurl(origin_url_text); |
3798 GURL action_target(action_target_text); | 3798 GURL action_target(action_target_text); |
3799 | 3799 |
3800 webkit_glue::PasswordForm password_form; | 3800 webkit::forms::PasswordForm password_form; |
3801 password_form.signon_realm = signon_realm; | 3801 password_form.signon_realm = signon_realm; |
3802 password_form.username_value = username_value; | 3802 password_form.username_value = username_value; |
3803 password_form.password_value = password_value; | 3803 password_form.password_value = password_value; |
3804 password_form.origin = origin_gurl; | 3804 password_form.origin = origin_gurl; |
3805 password_form.username_element = username_element; | 3805 password_form.username_element = username_element; |
3806 password_form.password_element = password_element; | 3806 password_form.password_element = password_element; |
3807 password_form.submit_element = submit_element; | 3807 password_form.submit_element = submit_element; |
3808 password_form.action = action_target; | 3808 password_form.action = action_target; |
3809 password_form.blacklisted_by_user = blacklist; | 3809 password_form.blacklisted_by_user = blacklist; |
3810 password_form.date_created = time; | 3810 password_form.date_created = time; |
(...skipping 18 matching lines...) Expand all Loading... |
3829 } | 3829 } |
3830 | 3830 |
3831 // The "signon realm" is effectively the primary key and must be included. | 3831 // The "signon realm" is effectively the primary key and must be included. |
3832 // Check here before calling GetPasswordFormFromDict. | 3832 // Check here before calling GetPasswordFormFromDict. |
3833 if (!password_dict->HasKey("signon_realm")) { | 3833 if (!password_dict->HasKey("signon_realm")) { |
3834 AutomationJSONReply(this, reply_message).SendError( | 3834 AutomationJSONReply(this, reply_message).SendError( |
3835 "Password must include a value for 'signon_realm.'"); | 3835 "Password must include a value for 'signon_realm.'"); |
3836 return; | 3836 return; |
3837 } | 3837 } |
3838 | 3838 |
3839 webkit_glue::PasswordForm new_password = | 3839 webkit::forms::PasswordForm new_password = |
3840 GetPasswordFormFromDict(*password_dict); | 3840 GetPasswordFormFromDict(*password_dict); |
3841 | 3841 |
3842 // Use IMPLICIT_ACCESS since new passwords aren't added in incognito mode. | 3842 // Use IMPLICIT_ACCESS since new passwords aren't added in incognito mode. |
3843 PasswordStore* password_store = | 3843 PasswordStore* password_store = |
3844 browser->profile()->GetPasswordStore(Profile::IMPLICIT_ACCESS); | 3844 browser->profile()->GetPasswordStore(Profile::IMPLICIT_ACCESS); |
3845 | 3845 |
3846 // The password store does not exist for an incognito window. | 3846 // The password store does not exist for an incognito window. |
3847 if (password_store == NULL) { | 3847 if (password_store == NULL) { |
3848 scoped_ptr<DictionaryValue> return_value(new DictionaryValue); | 3848 scoped_ptr<DictionaryValue> return_value(new DictionaryValue); |
3849 return_value->SetBoolean("password_added", false); | 3849 return_value->SetBoolean("password_added", false); |
(...skipping 25 matching lines...) Expand all Loading... |
3875 return; | 3875 return; |
3876 } | 3876 } |
3877 | 3877 |
3878 // The "signon realm" is effectively the primary key and must be included. | 3878 // The "signon realm" is effectively the primary key and must be included. |
3879 // Check here before calling GetPasswordFormFromDict. | 3879 // Check here before calling GetPasswordFormFromDict. |
3880 if (!password_dict->HasKey("signon_realm")) { | 3880 if (!password_dict->HasKey("signon_realm")) { |
3881 AutomationJSONReply(this, reply_message).SendError( | 3881 AutomationJSONReply(this, reply_message).SendError( |
3882 "Password must include a value for 'signon_realm.'"); | 3882 "Password must include a value for 'signon_realm.'"); |
3883 return; | 3883 return; |
3884 } | 3884 } |
3885 webkit_glue::PasswordForm to_remove = | 3885 webkit::forms::PasswordForm to_remove = |
3886 GetPasswordFormFromDict(*password_dict); | 3886 GetPasswordFormFromDict(*password_dict); |
3887 | 3887 |
3888 // Use EXPLICIT_ACCESS since passwords can be removed in incognito mode. | 3888 // Use EXPLICIT_ACCESS since passwords can be removed in incognito mode. |
3889 PasswordStore* password_store = | 3889 PasswordStore* password_store = |
3890 browser->profile()->GetPasswordStore(Profile::EXPLICIT_ACCESS); | 3890 browser->profile()->GetPasswordStore(Profile::EXPLICIT_ACCESS); |
3891 if (password_store == NULL) { | 3891 if (password_store == NULL) { |
3892 AutomationJSONReply(this, reply_message).SendError( | 3892 AutomationJSONReply(this, reply_message).SendError( |
3893 "Unable to get password store."); | 3893 "Unable to get password store."); |
3894 return; | 3894 return; |
3895 } | 3895 } |
(...skipping 2765 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6661 | 6661 |
6662 Send(reply_message_); | 6662 Send(reply_message_); |
6663 redirect_query_ = 0; | 6663 redirect_query_ = 0; |
6664 reply_message_ = NULL; | 6664 reply_message_ = NULL; |
6665 } | 6665 } |
6666 | 6666 |
6667 void TestingAutomationProvider::OnRemoveProvider() { | 6667 void TestingAutomationProvider::OnRemoveProvider() { |
6668 if (g_browser_process) | 6668 if (g_browser_process) |
6669 g_browser_process->GetAutomationProviderList()->RemoveProvider(this); | 6669 g_browser_process->GetAutomationProviderList()->RemoveProvider(this); |
6670 } | 6670 } |
OLD | NEW |