OLD | NEW |
1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2015 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/instance_id/instance_id_profile_service.h" | 5 #include "chrome/browser/services/gcm/instance_id/instance_id_profile_service.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "chrome/browser/profiles/profile.h" | 8 #include "chrome/browser/profiles/profile.h" |
9 #include "chrome/browser/services/gcm/gcm_profile_service.h" | 9 #include "chrome/browser/services/gcm/gcm_profile_service.h" |
10 #include "chrome/browser/services/gcm/gcm_profile_service_factory.h" | 10 #include "chrome/browser/services/gcm/gcm_profile_service_factory.h" |
11 #include "chrome/common/chrome_version_info.h" | |
12 #include "components/gcm_driver/instance_id/instance_id_driver.h" | 11 #include "components/gcm_driver/instance_id/instance_id_driver.h" |
13 | 12 |
14 namespace instance_id { | 13 namespace instance_id { |
15 | 14 |
16 // static | 15 // static |
17 bool InstanceIDProfileService::IsInstanceIDEnabled(Profile* profile) { | 16 bool InstanceIDProfileService::IsInstanceIDEnabled(Profile* profile) { |
18 // Instance ID depends on GCM which has to been enabled. | 17 // Instance ID depends on GCM which has to been enabled. |
19 if (!gcm::GCMProfileService::IsGCMEnabled(profile)) | 18 if (!gcm::GCMProfileService::IsGCMEnabled(profile)) |
20 return false; | 19 return false; |
21 | 20 |
22 // Enabled only for trunk/canary/dev builds. | |
23 chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel(); | |
24 if (channel == chrome::VersionInfo::CHANNEL_BETA || | |
25 channel == chrome::VersionInfo::CHANNEL_STABLE) { | |
26 return false; | |
27 } | |
28 | |
29 return InstanceIDDriver::IsInstanceIDEnabled(); | 21 return InstanceIDDriver::IsInstanceIDEnabled(); |
30 } | 22 } |
31 | 23 |
32 InstanceIDProfileService::InstanceIDProfileService(Profile* profile) { | 24 InstanceIDProfileService::InstanceIDProfileService(Profile* profile) { |
33 DCHECK(!profile->IsOffTheRecord()); | 25 DCHECK(!profile->IsOffTheRecord()); |
34 | 26 |
35 driver_.reset(new InstanceIDDriver( | 27 driver_.reset(new InstanceIDDriver( |
36 gcm::GCMProfileServiceFactory::GetForProfile(profile)->driver())); | 28 gcm::GCMProfileServiceFactory::GetForProfile(profile)->driver())); |
37 } | 29 } |
38 | 30 |
39 InstanceIDProfileService::~InstanceIDProfileService() { | 31 InstanceIDProfileService::~InstanceIDProfileService() { |
40 } | 32 } |
41 | 33 |
42 } // namespace instance_id | 34 } // namespace instance_id |
OLD | NEW |