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

Side by Side Diff: chrome/browser/chromeos/dom_ui/internet_options_handler.cc

Issue 6516019: Made activate/buy button show consistently on network list and details pages.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 10 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/chromeos/dom_ui/internet_options_handler.h" 5 #include "chrome/browser/chromeos/dom_ui/internet_options_handler.h"
6 6
7 #include <ctype.h> 7 #include <ctype.h>
8 8
9 #include <map> 9 #include <map>
10 #include <string> 10 #include <string>
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after
425 for (chromeos::CellularDataPlanVector::const_iterator iter = plans.begin(); 425 for (chromeos::CellularDataPlanVector::const_iterator iter = plans.begin();
426 iter != plans.end(); 426 iter != plans.end();
427 ++iter) { 427 ++iter) {
428 plan_list->Append(CellularDataPlanToDictionary(*iter)); 428 plan_list->Append(CellularDataPlanToDictionary(*iter));
429 } 429 }
430 connection_plans.SetString("servicePath", cellular->service_path()); 430 connection_plans.SetString("servicePath", cellular->service_path());
431 connection_plans.SetBoolean("needsPlan", cellular->needs_new_plan()); 431 connection_plans.SetBoolean("needsPlan", cellular->needs_new_plan());
432 connection_plans.SetBoolean("activated", 432 connection_plans.SetBoolean("activated",
433 cellular->activation_state() == chromeos::ACTIVATION_STATE_ACTIVATED); 433 cellular->activation_state() == chromeos::ACTIVATION_STATE_ACTIVATED);
434 connection_plans.Set("plans", plan_list); 434 connection_plans.Set("plans", plan_list);
435 SetActivationButtonVisibility(cellular, &connection_plans);
435 dom_ui_->CallJavascriptFunction( 436 dom_ui_->CallJavascriptFunction(
436 L"options.InternetOptions.updateCellularPlans", connection_plans); 437 L"options.InternetOptions.updateCellularPlans", connection_plans);
437 } 438 }
438 439
439 DictionaryValue* InternetOptionsHandler::CellularDataPlanToDictionary( 440 DictionaryValue* InternetOptionsHandler::CellularDataPlanToDictionary(
440 const chromeos::CellularDataPlan* plan) { 441 const chromeos::CellularDataPlan* plan) {
441 DictionaryValue* plan_dict = new DictionaryValue(); 442 DictionaryValue* plan_dict = new DictionaryValue();
442 plan_dict->SetInteger("planType", plan->plan_type); 443 plan_dict->SetInteger("planType", plan->plan_type);
443 plan_dict->SetString("name", plan->plan_name); 444 plan_dict->SetString("name", plan->plan_name);
444 plan_dict->SetString("planSummary", plan->GetPlanDesciption()); 445 plan_dict->SetString("planSummary", plan->GetPlanDesciption());
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
549 dictionary.SetBoolean("connecting", net->connecting()); 550 dictionary.SetBoolean("connecting", net->connecting());
550 dictionary.SetBoolean("connected", net->connected()); 551 dictionary.SetBoolean("connected", net->connected());
551 dictionary.SetString("connectionState", net->GetStateString()); 552 dictionary.SetString("connectionState", net->GetStateString());
552 553
553 if (type == chromeos::TYPE_WIFI) { 554 if (type == chromeos::TYPE_WIFI) {
554 chromeos::WifiNetwork* wifi = 555 chromeos::WifiNetwork* wifi =
555 cros->FindWifiNetworkByPath(net->service_path()); 556 cros->FindWifiNetworkByPath(net->service_path());
556 if (!wifi) { 557 if (!wifi) {
557 LOG(WARNING) << "Cannot find network " << net->service_path(); 558 LOG(WARNING) << "Cannot find network " << net->service_path();
558 } else { 559 } else {
559 PopulateWifiDetails(&dictionary, wifi); 560 PopulateWifiDetails(wifi, &dictionary);
560 } 561 }
561 } else if (type == chromeos::TYPE_CELLULAR) { 562 } else if (type == chromeos::TYPE_CELLULAR) {
562 chromeos::CellularNetwork* cellular = 563 chromeos::CellularNetwork* cellular =
563 cros->FindCellularNetworkByPath(net->service_path()); 564 cros->FindCellularNetworkByPath(net->service_path());
564 if (!cellular) { 565 if (!cellular) {
565 LOG(WARNING) << "Cannot find network " << net->service_path(); 566 LOG(WARNING) << "Cannot find network " << net->service_path();
566 } else { 567 } else {
567 PopulateCellularDetails(&dictionary, cellular); 568 PopulateCellularDetails(cellular, &dictionary);
568 } 569 }
569 } 570 }
570 571
571 dom_ui_->CallJavascriptFunction( 572 dom_ui_->CallJavascriptFunction(
572 L"options.InternetOptions.showDetailedInfo", dictionary); 573 L"options.InternetOptions.showDetailedInfo", dictionary);
573 } 574 }
574 575
575 void InternetOptionsHandler::PopulateWifiDetails( 576 void InternetOptionsHandler::PopulateWifiDetails(
576 DictionaryValue* dictionary, 577 const chromeos::WifiNetwork* wifi,
577 const chromeos::WifiNetwork* wifi) { 578 DictionaryValue* dictionary) {
578 dictionary->SetString("ssid", wifi->name()); 579 dictionary->SetString("ssid", wifi->name());
579 dictionary->SetBoolean("autoConnect", wifi->auto_connect()); 580 dictionary->SetBoolean("autoConnect", wifi->auto_connect());
580 if (wifi->encrypted()) { 581 if (wifi->encrypted()) {
581 dictionary->SetBoolean("encrypted", true); 582 dictionary->SetBoolean("encrypted", true);
582 if (wifi->encryption() == chromeos::SECURITY_8021X) { 583 if (wifi->encryption() == chromeos::SECURITY_8021X) {
583 bool certificate_in_pkcs11 = 584 bool certificate_in_pkcs11 =
584 IsCertificateInPkcs11(wifi->cert_path()); 585 IsCertificateInPkcs11(wifi->cert_path());
585 if (certificate_in_pkcs11) { 586 if (certificate_in_pkcs11) {
586 dictionary->SetBoolean("certInPkcs", true); 587 dictionary->SetBoolean("certInPkcs", true);
587 } else { 588 } else {
588 dictionary->SetBoolean("certInPkcs", false); 589 dictionary->SetBoolean("certInPkcs", false);
589 } 590 }
590 dictionary->SetString("certPath", wifi->cert_path()); 591 dictionary->SetString("certPath", wifi->cert_path());
591 dictionary->SetString("ident", wifi->identity()); 592 dictionary->SetString("ident", wifi->identity());
592 dictionary->SetBoolean("certNeeded", true); 593 dictionary->SetBoolean("certNeeded", true);
593 dictionary->SetString("certPass", wifi->passphrase()); 594 dictionary->SetString("certPass", wifi->passphrase());
594 } else { 595 } else {
595 dictionary->SetBoolean("certNeeded", false); 596 dictionary->SetBoolean("certNeeded", false);
596 } 597 }
597 } else { 598 } else {
598 dictionary->SetBoolean("encrypted", false); 599 dictionary->SetBoolean("encrypted", false);
599 } 600 }
600 } 601 }
601 602
602 void InternetOptionsHandler::PopulateCellularDetails( 603 void InternetOptionsHandler::PopulateCellularDetails(
603 DictionaryValue* dictionary, 604 const chromeos::CellularNetwork* cellular,
604 const chromeos::CellularNetwork* cellular) { 605 DictionaryValue* dictionary) {
605 // Cellular network / connection settings. 606 // Cellular network / connection settings.
606 dictionary->SetString("serviceName", cellular->service_name()); 607 dictionary->SetString("serviceName", cellular->service_name());
607 dictionary->SetString("networkTechnology", 608 dictionary->SetString("networkTechnology",
608 cellular->GetNetworkTechnologyString()); 609 cellular->GetNetworkTechnologyString());
609 dictionary->SetString("operatorName", cellular->operator_name()); 610 dictionary->SetString("operatorName", cellular->operator_name());
610 dictionary->SetString("operatorCode", cellular->operator_code()); 611 dictionary->SetString("operatorCode", cellular->operator_code());
611 dictionary->SetString("activationState", 612 dictionary->SetString("activationState",
612 cellular->GetActivationStateString()); 613 cellular->GetActivationStateString());
613 dictionary->SetString("roamingState", 614 dictionary->SetString("roamingState",
614 cellular->GetRoamingStateString()); 615 cellular->GetRoamingStateString());
615 dictionary->SetString("restrictedPool", 616 dictionary->SetString("restrictedPool",
616 cellular->restricted_pool() ? 617 cellular->restricted_pool() ?
617 l10n_util::GetStringUTF8( 618 l10n_util::GetStringUTF8(
618 IDS_CONFIRM_MESSAGEBOX_YES_BUTTON_LABEL) : 619 IDS_CONFIRM_MESSAGEBOX_YES_BUTTON_LABEL) :
619 l10n_util::GetStringUTF8( 620 l10n_util::GetStringUTF8(
620 IDS_CONFIRM_MESSAGEBOX_NO_BUTTON_LABEL)); 621 IDS_CONFIRM_MESSAGEBOX_NO_BUTTON_LABEL));
621 dictionary->SetString("errorState", cellular->GetErrorString()); 622 dictionary->SetString("errorState", cellular->GetErrorString());
622 dictionary->SetString("supportUrl", cellular->payment_url()); 623 dictionary->SetString("supportUrl", cellular->payment_url());
624 dictionary->SetBoolean("needsPlan", cellular->needs_new_plan());
623 625
624 // Device settings. 626 // Device settings.
625 dictionary->SetString("manufacturer", cellular->manufacturer()); 627 dictionary->SetString("manufacturer", cellular->manufacturer());
626 dictionary->SetString("modelId", cellular->model_id()); 628 dictionary->SetString("modelId", cellular->model_id());
627 dictionary->SetString("firmwareRevision", cellular->firmware_revision()); 629 dictionary->SetString("firmwareRevision", cellular->firmware_revision());
628 dictionary->SetString("hardwareRevision", cellular->hardware_revision()); 630 dictionary->SetString("hardwareRevision", cellular->hardware_revision());
629 dictionary->SetString("lastUpdate", cellular->last_update()); 631 dictionary->SetString("lastUpdate", cellular->last_update());
630 dictionary->SetString("prlVersion", StringPrintf("%u", 632 dictionary->SetString("prlVersion", StringPrintf("%u",
631 cellular->prl_version())); 633 cellular->prl_version()));
632 dictionary->SetString("meid", cellular->meid()); 634 dictionary->SetString("meid", cellular->meid());
633 dictionary->SetString("imei", cellular->imei()); 635 dictionary->SetString("imei", cellular->imei());
634 dictionary->SetString("mdn", cellular->mdn()); 636 dictionary->SetString("mdn", cellular->mdn());
635 dictionary->SetString("imsi", cellular->imsi()); 637 dictionary->SetString("imsi", cellular->imsi());
636 dictionary->SetString("esn", cellular->esn()); 638 dictionary->SetString("esn", cellular->esn());
637 dictionary->SetString("min", cellular->min()); 639 dictionary->SetString("min", cellular->min());
638 640
639 dictionary->SetBoolean("gsm", cellular->is_gsm()); 641 dictionary->SetBoolean("gsm", cellular->is_gsm());
642
643 SetActivationButtonVisibility(cellular, dictionary);
640 } 644 }
641 645
646 void InternetOptionsHandler::SetActivationButtonVisibility(
647 const chromeos::CellularNetwork* cellular,
648 DictionaryValue* dictionary) {
649 bool show_activate =
650 cellular->activation_state() != chromeos::ACTIVATION_STATE_ACTIVATING &&
651 cellular->activation_state() != chromeos::ACTIVATION_STATE_ACTIVATED;
652 if (show_activate || cellular->needs_new_plan()) {
Charlie Lee 2011/02/14 20:50:32 I think this logic should be changed to: if (need
zel 2011/02/17 00:56:05 Done.
653 if (cellular->needs_new_plan())
654 dictionary->SetBoolean('showBuyButton', true);
Charlie Lee 2011/02/14 20:50:32 use double quotes so it's consistent
zel 2011/02/17 00:56:05 Done.
655 else
656 dictionary->SetBoolean('showActivateButton', true);
Charlie Lee 2011/02/14 20:50:32 use double quotes so it's consistent
zel 2011/02/17 00:56:05 Done.
657 }
658 }
659
660
642 void InternetOptionsHandler::LoginCallback(const ListValue* args) { 661 void InternetOptionsHandler::LoginCallback(const ListValue* args) {
643 std::string service_path; 662 std::string service_path;
644 std::string password; 663 std::string password;
645 664
646 if (args->GetSize() != 2 || 665 if (args->GetSize() != 2 ||
647 !args->GetString(0, &service_path) || 666 !args->GetString(0, &service_path) ||
648 !args->GetString(1, &password)) { 667 !args->GetString(1, &password)) {
649 NOTREACHED(); 668 NOTREACHED();
650 return; 669 return;
651 } 670 }
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after
1067 DictionaryValue* dictionary, chromeos::NetworkLibrary* cros) { 1086 DictionaryValue* dictionary, chromeos::NetworkLibrary* cros) {
1068 dictionary->SetBoolean("accessLocked", cros->IsLocked()); 1087 dictionary->SetBoolean("accessLocked", cros->IsLocked());
1069 dictionary->Set("wiredList", GetWiredList()); 1088 dictionary->Set("wiredList", GetWiredList());
1070 dictionary->Set("wirelessList", GetWirelessList()); 1089 dictionary->Set("wirelessList", GetWirelessList());
1071 dictionary->Set("rememberedList", GetRememberedList()); 1090 dictionary->Set("rememberedList", GetRememberedList());
1072 dictionary->SetBoolean("wifiAvailable", cros->wifi_available()); 1091 dictionary->SetBoolean("wifiAvailable", cros->wifi_available());
1073 dictionary->SetBoolean("wifiEnabled", cros->wifi_enabled()); 1092 dictionary->SetBoolean("wifiEnabled", cros->wifi_enabled());
1074 dictionary->SetBoolean("cellularAvailable", cros->cellular_available()); 1093 dictionary->SetBoolean("cellularAvailable", cros->cellular_available());
1075 dictionary->SetBoolean("cellularEnabled", cros->cellular_enabled()); 1094 dictionary->SetBoolean("cellularEnabled", cros->cellular_enabled());
1076 } 1095 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698