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" |
(...skipping 15 matching lines...) Expand all Loading... |
26 registrar_.Add( | 26 registrar_.Add( |
27 gcm::prefs::kGCMChannelStatus, | 27 gcm::prefs::kGCMChannelStatus, |
28 base::Bind(&TiclProfileSettingsProvider::FireOnUseGCMChannelChanged, | 28 base::Bind(&TiclProfileSettingsProvider::FireOnUseGCMChannelChanged, |
29 base::Unretained(this))); | 29 base::Unretained(this))); |
30 } | 30 } |
31 | 31 |
32 TiclProfileSettingsProvider::~TiclProfileSettingsProvider() { | 32 TiclProfileSettingsProvider::~TiclProfileSettingsProvider() { |
33 } | 33 } |
34 | 34 |
35 bool TiclProfileSettingsProvider::UseGCMChannel() const { | 35 bool TiclProfileSettingsProvider::UseGCMChannel() const { |
36 if (!gcm::GCMProfileService::IsGCMEnabled(profile_)) { | |
37 // Do not try to use GCM channel if GCM is disabled. | |
38 return false; | |
39 } | |
40 | |
41 if (profile_->GetPrefs()->GetBoolean( | 36 if (profile_->GetPrefs()->GetBoolean( |
42 prefs::kInvalidationServiceUseGCMChannel)) { | 37 prefs::kInvalidationServiceUseGCMChannel)) { |
43 // Use GCM channel if it was enabled via prefs. | 38 // Use GCM channel if it was enabled via prefs. |
44 return true; | 39 return true; |
45 } | 40 } |
46 | 41 |
47 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 42 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
48 switches::kInvalidationUseGCMChannel)) { | 43 switches::kInvalidationUseGCMChannel)) { |
49 // Use GCM channel if it was enabled via a command-line switch. | 44 // Use GCM channel if it was enabled via a command-line switch. |
50 return true; | 45 return true; |
51 } | 46 } |
52 | 47 |
53 // By default, do not use GCM channel. | 48 // By default, do not use GCM channel. |
54 return false; | 49 return false; |
55 } | 50 } |
56 | 51 |
57 } // namespace invalidation | 52 } // namespace invalidation |
OLD | NEW |