| 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/testing_automation_provider.h" | 5 #include "chrome/browser/automation/testing_automation_provider.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/i18n/time_formatting.h" | 8 #include "base/i18n/time_formatting.h" |
| 9 #include "base/stringprintf.h" | 9 #include "base/stringprintf.h" |
| 10 #include "base/time.h" | 10 #include "base/time.h" |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 #include "policy/policy_constants.h" | 41 #include "policy/policy_constants.h" |
| 42 #include "views/widget/widget.h" | 42 #include "views/widget/widget.h" |
| 43 | 43 |
| 44 using chromeos::CrosLibrary; | 44 using chromeos::CrosLibrary; |
| 45 using chromeos::NetworkLibrary; | 45 using chromeos::NetworkLibrary; |
| 46 using chromeos::UpdateLibrary; | 46 using chromeos::UpdateLibrary; |
| 47 using chromeos::UserManager; | 47 using chromeos::UserManager; |
| 48 | 48 |
| 49 namespace { | 49 namespace { |
| 50 | 50 |
| 51 bool EnsureCrosLibraryLoaded(AutomationProvider* provider, | |
| 52 IPC::Message* reply_message) { | |
| 53 if (!CrosLibrary::Get()->EnsureLoaded()) { | |
| 54 AutomationJSONReply(provider, reply_message).SendError( | |
| 55 "Could not load cros library."); | |
| 56 return false; | |
| 57 } | |
| 58 return true; | |
| 59 } | |
| 60 | |
| 61 DictionaryValue* GetNetworkInfoDict(const chromeos::Network* network) { | 51 DictionaryValue* GetNetworkInfoDict(const chromeos::Network* network) { |
| 62 DictionaryValue* item = new DictionaryValue; | 52 DictionaryValue* item = new DictionaryValue; |
| 63 item->SetString("name", network->name()); | 53 item->SetString("name", network->name()); |
| 64 item->SetString("device_path", network->device_path()); | 54 item->SetString("device_path", network->device_path()); |
| 65 item->SetString("ip_address", network->ip_address()); | 55 item->SetString("ip_address", network->ip_address()); |
| 66 item->SetString("status", network->GetStateString()); | 56 item->SetString("status", network->GetStateString()); |
| 67 return item; | 57 return item; |
| 68 } | 58 } |
| 69 | 59 |
| 70 base::Value* GetProxySetting(Browser* browser, | 60 base::Value* GetProxySetting(Browser* browser, |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 276 new LoginObserver(controller, this, reply_message); | 266 new LoginObserver(controller, this, reply_message); |
| 277 | 267 |
| 278 // WebUI login. | 268 // WebUI login. |
| 279 chromeos::WebUILoginDisplay* webui_login_display = | 269 chromeos::WebUILoginDisplay* webui_login_display = |
| 280 static_cast<chromeos::WebUILoginDisplay*>(controller->login_display()); | 270 static_cast<chromeos::WebUILoginDisplay*>(controller->login_display()); |
| 281 webui_login_display->ShowSigninScreenForCreds(username, password); | 271 webui_login_display->ShowSigninScreenForCreds(username, password); |
| 282 } | 272 } |
| 283 | 273 |
| 284 void TestingAutomationProvider::LockScreen(DictionaryValue* args, | 274 void TestingAutomationProvider::LockScreen(DictionaryValue* args, |
| 285 IPC::Message* reply_message) { | 275 IPC::Message* reply_message) { |
| 286 if (!EnsureCrosLibraryLoaded(this, reply_message)) | |
| 287 return; | |
| 288 | |
| 289 new ScreenLockUnlockObserver(this, reply_message, true); | 276 new ScreenLockUnlockObserver(this, reply_message, true); |
| 290 CrosLibrary::Get()->GetScreenLockLibrary()-> | 277 CrosLibrary::Get()->GetScreenLockLibrary()-> |
| 291 NotifyScreenLockRequested(); | 278 NotifyScreenLockRequested(); |
| 292 } | 279 } |
| 293 | 280 |
| 294 void TestingAutomationProvider::UnlockScreen(DictionaryValue* args, | 281 void TestingAutomationProvider::UnlockScreen(DictionaryValue* args, |
| 295 IPC::Message* reply_message) { | 282 IPC::Message* reply_message) { |
| 296 std::string password; | 283 std::string password; |
| 297 if (!args->GetString("password", &password)) { | 284 if (!args->GetString("password", &password)) { |
| 298 AutomationJSONReply(this, reply_message).SendError( | 285 AutomationJSONReply(this, reply_message).SendError( |
| (...skipping 28 matching lines...) Expand all Loading... |
| 327 } | 314 } |
| 328 | 315 |
| 329 // Send success before stopping session because if we're a child of | 316 // Send success before stopping session because if we're a child of |
| 330 // session manager then we'll die when the session is stopped. | 317 // session manager then we'll die when the session is stopped. |
| 331 reply.SendSuccess(NULL); | 318 reply.SendSuccess(NULL); |
| 332 screen_locker->Signout(); | 319 screen_locker->Signout(); |
| 333 } | 320 } |
| 334 | 321 |
| 335 void TestingAutomationProvider::GetBatteryInfo(DictionaryValue* args, | 322 void TestingAutomationProvider::GetBatteryInfo(DictionaryValue* args, |
| 336 IPC::Message* reply_message) { | 323 IPC::Message* reply_message) { |
| 337 if (!EnsureCrosLibraryLoaded(this, reply_message)) | |
| 338 return; | |
| 339 | |
| 340 scoped_ptr<DictionaryValue> return_value(new DictionaryValue); | 324 scoped_ptr<DictionaryValue> return_value(new DictionaryValue); |
| 341 | 325 |
| 342 return_value->SetBoolean("battery_is_present", | 326 return_value->SetBoolean("battery_is_present", |
| 343 power_status.battery_is_present); | 327 power_status.battery_is_present); |
| 344 return_value->SetBoolean("line_power_on", power_status.line_power_on); | 328 return_value->SetBoolean("line_power_on", power_status.line_power_on); |
| 345 if (power_status.battery_is_present) { | 329 if (power_status.battery_is_present) { |
| 346 return_value->SetBoolean("battery_fully_charged", | 330 return_value->SetBoolean("battery_fully_charged", |
| 347 power_status.battery_is_full); | 331 power_status.battery_is_full); |
| 348 return_value->SetDouble("battery_percentage", | 332 return_value->SetDouble("battery_percentage", |
| 349 power_status.battery_percentage); | 333 power_status.battery_percentage); |
| 350 if (power_status.line_power_on) { | 334 if (power_status.line_power_on) { |
| 351 int64 time = power_status.battery_seconds_to_full; | 335 int64 time = power_status.battery_seconds_to_full; |
| 352 if (time > 0 || power_status.battery_is_full) | 336 if (time > 0 || power_status.battery_is_full) |
| 353 return_value->SetInteger("battery_seconds_to_full", time); | 337 return_value->SetInteger("battery_seconds_to_full", time); |
| 354 } else { | 338 } else { |
| 355 int64 time = power_status.battery_seconds_to_empty; | 339 int64 time = power_status.battery_seconds_to_empty; |
| 356 if (time > 0) | 340 if (time > 0) |
| 357 return_value->SetInteger("battery_seconds_to_empty", time); | 341 return_value->SetInteger("battery_seconds_to_empty", time); |
| 358 } | 342 } |
| 359 } | 343 } |
| 360 | 344 |
| 361 AutomationJSONReply(this, reply_message).SendSuccess(return_value.get()); | 345 AutomationJSONReply(this, reply_message).SendSuccess(return_value.get()); |
| 362 } | 346 } |
| 363 | 347 |
| 364 void TestingAutomationProvider::GetNetworkInfo(DictionaryValue* args, | 348 void TestingAutomationProvider::GetNetworkInfo(DictionaryValue* args, |
| 365 IPC::Message* reply_message) { | 349 IPC::Message* reply_message) { |
| 366 if (!EnsureCrosLibraryLoaded(this, reply_message)) | |
| 367 return; | |
| 368 | |
| 369 scoped_ptr<DictionaryValue> return_value(new DictionaryValue); | 350 scoped_ptr<DictionaryValue> return_value(new DictionaryValue); |
| 370 NetworkLibrary* network_library = CrosLibrary::Get()->GetNetworkLibrary(); | 351 NetworkLibrary* network_library = CrosLibrary::Get()->GetNetworkLibrary(); |
| 371 | 352 |
| 372 return_value->SetBoolean("offline_mode", | 353 return_value->SetBoolean("offline_mode", |
| 373 net::NetworkChangeNotifier::IsOffline()); | 354 net::NetworkChangeNotifier::IsOffline()); |
| 374 | 355 |
| 375 // IP address. | 356 // IP address. |
| 376 return_value->SetString("ip_address", network_library->IPAddress()); | 357 return_value->SetString("ip_address", network_library->IPAddress()); |
| 377 | 358 |
| 378 // Currently connected networks. | 359 // Currently connected networks. |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 462 const chromeos::WifiNetwork* wifi = *iter; | 443 const chromeos::WifiNetwork* wifi = *iter; |
| 463 items->Append(base::Value::CreateStringValue(wifi->service_path())); | 444 items->Append(base::Value::CreateStringValue(wifi->service_path())); |
| 464 } | 445 } |
| 465 return_value->Set("remembered_wifi", items); | 446 return_value->Set("remembered_wifi", items); |
| 466 | 447 |
| 467 AutomationJSONReply(this, reply_message).SendSuccess(return_value.get()); | 448 AutomationJSONReply(this, reply_message).SendSuccess(return_value.get()); |
| 468 } | 449 } |
| 469 | 450 |
| 470 void TestingAutomationProvider::NetworkScan(DictionaryValue* args, | 451 void TestingAutomationProvider::NetworkScan(DictionaryValue* args, |
| 471 IPC::Message* reply_message) { | 452 IPC::Message* reply_message) { |
| 472 if (!EnsureCrosLibraryLoaded(this, reply_message)) | |
| 473 return; | |
| 474 | |
| 475 NetworkLibrary* network_library = CrosLibrary::Get()->GetNetworkLibrary(); | 453 NetworkLibrary* network_library = CrosLibrary::Get()->GetNetworkLibrary(); |
| 476 network_library->RequestNetworkScan(); | 454 network_library->RequestNetworkScan(); |
| 477 | 455 |
| 478 // Set up an observer (it will delete itself). | 456 // Set up an observer (it will delete itself). |
| 479 new NetworkScanObserver(this, reply_message); | 457 new NetworkScanObserver(this, reply_message); |
| 480 } | 458 } |
| 481 | 459 |
| 482 void TestingAutomationProvider::ToggleNetworkDevice( | 460 void TestingAutomationProvider::ToggleNetworkDevice( |
| 483 DictionaryValue* args, IPC::Message* reply_message) { | 461 DictionaryValue* args, IPC::Message* reply_message) { |
| 484 if (!EnsureCrosLibraryLoaded(this, reply_message)) | |
| 485 return; | |
| 486 | |
| 487 AutomationJSONReply reply(this, reply_message); | 462 AutomationJSONReply reply(this, reply_message); |
| 488 std::string device; | 463 std::string device; |
| 489 bool enable; | 464 bool enable; |
| 490 if (!args->GetString("device", &device) || | 465 if (!args->GetString("device", &device) || |
| 491 !args->GetBoolean("enable", &enable)) { | 466 !args->GetBoolean("enable", &enable)) { |
| 492 reply.SendError("Invalid or missing args."); | 467 reply.SendError("Invalid or missing args."); |
| 493 return; | 468 return; |
| 494 } | 469 } |
| 495 | 470 |
| 496 // Set up an observer (it will delete itself). | 471 // Set up an observer (it will delete itself). |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 544 setting_path.append(key); | 519 setting_path.append(key); |
| 545 | 520 |
| 546 // ProxyCrosSettingsProvider will own the Value* passed to Set(). | 521 // ProxyCrosSettingsProvider will own the Value* passed to Set(). |
| 547 chromeos::proxy_cros_settings_parser::SetProxyPrefValue( | 522 chromeos::proxy_cros_settings_parser::SetProxyPrefValue( |
| 548 browser->profile(), setting_path, value); | 523 browser->profile(), setting_path, value); |
| 549 reply.SendSuccess(NULL); | 524 reply.SendSuccess(NULL); |
| 550 } | 525 } |
| 551 | 526 |
| 552 void TestingAutomationProvider::ConnectToCellularNetwork( | 527 void TestingAutomationProvider::ConnectToCellularNetwork( |
| 553 DictionaryValue* args, IPC::Message* reply_message) { | 528 DictionaryValue* args, IPC::Message* reply_message) { |
| 554 if (!EnsureCrosLibraryLoaded(this, reply_message)) | |
| 555 return; | |
| 556 | |
| 557 std::string service_path; | 529 std::string service_path; |
| 558 if (!args->GetString("service_path", &service_path)) { | 530 if (!args->GetString("service_path", &service_path)) { |
| 559 AutomationJSONReply(this, reply_message).SendError( | 531 AutomationJSONReply(this, reply_message).SendError( |
| 560 "Invalid or missing args."); | 532 "Invalid or missing args."); |
| 561 return; | 533 return; |
| 562 } | 534 } |
| 563 | 535 |
| 564 NetworkLibrary* network_library = CrosLibrary::Get()->GetNetworkLibrary(); | 536 NetworkLibrary* network_library = CrosLibrary::Get()->GetNetworkLibrary(); |
| 565 chromeos::CellularNetwork* cellular = | 537 chromeos::CellularNetwork* cellular = |
| 566 network_library->FindCellularNetworkByPath(service_path); | 538 network_library->FindCellularNetworkByPath(service_path); |
| 567 if (!cellular) { | 539 if (!cellular) { |
| 568 AutomationJSONReply(this, reply_message).SendError( | 540 AutomationJSONReply(this, reply_message).SendError( |
| 569 "No network found with specified service path."); | 541 "No network found with specified service path."); |
| 570 return; | 542 return; |
| 571 } | 543 } |
| 572 | 544 |
| 573 // Set up an observer (it will delete itself). | 545 // Set up an observer (it will delete itself). |
| 574 new ServicePathConnectObserver(this, reply_message, service_path); | 546 new ServicePathConnectObserver(this, reply_message, service_path); |
| 575 | 547 |
| 576 network_library->ConnectToCellularNetwork(cellular); | 548 network_library->ConnectToCellularNetwork(cellular); |
| 577 network_library->RequestNetworkScan(); | 549 network_library->RequestNetworkScan(); |
| 578 } | 550 } |
| 579 | 551 |
| 580 void TestingAutomationProvider::DisconnectFromCellularNetwork( | 552 void TestingAutomationProvider::DisconnectFromCellularNetwork( |
| 581 DictionaryValue* args, IPC::Message* reply_message) { | 553 DictionaryValue* args, IPC::Message* reply_message) { |
| 582 if (!EnsureCrosLibraryLoaded(this, reply_message)) | |
| 583 return; | |
| 584 | |
| 585 NetworkLibrary* network_library = CrosLibrary::Get()->GetNetworkLibrary(); | 554 NetworkLibrary* network_library = CrosLibrary::Get()->GetNetworkLibrary(); |
| 586 const chromeos::CellularNetwork* cellular = | 555 const chromeos::CellularNetwork* cellular = |
| 587 network_library->cellular_network(); | 556 network_library->cellular_network(); |
| 588 if (!cellular) { | 557 if (!cellular) { |
| 589 AutomationJSONReply(this, reply_message).SendError( | 558 AutomationJSONReply(this, reply_message).SendError( |
| 590 "Not connected to any cellular network."); | 559 "Not connected to any cellular network."); |
| 591 return; | 560 return; |
| 592 } | 561 } |
| 593 | 562 |
| 594 // Set up an observer (it will delete itself). | 563 // Set up an observer (it will delete itself). |
| 595 new NetworkDisconnectObserver(this, reply_message, cellular->service_path()); | 564 new NetworkDisconnectObserver(this, reply_message, cellular->service_path()); |
| 596 | 565 |
| 597 network_library->DisconnectFromNetwork(cellular); | 566 network_library->DisconnectFromNetwork(cellular); |
| 598 } | 567 } |
| 599 | 568 |
| 600 void TestingAutomationProvider::ConnectToWifiNetwork( | 569 void TestingAutomationProvider::ConnectToWifiNetwork( |
| 601 DictionaryValue* args, IPC::Message* reply_message) { | 570 DictionaryValue* args, IPC::Message* reply_message) { |
| 602 if (!EnsureCrosLibraryLoaded(this, reply_message)) | |
| 603 return; | |
| 604 | |
| 605 AutomationJSONReply reply(this, reply_message); | 571 AutomationJSONReply reply(this, reply_message); |
| 606 std::string service_path, password; | 572 std::string service_path, password; |
| 607 bool shared; | 573 bool shared; |
| 608 if (!args->GetString("service_path", &service_path) || | 574 if (!args->GetString("service_path", &service_path) || |
| 609 !args->GetString("password", &password) || | 575 !args->GetString("password", &password) || |
| 610 !args->GetBoolean("shared", &shared)) { | 576 !args->GetBoolean("shared", &shared)) { |
| 611 reply.SendError("Invalid or missing args."); | 577 reply.SendError("Invalid or missing args."); |
| 612 return; | 578 return; |
| 613 } | 579 } |
| 614 | 580 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 629 | 595 |
| 630 // Set up an observer (it will delete itself). | 596 // Set up an observer (it will delete itself). |
| 631 new ServicePathConnectObserver(this, reply_message, service_path); | 597 new ServicePathConnectObserver(this, reply_message, service_path); |
| 632 | 598 |
| 633 network_library->ConnectToWifiNetwork(wifi, shared); | 599 network_library->ConnectToWifiNetwork(wifi, shared); |
| 634 network_library->RequestNetworkScan(); | 600 network_library->RequestNetworkScan(); |
| 635 } | 601 } |
| 636 | 602 |
| 637 void TestingAutomationProvider::ForgetWifiNetwork( | 603 void TestingAutomationProvider::ForgetWifiNetwork( |
| 638 DictionaryValue* args, IPC::Message* reply_message) { | 604 DictionaryValue* args, IPC::Message* reply_message) { |
| 639 if (!EnsureCrosLibraryLoaded(this, reply_message)) | |
| 640 return; | |
| 641 std::string service_path; | 605 std::string service_path; |
| 642 if (!args->GetString("service_path", &service_path)) { | 606 if (!args->GetString("service_path", &service_path)) { |
| 643 AutomationJSONReply(this, reply_message).SendError( | 607 AutomationJSONReply(this, reply_message).SendError( |
| 644 "Invalid or missing args."); | 608 "Invalid or missing args."); |
| 645 return; | 609 return; |
| 646 } | 610 } |
| 647 | 611 |
| 648 CrosLibrary::Get()->GetNetworkLibrary()->ForgetNetwork(service_path); | 612 CrosLibrary::Get()->GetNetworkLibrary()->ForgetNetwork(service_path); |
| 649 AutomationJSONReply(this, reply_message).SendSuccess(NULL); | 613 AutomationJSONReply(this, reply_message).SendSuccess(NULL); |
| 650 } | 614 } |
| 651 | 615 |
| 652 void TestingAutomationProvider::ConnectToHiddenWifiNetwork( | 616 void TestingAutomationProvider::ConnectToHiddenWifiNetwork( |
| 653 DictionaryValue* args, IPC::Message* reply_message) { | 617 DictionaryValue* args, IPC::Message* reply_message) { |
| 654 if (!EnsureCrosLibraryLoaded(this, reply_message)) | |
| 655 return; | |
| 656 | |
| 657 std::string ssid, security, password; | 618 std::string ssid, security, password; |
| 658 bool shared; | 619 bool shared; |
| 659 if (!args->GetString("ssid", &ssid) || | 620 if (!args->GetString("ssid", &ssid) || |
| 660 !args->GetString("security", &security) || | 621 !args->GetString("security", &security) || |
| 661 !args->GetString("password", &password) || | 622 !args->GetString("password", &password) || |
| 662 !args->GetBoolean("shared", &shared)) { | 623 !args->GetBoolean("shared", &shared)) { |
| 663 AutomationJSONReply(this, reply_message).SendError( | 624 AutomationJSONReply(this, reply_message).SendError( |
| 664 "Invalid or missing args."); | 625 "Invalid or missing args."); |
| 665 return; | 626 return; |
| 666 } | 627 } |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 740 save_credentials, shared); | 701 save_credentials, shared); |
| 741 } else { | 702 } else { |
| 742 network_library->ConnectToUnconfiguredWifiNetwork( | 703 network_library->ConnectToUnconfiguredWifiNetwork( |
| 743 ssid, connection_security, password, NULL, | 704 ssid, connection_security, password, NULL, |
| 744 save_credentials, shared); | 705 save_credentials, shared); |
| 745 } | 706 } |
| 746 } | 707 } |
| 747 | 708 |
| 748 void TestingAutomationProvider::DisconnectFromWifiNetwork( | 709 void TestingAutomationProvider::DisconnectFromWifiNetwork( |
| 749 DictionaryValue* args, IPC::Message* reply_message) { | 710 DictionaryValue* args, IPC::Message* reply_message) { |
| 750 if (!EnsureCrosLibraryLoaded(this, reply_message)) | |
| 751 return; | |
| 752 | |
| 753 AutomationJSONReply reply(this, reply_message); | 711 AutomationJSONReply reply(this, reply_message); |
| 754 NetworkLibrary* network_library = CrosLibrary::Get()->GetNetworkLibrary(); | 712 NetworkLibrary* network_library = CrosLibrary::Get()->GetNetworkLibrary(); |
| 755 const chromeos::WifiNetwork* wifi = network_library->wifi_network(); | 713 const chromeos::WifiNetwork* wifi = network_library->wifi_network(); |
| 756 if (!wifi) { | 714 if (!wifi) { |
| 757 reply.SendError("Not connected to any wifi network."); | 715 reply.SendError("Not connected to any wifi network."); |
| 758 return; | 716 return; |
| 759 } | 717 } |
| 760 | 718 |
| 761 network_library->DisconnectFromNetwork(wifi); | 719 network_library->DisconnectFromNetwork(wifi); |
| 762 reply.SendSuccess(NULL); | 720 reply.SendSuccess(NULL); |
| 763 } | 721 } |
| 764 | 722 |
| 765 void TestingAutomationProvider::AddPrivateNetwork( | 723 void TestingAutomationProvider::AddPrivateNetwork( |
| 766 DictionaryValue* args, IPC::Message* reply_message) { | 724 DictionaryValue* args, IPC::Message* reply_message) { |
| 767 if (!EnsureCrosLibraryLoaded(this, reply_message)) | |
| 768 return; | |
| 769 | |
| 770 std::string hostname, service_name, provider_type, key, cert_id, cert_nss, | 725 std::string hostname, service_name, provider_type, key, cert_id, cert_nss, |
| 771 username, password; | 726 username, password; |
| 772 if (!args->GetString("hostname", &hostname) || | 727 if (!args->GetString("hostname", &hostname) || |
| 773 !args->GetString("service_name", &service_name) || | 728 !args->GetString("service_name", &service_name) || |
| 774 !args->GetString("provider_type", &provider_type) || | 729 !args->GetString("provider_type", &provider_type) || |
| 775 !args->GetString("username", &username) || | 730 !args->GetString("username", &username) || |
| 776 !args->GetString("password", &password)) { | 731 !args->GetString("password", &password)) { |
| 777 AutomationJSONReply(this, reply_message) | 732 AutomationJSONReply(this, reply_message) |
| 778 .SendError("Invalid or missing args."); | 733 .SendError("Invalid or missing args."); |
| 779 return; | 734 return; |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 838 config_data); | 793 config_data); |
| 839 } else { | 794 } else { |
| 840 AutomationJSONReply(this, reply_message) | 795 AutomationJSONReply(this, reply_message) |
| 841 .SendError("Unsupported provider type."); | 796 .SendError("Unsupported provider type."); |
| 842 return; | 797 return; |
| 843 } | 798 } |
| 844 } | 799 } |
| 845 | 800 |
| 846 void TestingAutomationProvider::ConnectToPrivateNetwork( | 801 void TestingAutomationProvider::ConnectToPrivateNetwork( |
| 847 DictionaryValue* args, IPC::Message* reply_message) { | 802 DictionaryValue* args, IPC::Message* reply_message) { |
| 848 if (!EnsureCrosLibraryLoaded(this, reply_message)) | |
| 849 return; | |
| 850 | |
| 851 AutomationJSONReply reply(this, reply_message); | 803 AutomationJSONReply reply(this, reply_message); |
| 852 std::string service_path; | 804 std::string service_path; |
| 853 if (!args->GetString("service_path", &service_path)) { | 805 if (!args->GetString("service_path", &service_path)) { |
| 854 reply.SendError("Invalid or missing args."); | 806 reply.SendError("Invalid or missing args."); |
| 855 return; | 807 return; |
| 856 } | 808 } |
| 857 | 809 |
| 858 // Connect to a remembered VPN by its service_path. Valid service_paths | 810 // Connect to a remembered VPN by its service_path. Valid service_paths |
| 859 // can be found in the dictionary returned by GetPrivateNetworkInfo. | 811 // can be found in the dictionary returned by GetPrivateNetworkInfo. |
| 860 NetworkLibrary* network_library = CrosLibrary::Get()->GetNetworkLibrary(); | 812 NetworkLibrary* network_library = CrosLibrary::Get()->GetNetworkLibrary(); |
| 861 chromeos::VirtualNetwork* network = | 813 chromeos::VirtualNetwork* network = |
| 862 network_library->FindVirtualNetworkByPath(service_path); | 814 network_library->FindVirtualNetworkByPath(service_path); |
| 863 if (!network) { | 815 if (!network) { |
| 864 reply.SendError(StringPrintf("No virtual network found: %s", | 816 reply.SendError(StringPrintf("No virtual network found: %s", |
| 865 service_path.c_str())); | 817 service_path.c_str())); |
| 866 return; | 818 return; |
| 867 } | 819 } |
| 868 if (network->NeedMoreInfoToConnect()) { | 820 if (network->NeedMoreInfoToConnect()) { |
| 869 reply.SendError("Virtual network is missing info required to connect."); | 821 reply.SendError("Virtual network is missing info required to connect."); |
| 870 return; | 822 return; |
| 871 }; | 823 }; |
| 872 | 824 |
| 873 // Set up an observer (it will delete itself). | 825 // Set up an observer (it will delete itself). |
| 874 new VirtualConnectObserver(this, reply_message, network->name()); | 826 new VirtualConnectObserver(this, reply_message, network->name()); |
| 875 network_library->ConnectToVirtualNetwork(network); | 827 network_library->ConnectToVirtualNetwork(network); |
| 876 } | 828 } |
| 877 | 829 |
| 878 void TestingAutomationProvider::GetPrivateNetworkInfo( | 830 void TestingAutomationProvider::GetPrivateNetworkInfo( |
| 879 DictionaryValue* args, IPC::Message* reply_message) { | 831 DictionaryValue* args, IPC::Message* reply_message) { |
| 880 if (!EnsureCrosLibraryLoaded(this, reply_message)) | |
| 881 return; | |
| 882 | |
| 883 scoped_ptr<DictionaryValue> return_value(new DictionaryValue); | 832 scoped_ptr<DictionaryValue> return_value(new DictionaryValue); |
| 884 NetworkLibrary* network_library = CrosLibrary::Get()->GetNetworkLibrary(); | 833 NetworkLibrary* network_library = CrosLibrary::Get()->GetNetworkLibrary(); |
| 885 const chromeos::VirtualNetworkVector& virtual_networks = | 834 const chromeos::VirtualNetworkVector& virtual_networks = |
| 886 network_library->virtual_networks(); | 835 network_library->virtual_networks(); |
| 887 | 836 |
| 888 // Construct a dictionary of fields describing remembered VPNs. Also list | 837 // Construct a dictionary of fields describing remembered VPNs. Also list |
| 889 // the currently active VPN, if any. | 838 // the currently active VPN, if any. |
| 890 if (network_library->virtual_network()) | 839 if (network_library->virtual_network()) |
| 891 return_value->SetString("connected", | 840 return_value->SetString("connected", |
| 892 network_library->virtual_network()->service_path()); | 841 network_library->virtual_network()->service_path()); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 904 item->SetString("username", virt->username()); | 853 item->SetString("username", virt->username()); |
| 905 item->SetString("password", virt->user_passphrase()); | 854 item->SetString("password", virt->user_passphrase()); |
| 906 return_value->Set(virt->service_path(), item); | 855 return_value->Set(virt->service_path(), item); |
| 907 } | 856 } |
| 908 | 857 |
| 909 AutomationJSONReply(this, reply_message).SendSuccess(return_value.get()); | 858 AutomationJSONReply(this, reply_message).SendSuccess(return_value.get()); |
| 910 } | 859 } |
| 911 | 860 |
| 912 void TestingAutomationProvider::DisconnectFromPrivateNetwork( | 861 void TestingAutomationProvider::DisconnectFromPrivateNetwork( |
| 913 DictionaryValue* args, IPC::Message* reply_message) { | 862 DictionaryValue* args, IPC::Message* reply_message) { |
| 914 if (!EnsureCrosLibraryLoaded(this, reply_message)) | |
| 915 return; | |
| 916 | |
| 917 AutomationJSONReply reply(this, reply_message); | 863 AutomationJSONReply reply(this, reply_message); |
| 918 NetworkLibrary* network_library = CrosLibrary::Get()->GetNetworkLibrary(); | 864 NetworkLibrary* network_library = CrosLibrary::Get()->GetNetworkLibrary(); |
| 919 const chromeos::VirtualNetwork* virt = network_library->virtual_network(); | 865 const chromeos::VirtualNetwork* virt = network_library->virtual_network(); |
| 920 if (!virt) { | 866 if (!virt) { |
| 921 reply.SendError("Not connected to any virtual network."); | 867 reply.SendError("Not connected to any virtual network."); |
| 922 return; | 868 return; |
| 923 } | 869 } |
| 924 | 870 |
| 925 network_library->DisconnectFromNetwork(virt); | 871 network_library->DisconnectFromNetwork(virt); |
| 926 reply.SendSuccess(NULL); | 872 reply.SendSuccess(NULL); |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1099 | 1045 |
| 1100 icu::TimeZone* timezone = | 1046 icu::TimeZone* timezone = |
| 1101 icu::TimeZone::createTimeZone(icu::UnicodeString::fromUTF8(timezone_id)); | 1047 icu::TimeZone::createTimeZone(icu::UnicodeString::fromUTF8(timezone_id)); |
| 1102 chromeos::system::TimezoneSettings::GetInstance()->SetTimezone(*timezone); | 1048 chromeos::system::TimezoneSettings::GetInstance()->SetTimezone(*timezone); |
| 1103 delete timezone; | 1049 delete timezone; |
| 1104 AutomationJSONReply(this, reply_message).SendSuccess(NULL); | 1050 AutomationJSONReply(this, reply_message).SendSuccess(NULL); |
| 1105 } | 1051 } |
| 1106 | 1052 |
| 1107 void TestingAutomationProvider::GetUpdateInfo(DictionaryValue* args, | 1053 void TestingAutomationProvider::GetUpdateInfo(DictionaryValue* args, |
| 1108 IPC::Message* reply_message) { | 1054 IPC::Message* reply_message) { |
| 1109 if (!EnsureCrosLibraryLoaded(this, reply_message)) | |
| 1110 return; | |
| 1111 | |
| 1112 UpdateLibrary* update_library = CrosLibrary::Get()->GetUpdateLibrary(); | 1055 UpdateLibrary* update_library = CrosLibrary::Get()->GetUpdateLibrary(); |
| 1113 AutomationJSONReply* reply = new AutomationJSONReply(this, reply_message); | 1056 AutomationJSONReply* reply = new AutomationJSONReply(this, reply_message); |
| 1114 update_library->GetReleaseTrack(GetReleaseTrackCallback, reply); | 1057 update_library->GetReleaseTrack(GetReleaseTrackCallback, reply); |
| 1115 } | 1058 } |
| 1116 | 1059 |
| 1117 void TestingAutomationProvider::UpdateCheck( | 1060 void TestingAutomationProvider::UpdateCheck( |
| 1118 DictionaryValue* args, | 1061 DictionaryValue* args, |
| 1119 IPC::Message* reply_message) { | 1062 IPC::Message* reply_message) { |
| 1120 if (!EnsureCrosLibraryLoaded(this, reply_message)) | |
| 1121 return; | |
| 1122 | |
| 1123 UpdateLibrary* update_library = CrosLibrary::Get()->GetUpdateLibrary(); | 1063 UpdateLibrary* update_library = CrosLibrary::Get()->GetUpdateLibrary(); |
| 1124 AutomationJSONReply* reply = new AutomationJSONReply(this, reply_message); | 1064 AutomationJSONReply* reply = new AutomationJSONReply(this, reply_message); |
| 1125 update_library->RequestUpdateCheck(UpdateCheckCallback, reply); | 1065 update_library->RequestUpdateCheck(UpdateCheckCallback, reply); |
| 1126 } | 1066 } |
| 1127 | 1067 |
| 1128 void TestingAutomationProvider::SetReleaseTrack(DictionaryValue* args, | 1068 void TestingAutomationProvider::SetReleaseTrack(DictionaryValue* args, |
| 1129 IPC::Message* reply_message) { | 1069 IPC::Message* reply_message) { |
| 1130 if (!EnsureCrosLibraryLoaded(this, reply_message)) | |
| 1131 return; | |
| 1132 | |
| 1133 AutomationJSONReply reply(this, reply_message); | 1070 AutomationJSONReply reply(this, reply_message); |
| 1134 std::string track; | 1071 std::string track; |
| 1135 if (!args->GetString("track", &track)) { | 1072 if (!args->GetString("track", &track)) { |
| 1136 reply.SendError("Invalid or missing args."); | 1073 reply.SendError("Invalid or missing args."); |
| 1137 return; | 1074 return; |
| 1138 } | 1075 } |
| 1139 | 1076 |
| 1140 UpdateLibrary* update_library = CrosLibrary::Get()->GetUpdateLibrary(); | 1077 UpdateLibrary* update_library = CrosLibrary::Get()->GetUpdateLibrary(); |
| 1141 update_library->SetReleaseTrack(track); | 1078 update_library->SetReleaseTrack(track); |
| 1142 reply.SendSuccess(NULL); | 1079 reply.SendSuccess(NULL); |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1204 views::Widget* window = browser::CreateViewsWindow( | 1141 views::Widget* window = browser::CreateViewsWindow( |
| 1205 browser->window()->GetNativeHandle(), take_photo_dialog); | 1142 browser->window()->GetNativeHandle(), take_photo_dialog); |
| 1206 window->SetAlwaysOnTop(true); | 1143 window->SetAlwaysOnTop(true); |
| 1207 window->Show(); | 1144 window->Show(); |
| 1208 } | 1145 } |
| 1209 | 1146 |
| 1210 void TestingAutomationProvider::PowerChanged( | 1147 void TestingAutomationProvider::PowerChanged( |
| 1211 const chromeos::PowerSupplyStatus& status) { | 1148 const chromeos::PowerSupplyStatus& status) { |
| 1212 power_status = status; | 1149 power_status = status; |
| 1213 } | 1150 } |
| OLD | NEW |