summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/autofill/autofill_dialog.h5
-rw-r--r--chrome/browser/autofill/autofill_dialog_controller_mac.h18
-rw-r--r--chrome/browser/autofill/autofill_dialog_controller_mac.mm29
-rw-r--r--chrome/browser/autofill/autofill_dialog_controller_mac_unittest.mm48
-rw-r--r--chrome/browser/autofill/autofill_dialog_gtk.cc4
-rw-r--r--chrome/browser/autofill/autofill_dialog_mac.mm9
-rw-r--r--chrome/browser/autofill/autofill_manager.cc6
-rw-r--r--chrome/browser/autofill/personal_data_manager.h3
-rw-r--r--chrome/browser/cocoa/preferences_window_controller.mm31
-rw-r--r--chrome/browser/cocoa/vertical_layout_view.mm2
-rw-r--r--chrome/browser/gtk/options/content_page_gtk.cc2
-rw-r--r--chrome/browser/views/autofill_profiles_view_win.cc3
-rw-r--r--chrome/browser/views/options/content_page_view.cc6
13 files changed, 130 insertions, 36 deletions
diff --git a/chrome/browser/autofill/autofill_dialog.h b/chrome/browser/autofill/autofill_dialog.h
index 7a5c966..31b497c 100644
--- a/chrome/browser/autofill/autofill_dialog.h
+++ b/chrome/browser/autofill/autofill_dialog.h
@@ -10,6 +10,8 @@
#include "chrome/browser/autofill/autofill_profile.h"
#include "chrome/browser/autofill/credit_card.h"
+class Profile;
+
// An interface the AutoFill dialog uses to notify its clients (observers) when
// the user has applied changes to the AutoFill profile data.
class AutoFillDialogObserver {
@@ -36,6 +38,7 @@ class AutoFillDialogObserver {
// whenever the web database is updated.
void ShowAutoFillDialog(AutoFillDialogObserver* observer,
const std::vector<AutoFillProfile*>& profiles,
- const std::vector<CreditCard*>& credit_cards);
+ const std::vector<CreditCard*>& credit_cards,
+ Profile* profile);
#endif // CHROME_BROWSER_AUTOFILL_AUTOFILL_DIALOG_H_
diff --git a/chrome/browser/autofill/autofill_dialog_controller_mac.h b/chrome/browser/autofill/autofill_dialog_controller_mac.h
index 2ea9c54..3f60b3c 100644
--- a/chrome/browser/autofill/autofill_dialog_controller_mac.h
+++ b/chrome/browser/autofill/autofill_dialog_controller_mac.h
@@ -14,6 +14,7 @@
@class AutoFillAddressViewController;
@class AutoFillCreditCardViewController;
+class Profile;
@class SectionSeparatorView;
@class WindowSizeAutosaver;
@@ -40,10 +41,15 @@
AutoFillDialogObserver* observer_; // Weak, not retained.
std::vector<AutoFillProfile> profiles_;
std::vector<CreditCard> creditCards_;
-
+ Profile* profile_; // Weak, not retained.
+ BOOL auxiliaryEnabled_;
scoped_nsobject<WindowSizeAutosaver> sizeSaver_;
}
+// Property representing state of Address Book "me" card usage. Checkbox is
+// bound to this in nib.
+@property (nonatomic) BOOL auxiliaryEnabled;
+
// Main interface for displaying an application modal autofill dialog on screen.
// This class method creates a new |AutoFillDialogController| and runs it as a
// modal dialog. The controller autoreleases itself when the dialog is closed.
@@ -53,9 +59,11 @@
// information.
// |profiles| and |creditCards| must have non-NULL entries (zero or more).
// These provide the initial data that is presented to the user.
+// |profile| must be non-NULL.
+ (void)showAutoFillDialogWithObserver:(AutoFillDialogObserver*)observer
autoFillProfiles:(const std::vector<AutoFillProfile*>&)profiles
- creditCards:(const std::vector<CreditCard*>&)creditCards;
+ creditCards:(const std::vector<CreditCard*>&)creditCards
+ profile:(Profile*)profile;
// IBActions for the dialog buttons.
- (IBAction)save:(id)sender;
@@ -87,11 +95,13 @@
+ (AutoFillDialogController*)controllerWithObserver:
(AutoFillDialogObserver*)observer
autoFillProfiles:(const std::vector<AutoFillProfile*>&)profiles
- creditCards:(const std::vector<CreditCard*>&)creditCards;
+ creditCards:(const std::vector<CreditCard*>&)creditCards
+ profile:(Profile*)profile;
- (id)initWithObserver:(AutoFillDialogObserver*)observer
autoFillProfiles:(const std::vector<AutoFillProfile*>&)profiles
- creditCards:(const std::vector<CreditCard*>&)creditCards;
+ creditCards:(const std::vector<CreditCard*>&)creditCards
+ profile:(Profile*)profile;
- (NSMutableArray*)addressFormViewControllers;
- (NSMutableArray*)creditCardFormViewControllers;
- (void)closeDialog;
diff --git a/chrome/browser/autofill/autofill_dialog_controller_mac.mm b/chrome/browser/autofill/autofill_dialog_controller_mac.mm
index e5f325e..3f6980b 100644
--- a/chrome/browser/autofill/autofill_dialog_controller_mac.mm
+++ b/chrome/browser/autofill/autofill_dialog_controller_mac.mm
@@ -13,6 +13,7 @@
#import "chrome/browser/cocoa/disclosure_view_controller.h"
#import "chrome/browser/cocoa/section_separator_view.h"
#import "chrome/browser/cocoa/window_size_autosaver.h"
+#include "chrome/browser/pref_service.h"
#include "chrome/browser/profile.h"
#include "chrome/common/pref_names.h"
#include "grit/generated_resources.h"
@@ -24,13 +25,17 @@
@implementation AutoFillDialogController
+@synthesize auxiliaryEnabled = auxiliaryEnabled_;
+
+ (void)showAutoFillDialogWithObserver:(AutoFillDialogObserver*)observer
autoFillProfiles:(const std::vector<AutoFillProfile*>&)profiles
- creditCards:(const std::vector<CreditCard*>&)creditCards {
+ creditCards:(const std::vector<CreditCard*>&)creditCards
+ profile:(Profile*)profile {
AutoFillDialogController* controller =
[AutoFillDialogController controllerWithObserver:observer
- autoFillProfiles:profiles
- creditCards:creditCards];
+ autoFillProfiles:profiles
+ creditCards:creditCards
+ profile:profile];
// Only run modal dialog if it is not already being shown.
if (![controller isWindowLoaded]) {
@@ -78,6 +83,8 @@
[creditCardFormViewController copyModelToCreditCard:&creditCards_[j]];
j++;
}
+ profile_->GetPrefs()->SetBoolean(prefs::kAutoFillAuxiliaryProfilesEnabled,
+ auxiliaryEnabled_);
observer_->OnAutoFillDialogApply(&profiles_, &creditCards_);
}
[self closeDialog];
@@ -221,13 +228,15 @@
+ (AutoFillDialogController*)controllerWithObserver:
(AutoFillDialogObserver*)observer
autoFillProfiles:(const std::vector<AutoFillProfile*>&)profiles
- creditCards:(const std::vector<CreditCard*>&)creditCards {
+ creditCards:(const std::vector<CreditCard*>&)creditCards
+ profile:(Profile*)profile {
// Deallocation is done upon window close. See |windowWillClose:|.
AutoFillDialogController* controller =
[[self alloc] initWithObserver:observer
autoFillProfiles:profiles
- creditCards:creditCards];
+ creditCards:creditCards
+ profile:profile];
return controller;
}
@@ -237,7 +246,9 @@
// |creditCards| are non-retained immutable list of credit card info.
- (id)initWithObserver:(AutoFillDialogObserver*)observer
autoFillProfiles:(const std::vector<AutoFillProfile*>&)profiles
- creditCards:(const std::vector<CreditCard*>&)creditCards {
+ creditCards:(const std::vector<CreditCard*>&)creditCards
+ profile:(Profile*)profile {
+ CHECK(profile);
// Use initWithWindowNibPath: instead of initWithWindowNibName: so we
// can override it in a unit test.
NSString* nibpath = [mac_util::MainAppBundle()
@@ -256,6 +267,12 @@
for (j = creditCards.begin(); j != creditCards.end(); ++j)
creditCards_.push_back(**j);
+ profile_ = profile;
+
+ // Use property here to trigger KVO binding.
+ [self setAuxiliaryEnabled:profile_->GetPrefs()->GetBoolean(
+ prefs::kAutoFillAuxiliaryProfilesEnabled)];
+
// Initialize array of sub-controllers.
addressFormViewControllers_.reset([[NSMutableArray array] retain]);
diff --git a/chrome/browser/autofill/autofill_dialog_controller_mac_unittest.mm b/chrome/browser/autofill/autofill_dialog_controller_mac_unittest.mm
index 6ea4c74..743728f 100644
--- a/chrome/browser/autofill/autofill_dialog_controller_mac_unittest.mm
+++ b/chrome/browser/autofill/autofill_dialog_controller_mac_unittest.mm
@@ -10,13 +10,16 @@
#include "chrome/browser/autofill/autofill_profile.h"
#include "chrome/browser/cocoa/browser_test_helper.h"
#import "chrome/browser/cocoa/cocoa_test_helper.h"
+#include "chrome/browser/pref_service.h"
#include "chrome/browser/profile.h"
+#include "chrome/common/pref_names.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace {
class AutoFillDialogObserverTester : public AutoFillDialogObserver {
public:
- AutoFillDialogObserverTester() : hit_(false) {}
+ AutoFillDialogObserverTester()
+ : hit_(false) {}
virtual ~AutoFillDialogObserverTester() {}
virtual void OnAutoFillDialogApply(
@@ -51,7 +54,8 @@ class AutoFillDialogControllerTest : public CocoaTest {
controller_ = [AutoFillDialogController
controllerWithObserver:&observer_
autoFillProfiles:profiles_
- creditCards:credit_cards_];
+ creditCards:credit_cards_
+ profile:helper_.profile()];
[controller_ window];
}
@@ -388,5 +392,45 @@ TEST_F(AutoFillDialogControllerTest, TwoCreditCardsDeleteOne) {
ASSERT_EQ(observer_.credit_cards_[0], credit_card);
}
+TEST_F(AutoFillDialogControllerTest, AuxiliaryProfilesFalse) {
+ LoadDialog();
+ [controller_ save:nil];
+
+ // Should hit our observer.
+ ASSERT_TRUE(observer_.hit_);
+
+ // Auxiliary profiles setting should be unchanged.
+ ASSERT_FALSE(helper_.profile()->GetPrefs()->GetBoolean(
+ prefs::kAutoFillAuxiliaryProfilesEnabled));
+}
+
+TEST_F(AutoFillDialogControllerTest, AuxiliaryProfilesTrue) {
+ helper_.profile()->GetPrefs()->SetBoolean(
+ prefs::kAutoFillAuxiliaryProfilesEnabled, true);
+ LoadDialog();
+ [controller_ save:nil];
+
+ // Should hit our observer.
+ ASSERT_TRUE(observer_.hit_);
+
+ // Auxiliary profiles setting should be unchanged.
+ ASSERT_TRUE(helper_.profile()->GetPrefs()->GetBoolean(
+ prefs::kAutoFillAuxiliaryProfilesEnabled));
+}
+
+TEST_F(AutoFillDialogControllerTest, AuxiliaryProfilesChanged) {
+ helper_.profile()->GetPrefs()->SetBoolean(
+ prefs::kAutoFillAuxiliaryProfilesEnabled, false);
+ LoadDialog();
+ [controller_ setAuxiliaryEnabled:YES];
+ [controller_ save:nil];
+
+ // Should hit our observer.
+ ASSERT_TRUE(observer_.hit_);
+
+ // Auxiliary profiles setting should be unchanged.
+ ASSERT_TRUE(helper_.profile()->GetPrefs()->GetBoolean(
+ prefs::kAutoFillAuxiliaryProfilesEnabled));
+}
}
diff --git a/chrome/browser/autofill/autofill_dialog_gtk.cc b/chrome/browser/autofill/autofill_dialog_gtk.cc
index 25d33d9..796a7de 100644
--- a/chrome/browser/autofill/autofill_dialog_gtk.cc
+++ b/chrome/browser/autofill/autofill_dialog_gtk.cc
@@ -17,6 +17,7 @@
#include "chrome/browser/autofill/form_group.h"
#include "chrome/browser/gtk/gtk_util.h"
#include "chrome/browser/gtk/options/options_layout_gtk.h"
+#include "chrome/browser/profile.h"
#include "grit/chromium_strings.h"
#include "grit/generated_resources.h"
#include "grit/locale_settings.h"
@@ -893,7 +894,8 @@ void AutoFillDialog::AddCreditCard(const CreditCard& credit_card) {
void ShowAutoFillDialog(AutoFillDialogObserver* observer,
const std::vector<AutoFillProfile*>& profiles,
- const std::vector<CreditCard*>& credit_cards) {
+ const std::vector<CreditCard*>& credit_cards,
+ Profile *profile) {
if (!dialog) {
dialog = new AutoFillDialog(observer, profiles, credit_cards);
}
diff --git a/chrome/browser/autofill/autofill_dialog_mac.mm b/chrome/browser/autofill/autofill_dialog_mac.mm
index 912ced4..d23236b 100644
--- a/chrome/browser/autofill/autofill_dialog_mac.mm
+++ b/chrome/browser/autofill/autofill_dialog_mac.mm
@@ -4,15 +4,18 @@
#import "chrome/browser/autofill/autofill_dialog_controller_mac.h"
#include "chrome/browser/autofill/autofill_dialog.h"
+#include "chrome/browser/profile.h"
// Mac implementation of |ShowAutoFillDialog| interface defined in
// |chrome/browser/autofill/autofill_dialog.h|.
void ShowAutoFillDialog(AutoFillDialogObserver* observer,
const std::vector<AutoFillProfile*>& profiles,
- const std::vector<CreditCard*>& credit_cards) {
+ const std::vector<CreditCard*>& credit_cards,
+ Profile *profile) {
[AutoFillDialogController
showAutoFillDialogWithObserver:observer
- autoFillProfiles:profiles
- creditCards:credit_cards];
+ autoFillProfiles:profiles
+ creditCards:credit_cards
+ profile:profile];
}
diff --git a/chrome/browser/autofill/autofill_manager.cc b/chrome/browser/autofill/autofill_manager.cc
index 9843f77..fe1e64c 100644
--- a/chrome/browser/autofill/autofill_manager.cc
+++ b/chrome/browser/autofill/autofill_manager.cc
@@ -42,6 +42,7 @@ void AutoFillManager::RegisterBrowserPrefs(PrefService* prefs) {
void AutoFillManager::RegisterUserPrefs(PrefService* prefs) {
prefs->RegisterBooleanPref(prefs::kAutoFillInfoBarShown, false);
prefs->RegisterBooleanPref(prefs::kAutoFillEnabled, true);
+ prefs->RegisterBooleanPref(prefs::kAutoFillAuxiliaryProfilesEnabled, false);
}
void AutoFillManager::FormFieldValuesSubmitted(
@@ -230,7 +231,10 @@ void AutoFillManager::OnPersonalDataLoaded() {
personal_data_->RemoveObserver(this);
ShowAutoFillDialog(
- this, personal_data_->profiles(), personal_data_->credit_cards());
+ this,
+ personal_data_->profiles(),
+ personal_data_->credit_cards(),
+ tab_contents_->profile()->GetOriginalProfile());
}
void AutoFillManager::OnInfoBarAccepted() {
diff --git a/chrome/browser/autofill/personal_data_manager.h b/chrome/browser/autofill/personal_data_manager.h
index 403d871..f5e6a977 100644
--- a/chrome/browser/autofill/personal_data_manager.h
+++ b/chrome/browser/autofill/personal_data_manager.h
@@ -45,11 +45,10 @@ class PersonalDataManager : public WebDataServiceConsumer,
virtual void OnWebDataServiceRequestDone(WebDataService::Handle h,
const WDTypedResult* result);
- // AutoFillDialogObserver implementation
+ // AutoFillDialogObserver implementation:
virtual void OnAutoFillDialogApply(std::vector<AutoFillProfile>* profiles,
std::vector<CreditCard>* credit_cards);
-
// Sets the listener to be notified of PersonalDataManager events.
void SetObserver(PersonalDataManager::Observer* observer);
diff --git a/chrome/browser/cocoa/preferences_window_controller.mm b/chrome/browser/cocoa/preferences_window_controller.mm
index 8422df7..f380661 100644
--- a/chrome/browser/cocoa/preferences_window_controller.mm
+++ b/chrome/browser/cocoa/preferences_window_controller.mm
@@ -427,8 +427,10 @@ class PrefObserverBridge : public NotificationObserver,
class PersonalDataManagerObserver : public PersonalDataManager::Observer {
public:
explicit PersonalDataManagerObserver(
- PersonalDataManager* personal_data_manager)
- : personal_data_manager_(personal_data_manager) {
+ PersonalDataManager* personal_data_manager,
+ Profile* profile)
+ : personal_data_manager_(personal_data_manager),
+ profile_(profile) {
}
virtual ~PersonalDataManagerObserver();
@@ -439,7 +441,8 @@ class PersonalDataManagerObserver : public PersonalDataManager::Observer {
// Static method to dispatch to |ShowAutoFillDialog| method in autofill
// module. This is public to facilitate direct external call when the
// data manager has already loaded its data.
- static void ShowAutoFillDialog(PersonalDataManager* personal_data_manager);
+ static void ShowAutoFillDialog(PersonalDataManager* personal_data_manager,
+ Profile* profile);
private:
// Utility method to remove |this| from |personal_data_manager_| as an
@@ -452,6 +455,9 @@ class PersonalDataManagerObserver : public PersonalDataManager::Observer {
// Weak reference.
PersonalDataManager* personal_data_manager_;
+ // Profile of caller. Held as weak reference. May not be NULL.
+ Profile* profile_;
+
private:
DISALLOW_COPY_AND_ASSIGN(PersonalDataManagerObserver);
};
@@ -474,24 +480,26 @@ void PersonalDataManagerObserver::RemoveObserver() {
// (deleting |this| in the process).
void PersonalDataManagerObserver::OnPersonalDataLoaded() {
RemoveObserver();
- PersonalDataManagerObserver::ShowAutoFillDialog(personal_data_manager_);
+ PersonalDataManagerObserver::ShowAutoFillDialog(personal_data_manager_,
+ profile_);
}
// Dispatches request to show the autofill dialog. If there are no profiles
// in the |personal_data_manager| the we create a new one here. Similary with
// credit card info.
void PersonalDataManagerObserver::ShowAutoFillDialog(
- PersonalDataManager* personal_data_manager) {
+ PersonalDataManager* personal_data_manager, Profile* profile) {
+ DCHECK(profile);
if (!personal_data_manager)
return;
std::vector<AutoFillProfile*> profiles = personal_data_manager->profiles();
- AutoFillProfile profile(ASCIIToUTF16(""), 0);
+ AutoFillProfile autofill_profile(ASCIIToUTF16(""), 0);
if (profiles.size() == 0) {
string16 new_profile_name =
l10n_util::GetStringUTF16(IDS_AUTOFILL_NEW_ADDRESS);
- profile.set_label(new_profile_name);
- profiles.push_back(&profile);
+ autofill_profile.set_label(new_profile_name);
+ profiles.push_back(&autofill_profile);
}
std::vector<CreditCard*> credit_cards = personal_data_manager->credit_cards();
@@ -503,7 +511,7 @@ void PersonalDataManagerObserver::ShowAutoFillDialog(
credit_cards.push_back(&credit_card);
}
- ::ShowAutoFillDialog(personal_data_manager, profiles, credit_cards);
+ ::ShowAutoFillDialog(personal_data_manager, profiles, credit_cards, profile);
}
@@ -1267,12 +1275,13 @@ const int kDisabledIndex = 1;
if (personalDataManager->IsDataLoaded()) {
// |personalDataManager| data is loaded, we can proceed with the dialog.
- PersonalDataManagerObserver::ShowAutoFillDialog(personalDataManager);
+ PersonalDataManagerObserver::ShowAutoFillDialog(personalDataManager,
+ profile_);
} else {
// |personalDataManager| data is NOT loaded, so we load it here, installing
// our observer.
personalDataManagerObserver_.reset(
- new PersonalDataManagerObserver(personalDataManager));
+ new PersonalDataManagerObserver(personalDataManager, profile_));
personalDataManager->SetObserver(personalDataManagerObserver_.get());
}
}
diff --git a/chrome/browser/cocoa/vertical_layout_view.mm b/chrome/browser/cocoa/vertical_layout_view.mm
index b4e6a5e..f2070db 100644
--- a/chrome/browser/cocoa/vertical_layout_view.mm
+++ b/chrome/browser/cocoa/vertical_layout_view.mm
@@ -29,7 +29,7 @@
}
// Override the default |viewWillDraw| to indicate to drawing machinery proper
-// arrangement of subvies.
+// arrangement of subviews.
- (void)viewWillDraw {
// Reposition child views prior to super's descent into its |viewWillDraw|
// pass.
diff --git a/chrome/browser/gtk/options/content_page_gtk.cc b/chrome/browser/gtk/options/content_page_gtk.cc
index d7ce179..64556cf 100644
--- a/chrome/browser/gtk/options/content_page_gtk.cc
+++ b/chrome/browser/gtk/options/content_page_gtk.cc
@@ -180,7 +180,7 @@ void ContentPageGtk::OnPersonalDataLoaded() {
ShowAutoFillDialog(
personal_data_, personal_data_->profiles(),
- personal_data_->credit_cards());
+ personal_data_->credit_cards(), profile());
}
GtkWidget* ContentPageGtk::InitPasswordSavingGroup() {
diff --git a/chrome/browser/views/autofill_profiles_view_win.cc b/chrome/browser/views/autofill_profiles_view_win.cc
index 7ff41d9..b18b365 100644
--- a/chrome/browser/views/autofill_profiles_view_win.cc
+++ b/chrome/browser/views/autofill_profiles_view_win.cc
@@ -1124,7 +1124,8 @@ void AutoFillProfilesView::AutoFillScrollView::Layout() {
// Declared in "chrome/browser/autofill/autofill_dialog.h"
void ShowAutoFillDialog(AutoFillDialogObserver* observer,
const std::vector<AutoFillProfile*>& profiles,
- const std::vector<CreditCard*>& credit_cards) {
+ const std::vector<CreditCard*>& credit_cards,
+ Profile* profile) {
AutoFillProfilesView::Show(observer, profiles, credit_cards);
}
diff --git a/chrome/browser/views/options/content_page_view.cc b/chrome/browser/views/options/content_page_view.cc
index 14bce89..a8f515c 100644
--- a/chrome/browser/views/options/content_page_view.cc
+++ b/chrome/browser/views/options/content_page_view.cc
@@ -118,7 +118,8 @@ void ContentPageView::ButtonPressed(
} else {
ShowAutoFillDialog(profile()->GetPersonalDataManager(),
profile()->GetPersonalDataManager()->profiles(),
- profile()->GetPersonalDataManager()->credit_cards());
+ profile()->GetPersonalDataManager()->credit_cards(),
+ profile());
}
} else if (sender == themes_reset_button_) {
UserMetricsRecordAction("Options_ThemesReset", profile()->GetPrefs());
@@ -420,7 +421,8 @@ void ContentPageView::OnConfirmMessageAccept() {
void ContentPageView::OnPersonalDataLoaded() {
ShowAutoFillDialog(profile()->GetPersonalDataManager(),
profile()->GetPersonalDataManager()->profiles(),
- profile()->GetPersonalDataManager()->credit_cards());
+ profile()->GetPersonalDataManager()->credit_cards(),
+ profile());
profile()->GetPersonalDataManager()->RemoveObserver(this);
}