Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(96)

Side by Side Diff: chrome/browser/invalidation/ticl_profile_settings_provider.cc

Issue 1418573005: [invalidation] Componentize TiclProfileSettingsProvider (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Maintain pref registration on Android Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/invalidation/ticl_profile_settings_provider.h"
6
7 #include "base/bind.h"
8 #include "base/bind_helpers.h"
9 #include "base/command_line.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"
16
17 namespace invalidation {
18
19 TiclProfileSettingsProvider::TiclProfileSettingsProvider(Profile* profile)
20 : profile_(profile) {
21 registrar_.Init(profile->GetPrefs());
22 registrar_.Add(
23 prefs::kInvalidationServiceUseGCMChannel,
24 base::Bind(&TiclProfileSettingsProvider::FireOnUseGCMChannelChanged,
25 base::Unretained(this)));
26 registrar_.Add(
27 gcm::prefs::kGCMChannelStatus,
28 base::Bind(&TiclProfileSettingsProvider::FireOnUseGCMChannelChanged,
29 base::Unretained(this)));
30 }
31
32 TiclProfileSettingsProvider::~TiclProfileSettingsProvider() {
33 }
34
35 bool TiclProfileSettingsProvider::UseGCMChannel() const {
36 if (profile_->GetPrefs()->GetBoolean(
37 prefs::kInvalidationServiceUseGCMChannel)) {
38 // Use GCM channel if it was enabled via prefs.
39 return true;
40 }
41
42 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
43 switches::kInvalidationUseGCMChannel)) {
44 // Use GCM channel if it was enabled via a command-line switch.
45 return true;
46 }
47
48 // By default, do not use GCM channel.
49 return false;
50 }
51
52 } // namespace invalidation
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698