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

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

Issue 7031038: Protect against NULL PasswordStore (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add comment; Check for NULL PasswordStore in TestingAutomationProvider. Created 9 years, 7 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/profiles/profile.h » ('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) 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 3588 matching lines...) Expand 10 before | Expand all | Expand 10 after
3599 reply.SendError("Password must include signon_realm."); 3599 reply.SendError("Password must include signon_realm.");
3600 return; 3600 return;
3601 } 3601 }
3602 webkit_glue::PasswordForm to_remove = 3602 webkit_glue::PasswordForm to_remove =
3603 GetPasswordFormFromDict(*password_dict); 3603 GetPasswordFormFromDict(*password_dict);
3604 3604
3605 Profile* profile = browser->profile(); 3605 Profile* profile = browser->profile();
3606 // Use EXPLICIT_ACCESS since passwords can be removed in incognito mode. 3606 // Use EXPLICIT_ACCESS since passwords can be removed in incognito mode.
3607 PasswordStore* password_store = 3607 PasswordStore* password_store =
3608 profile->GetPasswordStore(Profile::EXPLICIT_ACCESS); 3608 profile->GetPasswordStore(Profile::EXPLICIT_ACCESS);
3609 3609 if (password_store == NULL) {
3610 reply.SendError("Unable to get password store.");
James Hawkins 2011/05/20 22:28:18 This is likely more useful as LOG(ERROR), here and
3611 return;
3612 }
3610 password_store->RemoveLogin(to_remove); 3613 password_store->RemoveLogin(to_remove);
3611 reply.SendSuccess(NULL); 3614 reply.SendSuccess(NULL);
3612 } 3615 }
3613 3616
3614 // Sample json input: { "command": "GetSavedPasswords" } 3617 // Sample json input: { "command": "GetSavedPasswords" }
3615 // Refer to GetSavedPasswords() in chrome/test/pyautolib/pyauto.py for sample 3618 // Refer to GetSavedPasswords() in chrome/test/pyautolib/pyauto.py for sample
3616 // json output. 3619 // json output.
3617 void TestingAutomationProvider::GetSavedPasswords( 3620 void TestingAutomationProvider::GetSavedPasswords(
3618 Browser* browser, 3621 Browser* browser,
3619 DictionaryValue* args, 3622 DictionaryValue* args,
3620 IPC::Message* reply_message) { 3623 IPC::Message* reply_message) {
3621 Profile* profile = browser->profile(); 3624 Profile* profile = browser->profile();
3622 // Use EXPLICIT_ACCESS since saved passwords can be retrieved in 3625 // Use EXPLICIT_ACCESS since saved passwords can be retrieved in
3623 // incognito mode. 3626 // incognito mode.
3624 PasswordStore* password_store = 3627 PasswordStore* password_store =
3625 profile->GetPasswordStore(Profile::EXPLICIT_ACCESS); 3628 profile->GetPasswordStore(Profile::EXPLICIT_ACCESS);
3629 if (password_store == NULL) {
3630 AutomationJSONReply reply(this, reply_message);
3631 reply.SendError("Unable to get password store.");
3632 return;
3633 }
3626 password_store->GetAutofillableLogins( 3634 password_store->GetAutofillableLogins(
3627 new AutomationProviderGetPasswordsObserver(this, reply_message)); 3635 new AutomationProviderGetPasswordsObserver(this, reply_message));
3628 // Observer deletes itself after returning. 3636 // Observer deletes itself after returning.
3629 } 3637 }
3630 3638
3631 // Refer to ClearBrowsingData() in chrome/test/pyautolib/pyauto.py for sample 3639 // Refer to ClearBrowsingData() in chrome/test/pyautolib/pyauto.py for sample
3632 // json input. 3640 // json input.
3633 // Sample json output: {} 3641 // Sample json output: {}
3634 void TestingAutomationProvider::ClearBrowsingData( 3642 void TestingAutomationProvider::ClearBrowsingData(
3635 Browser* browser, 3643 Browser* browser,
(...skipping 2255 matching lines...) Expand 10 before | Expand all | Expand 10 after
5891 IPC::ParamTraits<std::vector<GURL> >::Write(reply_message_, redirects_gurl); 5899 IPC::ParamTraits<std::vector<GURL> >::Write(reply_message_, redirects_gurl);
5892 5900
5893 Send(reply_message_); 5901 Send(reply_message_);
5894 redirect_query_ = 0; 5902 redirect_query_ = 0;
5895 reply_message_ = NULL; 5903 reply_message_ = NULL;
5896 } 5904 }
5897 5905
5898 void TestingAutomationProvider::OnRemoveProvider() { 5906 void TestingAutomationProvider::OnRemoveProvider() {
5899 AutomationProviderList::GetInstance()->RemoveProvider(this); 5907 AutomationProviderList::GetInstance()->RemoveProvider(this);
5900 } 5908 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/profiles/profile.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698