| 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 "chrome/browser/chromeos/login/default_user_images.h" | 8 #include "chrome/browser/chromeos/login/default_user_images.h" |
| 9 #include "chrome/browser/chromeos/login/login_utils.h" | 9 #include "chrome/browser/chromeos/login/login_utils.h" |
| 10 #include "chrome/browser/chromeos/login/screen_observer.h" | 10 #include "chrome/browser/chromeos/login/screen_observer.h" |
| 11 #include "chrome/browser/chromeos/login/user_image_view.h" | 11 #include "chrome/browser/chromeos/login/user_image_view.h" |
| 12 #include "chrome/browser/chromeos/login/user_manager.h" | 12 #include "chrome/browser/chromeos/login/user_manager.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 "content/common/notification_type.h" | |
| 15 #include "grit/theme_resources.h" | 15 #include "grit/theme_resources.h" |
| 16 #include "ui/base/resource/resource_bundle.h" | 16 #include "ui/base/resource/resource_bundle.h" |
| 17 | 17 |
| 18 namespace chromeos { | 18 namespace chromeos { |
| 19 | 19 |
| 20 namespace { | 20 namespace { |
| 21 | 21 |
| 22 // The resolution of the picture we want to get from the camera. | 22 // The resolution of the picture we want to get from the camera. |
| 23 const int kFrameWidth = 480; | 23 const int kFrameWidth = 480; |
| 24 const int kFrameHeight = 480; | 24 const int kFrameHeight = 480; |
| 25 | 25 |
| 26 } // namespace | 26 } // namespace |
| 27 | 27 |
| 28 UserImageScreen::UserImageScreen(ViewScreenDelegate* delegate) | 28 UserImageScreen::UserImageScreen(ViewScreenDelegate* delegate) |
| 29 : ViewScreen<UserImageView>(delegate), | 29 : ViewScreen<UserImageView>(delegate), |
| 30 camera_controller_(this) { | 30 camera_controller_(this) { |
| 31 camera_controller_.set_frame_width(kFrameWidth); | 31 camera_controller_.set_frame_width(kFrameWidth); |
| 32 camera_controller_.set_frame_height(kFrameHeight); | 32 camera_controller_.set_frame_height(kFrameHeight); |
| 33 registrar_.Add( | 33 registrar_.Add( |
| 34 this, | 34 this, |
| 35 NotificationType::SCREEN_LOCK_STATE_CHANGED, | 35 chrome::NOTIFICATION_SCREEN_LOCK_STATE_CHANGED, |
| 36 NotificationService::AllSources()); | 36 NotificationService::AllSources()); |
| 37 } | 37 } |
| 38 | 38 |
| 39 UserImageScreen::~UserImageScreen() { | 39 UserImageScreen::~UserImageScreen() { |
| 40 } | 40 } |
| 41 | 41 |
| 42 void UserImageScreen::Refresh() { | 42 void UserImageScreen::Refresh() { |
| 43 DCHECK(view()); | 43 DCHECK(view()); |
| 44 UserManager* user_manager = UserManager::Get(); | 44 UserManager* user_manager = UserManager::Get(); |
| 45 std::string logged_in_user = user_manager->logged_in_user().email(); | 45 std::string logged_in_user = user_manager->logged_in_user().email(); |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 const SkBitmap* image = ResourceBundle::GetSharedInstance().GetBitmapNamed( | 106 const SkBitmap* image = ResourceBundle::GetSharedInstance().GetBitmapNamed( |
| 107 kDefaultImageResources[index]); | 107 kDefaultImageResources[index]); |
| 108 user_manager->SetLoggedInUserImage(*image); | 108 user_manager->SetLoggedInUserImage(*image); |
| 109 user_manager->SaveUserImagePath( | 109 user_manager->SaveUserImagePath( |
| 110 user.email(), | 110 user.email(), |
| 111 GetDefaultImagePath(static_cast<size_t>(index))); | 111 GetDefaultImagePath(static_cast<size_t>(index))); |
| 112 if (delegate()) | 112 if (delegate()) |
| 113 delegate()->GetObserver()->OnExit(ScreenObserver::USER_IMAGE_SELECTED); | 113 delegate()->GetObserver()->OnExit(ScreenObserver::USER_IMAGE_SELECTED); |
| 114 } | 114 } |
| 115 | 115 |
| 116 void UserImageScreen::Observe(NotificationType type, | 116 void UserImageScreen::Observe(int type, |
| 117 const NotificationSource& source, | 117 const NotificationSource& source, |
| 118 const NotificationDetails& details) { | 118 const NotificationDetails& details) { |
| 119 if (type != NotificationType::SCREEN_LOCK_STATE_CHANGED) | 119 if (type != chrome::NOTIFICATION_SCREEN_LOCK_STATE_CHANGED) |
| 120 return; | 120 return; |
| 121 | 121 |
| 122 bool is_screen_locked = *Details<bool>(details).ptr(); | 122 bool is_screen_locked = *Details<bool>(details).ptr(); |
| 123 if (is_screen_locked) | 123 if (is_screen_locked) |
| 124 StopCamera(); | 124 StopCamera(); |
| 125 else if (view()->IsCapturing()) | 125 else if (view()->IsCapturing()) |
| 126 StartCamera(); | 126 StartCamera(); |
| 127 } | 127 } |
| 128 | 128 |
| 129 } // namespace chromeos | 129 } // namespace chromeos |
| 130 | 130 |
| OLD | NEW |