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" | |
26 #include "extensions/browser/event_router.h" | 25 #include "extensions/browser/event_router.h" |
27 #include "extensions/browser/extension_registry.h" | 26 #include "extensions/browser/extension_registry.h" |
28 #include "extensions/common/extension.h" | 27 #include "extensions/common/extension.h" |
29 #include "extensions/common/manifest_constants.h" | 28 #include "extensions/common/manifest_constants.h" |
30 | 29 |
31 using user_prefs::PrefRegistrySyncable; | 30 using user_prefs::PrefRegistrySyncable; |
32 | 31 |
33 namespace extensions { | 32 namespace extensions { |
34 | 33 |
35 namespace { | 34 namespace { |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 DCHECK_EQ(copresence::AUDIO_FAIL, status); | 163 DCHECK_EQ(copresence::AUDIO_FAIL, status); |
165 std::unique_ptr<Event> event(new Event( | 164 std::unique_ptr<Event> event(new Event( |
166 events::COPRESENCE_ON_STATUS_UPDATED, OnStatusUpdated::kEventName, | 165 events::COPRESENCE_ON_STATUS_UPDATED, OnStatusUpdated::kEventName, |
167 OnStatusUpdated::Create(api::copresence::STATUS_AUDIOFAILED), | 166 OnStatusUpdated::Create(api::copresence::STATUS_AUDIOFAILED), |
168 browser_context_)); | 167 browser_context_)); |
169 EventRouter::Get(browser_context_)->BroadcastEvent(std::move(event)); | 168 EventRouter::Get(browser_context_)->BroadcastEvent(std::move(event)); |
170 DVLOG(2) << "Sent Audio Failed status update."; | 169 DVLOG(2) << "Sent Audio Failed status update."; |
171 } | 170 } |
172 | 171 |
173 net::URLRequestContextGetter* CopresenceService::GetRequestContext() const { | 172 net::URLRequestContextGetter* CopresenceService::GetRequestContext() const { |
174 return content::BrowserContext::GetDefaultStoragePartition(browser_context_)-> | 173 return browser_context_->GetRequestContext(); |
175 GetURLRequestContext(); | |
176 } | 174 } |
177 | 175 |
178 std::string CopresenceService::GetPlatformVersionString() const { | 176 std::string CopresenceService::GetPlatformVersionString() const { |
179 return chrome::GetVersionString(); | 177 return chrome::GetVersionString(); |
180 } | 178 } |
181 | 179 |
182 std::string | 180 std::string |
183 CopresenceService::GetAPIKey(const std::string& app_id) const { | 181 CopresenceService::GetAPIKey(const std::string& app_id) const { |
184 // Check first if the app has set its key via the API. | 182 // Check first if the app has set its key via the API. |
185 const auto& key = api_keys_by_app_.find(app_id); | 183 const auto& key = api_keys_by_app_.find(app_id); |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
298 SetAuthToken::Params::Create(*args_)); | 296 SetAuthToken::Params::Create(*args_)); |
299 EXTENSION_FUNCTION_VALIDATE(params.get()); | 297 EXTENSION_FUNCTION_VALIDATE(params.get()); |
300 | 298 |
301 // The token may be set to empty, to clear it. | 299 // The token may be set to empty, to clear it. |
302 CopresenceService::GetFactoryInstance()->Get(browser_context()) | 300 CopresenceService::GetFactoryInstance()->Get(browser_context()) |
303 ->set_auth_token(extension_id(), params->token); | 301 ->set_auth_token(extension_id(), params->token); |
304 return RespondNow(NoArguments()); | 302 return RespondNow(NoArguments()); |
305 } | 303 } |
306 | 304 |
307 } // namespace extensions | 305 } // namespace extensions |
OLD | NEW |