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/services/gcm/gcm_desktop_utils.h" | 5 #include "chrome/browser/services/gcm/gcm_desktop_utils.h" |
6 | 6 |
7 #include "base/command_line.h" | |
8 #include "base/logging.h" | 7 #include "base/logging.h" |
9 #include "base/sequenced_task_runner.h" | 8 #include "base/sequenced_task_runner.h" |
10 #include "base/threading/sequenced_worker_pool.h" | 9 #include "base/threading/sequenced_worker_pool.h" |
11 #include "chrome/browser/sync/glue/local_device_info_provider_impl.h" | 10 #include "chrome/browser/sync/glue/local_device_info_provider_impl.h" |
12 #include "chrome/browser/sync/profile_sync_service.h" | 11 #include "chrome/browser/sync/profile_sync_service.h" |
13 #include "chrome/common/chrome_version_info.h" | 12 #include "chrome/common/chrome_version_info.h" |
14 #include "components/gcm_driver/gcm_client.h" | 13 #include "components/gcm_driver/gcm_client.h" |
15 #include "components/gcm_driver/gcm_client_factory.h" | 14 #include "components/gcm_driver/gcm_client_factory.h" |
16 #include "components/gcm_driver/gcm_driver.h" | 15 #include "components/gcm_driver/gcm_driver.h" |
17 #include "components/gcm_driver/gcm_driver_desktop.h" | 16 #include "components/gcm_driver/gcm_driver_desktop.h" |
18 #include "content/public/browser/browser_thread.h" | 17 #include "content/public/browser/browser_thread.h" |
19 | 18 |
20 namespace gcm { | 19 namespace gcm { |
21 | 20 |
22 namespace { | 21 namespace { |
23 | 22 |
24 const char kChannelStatusRelativePath[] = "/experimentstatus"; | |
25 | |
26 GCMClient::ChromePlatform GetPlatform() { | 23 GCMClient::ChromePlatform GetPlatform() { |
27 #if defined(OS_WIN) | 24 #if defined(OS_WIN) |
28 return GCMClient::PLATFORM_WIN; | 25 return GCMClient::PLATFORM_WIN; |
29 #elif defined(OS_MACOSX) | 26 #elif defined(OS_MACOSX) |
30 return GCMClient::PLATFORM_MAC; | 27 return GCMClient::PLATFORM_MAC; |
31 #elif defined(OS_IOS) | 28 #elif defined(OS_IOS) |
32 return GCMClient::PLATFORM_IOS; | 29 return GCMClient::PLATFORM_IOS; |
33 #elif defined(OS_ANDROID) | 30 #elif defined(OS_ANDROID) |
34 return GCMClient::PLATFORM_ANDROID; | 31 return GCMClient::PLATFORM_ANDROID; |
35 #elif defined(OS_CHROMEOS) | 32 #elif defined(OS_CHROMEOS) |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 | 65 |
69 GCMClient::ChromeBuildInfo GetChromeBuildInfo() { | 66 GCMClient::ChromeBuildInfo GetChromeBuildInfo() { |
70 GCMClient::ChromeBuildInfo chrome_build_info; | 67 GCMClient::ChromeBuildInfo chrome_build_info; |
71 chrome_build_info.platform = GetPlatform(); | 68 chrome_build_info.platform = GetPlatform(); |
72 chrome_build_info.channel = GetChannel(); | 69 chrome_build_info.channel = GetChannel(); |
73 chrome_build_info.version = GetVersion(); | 70 chrome_build_info.version = GetVersion(); |
74 return chrome_build_info; | 71 return chrome_build_info; |
75 } | 72 } |
76 | 73 |
77 std::string GetChannelStatusRequestUrl() { | 74 std::string GetChannelStatusRequestUrl() { |
78 GURL sync_url( | 75 chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel(); |
79 ProfileSyncService::GetSyncServiceURL(*CommandLine::ForCurrentProcess())); | 76 if (channel == chrome::VersionInfo::CHANNEL_STABLE || |
80 return sync_url.spec() + kChannelStatusRelativePath; | 77 channel == chrome::VersionInfo::CHANNEL_BETA) { |
| 78 return ProfileSyncService::kSyncServerUrl; |
| 79 } |
| 80 |
| 81 return ProfileSyncService::kDevServerUrl; |
81 } | 82 } |
82 | 83 |
83 std::string GetUserAgent() { | 84 std::string GetUserAgent() { |
84 chrome::VersionInfo version_info; | 85 chrome::VersionInfo version_info; |
85 return browser_sync::LocalDeviceInfoProviderImpl::MakeUserAgentForSyncApi( | 86 return browser_sync::LocalDeviceInfoProviderImpl::MakeUserAgentForSyncApi( |
86 version_info); | 87 version_info); |
87 } | 88 } |
88 | 89 |
89 } // namespace | 90 } // namespace |
90 | 91 |
(...skipping 17 matching lines...) Expand all Loading... |
108 store_path, | 109 store_path, |
109 request_context, | 110 request_context, |
110 content::BrowserThread::GetMessageLoopProxyForThread( | 111 content::BrowserThread::GetMessageLoopProxyForThread( |
111 content::BrowserThread::UI), | 112 content::BrowserThread::UI), |
112 content::BrowserThread::GetMessageLoopProxyForThread( | 113 content::BrowserThread::GetMessageLoopProxyForThread( |
113 content::BrowserThread::IO), | 114 content::BrowserThread::IO), |
114 blocking_task_runner)); | 115 blocking_task_runner)); |
115 } | 116 } |
116 | 117 |
117 } // namespace gcm | 118 } // namespace gcm |
OLD | NEW |