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/invalidation/ticl_profile_settings_provider.h" | 5 #include "chrome/browser/invalidation/ticl_profile_settings_provider.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
11 #include "chrome/browser/profiles/profile.h" | 11 #include "chrome/browser/profiles/profile.h" |
12 #include "chrome/browser/services/gcm/gcm_profile_service.h" | 12 #include "chrome/browser/services/gcm/gcm_profile_service.h" |
13 #include "chrome/common/chrome_switches.h" | 13 #include "chrome/common/chrome_switches.h" |
14 #include "chrome/common/pref_names.h" | 14 #include "chrome/common/pref_names.h" |
| 15 #include "components/gcm_driver/gcm_channel_status_syncer.h" |
15 | 16 |
16 namespace invalidation { | 17 namespace invalidation { |
17 | 18 |
18 TiclProfileSettingsProvider::TiclProfileSettingsProvider(Profile* profile) | 19 TiclProfileSettingsProvider::TiclProfileSettingsProvider(Profile* profile) |
19 : profile_(profile) { | 20 : profile_(profile) { |
20 registrar_.Init(profile->GetPrefs()); | 21 registrar_.Init(profile->GetPrefs()); |
21 registrar_.Add( | 22 registrar_.Add( |
22 prefs::kInvalidationServiceUseGCMChannel, | 23 prefs::kInvalidationServiceUseGCMChannel, |
23 base::Bind(&TiclProfileSettingsProvider::FireOnUseGCMChannelChanged, | 24 base::Bind(&TiclProfileSettingsProvider::FireOnUseGCMChannelChanged, |
24 base::Unretained(this))); | 25 base::Unretained(this))); |
25 registrar_.Add( | 26 registrar_.Add( |
26 prefs::kGCMChannelEnabled, | 27 gcm::prefs::kGCMChannelStatus, |
27 base::Bind(&TiclProfileSettingsProvider::FireOnUseGCMChannelChanged, | 28 base::Bind(&TiclProfileSettingsProvider::FireOnUseGCMChannelChanged, |
28 base::Unretained(this))); | 29 base::Unretained(this))); |
29 } | 30 } |
30 | 31 |
31 TiclProfileSettingsProvider::~TiclProfileSettingsProvider() { | 32 TiclProfileSettingsProvider::~TiclProfileSettingsProvider() { |
32 } | 33 } |
33 | 34 |
34 bool TiclProfileSettingsProvider::UseGCMChannel() const { | 35 bool TiclProfileSettingsProvider::UseGCMChannel() const { |
35 if (!gcm::GCMProfileService::IsGCMEnabled(profile_)) { | 36 if (!gcm::GCMProfileService::IsGCMEnabled(profile_)) { |
36 // Do not try to use GCM channel if GCM is disabled. | 37 // Do not try to use GCM channel if GCM is disabled. |
(...skipping 10 matching lines...) Expand all Loading... |
47 switches::kInvalidationUseGCMChannel)) { | 48 switches::kInvalidationUseGCMChannel)) { |
48 // Use GCM channel if it was enabled via a command-line switch. | 49 // Use GCM channel if it was enabled via a command-line switch. |
49 return true; | 50 return true; |
50 } | 51 } |
51 | 52 |
52 // By default, do not use GCM channel. | 53 // By default, do not use GCM channel. |
53 return false; | 54 return false; |
54 } | 55 } |
55 | 56 |
56 } // namespace invalidation | 57 } // namespace invalidation |
OLD | NEW |