Index: chrome/browser/extensions/app_notify_channel_setup.cc |
diff --git a/chrome/browser/extensions/app_notify_channel_setup.cc b/chrome/browser/extensions/app_notify_channel_setup.cc |
index 2e11a49ee14852d5afaab6d87cb96c10cc21b4c3..e87f6ceeba315435ca56258d600b7e9c6088ef31 100644 |
--- a/chrome/browser/extensions/app_notify_channel_setup.cc |
+++ b/chrome/browser/extensions/app_notify_channel_setup.cc |
@@ -31,6 +31,7 @@ using content::BrowserThread; |
using content::URLFetcher; |
namespace { |
+ |
static const char kChannelSetupAuthError[] = "unauthorized"; |
static const char kChannelSetupInternalError[] = "internal_error"; |
static const char kChannelSetupCanceledByUser[] = "canceled_by_user"; |
@@ -55,8 +56,20 @@ static const char* kRelevantGaiaServices[] = { |
GaiaConstants::kLSOService, |
}; |
static const int kRelevantGaiaServicesCount = arraysize(kRelevantGaiaServices); |
+ |
+static AppNotifyChannelSetup::InterceptorForTests* g_interceptor_for_tests = |
+ NULL; |
+ |
} // namespace. |
+// static |
+void AppNotifyChannelSetup::SetInterceptorForTests( |
+ AppNotifyChannelSetup::InterceptorForTests* interceptor) { |
+ // Only one interceptor at a time, please. |
+ CHECK(g_interceptor_for_tests == NULL); |
+ g_interceptor_for_tests = interceptor; |
+} |
+ |
AppNotifyChannelSetup::AppNotifyChannelSetup( |
Profile* profile, |
const std::string& extension_id, |
@@ -81,6 +94,13 @@ AppNotifyChannelSetup::AppNotifyChannelSetup( |
AppNotifyChannelSetup::~AppNotifyChannelSetup() {} |
void AppNotifyChannelSetup::Start() { |
+ if (g_interceptor_for_tests) { |
+ std::string channel_id; |
+ std::string error; |
+ g_interceptor_for_tests->DoIntercept(this, &channel_id, &error); |
+ delegate_->AppNotifyChannelSetupComplete(channel_id, error, this); |
+ return; |
+ } |
AddRef(); // Balanced in ReportResult. |
BeginLogin(); |
} |
@@ -317,8 +337,7 @@ void AppNotifyChannelSetup::ReportResult( |
CHECK(state_ == CHANNEL_ID_SETUP_DONE || state_ == ERROR_STATE); |
if (delegate_.get()) { |
- delegate_->AppNotifyChannelSetupComplete( |
- channel_id, error, return_route_id_, callback_id_); |
+ delegate_->AppNotifyChannelSetupComplete(channel_id, error, this); |
} |
Release(); // Matches AddRef in Start. |
} |