Chromium Code Reviews| 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 "content/public/common/push_messaging_status.h" | 5 #include "content/public/common/push_messaging_status.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 | 8 |
| 9 namespace content { | 9 namespace content { |
| 10 | 10 |
| 11 const char* PushRegistrationStatusToString(PushRegistrationStatus status) { | 11 // TODO(peter): Finish the registration -> subscription rename by changing the |
| 12 // following string values as well. These are Web exposed, however, so have to | |
| 13 // be considered with more care. https://crbug.com/446883. | |
| 14 | |
| 15 const char* PushSubscriptionStatusToString(PushSubscriptionStatus status) { | |
| 12 switch (status) { | 16 switch (status) { |
| 13 case PUSH_REGISTRATION_STATUS_SUCCESS_FROM_PUSH_SERVICE: | 17 case PUSH_SUBSCRIPTION_STATUS_SUCCESS_FROM_PUSH_SERVICE: |
| 14 return "Registration successful - from push service"; | 18 return "Registration successful - from push service"; |
| 15 | 19 |
| 16 case PUSH_REGISTRATION_STATUS_NO_SERVICE_WORKER: | 20 case PUSH_SUBSCRIPTION_STATUS_NO_SERVICE_WORKER: |
| 17 return "Registration failed - no Service Worker"; | 21 return "Registration failed - no Service Worker"; |
|
johnme
2015/05/07 13:31:26
Please also rename all these strings. Since the we
| |
| 18 | 22 |
| 19 case PUSH_REGISTRATION_STATUS_SERVICE_NOT_AVAILABLE: | 23 case PUSH_SUBSCRIPTION_STATUS_SERVICE_NOT_AVAILABLE: |
| 20 return "Registration failed - push service not available"; | 24 return "Registration failed - push service not available"; |
| 21 | 25 |
| 22 case PUSH_REGISTRATION_STATUS_LIMIT_REACHED: | 26 case PUSH_SUBSCRIPTION_STATUS_LIMIT_REACHED: |
| 23 return "Registration failed - registration limit has been reached"; | 27 return "Registration failed - registration limit has been reached"; |
| 24 | 28 |
| 25 case PUSH_REGISTRATION_STATUS_PERMISSION_DENIED: | 29 case PUSH_SUBSCRIPTION_STATUS_PERMISSION_DENIED: |
| 26 return "Registration failed - permission denied"; | 30 return "Registration failed - permission denied"; |
| 27 | 31 |
| 28 case PUSH_REGISTRATION_STATUS_SERVICE_ERROR: | 32 case PUSH_SUBSCRIPTION_STATUS_SERVICE_ERROR: |
| 29 return "Registration failed - push service error"; | 33 return "Registration failed - push service error"; |
| 30 | 34 |
| 31 case PUSH_REGISTRATION_STATUS_NO_SENDER_ID: | 35 case PUSH_SUBSCRIPTION_STATUS_NO_SENDER_ID: |
| 32 return "Registration failed - no sender id provided"; | 36 return "Registration failed - no sender id provided"; |
| 33 | 37 |
| 34 case PUSH_REGISTRATION_STATUS_STORAGE_ERROR: | 38 case PUSH_SUBSCRIPTION_STATUS_STORAGE_ERROR: |
| 35 return "Registration failed - storage error"; | 39 return "Registration failed - storage error"; |
| 36 | 40 |
| 37 case PUSH_REGISTRATION_STATUS_SUCCESS_FROM_CACHE: | 41 case PUSH_SUBSCRIPTION_STATUS_SUCCESS_FROM_CACHE: |
| 38 return "Registration successful - from cache"; | 42 return "Registration successful - from cache"; |
| 39 | 43 |
| 40 case PUSH_REGISTRATION_STATUS_NETWORK_ERROR: | 44 case PUSH_SUBSCRIPTION_STATUS_NETWORK_ERROR: |
| 41 return "Registration failed - could not connect to push server"; | 45 return "Registration failed - could not connect to push server"; |
| 42 | 46 |
| 43 case PUSH_REGISTRATION_STATUS_INCOGNITO_PERMISSION_DENIED: | 47 case PUSH_SUBSCRIPTION_STATUS_INCOGNITO_PERMISSION_DENIED: |
| 44 // We split this out for UMA, but it must be indistinguishable to JS. | 48 // We split this out for UMA, but it must be indistinguishable to JS. |
| 45 return PushRegistrationStatusToString( | 49 return PushSubscriptionStatusToString( |
| 46 PUSH_REGISTRATION_STATUS_PERMISSION_DENIED); | 50 PUSH_SUBSCRIPTION_STATUS_PERMISSION_DENIED); |
| 47 } | 51 } |
| 48 NOTREACHED(); | 52 NOTREACHED(); |
| 49 return ""; | 53 return ""; |
| 50 } | 54 } |
| 51 | 55 |
| 52 const char* PushUnregistrationStatusToString(PushUnregistrationStatus status) { | 56 const char* PushUnsubscriptionStatusToString(PushUnsubscriptionStatus status) { |
| 53 switch (status) { | 57 switch (status) { |
| 54 case PUSH_UNREGISTRATION_STATUS_SUCCESS_UNREGISTERED: | 58 case PUSH_UNSUBSCRIPTION_STATUS_SUCCESS_UNSUBSCRIBED: |
| 55 return "Unregistration successful - from push service"; | 59 return "Unregistration successful - from push service"; |
| 56 | 60 |
| 57 case PUSH_UNREGISTRATION_STATUS_SUCCESS_WAS_NOT_REGISTERED: | 61 case PUSH_UNSUBSCRIPTION_STATUS_SUCCESS_WAS_NOT_SUBSCRIBED: |
| 58 return "Unregistration successful - was not registered"; | 62 return "Unregistration successful - was not registered"; |
| 59 | 63 |
| 60 case PUSH_UNREGISTRATION_STATUS_PENDING_NETWORK_ERROR: | 64 case PUSH_UNSUBSCRIPTION_STATUS_PENDING_NETWORK_ERROR: |
| 61 return "Unregistration pending - a network error occurred, but it will " | 65 return "Unregistration pending - a network error occurred, but it will " |
| 62 "be retried until it succeeds"; | 66 "be retried until it succeeds"; |
| 63 | 67 |
| 64 case PUSH_UNREGISTRATION_STATUS_NO_SERVICE_WORKER: | 68 case PUSH_UNSUBSCRIPTION_STATUS_NO_SERVICE_WORKER: |
| 65 return "Unregistration failed - no Service Worker"; | 69 return "Unregistration failed - no Service Worker"; |
| 66 | 70 |
| 67 case PUSH_UNREGISTRATION_STATUS_SERVICE_NOT_AVAILABLE: | 71 case PUSH_UNSUBSCRIPTION_STATUS_SERVICE_NOT_AVAILABLE: |
| 68 return "Unregistration failed - push service not available"; | 72 return "Unregistration failed - push service not available"; |
| 69 | 73 |
| 70 case PUSH_UNREGISTRATION_STATUS_PENDING_SERVICE_ERROR: | 74 case PUSH_UNSUBSCRIPTION_STATUS_PENDING_SERVICE_ERROR: |
| 71 return "Unregistration pending - a push service error occurred, but it " | 75 return "Unregistration pending - a push service error occurred, but it " |
| 72 "will be retried until it succeeds"; | 76 "will be retried until it succeeds"; |
| 73 | 77 |
| 74 case PUSH_UNREGISTRATION_STATUS_STORAGE_ERROR: | 78 case PUSH_UNSUBSCRIPTION_STATUS_STORAGE_ERROR: |
| 75 return "Unregistration failed - storage error"; | 79 return "Unregistration failed - storage error"; |
| 76 | 80 |
| 77 case PUSH_UNREGISTRATION_STATUS_NETWORK_ERROR: | 81 case PUSH_UNSUBSCRIPTION_STATUS_NETWORK_ERROR: |
| 78 return "Unregistration failed - could not connect to push server"; | 82 return "Unregistration failed - could not connect to push server"; |
| 79 } | 83 } |
| 80 NOTREACHED(); | 84 NOTREACHED(); |
| 81 return ""; | 85 return ""; |
| 82 } | 86 } |
| 83 | 87 |
| 84 } // namespace content | 88 } // namespace content |
| OLD | NEW |