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 "chrome/browser/extensions/api/copresence/copresence_api.h" | 5 #include "chrome/browser/extensions/api/copresence/copresence_api.h" |
6 | 6 |
7 #include "base/lazy_instance.h" | 7 #include "base/lazy_instance.h" |
8 #include "base/memory/linked_ptr.h" | 8 #include "base/memory/linked_ptr.h" |
9 #include "chrome/browser/copresence/chrome_whispernet_client.h" | 9 #include "chrome/browser/copresence/chrome_whispernet_client.h" |
| 10 #include "chrome/browser/services/gcm/gcm_profile_service.h" |
| 11 #include "chrome/browser/services/gcm/gcm_profile_service_factory.h" |
10 #include "chrome/common/chrome_version_info.h" | 12 #include "chrome/common/chrome_version_info.h" |
11 #include "chrome/common/extensions/api/copresence.h" | 13 #include "chrome/common/extensions/api/copresence.h" |
12 #include "components/copresence/copresence_manager_impl.h" | 14 #include "components/copresence/copresence_manager_impl.h" |
13 #include "components/copresence/proto/data.pb.h" | 15 #include "components/copresence/proto/data.pb.h" |
14 #include "components/copresence/proto/enums.pb.h" | 16 #include "components/copresence/proto/enums.pb.h" |
15 #include "components/copresence/proto/rpcs.pb.h" | 17 #include "components/copresence/proto/rpcs.pb.h" |
16 #include "components/copresence/public/whispernet_client.h" | 18 #include "components/copresence/public/whispernet_client.h" |
17 #include "content/public/browser/browser_context.h" | 19 #include "content/public/browser/browser_context.h" |
18 #include "extensions/browser/event_router.h" | 20 #include "extensions/browser/event_router.h" |
19 | 21 |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 const { | 140 const { |
139 // This won't be const if we use map[] | 141 // This won't be const if we use map[] |
140 const auto& key = api_keys_by_app_.find(app_id); | 142 const auto& key = api_keys_by_app_.find(app_id); |
141 return key == api_keys_by_app_.end() ? std::string() : key->second; | 143 return key == api_keys_by_app_.end() ? std::string() : key->second; |
142 } | 144 } |
143 | 145 |
144 copresence::WhispernetClient* CopresenceService::GetWhispernetClient() { | 146 copresence::WhispernetClient* CopresenceService::GetWhispernetClient() { |
145 return whispernet_client(); | 147 return whispernet_client(); |
146 } | 148 } |
147 | 149 |
| 150 gcm::GCMDriver* CopresenceService::GetGCMDriver() { |
| 151 return gcm::GCMProfileServiceFactory::GetForProfile(browser_context_) |
| 152 ->driver(); |
| 153 } |
| 154 |
148 template <> | 155 template <> |
149 void | 156 void |
150 BrowserContextKeyedAPIFactory<CopresenceService>::DeclareFactoryDependencies() { | 157 BrowserContextKeyedAPIFactory<CopresenceService>::DeclareFactoryDependencies() { |
151 DependsOn(ExtensionsBrowserClient::Get()->GetExtensionSystemFactory()); | 158 DependsOn(ExtensionsBrowserClient::Get()->GetExtensionSystemFactory()); |
152 } | 159 } |
153 | 160 |
154 // CopresenceExecuteFunction implementation. | 161 // CopresenceExecuteFunction implementation. |
155 ExtensionFunction::ResponseAction CopresenceExecuteFunction::Run() { | 162 ExtensionFunction::ResponseAction CopresenceExecuteFunction::Run() { |
156 scoped_ptr<api::copresence::Execute::Params> params( | 163 scoped_ptr<api::copresence::Execute::Params> params( |
157 api::copresence::Execute::Params::Create(*args_)); | 164 api::copresence::Execute::Params::Create(*args_)); |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 EXTENSION_FUNCTION_VALIDATE(params.get()); | 216 EXTENSION_FUNCTION_VALIDATE(params.get()); |
210 | 217 |
211 // The token may be set to empty, to clear it. | 218 // The token may be set to empty, to clear it. |
212 // TODO(ckehoe): Scope the auth token appropriately (crbug/423517). | 219 // TODO(ckehoe): Scope the auth token appropriately (crbug/423517). |
213 CopresenceService::GetFactoryInstance()->Get(browser_context()) | 220 CopresenceService::GetFactoryInstance()->Get(browser_context()) |
214 ->set_auth_token(params->token); | 221 ->set_auth_token(params->token); |
215 return RespondNow(NoArguments()); | 222 return RespondNow(NoArguments()); |
216 } | 223 } |
217 | 224 |
218 } // namespace extensions | 225 } // namespace extensions |
OLD | NEW |