diff options
author | raz@chromium.org <raz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-11 15:48:01 +0000 |
---|---|---|
committer | raz@chromium.org <raz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-11 15:48:01 +0000 |
commit | d575770adfc5473264389b6d5487a13f08ccc3ee (patch) | |
tree | 0735e181987dadf9c40160ec9384510dfa797910 /chrome/browser | |
parent | fc61e22e068da641dc88c528ba4f37c9f55001d0 (diff) | |
download | chromium_src-d575770adfc5473264389b6d5487a13f08ccc3ee.zip chromium_src-d575770adfc5473264389b6d5487a13f08ccc3ee.tar.gz chromium_src-d575770adfc5473264389b6d5487a13f08ccc3ee.tar.bz2 |
Fixed 58452 + disabled clear server button, don't hide the UI
BUG=58452
TEST=repro steps in 58452, and in UI clear server data, note the button is greyed out not disabled
Review URL: http://codereview.chromium.org/3626006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@62147 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r-- | chrome/browser/views/clear_server_data.cc | 59 | ||||
-rw-r--r-- | chrome/browser/views/clear_server_data.h | 4 |
2 files changed, 44 insertions, 19 deletions
diff --git a/chrome/browser/views/clear_server_data.cc b/chrome/browser/views/clear_server_data.cc index 506083b..ee4e1eb 100644 --- a/chrome/browser/views/clear_server_data.cc +++ b/chrome/browser/views/clear_server_data.cc @@ -52,8 +52,16 @@ ClearServerDataView::ClearServerDataView(Profile* profile, DCHECK(profile); DCHECK(clear_data_view); - profile_->GetProfileSyncService()->ResetClearServerDataState(); - profile_->GetProfileSyncService()->AddObserver(this); + // Always show preferences for the original profile. Most state when off + // the record comes from the original profile, but we explicitly use + // the original profile to avoid potential problems. + profile_ = profile->GetOriginalProfile(); + sync_service_ = profile_->GetProfileSyncService(); + + if (NULL != sync_service_) { + sync_service_->ResetClearServerDataState(); + sync_service_->AddObserver(this); + } Init(); InitControlLayout(); @@ -61,7 +69,9 @@ ClearServerDataView::ClearServerDataView(Profile* profile, } ClearServerDataView::~ClearServerDataView(void) { - profile_->GetProfileSyncService()->RemoveObserver(this); + if (NULL != sync_service_) { + sync_service_->RemoveObserver(this); + } } void ClearServerDataView::Init() { @@ -161,19 +171,19 @@ void ClearServerDataView::InitControlVisibility() { CommandLine::ForCurrentProcess()->HasSwitch( switches::kEnableClearServerData); - bool sync_enabled = allow_clear_server_data_ui && - profile_->GetProfileSyncService()->HasSyncSetupCompleted(); - // Hide progress indicators throbber_->SetVisible(false); status_label_->SetVisible(false); - // Only show the sync portion if sync is enabled - chrome_sync_title_label_->SetVisible(sync_enabled); - chrome_sync_description_label_->SetVisible(sync_enabled); - clear_server_data_button_->SetVisible(sync_enabled); - dashboard_label_->SetVisible(sync_enabled); - dashboard_link_->SetVisible(sync_enabled); + // Only show the sync portion if not behind the flag + chrome_sync_title_label_->SetVisible(allow_clear_server_data_ui); + chrome_sync_description_label_->SetVisible(allow_clear_server_data_ui); + clear_server_data_button_->SetVisible(allow_clear_server_data_ui); + dashboard_label_->SetVisible(allow_clear_server_data_ui); + dashboard_link_->SetVisible(allow_clear_server_data_ui); + + // Enable our clear button, set false for delete_in_progress + UpdateClearButtonEnabledState(false); } void ClearServerDataView::SetAllowClear(bool allow) { @@ -220,7 +230,7 @@ void ClearServerDataView::ButtonPressed( // message, and the syncer syncs and resets itself before the // user tries pressing the Clear button in this dialog again. // TODO(raz) Confirm whether we have an issue here - if (profile_->GetProfileSyncService()->HasSyncSetupCompleted()) { + if (sync_service_->HasSyncSetupCompleted()) { ConfirmMessageBoxDialog::Run( GetWindow()->GetNativeWindow(), this, @@ -251,7 +261,7 @@ void ClearServerDataView::LinkActivated(views::Link* source, void ClearServerDataView::OnConfirmMessageAccept() { clear_data_parent_window_->StartClearingServerData(); - profile_->GetProfileSyncService()->ClearServerData(); + sync_service_->ClearServerData(); UpdateControlEnabledState(); } @@ -280,8 +290,13 @@ void ClearServerDataView::UpdateControlEnabledState() { // time the view is refreshed. As such, on success/failure handle that state // and immediately reset things back to CLEAR_NOT_STARTED. ProfileSyncService::ClearServerDataState clear_state = - profile_->GetProfileSyncService()->GetClearServerDataState(); - profile_->GetProfileSyncService()->ResetClearServerDataState(); + (sync_service_ == NULL) ? + ProfileSyncService::CLEAR_NOT_STARTED : + sync_service_->GetClearServerDataState(); + + if (NULL != sync_service_) { + sync_service_->ResetClearServerDataState(); + } switch (clear_state) { case ProfileSyncService::CLEAR_NOT_STARTED: @@ -313,9 +328,7 @@ void ClearServerDataView::UpdateControlEnabledState() { // allow_clear can be false when a local browsing data clear is happening // from the neighboring tab. delete_in_progress means that a clear is // pending in the current tab. - this->clear_server_data_button_->SetEnabled( - profile_->GetProfileSyncService()->HasSyncSetupCompleted() && - !delete_in_progress && allow_clear_); + UpdateClearButtonEnabledState(delete_in_progress); throbber_->SetVisible(delete_in_progress); if (delete_in_progress) @@ -324,3 +337,11 @@ void ClearServerDataView::UpdateControlEnabledState() { throbber_->Stop(); } +void ClearServerDataView::UpdateClearButtonEnabledState( + bool delete_in_progress) { + this->clear_server_data_button_->SetEnabled( + sync_service_ != NULL && + sync_service_->HasSyncSetupCompleted() && + !delete_in_progress && allow_clear_); +} + diff --git a/chrome/browser/views/clear_server_data.h b/chrome/browser/views/clear_server_data.h index e10d464..64254f3 100644 --- a/chrome/browser/views/clear_server_data.h +++ b/chrome/browser/views/clear_server_data.h @@ -81,6 +81,9 @@ class ClearServerDataView : public views::View, // have a delete operation in progress or not. void UpdateControlEnabledState(); + // Enables/disables the clear button as appropriate + void UpdateClearButtonEnabledState(bool delete_in_progress); + // Starts the process of deleting the browsing data depending on what the // user selected. void OnDelete(); @@ -94,6 +97,7 @@ class ClearServerDataView : public views::View, ClearDataView* clear_data_parent_window_; Profile* profile_; + ProfileSyncService* sync_service_; bool allow_clear_; views::Label* flash_title_label_; |