OLD | NEW |
---|---|
1 // Copyright (c) 2012 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/prefs/pref_service.h" | 7 #include "base/prefs/pref_service.h" |
8 #include "base/strings/utf_string_conversions.h" | |
8 #include "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
9 #include "chrome/browser/chrome_notification_types.h" | 10 #include "chrome/browser/chrome_notification_types.h" |
10 #include "chrome/browser/profiles/profile.h" | 11 #include "chrome/browser/profiles/profile.h" |
11 #include "chrome/browser/profiles/profile_info_cache.h" | 12 #include "chrome/browser/profiles/profile_info_cache.h" |
12 #include "chrome/browser/profiles/profile_manager.h" | 13 #include "chrome/browser/profiles/profile_manager.h" |
14 #include "chrome/browser/profiles/profiles_state.h" | |
13 #include "chrome/browser/signin/signin_manager_factory.h" | 15 #include "chrome/browser/signin/signin_manager_factory.h" |
14 #include "chrome/browser/sync/profile_sync_service.h" | 16 #include "chrome/browser/sync/profile_sync_service.h" |
15 #include "chrome/common/pref_names.h" | 17 #include "chrome/common/pref_names.h" |
16 #include "components/signin/core/common/profile_management_switches.h" | 18 #include "components/signin/core/common/profile_management_switches.h" |
17 #include "content/public/browser/notification_details.h" | 19 #include "content/public/browser/notification_details.h" |
18 #include "third_party/skia/include/core/SkBitmap.h" | 20 #include "third_party/skia/include/core/SkBitmap.h" |
19 #include "ui/gfx/image/image.h" | 21 #include "ui/gfx/image/image.h" |
20 | 22 |
21 namespace { | 23 namespace { |
22 | 24 |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
128 DCHECK_NE(profile_index, std::string::npos); | 130 DCHECK_NE(profile_index, std::string::npos); |
129 | 131 |
130 if (picture_status == ProfileDownloader::PICTURE_SUCCESS) { | 132 if (picture_status == ProfileDownloader::PICTURE_SUCCESS) { |
131 profile_->GetPrefs()->SetString(prefs::kProfileGAIAInfoPictureURL, | 133 profile_->GetPrefs()->SetString(prefs::kProfileGAIAInfoPictureURL, |
132 picture_url); | 134 picture_url); |
133 gfx::Image gfx_image = gfx::Image::CreateFrom1xBitmap(bitmap); | 135 gfx::Image gfx_image = gfx::Image::CreateFrom1xBitmap(bitmap); |
134 cache.SetGAIAPictureOfProfileAtIndex(profile_index, &gfx_image); | 136 cache.SetGAIAPictureOfProfileAtIndex(profile_index, &gfx_image); |
135 } else if (picture_status == ProfileDownloader::PICTURE_DEFAULT) { | 137 } else if (picture_status == ProfileDownloader::PICTURE_DEFAULT) { |
136 cache.SetGAIAPictureOfProfileAtIndex(profile_index, NULL); | 138 cache.SetGAIAPictureOfProfileAtIndex(profile_index, NULL); |
137 } | 139 } |
140 | |
141 base::string16 hosted_domain = downloader->GetProfileHostedDomain(); | |
noms (inactive)
2014/09/15 18:52:40
nit: const?
Mike Lerman
2014/09/15 19:51:41
Sure?
| |
142 profile_->GetPrefs()->SetInteger(prefs::kProfileIsLockableVersion, | |
143 profiles::kCurrentLockAlgorithmVersion); | |
144 profile_->GetPrefs()->SetBoolean(prefs::kProfileIsLockable, | |
145 hosted_domain.empty() || | |
146 hosted_domain == base::UTF8ToUTF16("google.com")); | |
noms (inactive)
2014/09/15 18:52:40
nit: please put brackets around the == part to mak
Mike Lerman
2014/09/15 19:51:41
Ternaries are always scary.
| |
138 } | 147 } |
139 | 148 |
140 void GAIAInfoUpdateService::OnProfileDownloadFailure( | 149 void GAIAInfoUpdateService::OnProfileDownloadFailure( |
141 ProfileDownloader* downloader, | 150 ProfileDownloader* downloader, |
142 ProfileDownloaderDelegate::FailureReason reason) { | 151 ProfileDownloaderDelegate::FailureReason reason) { |
143 profile_image_downloader_.reset(); | 152 profile_image_downloader_.reset(); |
144 | 153 |
145 // Save the last updated time. | 154 // Save the last updated time. |
146 last_updated_ = base::Time::Now(); | 155 last_updated_ = base::Time::Now(); |
147 profile_->GetPrefs()->SetInt64(prefs::kProfileGAIAInfoUpdateTime, | 156 profile_->GetPrefs()->SetInt64(prefs::kProfileGAIAInfoUpdateTime, |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
207 const std::string& account_id, | 216 const std::string& account_id, |
208 const std::string& username, | 217 const std::string& username, |
209 const std::string& password) { | 218 const std::string& password) { |
210 OnUsernameChanged(username); | 219 OnUsernameChanged(username); |
211 } | 220 } |
212 | 221 |
213 void GAIAInfoUpdateService::GoogleSignedOut(const std::string& account_id, | 222 void GAIAInfoUpdateService::GoogleSignedOut(const std::string& account_id, |
214 const std::string& username) { | 223 const std::string& username) { |
215 OnUsernameChanged(std::string()); | 224 OnUsernameChanged(std::string()); |
216 } | 225 } |
OLD | NEW |