| 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/common/chrome_notification_types.h" | 10 #include "chrome/common/chrome_notification_types.h" |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 state->role = ui::AccessibilityTypes::ROLE_DIALOG; | 85 state->role = ui::AccessibilityTypes::ROLE_DIALOG; |
| 86 } | 86 } |
| 87 | 87 |
| 88 void TakePhotoDialog::OnCapturingStarted() { | 88 void TakePhotoDialog::OnCapturingStarted() { |
| 89 GetDialogClientView()->ok_button()->SetEnabled(false); | 89 GetDialogClientView()->ok_button()->SetEnabled(false); |
| 90 } | 90 } |
| 91 | 91 |
| 92 void TakePhotoDialog::OnCapturingStopped() { | 92 void TakePhotoDialog::OnCapturingStopped() { |
| 93 GetDialogClientView()->ok_button()->SetEnabled(true); | 93 GetDialogClientView()->ok_button()->SetEnabled(true); |
| 94 GetDialogClientView()->ok_button()->RequestFocus(); | 94 GetDialogClientView()->ok_button()->RequestFocus(); |
| 95 NotifyOnCapturingStopped(); |
| 95 } | 96 } |
| 96 | 97 |
| 97 void TakePhotoDialog::OnCaptureSuccess() { | 98 void TakePhotoDialog::OnCaptureSuccess() { |
| 98 SkBitmap frame; | 99 SkBitmap frame; |
| 99 camera_controller_.GetFrame(&frame); | 100 camera_controller_.GetFrame(&frame); |
| 100 if (!frame.isNull()) | 101 if (!frame.isNull()) { |
| 101 take_photo_view_->UpdateVideoFrame(frame); | 102 take_photo_view_->UpdateVideoFrame(frame); |
| 103 NotifyOnCaptureSuccess(); |
| 104 } |
| 102 } | 105 } |
| 103 | 106 |
| 104 void TakePhotoDialog::OnCaptureFailure() { | 107 void TakePhotoDialog::OnCaptureFailure() { |
| 105 take_photo_view_->ShowCameraError(); | 108 take_photo_view_->ShowCameraError(); |
| 109 NotifyOnCaptureFailure(); |
| 110 } |
| 111 |
| 112 void TakePhotoDialog::AddObserver(Observer* obs) { |
| 113 observer_list_.AddObserver(obs); |
| 114 } |
| 115 |
| 116 void TakePhotoDialog::RemoveObserver(Observer* obs) { |
| 117 observer_list_.RemoveObserver(obs); |
| 118 } |
| 119 |
| 120 void TakePhotoDialog::NotifyOnCaptureSuccess() { |
| 121 FOR_EACH_OBSERVER( |
| 122 Observer, |
| 123 observer_list_, |
| 124 OnCaptureSuccess(this, take_photo_view_)); |
| 125 } |
| 126 |
| 127 void TakePhotoDialog::NotifyOnCaptureFailure() { |
| 128 FOR_EACH_OBSERVER( |
| 129 Observer, |
| 130 observer_list_, |
| 131 OnCaptureFailure(this, take_photo_view_)); |
| 132 } |
| 133 |
| 134 void TakePhotoDialog::NotifyOnCapturingStopped() { |
| 135 FOR_EACH_OBSERVER( |
| 136 Observer, |
| 137 observer_list_, |
| 138 OnCapturingStopped(this, take_photo_view_)); |
| 106 } | 139 } |
| 107 | 140 |
| 108 void TakePhotoDialog::Observe(int type, | 141 void TakePhotoDialog::Observe(int type, |
| 109 const NotificationSource& source, | 142 const NotificationSource& source, |
| 110 const NotificationDetails& details) { | 143 const NotificationDetails& details) { |
| 111 if (type != chrome::NOTIFICATION_SCREEN_LOCK_STATE_CHANGED) | 144 if (type != chrome::NOTIFICATION_SCREEN_LOCK_STATE_CHANGED) |
| 112 return; | 145 return; |
| 113 | 146 |
| 114 bool is_screen_locked = *Details<bool>(details).ptr(); | 147 bool is_screen_locked = *Details<bool>(details).ptr(); |
| 115 if (is_screen_locked) | 148 if (is_screen_locked) |
| (...skipping 14 matching lines...) Expand all Loading... |
| 130 return gfx::Size(login::kUserImageSize * 2, (login::kUserImageSize * 3 / 2)); | 163 return gfx::Size(login::kUserImageSize * 2, (login::kUserImageSize * 3 / 2)); |
| 131 } | 164 } |
| 132 | 165 |
| 133 void TakePhotoDialog::InitCamera() { | 166 void TakePhotoDialog::InitCamera() { |
| 134 take_photo_view_->ShowCameraInitializing(); | 167 take_photo_view_->ShowCameraInitializing(); |
| 135 camera_controller_.Start(); | 168 camera_controller_.Start(); |
| 136 } | 169 } |
| 137 | 170 |
| 138 } // namespace chromeos | 171 } // namespace chromeos |
| 139 | 172 |
| OLD | NEW |