OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/profiles/gaia_info_update_service.h" | 5 #include "chrome/browser/profiles/gaia_info_update_service.h" |
6 | 6 |
| 7 #include "base/command_line.h" |
7 #include "chrome/browser/browser_process.h" | 8 #include "chrome/browser/browser_process.h" |
8 #include "chrome/browser/prefs/pref_service.h" | 9 #include "chrome/browser/prefs/pref_service.h" |
9 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
10 #include "chrome/browser/profiles/profile_info_cache.h" | 11 #include "chrome/browser/profiles/profile_info_cache.h" |
11 #include "chrome/browser/profiles/profile_manager.h" | 12 #include "chrome/browser/profiles/profile_manager.h" |
12 #include "chrome/browser/sync/profile_sync_service.h" | 13 #include "chrome/browser/sync/profile_sync_service.h" |
13 #include "chrome/common/chrome_notification_types.h" | 14 #include "chrome/common/chrome_notification_types.h" |
| 15 #include "chrome/common/chrome_switches.h" |
14 #include "chrome/common/pref_names.h" | 16 #include "chrome/common/pref_names.h" |
15 #include "content/public/browser/notification_details.h" | 17 #include "content/public/browser/notification_details.h" |
16 #include "third_party/skia/include/core/SkBitmap.h" | 18 #include "third_party/skia/include/core/SkBitmap.h" |
17 #include "ui/gfx/image/image.h" | 19 #include "ui/gfx/image/image.h" |
18 | 20 |
19 namespace { | 21 namespace { |
20 | 22 |
21 // Update the user's GAIA info every 24 hours. | 23 // Update the user's GAIA info every 24 hours. |
22 const int kUpdateIntervalHours = 24; | 24 const int kUpdateIntervalHours = 24; |
23 | 25 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 // static | 58 // static |
57 bool GAIAInfoUpdateService::ShouldUseGAIAProfileInfo(Profile* profile) { | 59 bool GAIAInfoUpdateService::ShouldUseGAIAProfileInfo(Profile* profile) { |
58 #if defined(OS_CHROMEOS) | 60 #if defined(OS_CHROMEOS) |
59 return false; | 61 return false; |
60 #endif | 62 #endif |
61 | 63 |
62 // Sync must be allowed. | 64 // Sync must be allowed. |
63 if (!profile->GetOriginalProfile()->IsSyncAccessible()) | 65 if (!profile->GetOriginalProfile()->IsSyncAccessible()) |
64 return false; | 66 return false; |
65 | 67 |
66 return true; | 68 // To enable this feature for testing pass "--gaia-profile-info". |
| 69 if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 70 switches::kGaiaProfileInfo)) { |
| 71 return true; |
| 72 } |
| 73 |
| 74 // This feature is disable by default. |
| 75 return false; |
67 } | 76 } |
68 | 77 |
69 // static | 78 // static |
70 void GAIAInfoUpdateService::RegisterUserPrefs(PrefService* prefs) { | 79 void GAIAInfoUpdateService::RegisterUserPrefs(PrefService* prefs) { |
71 prefs->RegisterInt64Pref( | 80 prefs->RegisterInt64Pref( |
72 prefs::kProfileGAIAInfoUpdateTime, 0, PrefService::UNSYNCABLE_PREF); | 81 prefs::kProfileGAIAInfoUpdateTime, 0, PrefService::UNSYNCABLE_PREF); |
73 prefs->RegisterStringPref( | 82 prefs->RegisterStringPref( |
74 prefs::kProfileGAIAInfoPictureURL, "", PrefService::UNSYNCABLE_PREF); | 83 prefs::kProfileGAIAInfoPictureURL, "", PrefService::UNSYNCABLE_PREF); |
75 } | 84 } |
76 | 85 |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 const base::TimeDelta update_delta = base::Time::Now() - last_updated_; | 198 const base::TimeDelta update_delta = base::Time::Now() - last_updated_; |
190 | 199 |
191 base::TimeDelta delta; | 200 base::TimeDelta delta; |
192 if (update_delta < base::TimeDelta() || update_delta > desired_delta) | 201 if (update_delta < base::TimeDelta() || update_delta > desired_delta) |
193 delta = base::TimeDelta::FromSeconds(kMinUpdateIntervalSeconds); | 202 delta = base::TimeDelta::FromSeconds(kMinUpdateIntervalSeconds); |
194 else | 203 else |
195 delta = desired_delta - update_delta; | 204 delta = desired_delta - update_delta; |
196 | 205 |
197 timer_.Start(FROM_HERE, delta, this, &GAIAInfoUpdateService::Update); | 206 timer_.Start(FROM_HERE, delta, this, &GAIAInfoUpdateService::Update); |
198 } | 207 } |
OLD | NEW |