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

Side by Side 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: Addressed all the comments Created 9 years, 4 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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
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_,
379 reply_message_.release()).SendError("Capture failure");
380 delete this;
381 }
382
383 void PhotoCaptureObserver::OnCapturingStopped(
384 chromeos::TakePhotoDialog* take_photo_dialog,
385 chromeos::TakePhotoView* take_photo_view) {
386 take_photo_dialog->Accept();
387 const SkBitmap& photo = take_photo_view->GetImage();
388 chromeos::UserManager* user_manager = chromeos::UserManager::Get();
389 if(!user_manager) {
390 AutomationJSONReply(automation_,
391 reply_message_.release()).SendError(
392 "No user manager");
393 }
394
395 const chromeos::UserManager::User& user = user_manager->logged_in_user();
Nirnimesh 2011/07/30 10:32:31 It's possible to reach here if user_manager == NUL
frankf 2011/08/01 19:31:09 Done.
396 if(user.email().empty()) {
397 AutomationJSONReply(automation_,
398 reply_message_.release()).SendError(
399 "User email is not set");
400 }
401
402 user_manager->SetLoggedInUserImage(photo);
403 user_manager->SaveUserImage(user.email(), photo);
404
405 AutomationJSONReply(automation_, reply_message_.release()).SendSuccess(NULL);
406 delete this;
407 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698