Chromium Code Reviews| 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/automation/automation_provider_observers.h" | 5 #include "chrome/browser/automation/automation_provider_observers.h" |
| 6 | 6 |
| 7 #include "base/values.h" | 7 #include "base/values.h" |
| 8 #include "chrome/browser/automation/automation_provider.h" | 8 #include "chrome/browser/automation/automation_provider.h" |
| 9 #include "chrome/browser/chromeos/cros/cros_library.h" | 9 #include "chrome/browser/chromeos/cros/cros_library.h" |
| 10 #include "chrome/browser/chromeos/login/authentication_notification_details.h" | 10 #include "chrome/browser/chromeos/login/authentication_notification_details.h" |
| 11 #include "chrome/browser/chromeos/login/enterprise_enrollment_screen_actor.h" | 11 #include "chrome/browser/chromeos/login/enterprise_enrollment_screen_actor.h" |
| 12 #include "chrome/browser/chromeos/login/existing_user_controller.h" | 12 #include "chrome/browser/chromeos/login/existing_user_controller.h" |
| 13 #include "chrome/browser/chromeos/login/screen_locker.h" | 13 #include "chrome/browser/chromeos/login/screen_locker.h" |
| 14 #include "chrome/browser/chromeos/login/user_manager.h" | |
| 14 #include "chrome/browser/chromeos/login/wizard_controller.h" | 15 #include "chrome/browser/chromeos/login/wizard_controller.h" |
| 15 #include "chrome/common/chrome_notification_types.h" | 16 #include "chrome/common/chrome_notification_types.h" |
| 16 #include "content/common/notification_service.h" | 17 #include "content/common/notification_service.h" |
| 17 | 18 |
| 18 using chromeos::CrosLibrary; | 19 using chromeos::CrosLibrary; |
| 19 using chromeos::NetworkLibrary; | 20 using chromeos::NetworkLibrary; |
| 20 | 21 |
| 21 NetworkManagerInitObserver::NetworkManagerInitObserver( | 22 NetworkManagerInitObserver::NetworkManagerInitObserver( |
| 22 AutomationProvider* automation) | 23 AutomationProvider* automation) |
| 23 : automation_(automation->AsWeakPtr()) {} | 24 : automation_(automation->AsWeakPtr()) {} |
| (...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 345 const chromeos::WifiNetworkVector& wifi_networks = | 346 const chromeos::WifiNetworkVector& wifi_networks = |
| 346 network_library->wifi_networks(); | 347 network_library->wifi_networks(); |
| 347 for (chromeos::WifiNetworkVector::const_iterator iter = wifi_networks.begin(); | 348 for (chromeos::WifiNetworkVector::const_iterator iter = wifi_networks.begin(); |
| 348 iter != wifi_networks.end(); ++iter) { | 349 iter != wifi_networks.end(); ++iter) { |
| 349 const chromeos::WifiNetwork* wifi = *iter; | 350 const chromeos::WifiNetwork* wifi = *iter; |
| 350 if (wifi->name() == ssid_) | 351 if (wifi->name() == ssid_) |
| 351 return wifi; | 352 return wifi; |
| 352 } | 353 } |
| 353 return NULL; | 354 return NULL; |
| 354 } | 355 } |
| 356 | |
| 357 PhotoCaptureObserver::PhotoCaptureObserver( | |
| 358 AutomationProvider* automation, | |
| 359 IPC::Message* reply_message) | |
| 360 : automation_(automation->AsWeakPtr()), | |
| 361 reply_message_(reply_message) { | |
| 362 } | |
| 363 | |
| 364 PhotoCaptureObserver::~PhotoCaptureObserver() { | |
| 365 //TODO(frankf): Currently, we do not destroy TakePhotoDialog | |
|
dennis_jeffrey
2011/07/29 20:10:06
nit: add space after the '//', and add a period at
frankf
2011/07/29 21:50:40
Done.
| |
| 366 // or any of its children | |
| 367 } | |
| 368 | |
| 369 void PhotoCaptureObserver::OnCaptureSuccess( | |
| 370 chromeos::TakePhotoDialog* take_photo_dialog, | |
| 371 chromeos::TakePhotoView* take_photo_view) { | |
| 372 take_photo_view->ButtonPressed(); | |
| 373 } | |
| 374 | |
| 375 void PhotoCaptureObserver::OnCaptureFailure( | |
| 376 chromeos::TakePhotoDialog* take_photo_dialog, | |
| 377 chromeos::TakePhotoView* take_photo_view) { | |
| 378 AutomationJSONReply(automation_, reply_message_.release()).SendError("Capture failure"); | |
|
dennis_jeffrey
2011/07/29 20:10:06
line too long; 80 chars max
frankf
2011/07/29 21:50:40
Done.
| |
| 379 delete this; | |
| 380 } | |
| 381 | |
| 382 void PhotoCaptureObserver::OnCapturingStopped( | |
| 383 chromeos::TakePhotoDialog* take_photo_dialog, | |
| 384 chromeos::TakePhotoView* take_photo_view) { | |
| 385 take_photo_dialog->Accept(); | |
| 386 const SkBitmap& photo = take_photo_view->GetImage(); | |
| 387 chromeos::UserManager* user_manager = chromeos::UserManager::Get(); | |
| 388 DCHECK(user_manager); | |
|
dennis_jeffrey
2011/07/29 20:10:06
instead of a DCHECK, maybe we could send an inform
frankf
2011/07/29 21:50:40
Done.
| |
| 389 | |
| 390 const chromeos::UserManager::User& user = user_manager->logged_in_user(); | |
| 391 DCHECK(!user.email().empty()); | |
| 392 | |
| 393 user_manager->SetLoggedInUserImage(photo); | |
| 394 user_manager->SaveUserImage(user.email(), photo); | |
| 395 | |
| 396 AutomationJSONReply(automation_, reply_message_.release()).SendSuccess(NULL); | |
|
dennis_jeffrey
2011/07/29 20:10:06
Rather than returning success here, shouldn't we w
frankf
2011/07/29 21:50:40
We reach this point only when we execute PhotoCapt
| |
| 397 delete this; | |
| 398 } | |
| OLD | NEW |