Skip to content

Commit

Permalink
Don't offer to save Autofill info in incognito.
Browse files Browse the repository at this point in the history
R=isherman@chromium.org
BUG=235153

Review URL: https://chromiumcodereview.appspot.com/14471014

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@196367 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
dbeam@chromium.org committed Apr 25, 2013
1 parent a8d3088 commit 0175eb3
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,8 @@ string16 AutofillDialogControllerImpl::SignInLinkText() const {
}

bool AutofillDialogControllerImpl::ShouldOfferToSaveInChrome() const {
return !IsPayingWithWallet() && IsManuallyEditingAnySection();
return !IsPayingWithWallet() && !profile_->IsOffTheRecord() &&
IsManuallyEditingAnySection();
}

bool AutofillDialogControllerImpl::AutocheckoutIsRunning() const {
Expand Down
25 changes: 25 additions & 0 deletions chrome/browser/ui/autofill/autofill_dialog_controller_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -878,4 +878,29 @@ TEST_F(AutofillDialogControllerTest, HideWalletEmail) {
ASSERT_LT(i, form_structure()->field_count());
}

TEST_F(AutofillDialogControllerTest, SaveDetailsInChrome) {
EXPECT_CALL(*controller()->GetView(), ModelChanged()).Times(2);

AutofillProfile full_profile(test::GetFullProfile());
controller()->GetTestingManager()->AddTestingProfile(&full_profile);

CreditCard card;
test::SetCreditCardInfo(
&card, "Donald Trump", "4111-1111-1111-1111", "10", "2025");
controller()->GetTestingManager()->AddTestingCreditCard(&card);
EXPECT_FALSE(controller()->ShouldOfferToSaveInChrome());

controller()->EditClickedForSection(SECTION_EMAIL);
EXPECT_TRUE(controller()->ShouldOfferToSaveInChrome());

controller()->EditCancelledForSection(SECTION_EMAIL);
EXPECT_FALSE(controller()->ShouldOfferToSaveInChrome());

controller()->MenuModelForSection(SECTION_EMAIL)->ActivatedAt(1);
EXPECT_TRUE(controller()->ShouldOfferToSaveInChrome());

profile()->set_incognito(true);
EXPECT_FALSE(controller()->ShouldOfferToSaveInChrome());
}

} // namespace autofill
10 changes: 10 additions & 0 deletions components/autofill/browser/test_personal_data_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,20 @@ void TestPersonalDataManager::AddTestingProfile(AutofillProfile* profile) {
OnPersonalDataChanged());
}

void TestPersonalDataManager::AddTestingCreditCard(CreditCard* credit_card) {
credit_cards_.push_back(credit_card);
FOR_EACH_OBSERVER(PersonalDataManagerObserver, observers_,
OnPersonalDataChanged());
}

const std::vector<AutofillProfile*>& TestPersonalDataManager::GetProfiles() {
return profiles_;
}

const std::vector<CreditCard*>& TestPersonalDataManager::credit_cards() const {
return credit_cards_;
}

void TestPersonalDataManager::SaveImportedProfile(
const AutofillProfile& imported_profile) {
imported_profile_ = imported_profile;
Expand Down
7 changes: 7 additions & 0 deletions components/autofill/browser/test_personal_data_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <vector>

#include "components/autofill/browser/autofill_profile.h"
#include "components/autofill/browser/credit_card.h"
#include "components/autofill/browser/personal_data_manager.h"

namespace autofill {
Expand All @@ -21,14 +22,20 @@ class TestPersonalDataManager : public PersonalDataManager {
// Adds |profile| to |profiles_|. This does not take ownership of |profile|.
void AddTestingProfile(AutofillProfile* profile);

// Adds |credit_card| to |credit_cards_|. This does not take ownership of
// |credit_card|.
void AddTestingCreditCard(CreditCard* credit_card);

virtual const std::vector<AutofillProfile*>& GetProfiles() OVERRIDE;
virtual void SaveImportedProfile(const AutofillProfile& imported_profile)
OVERRIDE;

const AutofillProfile& imported_profile() { return imported_profile_; }
virtual const std::vector<CreditCard*>& credit_cards() const OVERRIDE;

private:
std::vector<AutofillProfile*> profiles_;
std::vector<CreditCard*> credit_cards_;
AutofillProfile imported_profile_;
};

Expand Down

0 comments on commit 0175eb3

Please sign in to comment.