OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/gcm_profile_service.h" | 5 #include "chrome/browser/services/gcm/gcm_profile_service.h" |
6 | 6 |
7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
10 #include "base/values.h" | 10 #include "base/values.h" |
11 #include "chrome/browser/profiles/profile.h" | 11 #include "chrome/browser/profiles/profile.h" |
12 #include "chrome/browser/services/gcm/gcm_driver.h" | 12 #include "chrome/browser/services/gcm/gcm_driver.h" |
13 #include "chrome/browser/services/gcm/gcm_utils.h" | 13 #include "chrome/browser/services/gcm/gcm_utils.h" |
14 #include "chrome/browser/signin/profile_identity_provider.h" | 14 #include "chrome/browser/signin/profile_identity_provider.h" |
15 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" | 15 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" |
16 #include "chrome/browser/signin/signin_manager_factory.h" | 16 #include "chrome/browser/signin/signin_manager_factory.h" |
17 #include "chrome/common/chrome_constants.h" | 17 #include "chrome/common/chrome_constants.h" |
18 #include "chrome/common/chrome_version_info.h" | |
19 #include "chrome/common/pref_names.h" | 18 #include "chrome/common/pref_names.h" |
20 #include "components/gcm_driver/gcm_client_factory.h" | 19 #include "components/gcm_driver/gcm_client_factory.h" |
21 #include "components/pref_registry/pref_registry_syncable.h" | 20 #include "components/pref_registry/pref_registry_syncable.h" |
22 #include "components/signin/core/browser/signin_manager.h" | 21 #include "components/signin/core/browser/signin_manager.h" |
23 #include "content/public/browser/browser_thread.h" | 22 #include "content/public/browser/browser_thread.h" |
24 #include "google_apis/gaia/identity_provider.h" | 23 #include "google_apis/gaia/identity_provider.h" |
25 #include "net/url_request/url_request_context_getter.h" | 24 #include "net/url_request/url_request_context_getter.h" |
26 | 25 |
27 #if !defined(OS_ANDROID) | 26 #if !defined(OS_ANDROID) |
28 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h" | 27 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h" |
(...skipping 27 matching lines...) Expand all Loading... |
56 return "ALWAYS_DISABLED"; | 55 return "ALWAYS_DISABLED"; |
57 default: | 56 default: |
58 NOTREACHED(); | 57 NOTREACHED(); |
59 return std::string(); | 58 return std::string(); |
60 } | 59 } |
61 } | 60 } |
62 | 61 |
63 // static | 62 // static |
64 void GCMProfileService::RegisterProfilePrefs( | 63 void GCMProfileService::RegisterProfilePrefs( |
65 user_prefs::PrefRegistrySyncable* registry) { | 64 user_prefs::PrefRegistrySyncable* registry) { |
66 // GCM support is only enabled by default for Canary/Dev/Custom builds. | |
67 chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel(); | |
68 bool on_by_default = false; | |
69 if (channel == chrome::VersionInfo::CHANNEL_UNKNOWN || | |
70 channel == chrome::VersionInfo::CHANNEL_CANARY || | |
71 channel == chrome::VersionInfo::CHANNEL_DEV) { | |
72 on_by_default = true; | |
73 } | |
74 registry->RegisterBooleanPref( | 65 registry->RegisterBooleanPref( |
75 prefs::kGCMChannelEnabled, | 66 prefs::kGCMChannelEnabled, |
76 on_by_default, | 67 true, |
77 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); | 68 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
78 } | 69 } |
79 | 70 |
80 GCMProfileService::GCMProfileService( | 71 GCMProfileService::GCMProfileService( |
81 Profile* profile, | 72 Profile* profile, |
82 scoped_ptr<GCMClientFactory> gcm_client_factory) | 73 scoped_ptr<GCMClientFactory> gcm_client_factory) |
83 : profile_(profile) { | 74 : profile_(profile) { |
84 DCHECK(!profile->IsOffTheRecord()); | 75 DCHECK(!profile->IsOffTheRecord()); |
85 | 76 |
86 scoped_refptr<base::SequencedWorkerPool> worker_pool( | 77 scoped_refptr<base::SequencedWorkerPool> worker_pool( |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 driver_->Shutdown(); | 132 driver_->Shutdown(); |
142 driver_.reset(); | 133 driver_.reset(); |
143 } | 134 } |
144 } | 135 } |
145 | 136 |
146 void GCMProfileService::SetDriverForTesting(GCMDriver* driver) { | 137 void GCMProfileService::SetDriverForTesting(GCMDriver* driver) { |
147 driver_.reset(driver); | 138 driver_.reset(driver); |
148 } | 139 } |
149 | 140 |
150 } // namespace gcm | 141 } // namespace gcm |
OLD | NEW |