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

Unified Diff: chrome/browser/chromeos/login/screens/user_image_screen.cc

Issue 466793002: [cleanup] Removed dead code from avatar selection screen. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased. Created 6 years, 4 months 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/login/screens/user_image_screen.cc
diff --git a/chrome/browser/chromeos/login/screens/user_image_screen.cc b/chrome/browser/chromeos/login/screens/user_image_screen.cc
index adbf390643bbc4e3f6ab5fe831a402188b6f326f..b1f339119a0a5b915f85d982b8184f2d76f95200 100644
--- a/chrome/browser/chromeos/login/screens/user_image_screen.cc
+++ b/chrome/browser/chromeos/login/screens/user_image_screen.cc
@@ -62,13 +62,17 @@ UserImageScreen::UserImageScreen(ScreenObserver* screen_observer,
actor_(actor),
accept_photo_after_decoding_(false),
selected_image_(user_manager::User::USER_IMAGE_INVALID),
- profile_picture_enabled_(false),
profile_picture_data_url_(url::kAboutBlankURL),
profile_picture_absent_(false),
is_screen_ready_(false),
user_has_selected_image_(false) {
actor_->SetDelegate(this);
- SetProfilePictureEnabled(true);
+ notification_registrar_.Add(this,
+ chrome::NOTIFICATION_PROFILE_IMAGE_UPDATED,
+ content::NotificationService::AllSources());
+ notification_registrar_.Add(this,
+ chrome::NOTIFICATION_PROFILE_IMAGE_UPDATE_FAILED,
+ content::NotificationService::AllSources());
notification_registrar_.Add(this,
chrome::NOTIFICATION_LOGIN_USER_IMAGE_CHANGED,
content::NotificationService::AllSources());
@@ -209,45 +213,13 @@ void UserImageScreen::OnImageAccepted() {
}
-void UserImageScreen::SetProfilePictureEnabled(bool profile_picture_enabled) {
- if (profile_picture_enabled_ == profile_picture_enabled)
- return;
- profile_picture_enabled_ = profile_picture_enabled;
- if (profile_picture_enabled) {
- notification_registrar_.Add(this,
- chrome::NOTIFICATION_PROFILE_IMAGE_UPDATED,
- content::NotificationService::AllSources());
- notification_registrar_.Add(
- this,
- chrome::NOTIFICATION_PROFILE_IMAGE_UPDATE_FAILED,
- content::NotificationService::AllSources());
- } else {
- notification_registrar_.Remove(this,
- chrome::NOTIFICATION_PROFILE_IMAGE_UPDATED,
- content::NotificationService::AllSources());
- notification_registrar_.Remove(
- this,
- chrome::NOTIFICATION_PROFILE_IMAGE_UPDATE_FAILED,
- content::NotificationService::AllSources());
- }
- if (actor_)
- actor_->SetProfilePictureEnabled(profile_picture_enabled);
-}
-
-void UserImageScreen::SetUserID(const std::string& user_id) {
- DCHECK(!user_id.empty());
- user_id_ = user_id;
-}
-
void UserImageScreen::PrepareToShow() {
if (actor_)
actor_->PrepareToShow();
}
const user_manager::User* UserImageScreen::GetUser() {
- if (user_id_.empty())
- return UserManager::Get()->GetLoggedInUser();
- return UserManager::Get()->FindUser(user_id_);
+ return UserManager::Get()->GetLoggedInUser();
}
UserImageManager* UserImageScreen::GetUserImageManager() {
@@ -263,8 +235,7 @@ void UserImageScreen::Show() {
return;
DCHECK(!policy_registrar_);
- Profile* profile = ProfileHelper::Get()->GetProfileByUserUnsafe(GetUser());
- if (profile) {
+ if (Profile* profile = ProfileHelper::Get()->GetProfileByUser(GetUser())) {
policy::PolicyService* policy_service =
policy::ProfilePolicyConnectorFactory::GetForProfile(profile)->
policy_service();
@@ -309,19 +280,17 @@ void UserImageScreen::Show() {
}
CameraPresenceNotifier::GetInstance()->AddObserver(this);
actor_->Show();
- actor_->SetProfilePictureEnabled(profile_picture_enabled_);
selected_image_ = GetUser()->image_index();
actor_->SelectImage(selected_image_);
- if (profile_picture_enabled_) {
- // Start fetching the profile image.
- GetUserImageManager()->DownloadProfileImage(kProfileDownloadReason);
- }
+ // Start fetching the profile image.
+ GetUserImageManager()->DownloadProfileImage(kProfileDownloadReason);
}
void UserImageScreen::Hide() {
CameraPresenceNotifier::GetInstance()->RemoveObserver(this);
+ notification_registrar_.RemoveAll();
if (actor_)
actor_->Hide();
}
@@ -338,7 +307,6 @@ void UserImageScreen::OnActorDestroyed(UserImageScreenActor* actor) {
void UserImageScreen::Observe(int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) {
- DCHECK(profile_picture_enabled_);
switch (type) {
case chrome::NOTIFICATION_PROFILE_IMAGE_UPDATED: {
// We've got a new profile image.

Powered by Google App Engine
This is Rietveld 408576698