| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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" |
| (...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 359 virtual_networks.begin(); iter != virtual_networks.end(); ++iter) { | 359 virtual_networks.begin(); iter != virtual_networks.end(); ++iter) { |
| 360 chromeos::VirtualNetwork* v = *iter; | 360 chromeos::VirtualNetwork* v = *iter; |
| 361 if (v->name() == service_name_) { | 361 if (v->name() == service_name_) { |
| 362 virt = v; | 362 virt = v; |
| 363 break; | 363 break; |
| 364 } | 364 } |
| 365 } | 365 } |
| 366 return virt; | 366 return virt; |
| 367 } | 367 } |
| 368 | 368 |
| 369 EnrollmentObserver::EnrollmentObserver(AutomationProvider* automation, | |
| 370 IPC::Message* reply_message, | |
| 371 chromeos::EnterpriseEnrollmentScreenActor* enrollment_screen_actor, | |
| 372 chromeos::EnterpriseEnrollmentScreen* enrollment_screen) | |
| 373 : automation_(automation->AsWeakPtr()), | |
| 374 reply_message_(reply_message), | |
| 375 enrollment_screen_(enrollment_screen) { | |
| 376 enrollment_screen_actor->AddObserver(this); | |
| 377 } | |
| 378 | |
| 379 EnrollmentObserver::~EnrollmentObserver() {} | |
| 380 | |
| 381 void EnrollmentObserver::OnEnrollmentComplete( | |
| 382 chromeos::EnterpriseEnrollmentScreenActor* enrollment_screen_actor, | |
| 383 bool succeeded) { | |
| 384 enrollment_screen_actor->RemoveObserver(this); | |
| 385 if (automation_) { | |
| 386 if (succeeded) { | |
| 387 AutomationJSONReply(automation_, | |
| 388 reply_message_.release()).SendSuccess(NULL); | |
| 389 } else { | |
| 390 scoped_ptr<DictionaryValue> return_value(new DictionaryValue); | |
| 391 return_value->SetString("error_string", "Enrollment failed."); | |
| 392 AutomationJSONReply(automation_, reply_message_.release()) | |
| 393 .SendSuccess(return_value.get()); | |
| 394 } | |
| 395 } | |
| 396 delete this; | |
| 397 } | |
| 398 | |
| 399 PhotoCaptureObserver::PhotoCaptureObserver( | 369 PhotoCaptureObserver::PhotoCaptureObserver( |
| 400 AutomationProvider* automation, | 370 AutomationProvider* automation, |
| 401 IPC::Message* reply_message) | 371 IPC::Message* reply_message) |
| 402 : automation_(automation->AsWeakPtr()), | 372 : automation_(automation->AsWeakPtr()), |
| 403 reply_message_(reply_message) { | 373 reply_message_(reply_message) { |
| 404 } | 374 } |
| 405 | 375 |
| 406 PhotoCaptureObserver::~PhotoCaptureObserver() { | 376 PhotoCaptureObserver::~PhotoCaptureObserver() { |
| 407 // TODO(frankf): Currently, we do not destroy TakePhotoDialog | 377 // TODO(frankf): Currently, we do not destroy TakePhotoDialog |
| 408 // or any of its children. | 378 // or any of its children. |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 458 | 428 |
| 459 void PhotoCaptureObserver::LocalStateChanged( | 429 void PhotoCaptureObserver::LocalStateChanged( |
| 460 chromeos::UserManager* user_manager) { | 430 chromeos::UserManager* user_manager) { |
| 461 user_manager->RemoveObserver(this); | 431 user_manager->RemoveObserver(this); |
| 462 if (automation_) { | 432 if (automation_) { |
| 463 AutomationJSONReply( | 433 AutomationJSONReply( |
| 464 automation_, reply_message_.release()).SendSuccess(NULL); | 434 automation_, reply_message_.release()).SendSuccess(NULL); |
| 465 } | 435 } |
| 466 delete this; | 436 delete this; |
| 467 } | 437 } |
| OLD | NEW |