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 "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/lazy_instance.h" | 8 #include "base/lazy_instance.h" |
9 #include "base/location.h" | 9 #include "base/location.h" |
10 #include "chrome/browser/chrome_notification_types.h" | 10 #include "chrome/browser/chrome_notification_types.h" |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 } | 125 } |
126 | 126 |
127 RemoveAppHandler(extension->id()); | 127 RemoveAppHandler(extension->id()); |
128 } | 128 } |
129 | 129 |
130 void ExtensionGCMAppHandler::OnExtensionUninstalled( | 130 void ExtensionGCMAppHandler::OnExtensionUninstalled( |
131 content::BrowserContext* browser_context, | 131 content::BrowserContext* browser_context, |
132 const Extension* extension, | 132 const Extension* extension, |
133 extensions::UninstallReason reason) { | 133 extensions::UninstallReason reason) { |
134 if (IsGCMPermissionEnabled(extension)) { | 134 if (IsGCMPermissionEnabled(extension)) { |
| 135 #if defined(OS_ANDROID) |
| 136 LOG(FATAL) << "Unregistering from GCM requires a sender_id on Android"; |
| 137 #else |
| 138 std::vector<std::string> sender_ids; // These are ignored on desktop. |
135 GetGCMDriver()->Unregister( | 139 GetGCMDriver()->Unregister( |
136 extension->id(), | 140 extension->id(), |
| 141 sender_ids, |
137 base::Bind(&ExtensionGCMAppHandler::OnUnregisterCompleted, | 142 base::Bind(&ExtensionGCMAppHandler::OnUnregisterCompleted, |
138 weak_factory_.GetWeakPtr(), | 143 weak_factory_.GetWeakPtr(), |
139 extension->id())); | 144 extension->id())); |
140 RemoveAppHandler(extension->id()); | 145 RemoveAppHandler(extension->id()); |
| 146 #endif |
141 } | 147 } |
142 } | 148 } |
143 | 149 |
144 void ExtensionGCMAppHandler::AddDummyAppHandler() { | 150 void ExtensionGCMAppHandler::AddDummyAppHandler() { |
145 AddAppHandler(kDummyAppId); | 151 AddAppHandler(kDummyAppId); |
146 } | 152 } |
147 | 153 |
148 void ExtensionGCMAppHandler::RemoveDummyAppHandler() { | 154 void ExtensionGCMAppHandler::RemoveDummyAppHandler() { |
149 RemoveAppHandler(kDummyAppId); | 155 RemoveAppHandler(kDummyAppId); |
150 } | 156 } |
151 | 157 |
152 gcm::GCMDriver* ExtensionGCMAppHandler::GetGCMDriver() const { | 158 gcm::GCMDriver* ExtensionGCMAppHandler::GetGCMDriver() const { |
153 return gcm::GCMProfileServiceFactory::GetForProfile(profile_)->driver(); | 159 return gcm::GCMProfileServiceFactory::GetForProfile(profile_)->driver(); |
154 } | 160 } |
155 | 161 |
156 void ExtensionGCMAppHandler::OnUnregisterCompleted( | 162 void ExtensionGCMAppHandler::OnUnregisterCompleted( |
157 const std::string& app_id, gcm::GCMClient::Result result) { | 163 const std::string& app_id, gcm::GCMClient::Result result) { |
158 // Nothing to do. | 164 // Nothing to do. |
159 } | 165 } |
160 | 166 |
161 void ExtensionGCMAppHandler::AddAppHandler(const std::string& app_id) { | 167 void ExtensionGCMAppHandler::AddAppHandler(const std::string& app_id) { |
162 GetGCMDriver()->AddAppHandler(app_id, this); | 168 GetGCMDriver()->AddAppHandler(app_id, this); |
163 } | 169 } |
164 | 170 |
165 void ExtensionGCMAppHandler::RemoveAppHandler(const std::string& app_id) { | 171 void ExtensionGCMAppHandler::RemoveAppHandler(const std::string& app_id) { |
166 GetGCMDriver()->RemoveAppHandler(app_id); | 172 GetGCMDriver()->RemoveAppHandler(app_id); |
167 } | 173 } |
168 | 174 |
169 } // namespace extensions | 175 } // namespace extensions |
OLD | NEW |