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 "base/bind.h" | 5 #include "base/bind.h" |
6 #include "base/callback.h" | 6 #include "base/callback.h" |
7 #include "base/location.h" | 7 #include "base/location.h" |
8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
9 #include "base/single_thread_task_runner.h" | 9 #include "base/single_thread_task_runner.h" |
10 #include "base/thread_task_runner_handle.h" | 10 #include "base/thread_task_runner_handle.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 | 21 |
22 namespace invalidation { | 22 namespace invalidation { |
23 | 23 |
24 namespace { | 24 namespace { |
25 | 25 |
26 // For 3rd party developers SenderId should come from application dashboard when | 26 // For 3rd party developers SenderId should come from application dashboard when |
27 // server side application is registered with Google. Android invalidations use | 27 // server side application is registered with Google. Android invalidations use |
28 // legacy format where gmail account can be specificed. Below value is copied | 28 // legacy format where gmail account can be specificed. Below value is copied |
29 // from Android. | 29 // from Android. |
30 const char kInvalidationsSenderId[] = "ipc.invalidation@gmail.com"; | 30 const char kInvalidationsSenderId[] = "ipc.invalidation@gmail.com"; |
31 // In Android world AppId and Cert are provided by operating system and should | 31 // In Android world AppId is provided by operating system and should |
32 // match package name and hash of application. In desktop world these values | 32 // match package name and hash of application. In desktop world these values |
33 // are arbitrary and not verified/enforced by registration service (yet). | 33 // are arbitrary and not verified/enforced by registration service (yet). |
34 const char kInvalidationsAppId[] = "com.google.chrome.invalidations"; | 34 const char kInvalidationsAppId[] = "com.google.chrome.invalidations"; |
35 const char kInvalidationsCert[] = "ABC"; | |
36 | 35 |
37 // In each call to Register object of RegisterCall will be created. | 36 // In each call to Register object of RegisterCall will be created. |
38 // Its purpose is to pass context (profile and callback) around between threads | 37 // Its purpose is to pass context (profile and callback) around between threads |
39 // and async call to GCMProfilkeService::Register. | 38 // and async call to GCMProfilkeService::Register. |
40 class RegisterCall : public base::RefCountedThreadSafe<RegisterCall> { | 39 class RegisterCall : public base::RefCountedThreadSafe<RegisterCall> { |
41 public: | 40 public: |
42 RegisterCall(Profile* profile, | 41 RegisterCall(Profile* profile, |
43 syncer::GCMNetworkChannelDelegate::RegisterCallback callback); | 42 syncer::GCMNetworkChannelDelegate::RegisterCallback callback); |
44 | 43 |
45 void RegisterOnUIThread(); | 44 void RegisterOnUIThread(); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 gcm::GCMProfileService* gcm_profile_service = | 77 gcm::GCMProfileService* gcm_profile_service = |
79 gcm::GCMProfileServiceFactory::GetForProfile(profile_); | 78 gcm::GCMProfileServiceFactory::GetForProfile(profile_); |
80 if (gcm_profile_service == NULL) | 79 if (gcm_profile_service == NULL) |
81 return; | 80 return; |
82 | 81 |
83 std::vector<std::string> sender_ids; | 82 std::vector<std::string> sender_ids; |
84 sender_ids.push_back(kInvalidationsSenderId); | 83 sender_ids.push_back(kInvalidationsSenderId); |
85 gcm_profile_service->Register( | 84 gcm_profile_service->Register( |
86 kInvalidationsAppId, | 85 kInvalidationsAppId, |
87 sender_ids, | 86 sender_ids, |
88 kInvalidationsCert, | |
89 base::Bind(&RegisterCall::RegisterFinishedOnUIThread, this)); | 87 base::Bind(&RegisterCall::RegisterFinishedOnUIThread, this)); |
90 } | 88 } |
91 | 89 |
92 void RegisterCall::RegisterFinishedOnUIThread( | 90 void RegisterCall::RegisterFinishedOnUIThread( |
93 const std::string& registration_id, | 91 const std::string& registration_id, |
94 gcm::GCMClient::Result result) { | 92 gcm::GCMClient::Result result) { |
95 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 93 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
96 origin_thread_task_runner_->PostTask( | 94 origin_thread_task_runner_->PostTask( |
97 FROM_HERE, | 95 FROM_HERE, |
98 base::Bind( | 96 base::Bind( |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 | 176 |
179 ProfileOAuth2TokenService* oauth2_token_service = | 177 ProfileOAuth2TokenService* oauth2_token_service = |
180 ProfileOAuth2TokenServiceFactory::GetForProfile(profile); | 178 ProfileOAuth2TokenServiceFactory::GetForProfile(profile); |
181 std::string account_id = oauth2_token_service->GetPrimaryAccountId(); | 179 std::string account_id = oauth2_token_service->GetPrimaryAccountId(); |
182 OAuth2TokenService::ScopeSet scopes; | 180 OAuth2TokenService::ScopeSet scopes; |
183 scopes.insert(GaiaConstants::kGoogleTalkOAuth2Scope); | 181 scopes.insert(GaiaConstants::kGoogleTalkOAuth2Scope); |
184 oauth2_token_service->InvalidateToken(account_id, scopes, token); | 182 oauth2_token_service->InvalidateToken(account_id, scopes, token); |
185 } | 183 } |
186 | 184 |
187 } // namespace invalidation | 185 } // namespace invalidation |
OLD | NEW |