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 "components/invalidation/impl/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" | |
12 #include "chrome/browser/services/gcm/gcm_profile_service.h" | |
13 #include "chrome/common/chrome_switches.h" | |
14 #include "chrome/common/pref_names.h" | |
15 #include "components/gcm_driver/gcm_channel_status_syncer.h" | 11 #include "components/gcm_driver/gcm_channel_status_syncer.h" |
| 12 #include "components/invalidation/impl/invalidation_prefs.h" |
| 13 #include "components/invalidation/impl/invalidation_switches.h" |
| 14 #include "components/pref_registry/pref_registry_syncable.h" |
16 | 15 |
17 namespace invalidation { | 16 namespace invalidation { |
18 | 17 |
19 TiclProfileSettingsProvider::TiclProfileSettingsProvider(Profile* profile) | 18 TiclProfileSettingsProvider::TiclProfileSettingsProvider(PrefService* prefs) |
20 : profile_(profile) { | 19 : prefs_(prefs) { |
21 registrar_.Init(profile->GetPrefs()); | 20 registrar_.Init(prefs_); |
22 registrar_.Add( | 21 registrar_.Add( |
23 prefs::kInvalidationServiceUseGCMChannel, | 22 prefs::kInvalidationServiceUseGCMChannel, |
24 base::Bind(&TiclProfileSettingsProvider::FireOnUseGCMChannelChanged, | 23 base::Bind(&TiclProfileSettingsProvider::FireOnUseGCMChannelChanged, |
25 base::Unretained(this))); | 24 base::Unretained(this))); |
26 registrar_.Add( | 25 registrar_.Add( |
27 gcm::prefs::kGCMChannelStatus, | 26 gcm::prefs::kGCMChannelStatus, |
28 base::Bind(&TiclProfileSettingsProvider::FireOnUseGCMChannelChanged, | 27 base::Bind(&TiclProfileSettingsProvider::FireOnUseGCMChannelChanged, |
29 base::Unretained(this))); | 28 base::Unretained(this))); |
30 } | 29 } |
31 | 30 |
32 TiclProfileSettingsProvider::~TiclProfileSettingsProvider() { | 31 TiclProfileSettingsProvider::~TiclProfileSettingsProvider() {} |
33 } | |
34 | 32 |
35 bool TiclProfileSettingsProvider::UseGCMChannel() const { | 33 bool TiclProfileSettingsProvider::UseGCMChannel() const { |
36 if (profile_->GetPrefs()->GetBoolean( | 34 if (prefs_->GetBoolean(prefs::kInvalidationServiceUseGCMChannel)) { |
37 prefs::kInvalidationServiceUseGCMChannel)) { | |
38 // Use GCM channel if it was enabled via prefs. | 35 // Use GCM channel if it was enabled via prefs. |
39 return true; | 36 return true; |
40 } | 37 } |
41 | 38 |
42 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 39 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
43 switches::kInvalidationUseGCMChannel)) { | 40 switches::kInvalidationUseGCMChannel)) { |
44 // Use GCM channel if it was enabled via a command-line switch. | 41 // Use GCM channel if it was enabled via a command-line switch. |
45 return true; | 42 return true; |
46 } | 43 } |
47 | 44 |
48 // By default, do not use GCM channel. | 45 // By default, do not use GCM channel. |
49 return false; | 46 return false; |
50 } | 47 } |
51 | 48 |
52 } // namespace invalidation | 49 } // namespace invalidation |
OLD | NEW |