| Index: chrome/browser/webdata/web_data_service.cc
|
| diff --git a/chrome/browser/webdata/web_data_service.cc b/chrome/browser/webdata/web_data_service.cc
|
| index 3cedc20f78770c72f7a2279278f6e6b4831c8e0e..fe538dabb68b3643d35a024b71f6a22ddb8f468a 100644
|
| --- a/chrome/browser/webdata/web_data_service.cc
|
| +++ b/chrome/browser/webdata/web_data_service.cc
|
| @@ -22,10 +22,10 @@
|
| #include "chrome/browser/webdata/logins_table.h"
|
| #include "chrome/browser/webdata/token_service_table.h"
|
| #include "chrome/browser/webdata/web_apps_table.h"
|
| +#include "chrome/browser/webdata/web_data_service_observer.h"
|
| #include "chrome/browser/webdata/web_database_service.h"
|
| #include "chrome/browser/webdata/web_intents_table.h"
|
| #include "chrome/common/chrome_constants.h"
|
| -#include "chrome/common/chrome_notification_types.h"
|
| #include "components/autofill/browser/autofill_country.h"
|
| #include "components/autofill/browser/autofill_profile.h"
|
| #include "components/autofill/browser/credit_card.h"
|
| @@ -33,9 +33,6 @@
|
| #ifdef DEBUG
|
| #include "content/public/browser/browser_thread.h"
|
| #endif
|
| -#include "content/public/browser/notification_details.h"
|
| -#include "content/public/browser/notification_service.h"
|
| -#include "content/public/browser/notification_source.h"
|
| #include "grit/chromium_strings.h"
|
| #include "grit/generated_resources.h"
|
| #include "third_party/skia/include/core/SkBitmap.h"
|
| @@ -50,22 +47,6 @@ using base::Bind;
|
| using base::Time;
|
| using content::BrowserThread;
|
|
|
| -namespace {
|
| -
|
| -// A task used by WebDataService (for Sync mainly) to inform the
|
| -// PersonalDataManager living on the UI thread that it needs to refresh.
|
| -void NotifyOfMultipleAutofillChangesTask(
|
| - const scoped_refptr<WebDataService>& web_data_service) {
|
| - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
| -
|
| - content::NotificationService::current()->Notify(
|
| - chrome::NOTIFICATION_AUTOFILL_MULTIPLE_CHANGED,
|
| - content::Source<WebDataServiceBase>(web_data_service.get()),
|
| - content::NotificationService::NoDetails());
|
| -}
|
| -
|
| -} // namespace
|
| -
|
| WDAppImagesResult::WDAppImagesResult() : has_all_images(false) {}
|
|
|
| WDAppImagesResult::~WDAppImagesResult() {}
|
| @@ -98,7 +79,7 @@ void WebDataService::NotifyOfMultipleAutofillChanges(
|
|
|
| BrowserThread::PostTask(
|
| BrowserThread::UI, FROM_HERE,
|
| - Bind(&NotifyOfMultipleAutofillChangesTask,
|
| + Bind(&WebDataService::NotifyAutofillMultipleChangedOnUIThread,
|
| make_scoped_refptr(web_data_service)));
|
| }
|
|
|
| @@ -120,10 +101,6 @@ void WebDataService::CancelRequest(Handle h) {
|
| wdbs_->CancelRequest(h);
|
| }
|
|
|
| -content::NotificationSource WebDataService::GetNotificationSource() {
|
| - return content::Source<WebDataService>(this);
|
| -}
|
| -
|
| bool WebDataService::IsDatabaseLoaded() {
|
| return db_loaded_;
|
| }
|
| @@ -324,21 +301,20 @@ WebDataService::~WebDataService() {
|
| //
|
| ////////////////////////////////////////////////////////////////////////////////
|
|
|
| +void WebDataService::NotifyDatabaseLoadedOnUIThread() {
|
| + db_loaded_ = true;
|
| + // Notify that the database has been initialized.
|
| + FOR_EACH_OBSERVER(WebDataServiceObserver,
|
| + observer_list_,
|
| + WebDatabaseLoaded());
|
| +}
|
| +
|
| void WebDataService::DBInitFailed(sql::InitStatus sql_status) {
|
| ShowProfileErrorDialog(
|
| (sql_status == sql::INIT_FAILURE) ?
|
| IDS_COULDNT_OPEN_PROFILE_ERROR : IDS_PROFILE_TOO_NEW_ERROR);
|
| }
|
|
|
| -void WebDataService::NotifyDatabaseLoadedOnUIThread() {
|
| - db_loaded_ = true;
|
| - // Notify that the database has been initialized.
|
| - content::NotificationService::current()->Notify(
|
| - chrome::NOTIFICATION_WEB_DATABASE_LOADED,
|
| - content::Source<WebDataService>(this),
|
| - content::NotificationService::NoDetails());
|
| -}
|
| -
|
| void WebDataService::OnDatabaseInit(sql::InitStatus status) {
|
| if (status == sql::INIT_OK) {
|
| BrowserThread::PostTask(
|
| @@ -506,10 +482,9 @@ WebDatabase::State WebDataService::AddFormElementsImpl(
|
| // Post the notifications including the list of affected keys.
|
| // This is sent here so that work resulting from this notification will be
|
| // done on the DB thread, and not the UI thread.
|
| - content::NotificationService::current()->Notify(
|
| - chrome::NOTIFICATION_AUTOFILL_ENTRIES_CHANGED,
|
| - content::Source<WebDataService>(this),
|
| - content::Details<AutofillChangeList>(&changes));
|
| + FOR_EACH_OBSERVER(WebDataServiceObserver,
|
| + observer_list_,
|
| + AutofillEntriesChanged(changes));
|
|
|
| return WebDatabase::COMMIT_NEEDED;
|
| }
|
| @@ -534,10 +509,9 @@ WebDatabase::State WebDataService::RemoveFormElementsAddedBetweenImpl(
|
| // Post the notifications including the list of affected keys.
|
| // This is sent here so that work resulting from this notification
|
| // will be done on the DB thread, and not the UI thread.
|
| - content::NotificationService::current()->Notify(
|
| - chrome::NOTIFICATION_AUTOFILL_ENTRIES_CHANGED,
|
| - content::Source<WebDataService>(this),
|
| - content::Details<AutofillChangeList>(&changes));
|
| + FOR_EACH_OBSERVER(WebDataServiceObserver,
|
| + observer_list_,
|
| + AutofillEntriesChanged(changes));
|
| }
|
| return WebDatabase::COMMIT_NEEDED;
|
| }
|
| @@ -553,10 +527,9 @@ WebDatabase::State WebDataService::RemoveExpiredFormElementsImpl(
|
| // Post the notifications including the list of affected keys.
|
| // This is sent here so that work resulting from this notification
|
| // will be done on the DB thread, and not the UI thread.
|
| - content::NotificationService::current()->Notify(
|
| - chrome::NOTIFICATION_AUTOFILL_ENTRIES_CHANGED,
|
| - content::Source<WebDataService>(this),
|
| - content::Details<AutofillChangeList>(&changes));
|
| + FOR_EACH_OBSERVER(WebDataServiceObserver,
|
| + observer_list_,
|
| + AutofillEntriesChanged(changes));
|
| }
|
| return WebDatabase::COMMIT_NEEDED;
|
| }
|
| @@ -572,10 +545,9 @@ WebDatabase::State WebDataService::RemoveFormValueForElementNameImpl(
|
| AutofillKey(name, value)));
|
|
|
| // Post the notifications including the list of affected keys.
|
| - content::NotificationService::current()->Notify(
|
| - chrome::NOTIFICATION_AUTOFILL_ENTRIES_CHANGED,
|
| - content::Source<WebDataService>(this),
|
| - content::Details<AutofillChangeList>(&changes));
|
| + FOR_EACH_OBSERVER(WebDataServiceObserver,
|
| + observer_list_,
|
| + AutofillEntriesChanged(changes));
|
|
|
| return WebDatabase::COMMIT_NEEDED;
|
| }
|
| @@ -590,12 +562,11 @@ WebDatabase::State WebDataService::AddAutofillProfileImpl(
|
| }
|
|
|
| // Send GUID-based notification.
|
| - AutofillProfileChange change(AutofillProfileChange::ADD,
|
| - profile.guid(), &profile);
|
| - content::NotificationService::current()->Notify(
|
| - chrome::NOTIFICATION_AUTOFILL_PROFILE_CHANGED,
|
| - content::Source<WebDataService>(this),
|
| - content::Details<AutofillProfileChange>(&change));
|
| + AutofillProfileChange change(
|
| + AutofillProfileChange::ADD, profile.guid(), &profile);
|
| + FOR_EACH_OBSERVER(WebDataServiceObserver,
|
| + observer_list_,
|
| + AutofillProfileChanged(change));
|
|
|
| return WebDatabase::COMMIT_NEEDED;
|
| }
|
| @@ -620,10 +591,9 @@ WebDatabase::State WebDataService::UpdateAutofillProfileImpl(
|
| // Send GUID-based notification.
|
| AutofillProfileChange change(AutofillProfileChange::UPDATE,
|
| profile.guid(), &profile);
|
| - content::NotificationService::current()->Notify(
|
| - chrome::NOTIFICATION_AUTOFILL_PROFILE_CHANGED,
|
| - content::Source<WebDataService>(this),
|
| - content::Details<AutofillProfileChange>(&change));
|
| + FOR_EACH_OBSERVER(WebDataServiceObserver,
|
| + observer_list_,
|
| + AutofillProfileChanged(change));
|
|
|
| return WebDatabase::COMMIT_NEEDED;
|
| }
|
| @@ -644,10 +614,9 @@ WebDatabase::State WebDataService::RemoveAutofillProfileImpl(
|
|
|
| // Send GUID-based notification.
|
| AutofillProfileChange change(AutofillProfileChange::REMOVE, guid, NULL);
|
| - content::NotificationService::current()->Notify(
|
| - chrome::NOTIFICATION_AUTOFILL_PROFILE_CHANGED,
|
| - content::Source<WebDataService>(this),
|
| - content::Details<AutofillProfileChange>(&change));
|
| + FOR_EACH_OBSERVER(WebDataServiceObserver,
|
| + observer_list_,
|
| + AutofillProfileChanged(change));
|
|
|
| return WebDatabase::COMMIT_NEEDED;
|
| }
|
| @@ -728,10 +697,9 @@ WebDatabase::State
|
| iter != profile_guids.end(); ++iter) {
|
| AutofillProfileChange change(AutofillProfileChange::REMOVE, *iter,
|
| NULL);
|
| - content::NotificationService::current()->Notify(
|
| - chrome::NOTIFICATION_AUTOFILL_PROFILE_CHANGED,
|
| - content::Source<WebDataService>(this),
|
| - content::Details<AutofillProfileChange>(&change));
|
| + FOR_EACH_OBSERVER(WebDataServiceObserver,
|
| + observer_list_,
|
| + AutofillProfileChanged(change));
|
| }
|
| // Note: It is the caller's responsibility to post notifications for any
|
| // changes, e.g. by calling the Refresh() method of PersonalDataManager.
|
| @@ -740,6 +708,13 @@ WebDatabase::State
|
| return WebDatabase::COMMIT_NOT_NEEDED;
|
| }
|
|
|
| +void WebDataService::NotifyAutofillMultipleChangedOnUIThread() {
|
| + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
| + FOR_EACH_OBSERVER(WebDataServiceObserver,
|
| + observer_list_,
|
| + AutofillMultipleChanged());
|
| +}
|
| +
|
| AutofillProfileSyncableService*
|
| WebDataService::GetAutofillProfileSyncableService() const {
|
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB));
|
| @@ -756,6 +731,14 @@ AutocompleteSyncableService* WebDataService::GetAutocompleteSyncableService()
|
| return autocomplete_syncable_service_;
|
| }
|
|
|
| +void WebDataService::AddObserver(WebDataServiceObserver* observer) {
|
| + observer_list_.AddObserver(observer);
|
| +}
|
| +
|
| +void WebDataService::RemoveObserver(WebDataServiceObserver* observer) {
|
| + observer_list_.RemoveObserver(observer);
|
| +}
|
| +
|
| void WebDataService::DestroyAutofillProfileResult(const WDTypedResult* result) {
|
| DCHECK(result->GetType() == AUTOFILL_PROFILES_RESULT);
|
| const WDResult<std::vector<AutofillProfile*> >* r =
|
| @@ -773,4 +756,3 @@ void WebDataService::DestroyAutofillCreditCardResult(
|
| std::vector<CreditCard*> credit_cards = r->GetValue();
|
| STLDeleteElements(&credit_cards);
|
| }
|
| -
|
|
|