Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(264)

Unified Diff: chrome/browser/automation/automation_provider_observers_chromeos.cc

Issue 7523063: Add a hook for capturing a user profile photo and saving it to file and local state. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Created 9 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/automation/automation_provider_observers_chromeos.cc
diff --git a/chrome/browser/automation/automation_provider_observers_chromeos.cc b/chrome/browser/automation/automation_provider_observers_chromeos.cc
index 940bd5a32281cedef4a8c05a8c8665aa0e9efca8..d89f9204adc5ea229b4bb3d52bba2a5a5b81405e 100644
--- a/chrome/browser/automation/automation_provider_observers_chromeos.cc
+++ b/chrome/browser/automation/automation_provider_observers_chromeos.cc
@@ -11,6 +11,7 @@
#include "chrome/browser/chromeos/login/enterprise_enrollment_screen_actor.h"
#include "chrome/browser/chromeos/login/existing_user_controller.h"
#include "chrome/browser/chromeos/login/screen_locker.h"
+#include "chrome/browser/chromeos/login/user_manager.h"
#include "chrome/browser/chromeos/login/wizard_controller.h"
#include "chrome/common/chrome_notification_types.h"
#include "content/common/notification_service.h"
@@ -352,3 +353,46 @@ const chromeos::WifiNetwork* SSIDConnectObserver::GetWifiNetwork(
}
return NULL;
}
+
+PhotoCaptureObserver::PhotoCaptureObserver(
+ AutomationProvider* automation,
+ IPC::Message* reply_message)
+ : automation_(automation->AsWeakPtr()),
+ reply_message_(reply_message) {
+}
+
+PhotoCaptureObserver::~PhotoCaptureObserver() {
+ //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.
+ // or any of its children
+}
+
+void PhotoCaptureObserver::OnCaptureSuccess(
+ chromeos::TakePhotoDialog* take_photo_dialog,
+ chromeos::TakePhotoView* take_photo_view) {
+ take_photo_view->ButtonPressed();
+}
+
+void PhotoCaptureObserver::OnCaptureFailure(
+ chromeos::TakePhotoDialog* take_photo_dialog,
+ chromeos::TakePhotoView* take_photo_view) {
+ 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.
+ delete this;
+}
+
+void PhotoCaptureObserver::OnCapturingStopped(
+ chromeos::TakePhotoDialog* take_photo_dialog,
+ chromeos::TakePhotoView* take_photo_view) {
+ take_photo_dialog->Accept();
+ const SkBitmap& photo = take_photo_view->GetImage();
+ chromeos::UserManager* user_manager = chromeos::UserManager::Get();
+ 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.
+
+ const chromeos::UserManager::User& user = user_manager->logged_in_user();
+ DCHECK(!user.email().empty());
+
+ user_manager->SetLoggedInUserImage(photo);
+ user_manager->SaveUserImage(user.email(), photo);
+
+ 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
+ delete this;
+}

Powered by Google App Engine
This is Rietveld 408576698