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

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

Issue 8511064: GAIA Profile info prototype (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: test Created 9 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/profiles/profile_impl.h ('k') | chrome/browser/profiles/profile_info_cache.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/profile_impl.h" 5 #include "chrome/browser/profiles/profile_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/environment.h" 10 #include "base/environment.h"
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 #include "chrome/browser/password_manager/password_store_x.h" 132 #include "chrome/browser/password_manager/password_store_x.h"
133 #endif 133 #endif
134 134
135 #if defined(OS_CHROMEOS) 135 #if defined(OS_CHROMEOS)
136 #include "chrome/browser/chromeos/locale_change_guard.h" 136 #include "chrome/browser/chromeos/locale_change_guard.h"
137 #include "chrome/browser/chromeos/login/user_manager.h" 137 #include "chrome/browser/chromeos/login/user_manager.h"
138 #include "chrome/browser/chromeos/preferences.h" 138 #include "chrome/browser/chromeos/preferences.h"
139 #include "chrome/browser/chromeos/proxy_config_service_impl.h" 139 #include "chrome/browser/chromeos/proxy_config_service_impl.h"
140 #endif 140 #endif
141 141
142 #include "chrome/browser/gaia_userinfo/profile_image_downloader.h"
143
142 using base::Time; 144 using base::Time;
143 using base::TimeDelta; 145 using base::TimeDelta;
144 using content::BrowserThread; 146 using content::BrowserThread;
145 147
148 const char kHasMigratedToGAIAInfo[] = "test_profile_has_migrated_to_gaia_info";
149
150
151 class GAIAInfoUpdater : public ProfileImageDownloader::Delegate {
152 public:
153 explicit GAIAInfoUpdater(Profile* profile);
154 bool IsFinishedUpdating();
155
156 // ProfileImageDownloader::Delegate:
157 virtual int GetDesiredImageSize() OVERRIDE;
158 virtual std::string GetProfileUserName() OVERRIDE;
159 virtual Profile* GetProfile() OVERRIDE;
160 virtual void OnDownloadSuccess(const SkBitmap& image,
161 const string16& full_name) OVERRIDE;
162 virtual void OnDownloadFailure() OVERRIDE;
163 virtual void OnDownloadDefaultImage() OVERRIDE;
164
165 private:
166 Profile* profile_;
167 bool is_finished_updating_;
168 scoped_ptr<ProfileImageDownloader> profile_image_downloader_;
169 };
170
171 GAIAInfoUpdater::GAIAInfoUpdater(Profile* profile)
172 : profile_(profile),
173 is_finished_updating_(false) {
174 profile_image_downloader_.reset(new ProfileImageDownloader(this));
175 profile_image_downloader_->Start();
176 }
177
178 bool GAIAInfoUpdater::IsFinishedUpdating() {
179 return is_finished_updating_;
180 }
181
182 int GAIAInfoUpdater::GetDesiredImageSize() {
183 return 256;
184 }
185
186 std::string GAIAInfoUpdater::GetProfileUserName() {
187 return profile_->GetPrefs()->GetString(prefs::kGoogleServicesUsername);
188 }
189
190 Profile* GAIAInfoUpdater::GetProfile() {
191 return profile_;
192 }
193
194 void GAIAInfoUpdater::OnDownloadSuccess(const SkBitmap& image,
195 const string16& full_name) {
196 fprintf(stderr, "%s\n", __func__);
197 ProfileInfoCache& cache =
198 g_browser_process->profile_manager()->GetProfileInfoCache();
199 size_t profile_index = cache.GetIndexOfProfileWithPath(profile_->GetPath());
200 if (profile_index != std::string::npos) {
201 cache.SetGAIANameOfProfileAtIndex(profile_index, full_name);
202 cache.SetGAIAPictureOfProfileAtIndex(profile_index, image);
203
204 if (!profile_->GetPrefs()->GetBoolean(kHasMigratedToGAIAInfo)) {
205 fprintf(stderr, "%s, migrating to gaia image and name\n", __func__);
206 profile_->GetPrefs()->SetBoolean(kHasMigratedToGAIAInfo, true);
207 if (!image.isNull()) {
208 cache.SetIsUsingCustomAvatarIconForProfileAtIndex(profile_index, true);
209 }
210 if (!full_name.empty()) {
211 cache.SetIsUsingGAIANameForProfileAtIndex(profile_index, true);
212 }
213 }
214 }
215 is_finished_updating_ = true;
216 }
217
218 void GAIAInfoUpdater::OnDownloadFailure() {
219 fprintf(stderr, "%s\n", __func__);
220 is_finished_updating_ = true;
221 }
222
223 void GAIAInfoUpdater::OnDownloadDefaultImage() {
224 fprintf(stderr, "%s\n", __func__);
225 is_finished_updating_ = true;
226 }
227
146 namespace { 228 namespace {
147 229
148 // Delay, in milliseconds, before we explicitly create the SessionService. 230 // Delay, in milliseconds, before we explicitly create the SessionService.
149 static const int kCreateSessionServiceDelayMS = 500; 231 static const int kCreateSessionServiceDelayMS = 500;
150 232
151 #if defined(OS_MACOSX) 233 #if defined(OS_MACOSX)
152 // Capacity for mock keychain used for testing. 234 // Capacity for mock keychain used for testing.
153 static const int kMockKeychainSize = 1000; 235 static const int kMockKeychainSize = 1000;
154 #endif 236 #endif
155 237
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 false, 325 false,
244 PrefService::SYNCABLE_PREF); 326 PrefService::SYNCABLE_PREF);
245 #if !defined(OS_MACOSX) && !defined(OS_CHROMEOS) && defined(OS_POSIX) 327 #if !defined(OS_MACOSX) && !defined(OS_CHROMEOS) && defined(OS_POSIX)
246 prefs->RegisterIntegerPref(prefs::kLocalProfileId, 328 prefs->RegisterIntegerPref(prefs::kLocalProfileId,
247 kInvalidLocalProfileId, 329 kInvalidLocalProfileId,
248 PrefService::UNSYNCABLE_PREF); 330 PrefService::UNSYNCABLE_PREF);
249 // Notice that the preprocessor conditions above are exactly those that will 331 // Notice that the preprocessor conditions above are exactly those that will
250 // result in using PasswordStoreX in CreatePasswordStore() below. 332 // result in using PasswordStoreX in CreatePasswordStore() below.
251 PasswordStoreX::RegisterUserPrefs(prefs); 333 PasswordStoreX::RegisterUserPrefs(prefs);
252 #endif 334 #endif
335
336 prefs->RegisterBooleanPref(kHasMigratedToGAIAInfo,
337 false,
338 PrefService::UNSYNCABLE_PREF);
253 } 339 }
254 340
255 ProfileImpl::ProfileImpl(const FilePath& path, 341 ProfileImpl::ProfileImpl(const FilePath& path,
256 Profile::Delegate* delegate) 342 Profile::Delegate* delegate)
257 : path_(path), 343 : path_(path),
258 ALLOW_THIS_IN_INITIALIZER_LIST(visited_link_event_listener_( 344 ALLOW_THIS_IN_INITIALIZER_LIST(visited_link_event_listener_(
259 new VisitedLinkEventListener(this))), 345 new VisitedLinkEventListener(this))),
260 extension_devtools_manager_(NULL), 346 extension_devtools_manager_(NULL),
261 ALLOW_THIS_IN_INITIALIZER_LIST(io_data_(this)), 347 ALLOW_THIS_IN_INITIALIZER_LIST(io_data_(this)),
262 host_content_settings_map_(NULL), 348 host_content_settings_map_(NULL),
(...skipping 1088 matching lines...) Expand 10 before | Expand all | Expand 10 after
1351 host, Value::CreateDoubleValue(level)); 1437 host, Value::CreateDoubleValue(level));
1352 } 1438 }
1353 } 1439 }
1354 break; 1440 break;
1355 } 1441 }
1356 default: 1442 default:
1357 NOTREACHED(); 1443 NOTREACHED();
1358 } 1444 }
1359 } 1445 }
1360 1446
1447 void ProfileImpl::UpdateGAIAProfileInfo() {
1448 if (gaia_info_updated_.get() && !gaia_info_updated_->IsFinishedUpdating()) {
1449 fprintf(stderr, "%s, skipping updating because old one is pending\n",
1450 __func__);
1451 return;
1452 }
1453
1454 fprintf(stderr, "%s, starting new GAIA profile info update\n", __func__);
1455 gaia_info_updated_.reset(new GAIAInfoUpdater(this));
1456 }
1457
1361 void ProfileImpl::StopCreateSessionServiceTimer() { 1458 void ProfileImpl::StopCreateSessionServiceTimer() {
1362 create_session_service_timer_.Stop(); 1459 create_session_service_timer_.Stop();
1363 } 1460 }
1364 1461
1365 void ProfileImpl::EnsureSessionServiceCreated() { 1462 void ProfileImpl::EnsureSessionServiceCreated() {
1366 SessionServiceFactory::GetForProfile(this); 1463 SessionServiceFactory::GetForProfile(this);
1367 } 1464 }
1368 1465
1369 TokenService* ProfileImpl::GetTokenService() { 1466 TokenService* ProfileImpl::GetTokenService() {
1370 if (!token_service_.get()) { 1467 if (!token_service_.get()) {
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
1588 if (!home_page.is_valid()) 1685 if (!home_page.is_valid())
1589 return GURL(chrome::kChromeUINewTabURL); 1686 return GURL(chrome::kChromeUINewTabURL);
1590 return home_page; 1687 return home_page;
1591 } 1688 }
1592 1689
1593 SpellCheckProfile* ProfileImpl::GetSpellCheckProfile() { 1690 SpellCheckProfile* ProfileImpl::GetSpellCheckProfile() {
1594 if (!spellcheck_profile_.get()) 1691 if (!spellcheck_profile_.get())
1595 spellcheck_profile_.reset(new SpellCheckProfile(path_)); 1692 spellcheck_profile_.reset(new SpellCheckProfile(path_));
1596 return spellcheck_profile_.get(); 1693 return spellcheck_profile_.get();
1597 } 1694 }
1695
OLDNEW
« no previous file with comments | « chrome/browser/profiles/profile_impl.h ('k') | chrome/browser/profiles/profile_info_cache.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698