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 <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
10 #include "chrome/browser/copresence/chrome_whispernet_client.h" | 10 #include "chrome/browser/copresence/chrome_whispernet_client.h" |
11 #include "chrome/browser/profiles/profile.h" | 11 #include "chrome/browser/profiles/profile.h" |
12 #include "chrome/browser/services/gcm/gcm_profile_service_factory.h" | 12 #include "chrome/browser/services/gcm/gcm_profile_service_factory.h" |
13 #include "chrome/common/channel_info.h" | 13 #include "chrome/common/channel_info.h" |
14 #include "chrome/common/extensions/api/copresence.h" | 14 #include "chrome/common/extensions/api/copresence.h" |
15 #include "chrome/common/extensions/manifest_handlers/copresence_manifest.h" | 15 #include "chrome/common/extensions/manifest_handlers/copresence_manifest.h" |
16 #include "chrome/common/pref_names.h" | 16 #include "chrome/common/pref_names.h" |
17 #include "components/copresence/copresence_manager_impl.h" | 17 #include "components/copresence/copresence_manager_impl.h" |
18 #include "components/copresence/proto/data.pb.h" | 18 #include "components/copresence/proto/data.pb.h" |
19 #include "components/copresence/proto/enums.pb.h" | 19 #include "components/copresence/proto/enums.pb.h" |
20 #include "components/copresence/proto/rpcs.pb.h" | 20 #include "components/copresence/proto/rpcs.pb.h" |
21 #include "components/gcm_driver/gcm_profile_service.h" | 21 #include "components/gcm_driver/gcm_profile_service.h" |
22 #include "components/pref_registry/pref_registry_syncable.h" | 22 #include "components/pref_registry/pref_registry_syncable.h" |
23 #include "components/prefs/pref_service.h" | 23 #include "components/prefs/pref_service.h" |
24 #include "content/public/browser/browser_context.h" | 24 #include "content/public/browser/browser_context.h" |
| 25 #include "content/public/browser/storage_partition.h" |
25 #include "extensions/browser/event_router.h" | 26 #include "extensions/browser/event_router.h" |
26 #include "extensions/browser/extension_registry.h" | 27 #include "extensions/browser/extension_registry.h" |
27 #include "extensions/common/extension.h" | 28 #include "extensions/common/extension.h" |
28 #include "extensions/common/manifest_constants.h" | 29 #include "extensions/common/manifest_constants.h" |
29 | 30 |
30 using user_prefs::PrefRegistrySyncable; | 31 using user_prefs::PrefRegistrySyncable; |
31 | 32 |
32 namespace extensions { | 33 namespace extensions { |
33 | 34 |
34 namespace { | 35 namespace { |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 DCHECK_EQ(copresence::AUDIO_FAIL, status); | 164 DCHECK_EQ(copresence::AUDIO_FAIL, status); |
164 std::unique_ptr<Event> event(new Event( | 165 std::unique_ptr<Event> event(new Event( |
165 events::COPRESENCE_ON_STATUS_UPDATED, OnStatusUpdated::kEventName, | 166 events::COPRESENCE_ON_STATUS_UPDATED, OnStatusUpdated::kEventName, |
166 OnStatusUpdated::Create(api::copresence::STATUS_AUDIOFAILED), | 167 OnStatusUpdated::Create(api::copresence::STATUS_AUDIOFAILED), |
167 browser_context_)); | 168 browser_context_)); |
168 EventRouter::Get(browser_context_)->BroadcastEvent(std::move(event)); | 169 EventRouter::Get(browser_context_)->BroadcastEvent(std::move(event)); |
169 DVLOG(2) << "Sent Audio Failed status update."; | 170 DVLOG(2) << "Sent Audio Failed status update."; |
170 } | 171 } |
171 | 172 |
172 net::URLRequestContextGetter* CopresenceService::GetRequestContext() const { | 173 net::URLRequestContextGetter* CopresenceService::GetRequestContext() const { |
173 return browser_context_->GetRequestContext(); | 174 return content::BrowserContext::GetDefaultStoragePartition(browser_context_)-> |
| 175 GetURLRequestContext(); |
174 } | 176 } |
175 | 177 |
176 std::string CopresenceService::GetPlatformVersionString() const { | 178 std::string CopresenceService::GetPlatformVersionString() const { |
177 return chrome::GetVersionString(); | 179 return chrome::GetVersionString(); |
178 } | 180 } |
179 | 181 |
180 std::string | 182 std::string |
181 CopresenceService::GetAPIKey(const std::string& app_id) const { | 183 CopresenceService::GetAPIKey(const std::string& app_id) const { |
182 // Check first if the app has set its key via the API. | 184 // Check first if the app has set its key via the API. |
183 const auto& key = api_keys_by_app_.find(app_id); | 185 const auto& key = api_keys_by_app_.find(app_id); |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
296 SetAuthToken::Params::Create(*args_)); | 298 SetAuthToken::Params::Create(*args_)); |
297 EXTENSION_FUNCTION_VALIDATE(params.get()); | 299 EXTENSION_FUNCTION_VALIDATE(params.get()); |
298 | 300 |
299 // The token may be set to empty, to clear it. | 301 // The token may be set to empty, to clear it. |
300 CopresenceService::GetFactoryInstance()->Get(browser_context()) | 302 CopresenceService::GetFactoryInstance()->Get(browser_context()) |
301 ->set_auth_token(extension_id(), params->token); | 303 ->set_auth_token(extension_id(), params->token); |
302 return RespondNow(NoArguments()); | 304 return RespondNow(NoArguments()); |
303 } | 305 } |
304 | 306 |
305 } // namespace extensions | 307 } // namespace extensions |
OLD | NEW |