OLD | NEW |
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/chromeos/login/user_image_screen.h" | 5 #include "chrome/browser/chromeos/login/user_image_screen.h" |
6 | 6 |
7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
| 8 #include "base/metrics/histogram.h" |
8 #include "chrome/browser/chromeos/login/default_user_images.h" | 9 #include "chrome/browser/chromeos/login/default_user_images.h" |
9 #include "chrome/browser/chromeos/login/login_utils.h" | 10 #include "chrome/browser/chromeos/login/login_utils.h" |
10 #include "chrome/browser/chromeos/login/screen_observer.h" | 11 #include "chrome/browser/chromeos/login/screen_observer.h" |
11 #include "chrome/browser/chromeos/login/user_manager.h" | 12 #include "chrome/browser/chromeos/login/user_manager.h" |
12 #include "chrome/common/chrome_notification_types.h" | 13 #include "chrome/common/chrome_notification_types.h" |
13 #include "content/common/notification_service.h" | 14 #include "content/common/notification_service.h" |
14 #include "grit/theme_resources.h" | 15 #include "grit/theme_resources.h" |
15 #include "ui/base/resource/resource_bundle.h" | 16 #include "ui/base/resource/resource_bundle.h" |
16 | 17 |
17 namespace chromeos { | 18 namespace chromeos { |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 | 105 |
105 UserManager* user_manager = UserManager::Get(); | 106 UserManager* user_manager = UserManager::Get(); |
106 DCHECK(user_manager); | 107 DCHECK(user_manager); |
107 | 108 |
108 const UserManager::User& user = user_manager->logged_in_user(); | 109 const UserManager::User& user = user_manager->logged_in_user(); |
109 DCHECK(!user.email().empty()); | 110 DCHECK(!user.email().empty()); |
110 | 111 |
111 user_manager->SetLoggedInUserImage(image); | 112 user_manager->SetLoggedInUserImage(image); |
112 user_manager->SaveUserImage(user.email(), image); | 113 user_manager->SaveUserImage(user.email(), image); |
113 get_screen_observer()->OnExit(ScreenObserver::USER_IMAGE_SELECTED); | 114 get_screen_observer()->OnExit(ScreenObserver::USER_IMAGE_SELECTED); |
| 115 |
| 116 UMA_HISTOGRAM_ENUMERATION("UserImage.FirstTimeChoice", |
| 117 kDefaultImagesCount, |
| 118 kDefaultImagesCount + 1); |
114 } | 119 } |
115 | 120 |
116 void UserImageScreen::OnDefaultImageSelected(int index) { | 121 void UserImageScreen::OnDefaultImageSelected(int index) { |
117 camera_controller_.Stop(); | 122 camera_controller_.Stop(); |
118 | 123 |
119 UserManager* user_manager = UserManager::Get(); | 124 UserManager* user_manager = UserManager::Get(); |
120 DCHECK(user_manager); | 125 DCHECK(user_manager); |
121 | 126 |
122 const UserManager::User& user = user_manager->logged_in_user(); | 127 const UserManager::User& user = user_manager->logged_in_user(); |
123 DCHECK(!user.email().empty()); | 128 DCHECK(!user.email().empty()); |
124 | 129 |
125 const SkBitmap* image = ResourceBundle::GetSharedInstance().GetBitmapNamed( | 130 const SkBitmap* image = ResourceBundle::GetSharedInstance().GetBitmapNamed( |
126 kDefaultImageResources[index]); | 131 kDefaultImageResources[index]); |
127 user_manager->SetLoggedInUserImage(*image); | 132 user_manager->SetLoggedInUserImage(*image); |
128 user_manager->SaveUserImagePath( | 133 user_manager->SaveUserImagePath( |
129 user.email(), | 134 user.email(), |
130 GetDefaultImagePath(static_cast<size_t>(index))); | 135 GetDefaultImagePath(static_cast<size_t>(index))); |
131 get_screen_observer()->OnExit(ScreenObserver::USER_IMAGE_SELECTED); | 136 get_screen_observer()->OnExit(ScreenObserver::USER_IMAGE_SELECTED); |
| 137 |
| 138 UMA_HISTOGRAM_ENUMERATION("UserImage.FirstTimeChoice", |
| 139 index, |
| 140 kDefaultImagesCount + 1); |
132 } | 141 } |
133 | 142 |
134 void UserImageScreen::OnActorDestroyed(UserImageScreenActor* actor) { | 143 void UserImageScreen::OnActorDestroyed(UserImageScreenActor* actor) { |
135 if (actor_ == actor) | 144 if (actor_ == actor) |
136 actor_ = NULL; | 145 actor_ = NULL; |
137 } | 146 } |
138 | 147 |
139 void UserImageScreen::Observe(int type, | 148 void UserImageScreen::Observe(int type, |
140 const NotificationSource& source, | 149 const NotificationSource& source, |
141 const NotificationDetails& details) { | 150 const NotificationDetails& details) { |
142 if (type != chrome::NOTIFICATION_SCREEN_LOCK_STATE_CHANGED) | 151 if (type != chrome::NOTIFICATION_SCREEN_LOCK_STATE_CHANGED) |
143 return; | 152 return; |
144 | 153 |
145 bool is_screen_locked = *Details<bool>(details).ptr(); | 154 bool is_screen_locked = *Details<bool>(details).ptr(); |
146 if (is_screen_locked) | 155 if (is_screen_locked) |
147 StopCamera(); | 156 StopCamera(); |
148 else if (actor_ && actor_->IsCapturing()) | 157 else if (actor_ && actor_->IsCapturing()) |
149 StartCamera(); | 158 StartCamera(); |
150 } | 159 } |
151 | 160 |
152 } // namespace chromeos | 161 } // namespace chromeos |
153 | 162 |
OLD | NEW |