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