summaryrefslogtreecommitdiffstats
path: root/chrome/browser/views
diff options
context:
space:
mode:
authorgeorgey@chromium.org <georgey@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-10 22:52:34 +0000
committergeorgey@chromium.org <georgey@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-10 22:52:34 +0000
commitd857d72eb2795bb1a386878cf1a53e8e7ef6827a (patch)
tree0ddf3163521820abefde2ebeec10ea80c65a3fb9 /chrome/browser/views
parent2db27be7dbb16f02587b90f150a843d8ad234563 (diff)
downloadchromium_src-d857d72eb2795bb1a386878cf1a53e8e7ef6827a.zip
chromium_src-d857d72eb2795bb1a386878cf1a53e8e7ef6827a.tar.gz
chromium_src-d857d72eb2795bb1a386878cf1a53e8e7ef6827a.tar.bz2
Dialog showed now only if profiles are loaded - if not it waits until they are.
Added capability of multiple observers for profile loading. BUG=33026 TEST=If loading of profiles takes time (slow connection, for example), dialog does not appear until they are loaded. Review URL: http://codereview.chromium.org/601010 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@38688 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/views')
-rw-r--r--chrome/browser/views/options/content_page_view.cc26
-rw-r--r--chrome/browser/views/options/content_page_view.h7
2 files changed, 28 insertions, 5 deletions
diff --git a/chrome/browser/views/options/content_page_view.cc b/chrome/browser/views/options/content_page_view.cc
index e28f6a3..678d28c 100644
--- a/chrome/browser/views/options/content_page_view.cc
+++ b/chrome/browser/views/options/content_page_view.cc
@@ -73,6 +73,9 @@ ContentPageView::ContentPageView(Profile* profile)
}
ContentPageView::~ContentPageView() {
+ // Removes observer if we are observing Profile load. Does nothing otherwise.
+ if (profile()->GetPersonalDataManager())
+ profile()->GetPersonalDataManager()->RemoveObserver(this);
if (sync_service_)
sync_service_->RemoveObserver(this);
}
@@ -108,10 +111,15 @@ void ContentPageView::ButtonPressed(
UserMetricsRecordAction("Options_ShowPasswordsExceptions", NULL);
PasswordsExceptionsWindowView::Show(profile());
} else if (sender == change_autofill_settings_button_) {
- ShowAutoFillDialog(
- profile()->GetPersonalDataManager(),
- profile()->GetPersonalDataManager()->profiles(),
- profile()->GetPersonalDataManager()->credit_cards());
+ // This button should be disabled if we lack PersonalDataManager.
+ DCHECK(profile()->GetPersonalDataManager());
+ if (!profile()->GetPersonalDataManager()->IsDataLoaded()) {
+ profile()->GetPersonalDataManager()->SetObserver(this);
+ } else {
+ ShowAutoFillDialog(profile()->GetPersonalDataManager(),
+ profile()->GetPersonalDataManager()->profiles(),
+ profile()->GetPersonalDataManager()->credit_cards());
+ }
} else if (sender == themes_reset_button_) {
UserMetricsRecordAction("Options_ThemesReset", profile()->GetPrefs());
profile()->ClearTheme();
@@ -315,6 +323,9 @@ void ContentPageView::InitFormAutofillGroup() {
change_autofill_settings_button_ = new views::NativeButton(
this, l10n_util::GetString(IDS_OPTIONS_AUTOFILL_SETTINGS));
+ if (!profile()->GetPersonalDataManager())
+ change_autofill_settings_button_->SetEnabled(false);
+
using views::GridLayout;
using views::ColumnSet;
@@ -406,6 +417,13 @@ void ContentPageView::OnConfirmMessageAccept() {
ProfileSyncService::SyncEvent(ProfileSyncService::STOP_FROM_OPTIONS);
}
+void ContentPageView::OnPersonalDataLoaded() {
+ ShowAutoFillDialog(profile()->GetPersonalDataManager(),
+ profile()->GetPersonalDataManager()->profiles(),
+ profile()->GetPersonalDataManager()->credit_cards());
+ profile()->GetPersonalDataManager()->RemoveObserver(this);
+}
+
void ContentPageView::InitSyncGroup() {
sync_status_label_ = new views::Label;
sync_status_label_->SetMultiLine(true);
diff --git a/chrome/browser/views/options/content_page_view.h b/chrome/browser/views/options/content_page_view.h
index 0688c15..3f155ca 100644
--- a/chrome/browser/views/options/content_page_view.h
+++ b/chrome/browser/views/options/content_page_view.h
@@ -5,6 +5,7 @@
#ifndef CHROME_BROWSER_VIEWS_OPTIONS_CONTENT_PAGE_VIEW_H_
#define CHROME_BROWSER_VIEWS_OPTIONS_CONTENT_PAGE_VIEW_H_
+#include "chrome/browser/autofill/personal_data_manager.h"
#include "chrome/browser/sync/profile_sync_service.h"
#include "chrome/browser/views/options/options_page_view.h"
#include "chrome/browser/views/confirm_message_box_dialog.h"
@@ -30,7 +31,8 @@ class ContentPageView : public OptionsPageView,
public views::LinkController,
public ProfileSyncServiceObserver,
public views::ButtonListener,
- public ConfirmMessageBoxObserver {
+ public ConfirmMessageBoxObserver,
+ public PersonalDataManager::Observer {
public:
explicit ContentPageView(Profile* profile);
virtual ~ContentPageView();
@@ -44,6 +46,9 @@ class ContentPageView : public OptionsPageView,
// ConfirmMessageBoxObserver implementation.
virtual void OnConfirmMessageAccept();
+ // PersonalDataManager::Observer implementation.
+ virtual void OnPersonalDataLoaded();
+
// ProfileSyncServiceObserver method.
virtual void OnStateChanged();