Upstream version 10.38.222.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / extensions / extension_test_message_listener.cc
index e1aea6c..083594b 100644 (file)
@@ -6,12 +6,11 @@
 
 #include "base/strings/string_number_conversions.h"
 #include "base/strings/string_util.h"
-#include "chrome/browser/chrome_notification_types.h"
-#include "chrome/browser/chrome_notification_types.h"
-#include "chrome/browser/extensions/api/test/test_api.h"
-#include "chrome/test/base/ui_test_utils.h"
 #include "content/public/browser/notification_service.h"
 #include "content/public/browser/notification_source.h"
+#include "content/public/test/test_utils.h"
+#include "extensions/browser/api/test/test_api.h"
+#include "extensions/browser/notification_types.h"
 
 ExtensionTestMessageListener::ExtensionTestMessageListener(
     const std::string& expected_message,
@@ -23,7 +22,8 @@ ExtensionTestMessageListener::ExtensionTestMessageListener(
       will_reply_(will_reply),
       replied_(false),
       failed_(false) {
-  registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_TEST_MESSAGE,
+  registrar_.Add(this,
+                 extensions::NOTIFICATION_EXTENSION_TEST_MESSAGE,
                  content::NotificationService::AllSources());
 }
 
@@ -35,7 +35,7 @@ ExtensionTestMessageListener::ExtensionTestMessageListener(bool will_reply)
       replied_(false),
       failed_(false) {
   registrar_.Add(this,
-                 chrome::NOTIFICATION_EXTENSION_TEST_MESSAGE,
+                 extensions::NOTIFICATION_EXTENSION_TEST_MESSAGE,
                  content::NotificationService::AllSources());
 }
 
@@ -62,6 +62,15 @@ void ExtensionTestMessageListener::Reply(int message) {
   Reply(base::IntToString(message));
 }
 
+void ExtensionTestMessageListener::ReplyWithError(const std::string& error) {
+  CHECK(satisfied_);
+  CHECK(!replied_);
+
+  replied_ = true;
+  function_->ReplyWithError(error);
+  function_ = NULL;
+}
+
 void ExtensionTestMessageListener::Reset() {
   satisfied_ = false;
   failed_ = false;
@@ -73,6 +82,8 @@ void ExtensionTestMessageListener::Observe(
     int type,
     const content::NotificationSource& source,
     const content::NotificationDetails& details) {
+  DCHECK_EQ(extensions::NOTIFICATION_EXTENSION_TEST_MESSAGE, type);
+
   // Return immediately if we're already satisfied or it's not the right
   // extension.
   extensions::TestSendMessageFunction* function =
@@ -95,7 +106,7 @@ void ExtensionTestMessageListener::Observe(
     // Reply immediately, or save the function for future use.
     function_ = function;
     if (!will_reply_)
-      Reply(base::EmptyString());
+      Reply(std::string());
 
     if (waiting_) {
       waiting_ = false;