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

Side by Side Diff: chrome/browser/services/gcm/gcm_profile_service.cc

Issue 185133008: [GCM] Only allow the senders that the application is currently registered for (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Updates based on code reviews Created 6 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/services/gcm/gcm_profile_service_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/gcm_profile_service.h" 5 #include "chrome/browser/services/gcm/gcm_profile_service.h"
6 6
7 #include <algorithm>
7 #include <string> 8 #include <string>
8 #include <vector> 9 #include <vector>
9 10
10 #include "base/base64.h" 11 #include "base/base64.h"
11 #include "base/files/file_path.h" 12 #include "base/files/file_path.h"
12 #include "base/logging.h" 13 #include "base/logging.h"
13 #include "base/path_service.h" 14 #include "base/path_service.h"
14 #include "base/prefs/pref_service.h" 15 #include "base/prefs/pref_service.h"
15 #include "base/strings/string_number_conversions.h" 16 #include "base/strings/string_number_conversions.h"
16 #include "base/threading/sequenced_worker_pool.h" 17 #include "base/threading/sequenced_worker_pool.h"
(...skipping 888 matching lines...) Expand 10 before | Expand all | Expand 10 after
905 } 906 }
906 907
907 void GCMProfileService::MessageReceived(const std::string& app_id, 908 void GCMProfileService::MessageReceived(const std::string& app_id,
908 GCMClient::IncomingMessage message) { 909 GCMClient::IncomingMessage message) {
909 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 910 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
910 911
911 // Drop the event if signed out. 912 // Drop the event if signed out.
912 if (username_.empty()) 913 if (username_.empty())
913 return; 914 return;
914 915
916 RegistrationInfoMap::iterator iter = registration_info_map_.find(app_id);
917 // Dropping the message when application does not have a registration entry
jianli 2014/03/05 20:46:31 nit: move the comment above the previous line.
918 // or the app is not registered for the sender of the message.
919 if (iter == registration_info_map_.end() ||
920 std::find(iter->second.sender_ids.begin(),
921 iter->second.sender_ids.end(),
922 message.sender_id) == iter->second.sender_ids.end()) {
923 return;
924 }
925
915 GetEventRouter(app_id)->OnMessage(app_id, message); 926 GetEventRouter(app_id)->OnMessage(app_id, message);
916 } 927 }
917 928
918 void GCMProfileService::MessagesDeleted(const std::string& app_id) { 929 void GCMProfileService::MessagesDeleted(const std::string& app_id) {
919 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 930 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
920 931
921 // Drop the event if signed out. 932 // Drop the event if signed out.
922 if (username_.empty()) 933 if (username_.empty())
923 return; 934 return;
924 935
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
1069 1080
1070 return true; 1081 return true;
1071 } 1082 }
1072 1083
1073 // static 1084 // static
1074 const char* GCMProfileService::GetPersistentRegisterKeyForTesting() { 1085 const char* GCMProfileService::GetPersistentRegisterKeyForTesting() {
1075 return kRegistrationKey; 1086 return kRegistrationKey;
1076 } 1087 }
1077 1088
1078 } // namespace gcm 1089 } // namespace gcm
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/services/gcm/gcm_profile_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698