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

Side by Side Diff: chrome/browser/automation/testing_automation_provider.cc

Issue 9665007: Profile refactoring: Remove all PasswordStore code from the Profile interface. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add to factory list Created 8 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/browsing_data_remover.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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_preview_tab_controller.h" 76 #include "chrome/browser/printing/print_preview_tab_controller.h"
76 #include "chrome/browser/printing/print_view_manager.h" 77 #include "chrome/browser/printing/print_view_manager.h"
77 #include "chrome/browser/profiles/profile.h" 78 #include "chrome/browser/profiles/profile.h"
78 #include "chrome/browser/profiles/profile_info_cache.h" 79 #include "chrome/browser/profiles/profile_info_cache.h"
79 #include "chrome/browser/profiles/profile_manager.h" 80 #include "chrome/browser/profiles/profile_manager.h"
80 #include "chrome/browser/protector/protector_service.h" 81 #include "chrome/browser/protector/protector_service.h"
81 #include "chrome/browser/protector/protector_service_factory.h" 82 #include "chrome/browser/protector/protector_service_factory.h"
(...skipping 3894 matching lines...) Expand 10 before | Expand all | Expand 10 after
3976 if (!password_dict->HasKey("signon_realm")) { 3977 if (!password_dict->HasKey("signon_realm")) {
3977 AutomationJSONReply(this, reply_message).SendError( 3978 AutomationJSONReply(this, reply_message).SendError(
3978 "Password must include a value for 'signon_realm.'"); 3979 "Password must include a value for 'signon_realm.'");
3979 return; 3980 return;
3980 } 3981 }
3981 3982
3982 webkit::forms::PasswordForm new_password = 3983 webkit::forms::PasswordForm new_password =
3983 GetPasswordFormFromDict(*password_dict); 3984 GetPasswordFormFromDict(*password_dict);
3984 3985
3985 // Use IMPLICIT_ACCESS since new passwords aren't added in incognito mode. 3986 // Use IMPLICIT_ACCESS since new passwords aren't added in incognito mode.
3986 PasswordStore* password_store = 3987 PasswordStore* password_store = PasswordStoreFactory::GetForProfile(
3987 browser->profile()->GetPasswordStore(Profile::IMPLICIT_ACCESS); 3988 browser->profile(), Profile::IMPLICIT_ACCESS);
3988 3989
3989 // The password store does not exist for an incognito window. 3990 // The password store does not exist for an incognito window.
3990 if (password_store == NULL) { 3991 if (password_store == NULL) {
3991 scoped_ptr<DictionaryValue> return_value(new DictionaryValue); 3992 scoped_ptr<DictionaryValue> return_value(new DictionaryValue);
3992 return_value->SetBoolean("password_added", false); 3993 return_value->SetBoolean("password_added", false);
3993 AutomationJSONReply(this, reply_message).SendSuccess(return_value.get()); 3994 AutomationJSONReply(this, reply_message).SendSuccess(return_value.get());
3994 return; 3995 return;
3995 } 3996 }
3996 3997
3997 // This observer will delete itself. 3998 // This observer will delete itself.
(...skipping 24 matching lines...) Expand all
4022 // Check here before calling GetPasswordFormFromDict. 4023 // Check here before calling GetPasswordFormFromDict.
4023 if (!password_dict->HasKey("signon_realm")) { 4024 if (!password_dict->HasKey("signon_realm")) {
4024 AutomationJSONReply(this, reply_message).SendError( 4025 AutomationJSONReply(this, reply_message).SendError(
4025 "Password must include a value for 'signon_realm.'"); 4026 "Password must include a value for 'signon_realm.'");
4026 return; 4027 return;
4027 } 4028 }
4028 webkit::forms::PasswordForm to_remove = 4029 webkit::forms::PasswordForm to_remove =
4029 GetPasswordFormFromDict(*password_dict); 4030 GetPasswordFormFromDict(*password_dict);
4030 4031
4031 // Use EXPLICIT_ACCESS since passwords can be removed in incognito mode. 4032 // Use EXPLICIT_ACCESS since passwords can be removed in incognito mode.
4032 PasswordStore* password_store = 4033 PasswordStore* password_store = PasswordStoreFactory::GetForProfile(
4033 browser->profile()->GetPasswordStore(Profile::EXPLICIT_ACCESS); 4034 browser->profile(), Profile::EXPLICIT_ACCESS);
4034 if (password_store == NULL) { 4035 if (password_store == NULL) {
4035 AutomationJSONReply(this, reply_message).SendError( 4036 AutomationJSONReply(this, reply_message).SendError(
4036 "Unable to get password store."); 4037 "Unable to get password store.");
4037 return; 4038 return;
4038 } 4039 }
4039 4040
4040 // This observer will delete itself. 4041 // This observer will delete itself.
4041 PasswordStoreLoginsChangedObserver* observer = 4042 PasswordStoreLoginsChangedObserver* observer =
4042 new PasswordStoreLoginsChangedObserver( 4043 new PasswordStoreLoginsChangedObserver(
4043 this, reply_message, PasswordStoreChange::REMOVE, ""); 4044 this, reply_message, PasswordStoreChange::REMOVE, "");
4044 observer->Init(); 4045 observer->Init();
4045 4046
4046 password_store->RemoveLogin(to_remove); 4047 password_store->RemoveLogin(to_remove);
4047 } 4048 }
4048 4049
4049 // Sample json input: { "command": "GetSavedPasswords" } 4050 // Sample json input: { "command": "GetSavedPasswords" }
4050 // Refer to GetSavedPasswords() in chrome/test/pyautolib/pyauto.py for sample 4051 // Refer to GetSavedPasswords() in chrome/test/pyautolib/pyauto.py for sample
4051 // json output. 4052 // json output.
4052 void TestingAutomationProvider::GetSavedPasswords( 4053 void TestingAutomationProvider::GetSavedPasswords(
4053 Browser* browser, 4054 Browser* browser,
4054 DictionaryValue* args, 4055 DictionaryValue* args,
4055 IPC::Message* reply_message) { 4056 IPC::Message* reply_message) {
4056 // Use EXPLICIT_ACCESS since saved passwords can be retrieved in 4057 // Use EXPLICIT_ACCESS since saved passwords can be retrieved in
4057 // incognito mode. 4058 // incognito mode.
4058 PasswordStore* password_store = 4059 PasswordStore* password_store = PasswordStoreFactory::GetForProfile(
4059 browser->profile()->GetPasswordStore(Profile::EXPLICIT_ACCESS); 4060 browser->profile(), Profile::EXPLICIT_ACCESS);
4060 4061
4061 if (password_store == NULL) { 4062 if (password_store == NULL) {
4062 AutomationJSONReply reply(this, reply_message); 4063 AutomationJSONReply reply(this, reply_message);
4063 reply.SendError("Unable to get password store."); 4064 reply.SendError("Unable to get password store.");
4064 return; 4065 return;
4065 } 4066 }
4066 password_store->GetAutofillableLogins( 4067 password_store->GetAutofillableLogins(
4067 new AutomationProviderGetPasswordsObserver(this, reply_message)); 4068 new AutomationProviderGetPasswordsObserver(this, reply_message));
4068 // Observer deletes itself after sending the result. 4069 // Observer deletes itself after sending the result.
4069 } 4070 }
(...skipping 2999 matching lines...) Expand 10 before | Expand all | Expand 10 after
7069 7070
7070 Send(reply_message_); 7071 Send(reply_message_);
7071 redirect_query_ = 0; 7072 redirect_query_ = 0;
7072 reply_message_ = NULL; 7073 reply_message_ = NULL;
7073 } 7074 }
7074 7075
7075 void TestingAutomationProvider::OnRemoveProvider() { 7076 void TestingAutomationProvider::OnRemoveProvider() {
7076 if (g_browser_process) 7077 if (g_browser_process)
7077 g_browser_process->GetAutomationProviderList()->RemoveProvider(this); 7078 g_browser_process->GetAutomationProviderList()->RemoveProvider(this);
7078 } 7079 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/browsing_data_remover.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698