| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_notification_observer.h" | 5 #include "chrome/browser/extensions/extension_notification_observer.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 str += "]"; | 27 str += "]"; |
| 28 return str; | 28 return str; |
| 29 } | 29 } |
| 30 | 30 |
| 31 } // namespace | 31 } // namespace |
| 32 | 32 |
| 33 ExtensionNotificationObserver::ExtensionNotificationObserver( | 33 ExtensionNotificationObserver::ExtensionNotificationObserver( |
| 34 content::NotificationSource source, | 34 content::NotificationSource source, |
| 35 const std::set<std::string>& extension_ids) | 35 const std::set<std::string>& extension_ids) |
| 36 : extension_ids_(extension_ids) { | 36 : extension_ids_(extension_ids) { |
| 37 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED, source); | 37 registrar_.Add( |
| 38 this, chrome::NOTIFICATION_EXTENSION_LOADED_DEPRECATED, source); |
| 38 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_INSTALLED, source); | 39 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_INSTALLED, source); |
| 39 registrar_.Add( | 40 registrar_.Add( |
| 40 this, chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED, source); | 41 this, chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED, source); |
| 41 } | 42 } |
| 42 | 43 |
| 43 ExtensionNotificationObserver::~ExtensionNotificationObserver() {} | 44 ExtensionNotificationObserver::~ExtensionNotificationObserver() {} |
| 44 | 45 |
| 45 testing::AssertionResult ExtensionNotificationObserver::CheckNotifications() { | 46 testing::AssertionResult ExtensionNotificationObserver::CheckNotifications() { |
| 46 return CheckNotifications(std::vector<chrome::NotificationType>()); | 47 return CheckNotifications(std::vector<chrome::NotificationType>()); |
| 47 } | 48 } |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 const content::NotificationDetails& details) { | 96 const content::NotificationDetails& details) { |
| 96 switch (type) { | 97 switch (type) { |
| 97 case chrome::NOTIFICATION_EXTENSION_INSTALLED: { | 98 case chrome::NOTIFICATION_EXTENSION_INSTALLED: { |
| 98 const Extension* extension = | 99 const Extension* extension = |
| 99 content::Details<const InstalledExtensionInfo>(details)->extension; | 100 content::Details<const InstalledExtensionInfo>(details)->extension; |
| 100 if (extension_ids_.count(extension->id())) | 101 if (extension_ids_.count(extension->id())) |
| 101 notifications_.push_back(static_cast<chrome::NotificationType>(type)); | 102 notifications_.push_back(static_cast<chrome::NotificationType>(type)); |
| 102 break; | 103 break; |
| 103 } | 104 } |
| 104 | 105 |
| 105 case chrome::NOTIFICATION_EXTENSION_LOADED: { | 106 case chrome::NOTIFICATION_EXTENSION_LOADED_DEPRECATED: { |
| 106 const Extension* extension = | 107 const Extension* extension = |
| 107 content::Details<const Extension>(details).ptr(); | 108 content::Details<const Extension>(details).ptr(); |
| 108 if (extension_ids_.count(extension->id())) | 109 if (extension_ids_.count(extension->id())) |
| 109 notifications_.push_back(static_cast<chrome::NotificationType>(type)); | 110 notifications_.push_back(static_cast<chrome::NotificationType>(type)); |
| 110 break; | 111 break; |
| 111 } | 112 } |
| 112 | 113 |
| 113 case chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED: { | 114 case chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED: { |
| 114 UnloadedExtensionInfo* reason = | 115 UnloadedExtensionInfo* reason = |
| 115 content::Details<UnloadedExtensionInfo>(details).ptr(); | 116 content::Details<UnloadedExtensionInfo>(details).ptr(); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 133 const std::vector<chrome::NotificationType>& types) { | 134 const std::vector<chrome::NotificationType>& types) { |
| 134 testing::AssertionResult result = (notifications_ == types) ? | 135 testing::AssertionResult result = (notifications_ == types) ? |
| 135 testing::AssertionSuccess() : | 136 testing::AssertionSuccess() : |
| 136 testing::AssertionFailure() << "Expected " << Str(types) << ", " << | 137 testing::AssertionFailure() << "Expected " << Str(types) << ", " << |
| 137 "Got " << Str(notifications_); | 138 "Got " << Str(notifications_); |
| 138 notifications_.clear(); | 139 notifications_.clear(); |
| 139 return result; | 140 return result; |
| 140 } | 141 } |
| 141 | 142 |
| 142 } // namespace extensions | 143 } // namespace extensions |
| OLD | NEW |