| 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/options/take_photo_dialog.h" | 5 #include "chrome/browser/chromeos/options/take_photo_dialog.h" |
| 6 | 6 |
| 7 #include "base/string_util.h" | 7 #include "base/string_util.h" |
| 8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
| 9 #include "chrome/browser/chromeos/login/helper.h" | 9 #include "chrome/browser/chromeos/login/helper.h" |
| 10 #include "chrome/browser/chromeos/login/user_manager.h" | 10 #include "chrome/browser/chromeos/login/user_manager.h" |
| 11 #include "chrome/common/chrome_notification_types.h" |
| 11 #include "content/common/notification_service.h" | 12 #include "content/common/notification_service.h" |
| 12 #include "content/common/notification_type.h" | |
| 13 #include "grit/chromium_strings.h" | 13 #include "grit/chromium_strings.h" |
| 14 #include "grit/generated_resources.h" | 14 #include "grit/generated_resources.h" |
| 15 #include "grit/locale_settings.h" | 15 #include "grit/locale_settings.h" |
| 16 #include "ui/base/accessibility/accessible_view_state.h" | 16 #include "ui/base/accessibility/accessible_view_state.h" |
| 17 #include "ui/base/l10n/l10n_util.h" | 17 #include "ui/base/l10n/l10n_util.h" |
| 18 #include "views/layout/layout_constants.h" | 18 #include "views/layout/layout_constants.h" |
| 19 | 19 |
| 20 namespace chromeos { | 20 namespace chromeos { |
| 21 | 21 |
| 22 namespace { | 22 namespace { |
| 23 | 23 |
| 24 // The resolution of the picture we want to get from the camera. | 24 // The resolution of the picture we want to get from the camera. |
| 25 const int kFrameWidth = 480; | 25 const int kFrameWidth = 480; |
| 26 const int kFrameHeight = 480; | 26 const int kFrameHeight = 480; |
| 27 | 27 |
| 28 } // namespace | 28 } // namespace |
| 29 | 29 |
| 30 TakePhotoDialog::TakePhotoDialog() | 30 TakePhotoDialog::TakePhotoDialog() |
| 31 : take_photo_view_(NULL), | 31 : take_photo_view_(NULL), |
| 32 camera_controller_(this) { | 32 camera_controller_(this) { |
| 33 camera_controller_.set_frame_width(kFrameWidth); | 33 camera_controller_.set_frame_width(kFrameWidth); |
| 34 camera_controller_.set_frame_height(kFrameHeight); | 34 camera_controller_.set_frame_height(kFrameHeight); |
| 35 registrar_.Add( | 35 registrar_.Add( |
| 36 this, | 36 this, |
| 37 NotificationType::SCREEN_LOCK_STATE_CHANGED, | 37 chrome::NOTIFICATION_SCREEN_LOCK_STATE_CHANGED, |
| 38 NotificationService::AllSources()); | 38 NotificationService::AllSources()); |
| 39 } | 39 } |
| 40 | 40 |
| 41 bool TakePhotoDialog::IsDialogButtonEnabled( | 41 bool TakePhotoDialog::IsDialogButtonEnabled( |
| 42 MessageBoxFlags::DialogButton button) const { | 42 MessageBoxFlags::DialogButton button) const { |
| 43 if (button == MessageBoxFlags::DIALOGBUTTON_CANCEL) | 43 if (button == MessageBoxFlags::DIALOGBUTTON_CANCEL) |
| 44 return true; | 44 return true; |
| 45 else if (button == MessageBoxFlags::DIALOGBUTTON_OK) | 45 else if (button == MessageBoxFlags::DIALOGBUTTON_OK) |
| 46 return !take_photo_view_->is_capturing(); | 46 return !take_photo_view_->is_capturing(); |
| 47 NOTREACHED(); | 47 NOTREACHED(); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 SkBitmap frame; | 102 SkBitmap frame; |
| 103 camera_controller_.GetFrame(&frame); | 103 camera_controller_.GetFrame(&frame); |
| 104 if (!frame.isNull()) | 104 if (!frame.isNull()) |
| 105 take_photo_view_->UpdateVideoFrame(frame); | 105 take_photo_view_->UpdateVideoFrame(frame); |
| 106 } | 106 } |
| 107 | 107 |
| 108 void TakePhotoDialog::OnCaptureFailure() { | 108 void TakePhotoDialog::OnCaptureFailure() { |
| 109 take_photo_view_->ShowCameraError(); | 109 take_photo_view_->ShowCameraError(); |
| 110 } | 110 } |
| 111 | 111 |
| 112 void TakePhotoDialog::Observe(NotificationType type, | 112 void TakePhotoDialog::Observe(int type, |
| 113 const NotificationSource& source, | 113 const NotificationSource& source, |
| 114 const NotificationDetails& details) { | 114 const NotificationDetails& details) { |
| 115 if (type != NotificationType::SCREEN_LOCK_STATE_CHANGED) | 115 if (type != chrome::NOTIFICATION_SCREEN_LOCK_STATE_CHANGED) |
| 116 return; | 116 return; |
| 117 | 117 |
| 118 bool is_screen_locked = *Details<bool>(details).ptr(); | 118 bool is_screen_locked = *Details<bool>(details).ptr(); |
| 119 if (is_screen_locked) | 119 if (is_screen_locked) |
| 120 camera_controller_.Stop(); | 120 camera_controller_.Stop(); |
| 121 else | 121 else |
| 122 InitCamera(); | 122 InitCamera(); |
| 123 } | 123 } |
| 124 | 124 |
| 125 void TakePhotoDialog::Layout() { | 125 void TakePhotoDialog::Layout() { |
| 126 int left = views::kPanelHorizMargin; | 126 int left = views::kPanelHorizMargin; |
| 127 int top = views::kPanelVertMargin; | 127 int top = views::kPanelVertMargin; |
| 128 int contents_width = width() - 2 * left; | 128 int contents_width = width() - 2 * left; |
| 129 int contents_height = height() - 2 * top; | 129 int contents_height = height() - 2 * top; |
| 130 take_photo_view_->SetBounds(left, top, contents_width, contents_height); | 130 take_photo_view_->SetBounds(left, top, contents_width, contents_height); |
| 131 } | 131 } |
| 132 | 132 |
| 133 gfx::Size TakePhotoDialog::GetPreferredSize() { | 133 gfx::Size TakePhotoDialog::GetPreferredSize() { |
| 134 return gfx::Size(login::kUserImageSize * 2, (login::kUserImageSize * 3 / 2)); | 134 return gfx::Size(login::kUserImageSize * 2, (login::kUserImageSize * 3 / 2)); |
| 135 } | 135 } |
| 136 | 136 |
| 137 void TakePhotoDialog::InitCamera() { | 137 void TakePhotoDialog::InitCamera() { |
| 138 take_photo_view_->ShowCameraInitializing(); | 138 take_photo_view_->ShowCameraInitializing(); |
| 139 camera_controller_.Start(); | 139 camera_controller_.Start(); |
| 140 } | 140 } |
| 141 | 141 |
| 142 } // namespace chromeos | 142 } // namespace chromeos |
| 143 | 143 |
| OLD | NEW |