| 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 "components/gcm_driver/gcm_desktop_utils.h" | 5 #include "components/gcm_driver/gcm_desktop_utils.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/sequenced_task_runner.h" | 10 #include "base/sequenced_task_runner.h" |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 default: | 56 default: |
| 57 NOTREACHED(); | 57 NOTREACHED(); |
| 58 return GCMClient::CHANNEL_UNKNOWN; | 58 return GCMClient::CHANNEL_UNKNOWN; |
| 59 } | 59 } |
| 60 } | 60 } |
| 61 | 61 |
| 62 std::string GetVersion() { | 62 std::string GetVersion() { |
| 63 return version_info::GetVersionNumber(); | 63 return version_info::GetVersionNumber(); |
| 64 } | 64 } |
| 65 | 65 |
| 66 GCMClient::ChromeBuildInfo GetChromeBuildInfo(version_info::Channel channel) { | 66 GCMClient::ChromeBuildInfo GetChromeBuildInfo( |
| 67 version_info::Channel channel, |
| 68 const std::string& product_category_for_subtypes) { |
| 67 GCMClient::ChromeBuildInfo chrome_build_info; | 69 GCMClient::ChromeBuildInfo chrome_build_info; |
| 68 chrome_build_info.platform = GetPlatform(); | 70 chrome_build_info.platform = GetPlatform(); |
| 69 chrome_build_info.channel = GetChannel(channel); | 71 chrome_build_info.channel = GetChannel(channel); |
| 70 chrome_build_info.version = GetVersion(); | 72 chrome_build_info.version = GetVersion(); |
| 73 chrome_build_info.product_category_for_subtypes = |
| 74 product_category_for_subtypes; |
| 71 return chrome_build_info; | 75 return chrome_build_info; |
| 72 } | 76 } |
| 73 | 77 |
| 74 std::string GetChannelStatusRequestUrl(version_info::Channel channel) { | 78 std::string GetChannelStatusRequestUrl(version_info::Channel channel) { |
| 75 GURL sync_url(GetSyncServiceURL(*base::CommandLine::ForCurrentProcess(), | 79 GURL sync_url(GetSyncServiceURL(*base::CommandLine::ForCurrentProcess(), |
| 76 channel)); | 80 channel)); |
| 77 return sync_url.spec() + kChannelStatusRelativePath; | 81 return sync_url.spec() + kChannelStatusRelativePath; |
| 78 } | 82 } |
| 79 | 83 |
| 80 std::string GetUserAgent(version_info::Channel channel) { | 84 std::string GetUserAgent(version_info::Channel channel) { |
| 81 // TODO(pavely): Fix hardcoded is_tablet value in following call to | 85 // TODO(pavely): Fix hardcoded is_tablet value in following call to |
| 82 // MakeUserAgentForSync. Current implementation returns iPhone UserAgent for | 86 // MakeUserAgentForSync. Current implementation returns iPhone UserAgent for |
| 83 // iPad devices. | 87 // iPad devices. |
| 84 return MakeUserAgentForSync(channel, false); | 88 return MakeUserAgentForSync(channel, false); |
| 85 } | 89 } |
| 86 | 90 |
| 87 } // namespace | 91 } // namespace |
| 88 | 92 |
| 89 std::unique_ptr<GCMDriver> CreateGCMDriverDesktop( | 93 std::unique_ptr<GCMDriver> CreateGCMDriverDesktop( |
| 90 std::unique_ptr<GCMClientFactory> gcm_client_factory, | 94 std::unique_ptr<GCMClientFactory> gcm_client_factory, |
| 91 PrefService* prefs, | 95 PrefService* prefs, |
| 92 const base::FilePath& store_path, | 96 const base::FilePath& store_path, |
| 93 const scoped_refptr<net::URLRequestContextGetter>& request_context, | 97 const scoped_refptr<net::URLRequestContextGetter>& request_context, |
| 94 version_info::Channel channel, | 98 version_info::Channel channel, |
| 99 const std::string& product_category_for_subtypes, |
| 95 const scoped_refptr<base::SequencedTaskRunner>& ui_task_runner, | 100 const scoped_refptr<base::SequencedTaskRunner>& ui_task_runner, |
| 96 const scoped_refptr<base::SequencedTaskRunner>& io_task_runner, | 101 const scoped_refptr<base::SequencedTaskRunner>& io_task_runner, |
| 97 const scoped_refptr<base::SequencedTaskRunner>& blocking_task_runner) { | 102 const scoped_refptr<base::SequencedTaskRunner>& blocking_task_runner) { |
| 98 return std::unique_ptr<GCMDriver>(new GCMDriverDesktop( | 103 return std::unique_ptr<GCMDriver>(new GCMDriverDesktop( |
| 99 std::move(gcm_client_factory), GetChromeBuildInfo(channel), | 104 std::move(gcm_client_factory), |
| 105 GetChromeBuildInfo(channel, product_category_for_subtypes), |
| 100 GetChannelStatusRequestUrl(channel), GetUserAgent(channel), prefs, | 106 GetChannelStatusRequestUrl(channel), GetUserAgent(channel), prefs, |
| 101 store_path, request_context, ui_task_runner, io_task_runner, | 107 store_path, request_context, ui_task_runner, io_task_runner, |
| 102 blocking_task_runner)); | 108 blocking_task_runner)); |
| 103 } | 109 } |
| 104 | 110 |
| 105 } // namespace gcm | 111 } // namespace gcm |
| OLD | NEW |