| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/extensions/extension_gcm_app_handler.h" | 5 #include "chrome/browser/extensions/extension_gcm_app_handler.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 | 133 |
| 134 class FakeExtensionGCMAppHandler : public ExtensionGCMAppHandler { | 134 class FakeExtensionGCMAppHandler : public ExtensionGCMAppHandler { |
| 135 public: | 135 public: |
| 136 FakeExtensionGCMAppHandler(Profile* profile, Waiter* waiter) | 136 FakeExtensionGCMAppHandler(Profile* profile, Waiter* waiter) |
| 137 : ExtensionGCMAppHandler(profile), | 137 : ExtensionGCMAppHandler(profile), |
| 138 waiter_(waiter), | 138 waiter_(waiter), |
| 139 unregistration_result_(gcm::GCMClient::UNKNOWN_ERROR), | 139 unregistration_result_(gcm::GCMClient::UNKNOWN_ERROR), |
| 140 app_handler_count_drop_to_zero_(false) { | 140 app_handler_count_drop_to_zero_(false) { |
| 141 } | 141 } |
| 142 | 142 |
| 143 virtual ~FakeExtensionGCMAppHandler() { | 143 ~FakeExtensionGCMAppHandler() override {} |
| 144 } | |
| 145 | 144 |
| 146 virtual void OnMessage( | 145 void OnMessage(const std::string& app_id, |
| 146 const gcm::GCMClient::IncomingMessage& message) override {} |
| 147 |
| 148 void OnMessagesDeleted(const std::string& app_id) override {} |
| 149 |
| 150 void OnSendError( |
| 147 const std::string& app_id, | 151 const std::string& app_id, |
| 148 const gcm::GCMClient::IncomingMessage& message) override { | 152 const gcm::GCMClient::SendErrorDetails& send_error_details) override {} |
| 149 } | |
| 150 | 153 |
| 151 virtual void OnMessagesDeleted(const std::string& app_id) override { | 154 void OnUnregisterCompleted(const std::string& app_id, |
| 152 } | 155 gcm::GCMClient::Result result) override { |
| 153 | |
| 154 virtual void OnSendError( | |
| 155 const std::string& app_id, | |
| 156 const gcm::GCMClient::SendErrorDetails& send_error_details) override { | |
| 157 } | |
| 158 | |
| 159 virtual void OnUnregisterCompleted(const std::string& app_id, | |
| 160 gcm::GCMClient::Result result) override { | |
| 161 unregistration_result_ = result; | 156 unregistration_result_ = result; |
| 162 waiter_->SignalCompleted(); | 157 waiter_->SignalCompleted(); |
| 163 } | 158 } |
| 164 | 159 |
| 165 virtual void RemoveAppHandler(const std::string& app_id) override{ | 160 void RemoveAppHandler(const std::string& app_id) override { |
| 166 ExtensionGCMAppHandler::RemoveAppHandler(app_id); | 161 ExtensionGCMAppHandler::RemoveAppHandler(app_id); |
| 167 if (!GetGCMDriver()->app_handlers().size()) | 162 if (!GetGCMDriver()->app_handlers().size()) |
| 168 app_handler_count_drop_to_zero_ = true; | 163 app_handler_count_drop_to_zero_ = true; |
| 169 } | 164 } |
| 170 | 165 |
| 171 gcm::GCMClient::Result unregistration_result() const { | 166 gcm::GCMClient::Result unregistration_result() const { |
| 172 return unregistration_result_; | 167 return unregistration_result_; |
| 173 } | 168 } |
| 174 bool app_handler_count_drop_to_zero() const { | 169 bool app_handler_count_drop_to_zero() const { |
| 175 return app_handler_count_drop_to_zero_; | 170 return app_handler_count_drop_to_zero_; |
| (...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 490 | 485 |
| 491 // App handler is removed when the extension is updated to the version that | 486 // App handler is removed when the extension is updated to the version that |
| 492 // has GCM permission removed. | 487 // has GCM permission removed. |
| 493 UpdateExtension(extension.get(), "good2.crx"); | 488 UpdateExtension(extension.get(), "good2.crx"); |
| 494 waiter()->PumpUILoop(); | 489 waiter()->PumpUILoop(); |
| 495 EXPECT_TRUE(gcm_app_handler()->app_handler_count_drop_to_zero()); | 490 EXPECT_TRUE(gcm_app_handler()->app_handler_count_drop_to_zero()); |
| 496 EXPECT_FALSE(HasAppHandlers(extension->id())); | 491 EXPECT_FALSE(HasAppHandlers(extension->id())); |
| 497 } | 492 } |
| 498 | 493 |
| 499 } // namespace extensions | 494 } // namespace extensions |
| OLD | NEW |