Index: chrome/browser/automation/automation_provider_observers.cc |
=================================================================== |
--- chrome/browser/automation/automation_provider_observers.cc (revision 152427) |
+++ chrome/browser/automation/automation_provider_observers.cc (working copy) |
@@ -2242,180 +2242,6 @@ |
} |
} |
-AutofillDisplayedObserver::AutofillDisplayedObserver( |
- int notification, |
- RenderViewHost* render_view_host, |
- AutomationProvider* automation, |
- IPC::Message* reply_message) |
- : notification_(notification), |
- render_view_host_(render_view_host), |
- automation_(automation->AsWeakPtr()), |
- reply_message_(reply_message) { |
- content::Source<RenderViewHost> source(render_view_host_); |
- registrar_.Add(this, notification_, source); |
-} |
- |
-AutofillDisplayedObserver::~AutofillDisplayedObserver() {} |
- |
-void AutofillDisplayedObserver::Observe( |
- int type, |
- const content::NotificationSource& source, |
- const content::NotificationDetails& details) { |
- DCHECK_EQ(type, notification_); |
- DCHECK_EQ(content::Source<RenderViewHost>(source).ptr(), render_view_host_); |
- if (automation_) { |
- AutomationJSONReply(automation_, |
- reply_message_.release()).SendSuccess(NULL); |
- } |
- delete this; |
-} |
- |
-AutofillChangedObserver::AutofillChangedObserver( |
- AutomationProvider* automation, |
- IPC::Message* reply_message, |
- int num_profiles, |
- int num_credit_cards) |
- : automation_(automation->AsWeakPtr()), |
- reply_message_(reply_message), |
- num_profiles_(num_profiles), |
- num_credit_cards_(num_credit_cards), |
- done_event_(false, false) { |
- DCHECK(num_profiles_ >= 0 && num_credit_cards_ >= 0); |
- AddRef(); |
-} |
- |
-AutofillChangedObserver::~AutofillChangedObserver() { |
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
-} |
- |
-void AutofillChangedObserver::Init() { |
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
- BrowserThread::PostTask( |
- BrowserThread::DB, |
- FROM_HERE, |
- base::Bind(&AutofillChangedObserver::RegisterObserversTask, this)); |
- done_event_.Wait(); |
-} |
- |
-void AutofillChangedObserver::RegisterObserversTask() { |
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); |
- registrar_.reset(new content::NotificationRegistrar); |
- registrar_->Add(this, chrome::NOTIFICATION_AUTOFILL_CREDIT_CARD_CHANGED, |
- content::NotificationService::AllSources()); |
- registrar_->Add(this, chrome::NOTIFICATION_AUTOFILL_PROFILE_CHANGED, |
- content::NotificationService::AllSources()); |
- done_event_.Signal(); |
-} |
- |
-void AutofillChangedObserver::Observe( |
- int type, |
- const content::NotificationSource& source, |
- const content::NotificationDetails& details) { |
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); |
- |
- if (type == chrome::NOTIFICATION_AUTOFILL_CREDIT_CARD_CHANGED) { |
- num_credit_cards_--; |
- } else if (type == chrome::NOTIFICATION_AUTOFILL_PROFILE_CHANGED) { |
- num_profiles_--; |
- } else { |
- NOTREACHED(); |
- } |
- |
- if (num_profiles_ <= 0 && num_credit_cards_ <= 0) { |
- registrar_.reset(); // Must be done from the DB thread. |
- |
- // Notify the UI thread that we're done listening for all relevant |
- // autofill notifications. |
- BrowserThread::PostTask( |
- BrowserThread::UI, |
- FROM_HERE, |
- base::Bind(&AutofillChangedObserver::IndicateDone, this)); |
- } |
-} |
- |
-void AutofillChangedObserver::IndicateDone() { |
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
- if (automation_) { |
- AutomationJSONReply(automation_, |
- reply_message_.release()).SendSuccess(NULL); |
- } |
- Release(); |
-} |
- |
-AutofillFormSubmittedObserver::AutofillFormSubmittedObserver( |
- AutomationProvider* automation, |
- IPC::Message* reply_message, |
- PersonalDataManager* pdm) |
- : automation_(automation->AsWeakPtr()), |
- reply_message_(reply_message), |
- pdm_(pdm), |
- infobar_helper_(NULL) { |
- pdm_->SetObserver(this); |
- registrar_.Add(this, chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_ADDED, |
- content::NotificationService::AllSources()); |
-} |
- |
-AutofillFormSubmittedObserver::~AutofillFormSubmittedObserver() { |
- pdm_->RemoveObserver(this); |
- |
- if (infobar_helper_) { |
- InfoBarDelegate* infobar = NULL; |
- if (infobar_helper_->GetInfoBarCount() > 0 && |
- (infobar = infobar_helper_->GetInfoBarDelegateAt(0))) { |
- infobar_helper_->RemoveInfoBar(infobar); |
- } |
- } |
-} |
- |
-void AutofillFormSubmittedObserver::OnPersonalDataChanged() { |
- if (automation_) { |
- AutomationJSONReply(automation_, |
- reply_message_.release()).SendSuccess(NULL); |
- } |
- delete this; |
-} |
- |
-void AutofillFormSubmittedObserver::OnInsufficientFormData() { |
- if (automation_) { |
- AutomationJSONReply(automation_, |
- reply_message_.release()).SendSuccess(NULL); |
- } |
- delete this; |
-} |
- |
-void AutofillFormSubmittedObserver::Observe( |
- int type, |
- const content::NotificationSource& source, |
- const content::NotificationDetails& details) { |
- DCHECK(type == chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_ADDED); |
- |
- // Accept in the infobar. |
- infobar_helper_ = content::Source<InfoBarTabHelper>(source).ptr(); |
- InfoBarDelegate* infobar = NULL; |
- infobar = infobar_helper_->GetInfoBarDelegateAt(0); |
- |
- ConfirmInfoBarDelegate* confirm_infobar = infobar->AsConfirmInfoBarDelegate(); |
- if (!confirm_infobar) { |
- if (automation_) { |
- AutomationJSONReply( |
- automation_, reply_message_.release()).SendError( |
- "Infobar is not a confirm infobar."); |
- } |
- delete this; |
- return; |
- } |
- |
- if (!confirm_infobar->Accept()) { |
- if (automation_) { |
- AutomationJSONReply( |
- automation_, reply_message_.release()).SendError( |
- "Could not accept in the infobar."); |
- } |
- delete this; |
- return; |
- } |
-} |
- |
namespace { |
// Returns whether all active notifications have an associated process ID. |