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

Side by Side Diff: chrome/browser/profiles/gaia_info_update_service.cc

Issue 8742008: ChromeOS: Use OAuth2 refresh token to download GAIA info (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merge Created 9 years 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "chrome/browser/browser_process.h" 7 #include "chrome/browser/browser_process.h"
8 #include "chrome/browser/prefs/pref_service.h" 8 #include "chrome/browser/prefs/pref_service.h"
9 #include "chrome/browser/profiles/profile.h" 9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/browser/profiles/profile_info_cache.h" 10 #include "chrome/browser/profiles/profile_info_cache.h"
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 } 75 }
76 76
77 int GAIAInfoUpdateService::GetDesiredImageSideLength() const { 77 int GAIAInfoUpdateService::GetDesiredImageSideLength() const {
78 return 256; 78 return 256;
79 } 79 }
80 80
81 Profile* GAIAInfoUpdateService::GetBrowserProfile() { 81 Profile* GAIAInfoUpdateService::GetBrowserProfile() {
82 return profile_; 82 return profile_;
83 } 83 }
84 84
85 bool GAIAInfoUpdateService::ShouldUseOAuthRefreshToken() const {
86 return true;
87 }
88
89 std::string GAIAInfoUpdateService::GetCachedPictureURL() const { 85 std::string GAIAInfoUpdateService::GetCachedPictureURL() const {
90 return profile_->GetPrefs()->GetString(prefs::kProfileGAIAInfoPictureURL); 86 return profile_->GetPrefs()->GetString(prefs::kProfileGAIAInfoPictureURL);
91 } 87 }
92 88
93 void GAIAInfoUpdateService::OnDownloadComplete(ProfileDownloader* downloader, 89 void GAIAInfoUpdateService::OnDownloadComplete(ProfileDownloader* downloader,
94 bool success) { 90 bool success) {
95 // Save the last updated time. 91 // Save the last updated time.
96 last_updated_ = base::Time::Now(); 92 last_updated_ = base::Time::Now();
97 profile_->GetPrefs()->SetInt64(prefs::kProfileGAIAInfoUpdateTime, 93 profile_->GetPrefs()->SetInt64(prefs::kProfileGAIAInfoUpdateTime,
98 last_updated_.ToInternalValue()); 94 last_updated_.ToInternalValue());
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 const base::TimeDelta update_delta = base::Time::Now() - last_updated_; 173 const base::TimeDelta update_delta = base::Time::Now() - last_updated_;
178 174
179 base::TimeDelta delta; 175 base::TimeDelta delta;
180 if (update_delta < base::TimeDelta() || update_delta > desired_delta) 176 if (update_delta < base::TimeDelta() || update_delta > desired_delta)
181 delta = base::TimeDelta::FromSeconds(kMinUpdateIntervalSeconds); 177 delta = base::TimeDelta::FromSeconds(kMinUpdateIntervalSeconds);
182 else 178 else
183 delta = desired_delta - update_delta; 179 delta = desired_delta - update_delta;
184 180
185 timer_.Start(FROM_HERE, delta, this, &GAIAInfoUpdateService::Update); 181 timer_.Start(FROM_HERE, delta, this, &GAIAInfoUpdateService::Update);
186 } 182 }
OLDNEW
« no previous file with comments | « chrome/browser/profiles/gaia_info_update_service.h ('k') | chrome/browser/profiles/profile_downloader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698