| Index: chrome/browser/services/gcm/push_messaging_service_impl.cc
|
| diff --git a/chrome/browser/services/gcm/push_messaging_service_impl.cc b/chrome/browser/services/gcm/push_messaging_service_impl.cc
|
| index 1ee383de4a2fb08eb139cdcf240e28b63c3fae51..c52b5d2af3353c0a6afab6991ae184a2886993f2 100644
|
| --- a/chrome/browser/services/gcm/push_messaging_service_impl.cc
|
| +++ b/chrome/browser/services/gcm/push_messaging_service_impl.cc
|
| @@ -20,13 +20,13 @@
|
| #include "chrome/common/pref_names.h"
|
| #include "components/gcm_driver/gcm_driver.h"
|
| #include "components/pref_registry/pref_registry_syncable.h"
|
| +#include "content/public/browser/push_messaging_application_id.h"
|
| #include "content/public/browser/render_frame_host.h"
|
| #include "content/public/browser/web_contents.h"
|
|
|
| namespace gcm {
|
|
|
| namespace {
|
| -const char kAppIdPrefix[] = "push:";
|
| const int kMaxRegistrations = 1000000;
|
| } // namespace
|
|
|
| @@ -63,7 +63,8 @@ void PushMessagingServiceImpl::InitializeForProfile(Profile* profile) {
|
| static_cast<PushMessagingServiceImpl*>(
|
| gcm_service->push_messaging_service());
|
| // Register ourselves as an app handler.
|
| - gcm_service->driver()->AddAppHandler(kAppIdPrefix, push_service);
|
| + gcm_service->driver()->AddAppHandler(
|
| + content::kPushMessagingApplicationIdPrefix, push_service);
|
| }
|
|
|
| PushMessagingServiceImpl::PushMessagingServiceImpl(
|
| @@ -80,8 +81,7 @@ PushMessagingServiceImpl::~PushMessagingServiceImpl() {
|
| }
|
|
|
| bool PushMessagingServiceImpl::CanHandle(const std::string& app_id) const {
|
| - // TODO(mvanouwerkerk): Finalize and centralize format of Push API app_id.
|
| - return StartsWithASCII(app_id, kAppIdPrefix, true);
|
| + return content::PushMessagingApplicationId::Parse(app_id).is_valid();
|
| }
|
|
|
| void PushMessagingServiceImpl::ShutdownHandler() {
|
| @@ -104,8 +104,11 @@ void PushMessagingServiceImpl::OnMessage(
|
| // "delay_while_idle": true,
|
| // }
|
| // TODO(johnme): Make sure this is clearly documented for developers.
|
| + content::PushMessagingApplicationId application_id =
|
| + content::PushMessagingApplicationId::Parse(app_id);
|
| + DCHECK(application_id.is_valid());
|
| GCMClient::MessageData::const_iterator it = message.data.find("data");
|
| - if (it != message.data.end()) {
|
| + if (application_id.is_valid() && it != message.data.end()) {
|
| const std::string& data ALLOW_UNUSED = it->second;
|
| // TODO(mvanouwerkerk): Fire push event with data on the Service Worker
|
| // corresponding to app_id (and remove ALLOW_UNUSED above).
|
| @@ -152,8 +155,10 @@ void PushMessagingServiceImpl::Register(
|
|
|
| // If this is registering for the first time then the driver does not have
|
| // this as an app handler and registration would fail.
|
| - if (gcm_profile_service_->driver()->GetAppHandler(kAppIdPrefix) != this)
|
| - gcm_profile_service_->driver()->AddAppHandler(kAppIdPrefix, this);
|
| + if (gcm_profile_service_->driver()->GetAppHandler(
|
| + content::kPushMessagingApplicationIdPrefix) != this)
|
| + gcm_profile_service_->driver()->AddAppHandler(
|
| + content::kPushMessagingApplicationIdPrefix, this);
|
|
|
| content::RenderFrameHost* render_frame_host =
|
| content::RenderFrameHost::FromID(renderer_id, render_frame_id);
|
|
|