Upstream version 7.35.144.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / automation / automation_provider_observers.cc
index 95f4e31..8dae793 100644 (file)
 #include "chrome/browser/chrome_notification_types.h"
 #include "chrome/browser/content_settings/tab_specific_content_settings.h"
 #include "chrome/browser/extensions/crx_installer.h"
-#include "chrome/browser/extensions/extension_host.h"
 #include "chrome/browser/extensions/extension_service.h"
-#include "chrome/browser/extensions/extension_system.h"
 #include "chrome/browser/extensions/extension_tab_util.h"
 #include "chrome/browser/history/history_types.h"
 #include "chrome/browser/history/top_sites.h"
 #include "chrome/browser/infobars/confirm_infobar_delegate.h"
 #include "chrome/browser/infobars/infobar_service.h"
 #include "chrome/browser/metrics/metric_event_duration_details.h"
-#include "chrome/browser/password_manager/password_store_change.h"
 #include "chrome/browser/profiles/profile.h"
 #include "chrome/browser/renderer_host/chrome_render_message_filter.h"
 #include "chrome/browser/search_engines/template_url_service.h"
@@ -64,6 +61,7 @@
 #include "chrome/common/automation_messages.h"
 #include "chrome/common/content_settings_types.h"
 #include "chrome/common/extensions/extension_constants.h"
+#include "components/password_manager/core/browser/password_store_change.h"
 #include "content/public/browser/dom_operation_notification_details.h"
 #include "content/public/browser/navigation_controller.h"
 #include "content/public/browser/notification_service.h"
@@ -71,7 +69,9 @@
 #include "content/public/browser/render_view_host.h"
 #include "content/public/browser/web_contents.h"
 #include "content/public/common/process_type.h"
+#include "extensions/browser/extension_host.h"
 #include "extensions/browser/extension_registry.h"
+#include "extensions/browser/extension_system.h"
 #include "extensions/browser/process_manager.h"
 #include "extensions/browser/runtime_data.h"
 #include "extensions/common/extension.h"
@@ -655,7 +655,7 @@ void ExtensionReadyNotificationObserver::Observe(
 
 ExtensionUnloadNotificationObserver::ExtensionUnloadNotificationObserver()
     : did_receive_unload_notification_(false) {
-  registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED,
+  registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED,
                  content::NotificationService::AllSources());
 }
 
@@ -665,7 +665,7 @@ ExtensionUnloadNotificationObserver::~ExtensionUnloadNotificationObserver() {
 void ExtensionUnloadNotificationObserver::Observe(
     int type, const content::NotificationSource& source,
     const content::NotificationDetails& details) {
-  if (type == chrome::NOTIFICATION_EXTENSION_UNLOADED) {
+  if (type == chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED) {
     did_receive_unload_notification_ = true;
   } else {
     NOTREACHED();
@@ -1568,94 +1568,6 @@ void AutomationProviderGetPasswordsObserver::OnGetPasswordStoreResults(
   delete this;
 }
 
-PasswordStoreLoginsChangedObserver::PasswordStoreLoginsChangedObserver(
-    AutomationProvider* automation,
-    IPC::Message* reply_message,
-    PasswordStoreChange::Type expected_type,
-    const std::string& result_key)
-    : automation_(automation->AsWeakPtr()),
-      reply_message_(reply_message),
-      expected_type_(expected_type),
-      result_key_(result_key),
-      done_event_(false, false) {
-  AddRef();
-}
-
-PasswordStoreLoginsChangedObserver::~PasswordStoreLoginsChangedObserver() {
-  DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
-}
-
-void PasswordStoreLoginsChangedObserver::Init() {
-  DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
-  BrowserThread::PostTask(
-      BrowserThread::DB,
-      FROM_HERE,
-      base::Bind(&PasswordStoreLoginsChangedObserver::RegisterObserversTask,
-                 this));
-  done_event_.Wait();
-}
-
-void PasswordStoreLoginsChangedObserver::RegisterObserversTask() {
-  DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB));
-  registrar_.reset(new content::NotificationRegistrar);
-  registrar_->Add(this, chrome::NOTIFICATION_LOGINS_CHANGED,
-                  content::NotificationService::AllSources());
-  done_event_.Signal();
-}
-
-void PasswordStoreLoginsChangedObserver::Observe(
-    int type,
-    const content::NotificationSource& source,
-    const content::NotificationDetails& details) {
-  DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB));
-  DCHECK(type == chrome::NOTIFICATION_LOGINS_CHANGED);
-  registrar_.reset();  // Must be done from the DB thread.
-  PasswordStoreChangeList* change_details =
-      content::Details<PasswordStoreChangeList>(details).ptr();
-  if (change_details->size() != 1 ||
-      change_details->front().type() != expected_type_) {
-    // Notify the UI thread that there's an error.
-    std::string error = "Unexpected password store login change details.";
-    BrowserThread::PostTask(
-        BrowserThread::UI,
-        FROM_HERE,
-        base::Bind(&PasswordStoreLoginsChangedObserver::IndicateError, this,
-                   error));
-    return;
-  }
-
-  // Notify the UI thread that we're done listening.
-  BrowserThread::PostTask(
-      BrowserThread::UI,
-      FROM_HERE,
-      base::Bind(&PasswordStoreLoginsChangedObserver::IndicateDone, this));
-}
-
-void PasswordStoreLoginsChangedObserver::IndicateDone() {
-  DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
-  if (automation_.get()) {
-    if (result_key_.empty()) {
-      AutomationJSONReply(automation_.get(), reply_message_.release())
-          .SendSuccess(NULL);
-    } else {
-      scoped_ptr<base::DictionaryValue> return_value(new base::DictionaryValue);
-      return_value->SetBoolean(result_key_, true);
-      AutomationJSONReply(automation_.get(), reply_message_.release())
-          .SendSuccess(return_value.get());
-    }
-  }
-  Release();
-}
-
-void PasswordStoreLoginsChangedObserver::IndicateError(
-    const std::string& error) {
-  DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
-  if (automation_.get())
-    AutomationJSONReply(automation_.get(), reply_message_.release())
-        .SendError(error);
-  Release();
-}
-
 OmniboxAcceptNotificationObserver::OmniboxAcceptNotificationObserver(
     NavigationController* controller,
     AutomationProvider* automation,
@@ -1839,8 +1751,8 @@ NTPInfoObserver::NTPInfoObserver(AutomationProvider* automation,
   base::ListValue* default_sites_list = new base::ListValue;
   history::MostVisitedURLList urls = top_sites_->GetPrepopulatePages();
   for (size_t i = 0; i < urls.size(); ++i) {
-    default_sites_list->Append(base::Value::CreateStringValue(
-        urls[i].url.possibly_invalid_spec()));
+    default_sites_list->Append(
+        new base::StringValue(urls[i].url.possibly_invalid_spec()));
   }
   ntp_info_->Set("default_sites", default_sites_list);
 
@@ -2198,8 +2110,7 @@ void ProcessInfoObserver::OnDetailsAvailable() {
       base::ListValue* titles = new base::ListValue();
       for (size_t title_index = 0; title_index < iterator->titles.size();
            ++title_index) {
-        titles->Append(
-            base::Value::CreateStringValue(iterator->titles[title_index]));
+        titles->Append(new base::StringValue(iterator->titles[title_index]));
       }
       proc_data->Set("titles", titles);