Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1170)

Side by Side Diff: chrome/browser/push_messaging/push_messaging_application_id.cc

Issue 955673004: Move gcm-independent parts of push messaging out of gcm namespace and directory (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: buildfix push_messaging_application_id_unittest Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/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/strings/string_util.h" 13 #include "base/strings/string_util.h"
14 #include "base/values.h" 14 #include "base/values.h"
15 #include "chrome/browser/profiles/profile.h" 15 #include "chrome/browser/profiles/profile.h"
16 #include "chrome/common/pref_names.h" 16 #include "chrome/common/pref_names.h"
17 #include "components/pref_registry/pref_registry_syncable.h" 17 #include "components/pref_registry/pref_registry_syncable.h"
18 18
19 namespace { 19 namespace {
20 const char kSeparator = '#'; // Ok as only the origin of the url is used. 20 const char kSeparator = '#'; // Ok as only the origin of the url is used.
21 } // namespace 21 } // namespace
22 22
23 namespace gcm {
24
25 const char kPushMessagingApplicationIdPrefix[] = "wp:"; 23 const char kPushMessagingApplicationIdPrefix[] = "wp:";
26 24
27 // static 25 // static
28 void PushMessagingApplicationId::RegisterProfilePrefs( 26 void PushMessagingApplicationId::RegisterProfilePrefs(
29 user_prefs::PrefRegistrySyncable* registry) { 27 user_prefs::PrefRegistrySyncable* registry) {
30 registry->RegisterDictionaryPref( 28 registry->RegisterDictionaryPref(
31 prefs::kPushMessagingApplicationIdMap, 29 prefs::kPushMessagingApplicationIdMap,
32 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); 30 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
33 } 31 }
34 32
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 PushMessagingApplicationId::~PushMessagingApplicationId() { 159 PushMessagingApplicationId::~PushMessagingApplicationId() {
162 } 160 }
163 161
164 bool PushMessagingApplicationId::IsValid() const { 162 bool PushMessagingApplicationId::IsValid() const {
165 const size_t prefix_len = strlen(kPushMessagingApplicationIdPrefix); 163 const size_t prefix_len = strlen(kPushMessagingApplicationIdPrefix);
166 return origin_.is_valid() && origin_.GetOrigin() == origin_ 164 return origin_.is_valid() && origin_.GetOrigin() == origin_
167 && service_worker_registration_id_ >= 0 165 && service_worker_registration_id_ >= 0
168 && !app_id_guid_.compare(0, prefix_len, kPushMessagingApplicationIdPrefix) 166 && !app_id_guid_.compare(0, prefix_len, kPushMessagingApplicationIdPrefix)
169 && base::IsValidGUID(app_id_guid_.substr(prefix_len, std::string::npos)); 167 && base::IsValidGUID(app_id_guid_.substr(prefix_len, std::string::npos));
170 } 168 }
171
172 } // namespace gcm
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698