OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/services/gcm/push_messaging_application_id.h" | 5 #include "chrome/browser/push_messaging/push_messaging_application_id.h" |
6 | 6 |
7 #include "base/guid.h" | 7 #include "base/guid.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
10 #include "base/prefs/scoped_user_pref_update.h" | 10 #include "base/prefs/scoped_user_pref_update.h" |
11 #include "base/strings/string_number_conversions.h" | 11 #include "base/strings/string_number_conversions.h" |
12 #include "base/strings/string_split.h" | 12 #include "base/strings/string_split.h" |
13 #include "base/values.h" | 13 #include "base/values.h" |
14 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
15 #include "chrome/common/pref_names.h" | 15 #include "chrome/common/pref_names.h" |
16 #include "components/pref_registry/pref_registry_syncable.h" | 16 #include "components/pref_registry/pref_registry_syncable.h" |
17 | 17 |
18 namespace { | 18 namespace { |
19 const char kSeparator = '#'; // Ok as only the origin of the url is used. | 19 const char kSeparator = '#'; // Ok as only the origin of the url is used. |
20 } // namespace | 20 } // namespace |
21 | 21 |
22 namespace gcm { | |
23 | |
24 const char kPushMessagingApplicationIdPrefix[] = "wp:"; | 22 const char kPushMessagingApplicationIdPrefix[] = "wp:"; |
25 | 23 |
26 // static | 24 // static |
27 void PushMessagingApplicationId::RegisterProfilePrefs( | 25 void PushMessagingApplicationId::RegisterProfilePrefs( |
28 user_prefs::PrefRegistrySyncable* registry) { | 26 user_prefs::PrefRegistrySyncable* registry) { |
29 registry->RegisterDictionaryPref( | 27 registry->RegisterDictionaryPref( |
30 prefs::kPushMessagingApplicationIdMap, | 28 prefs::kPushMessagingApplicationIdMap, |
31 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); | 29 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
32 } | 30 } |
33 | 31 |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 PushMessagingApplicationId::~PushMessagingApplicationId() { | 149 PushMessagingApplicationId::~PushMessagingApplicationId() { |
152 } | 150 } |
153 | 151 |
154 bool PushMessagingApplicationId::IsValid() const { | 152 bool PushMessagingApplicationId::IsValid() const { |
155 const size_t prefix_len = strlen(kPushMessagingApplicationIdPrefix); | 153 const size_t prefix_len = strlen(kPushMessagingApplicationIdPrefix); |
156 return origin_.is_valid() && origin_.GetOrigin() == origin_ | 154 return origin_.is_valid() && origin_.GetOrigin() == origin_ |
157 && service_worker_registration_id_ >= 0 | 155 && service_worker_registration_id_ >= 0 |
158 && !app_id_guid_.compare(0, prefix_len, kPushMessagingApplicationIdPrefix) | 156 && !app_id_guid_.compare(0, prefix_len, kPushMessagingApplicationIdPrefix) |
159 && base::IsValidGUID(app_id_guid_.substr(prefix_len, std::string::npos)); | 157 && base::IsValidGUID(app_id_guid_.substr(prefix_len, std::string::npos)); |
160 } | 158 } |
161 | |
162 } // namespace gcm | |
OLD | NEW |