Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / password_manager / password_store_x.cc
index 4d1b031..19332fc 100644 (file)
@@ -13,8 +13,8 @@
 #include "base/prefs/pref_service.h"
 #include "base/stl_util.h"
 #include "chrome/browser/chrome_notification_types.h"
-#include "chrome/browser/password_manager/password_store_change.h"
 #include "chrome/common/pref_names.h"
+#include "components/password_manager/core/browser/password_store_change.h"
 #include "components/user_prefs/pref_registry_syncable.h"
 #include "content/public/browser/browser_thread.h"
 #include "content/public/browser/notification_service.h"
@@ -23,85 +23,78 @@ using autofill::PasswordForm;
 using content::BrowserThread;
 using std::vector;
 
-PasswordStoreX::PasswordStoreX(LoginDatabase* login_db,
-                               Profile* profile,
-                               NativeBackend* backend)
-    : PasswordStoreDefault(login_db, profile),
-      backend_(backend), migration_checked_(!backend), allow_fallback_(false) {
-}
+PasswordStoreX::PasswordStoreX(
+    scoped_refptr<base::SingleThreadTaskRunner> main_thread_runner,
+    scoped_refptr<base::SingleThreadTaskRunner> db_thread_runner,
+    LoginDatabase* login_db,
+    NativeBackend* backend)
+    : PasswordStoreDefault(main_thread_runner, db_thread_runner, login_db),
+      backend_(backend),
+      migration_checked_(!backend),
+      allow_fallback_(false) {}
 
 PasswordStoreX::~PasswordStoreX() {}
 
-void PasswordStoreX::AddLoginImpl(const PasswordForm& form) {
+PasswordStoreChangeList PasswordStoreX::AddLoginImpl(const PasswordForm& form) {
   CheckMigration();
+  PasswordStoreChangeList changes;
   if (use_native_backend() && backend_->AddLogin(form)) {
-    PasswordStoreChangeList changes;
     changes.push_back(PasswordStoreChange(PasswordStoreChange::ADD, form));
-    content::NotificationService::current()->Notify(
-        chrome::NOTIFICATION_LOGINS_CHANGED,
-        content::Source<PasswordStore>(this),
-        content::Details<PasswordStoreChangeList>(&changes));
     allow_fallback_ = false;
   } else if (allow_default_store()) {
-    PasswordStoreDefault::AddLoginImpl(form);
+    changes = PasswordStoreDefault::AddLoginImpl(form);
   }
+  return changes;
 }
 
-void PasswordStoreX::UpdateLoginImpl(const PasswordForm& form) {
+PasswordStoreChangeList PasswordStoreX::UpdateLoginImpl(
+    const PasswordForm& form) {
   CheckMigration();
+  PasswordStoreChangeList changes;
   if (use_native_backend() && backend_->UpdateLogin(form)) {
-    PasswordStoreChangeList changes;
     changes.push_back(PasswordStoreChange(PasswordStoreChange::UPDATE, form));
-    content::NotificationService::current()->Notify(
-        chrome::NOTIFICATION_LOGINS_CHANGED,
-        content::Source<PasswordStore>(this),
-        content::Details<PasswordStoreChangeList>(&changes));
     allow_fallback_ = false;
   } else if (allow_default_store()) {
-    PasswordStoreDefault::UpdateLoginImpl(form);
+    changes = PasswordStoreDefault::UpdateLoginImpl(form);
   }
+  return changes;
 }
 
-void PasswordStoreX::RemoveLoginImpl(const PasswordForm& form) {
+PasswordStoreChangeList PasswordStoreX::RemoveLoginImpl(
+    const PasswordForm& form) {
   CheckMigration();
+  PasswordStoreChangeList changes;
   if (use_native_backend() && backend_->RemoveLogin(form)) {
-    PasswordStoreChangeList changes;
     changes.push_back(PasswordStoreChange(PasswordStoreChange::REMOVE, form));
-    content::NotificationService::current()->Notify(
-        chrome::NOTIFICATION_LOGINS_CHANGED,
-        content::Source<PasswordStore>(this),
-        content::Details<PasswordStoreChangeList>(&changes));
     allow_fallback_ = false;
   } else if (allow_default_store()) {
-    PasswordStoreDefault::RemoveLoginImpl(form);
+    changes = PasswordStoreDefault::RemoveLoginImpl(form);
   }
+  return changes;
 }
 
-void PasswordStoreX::RemoveLoginsCreatedBetweenImpl(
+PasswordStoreChangeList PasswordStoreX::RemoveLoginsCreatedBetweenImpl(
     const base::Time& delete_begin,
     const base::Time& delete_end) {
   CheckMigration();
   vector<PasswordForm*> forms;
+  PasswordStoreChangeList changes;
   if (use_native_backend() &&
       backend_->GetLoginsCreatedBetween(delete_begin, delete_end, &forms) &&
       backend_->RemoveLoginsCreatedBetween(delete_begin, delete_end)) {
-    PasswordStoreChangeList changes;
     for (vector<PasswordForm*>::const_iterator it = forms.begin();
          it != forms.end(); ++it) {
       changes.push_back(PasswordStoreChange(PasswordStoreChange::REMOVE,
                                             **it));
     }
     LogStatsForBulkDeletion(changes.size());
-    content::NotificationService::current()->Notify(
-        chrome::NOTIFICATION_LOGINS_CHANGED,
-        content::Source<PasswordStore>(this),
-        content::Details<PasswordStoreChangeList>(&changes));
     allow_fallback_ = false;
   } else if (allow_default_store()) {
-    PasswordStoreDefault::RemoveLoginsCreatedBetweenImpl(delete_begin,
-                                                         delete_end);
+    changes = PasswordStoreDefault::RemoveLoginsCreatedBetweenImpl(delete_begin,
+                                                                   delete_end);
   }
   STLDeleteElements(&forms);
+  return changes;
 }
 
 namespace {