summaryrefslogtreecommitdiffstats
path: root/chrome/browser/chromeos/dom_ui
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser/chromeos/dom_ui')
-rw-r--r--chrome/browser/chromeos/dom_ui/accounts_options_handler.cc22
-rw-r--r--chrome/browser/chromeos/dom_ui/accounts_options_handler.h3
-rw-r--r--chrome/browser/chromeos/dom_ui/internet_options_handler.cc571
-rw-r--r--chrome/browser/chromeos/dom_ui/internet_options_handler.h31
-rw-r--r--chrome/browser/chromeos/dom_ui/keyboard_overlay_ui.cc282
-rw-r--r--chrome/browser/chromeos/dom_ui/keyboard_overlay_ui.h24
-rw-r--r--chrome/browser/chromeos/dom_ui/labs_handler.cc5
-rw-r--r--chrome/browser/chromeos/dom_ui/language_options_handler.cc18
-rw-r--r--chrome/browser/chromeos/dom_ui/language_options_handler.h4
-rw-r--r--chrome/browser/chromeos/dom_ui/menu_ui.cc88
-rw-r--r--chrome/browser/chromeos/dom_ui/menu_ui.h26
-rw-r--r--chrome/browser/chromeos/dom_ui/mobile_setup_ui.cc635
-rw-r--r--chrome/browser/chromeos/dom_ui/network_menu_ui.cc38
-rw-r--r--chrome/browser/chromeos/dom_ui/network_menu_ui.h2
-rw-r--r--chrome/browser/chromeos/dom_ui/system_info_ui.cc2
-rw-r--r--chrome/browser/chromeos/dom_ui/system_settings_provider.cc2
-rw-r--r--chrome/browser/chromeos/dom_ui/system_settings_provider.h3
-rw-r--r--chrome/browser/chromeos/dom_ui/wrench_menu_ui.cc45
-rw-r--r--chrome/browser/chromeos/dom_ui/wrench_menu_ui.h1
19 files changed, 1262 insertions, 540 deletions
diff --git a/chrome/browser/chromeos/dom_ui/accounts_options_handler.cc b/chrome/browser/chromeos/dom_ui/accounts_options_handler.cc
index 0176d7e..93361c6 100644
--- a/chrome/browser/chromeos/dom_ui/accounts_options_handler.cc
+++ b/chrome/browser/chromeos/dom_ui/accounts_options_handler.cc
@@ -31,6 +31,8 @@ void AccountsOptionsHandler::RegisterMessages() {
NewCallback(this, &AccountsOptionsHandler::UnwhitelistUser));
dom_ui_->RegisterMessageCallback("fetchUserPictures",
NewCallback(this, &AccountsOptionsHandler::FetchUserPictures));
+ dom_ui_->RegisterMessageCallback("whitelistExistingUsers",
+ NewCallback(this, &AccountsOptionsHandler::WhitelistExistingUsers));
}
void AccountsOptionsHandler::GetLocalizedValues(
@@ -97,4 +99,24 @@ void AccountsOptionsHandler::FetchUserPictures(const ListValue* args) {
user_pictures);
}
+void AccountsOptionsHandler::WhitelistExistingUsers(const ListValue* args) {
+ ListValue whitelist_users;
+
+ std::vector<UserManager::User> users = UserManager::Get()->GetUsers();
+ for (std::vector<UserManager::User>::const_iterator it = users.begin();
+ it < users.end(); ++it) {
+ const std::string& email = it->email();
+ if (!UserCrosSettingsProvider::IsEmailInCachedWhitelist(email)) {
+ DictionaryValue* user_dict = new DictionaryValue;
+ user_dict->SetString("name", it->GetDisplayName());
+ user_dict->SetString("email", email);
+ user_dict->SetBoolean("owner", false);
+
+ whitelist_users.Append(user_dict);
+ }
+ }
+
+ dom_ui_->CallJavascriptFunction(L"AccountsOptions.addUsers", whitelist_users);
+}
+
} // namespace chromeos
diff --git a/chrome/browser/chromeos/dom_ui/accounts_options_handler.h b/chrome/browser/chromeos/dom_ui/accounts_options_handler.h
index 177b447..2fbf76d 100644
--- a/chrome/browser/chromeos/dom_ui/accounts_options_handler.h
+++ b/chrome/browser/chromeos/dom_ui/accounts_options_handler.h
@@ -34,6 +34,9 @@ class AccountsOptionsHandler : public CrosOptionsPageUIHandler {
// Javascript callback to fetch known user pictures.
void FetchUserPictures(const ListValue* args);
+ // Javascript callback to auto add existing users to white list.
+ void WhitelistExistingUsers(const ListValue* args);
+
DISALLOW_COPY_AND_ASSIGN(AccountsOptionsHandler);
};
diff --git a/chrome/browser/chromeos/dom_ui/internet_options_handler.cc b/chrome/browser/chromeos/dom_ui/internet_options_handler.cc
index 87db039..fa0245f 100644
--- a/chrome/browser/chromeos/dom_ui/internet_options_handler.cc
+++ b/chrome/browser/chromeos/dom_ui/internet_options_handler.cc
@@ -24,6 +24,7 @@
#include "chrome/browser/browser_list.h"
#include "chrome/browser/browser_window.h"
#include "chrome/browser/chromeos/cros/cros_library.h"
+#include "chrome/browser/chromeos/login/ownership_service.h"
#include "chrome/browser/chromeos/status/network_menu.h"
#include "chrome/browser/dom_ui/dom_ui_util.h"
#include "chrome/browser/tab_contents/tab_contents.h"
@@ -56,11 +57,19 @@ std::string FormatHardwareAddress(const std::string& address) {
} // namespace
InternetOptionsHandler::InternetOptionsHandler() {
- chromeos::CrosLibrary::Get()->GetNetworkLibrary()->AddObserver(this);
+ chromeos::NetworkLibrary* netlib =
+ chromeos::CrosLibrary::Get()->GetNetworkLibrary();
+ netlib->AddNetworkManagerObserver(this);
+ netlib->AddCellularDataPlanObserver(this);
+ MonitorActiveNetwork(netlib);
}
InternetOptionsHandler::~InternetOptionsHandler() {
- chromeos::CrosLibrary::Get()->GetNetworkLibrary()->RemoveObserver(this);
+ chromeos::NetworkLibrary *netlib =
+ chromeos::CrosLibrary::Get()->GetNetworkLibrary();
+ netlib->RemoveNetworkManagerObserver(this);
+ netlib->RemoveCellularDataPlanObserver(this);
+ netlib->RemoveObserverForAllNetworks(this);
}
void InternetOptionsHandler::GetLocalizedValues(
@@ -92,6 +101,12 @@ void InternetOptionsHandler::GetLocalizedValues(
localized_strings->SetString("forget_button",
l10n_util::GetStringUTF16(
IDS_OPTIONS_SETTINGS_FORGET));
+ localized_strings->SetString("activate_button",
+ l10n_util::GetStringUTF16(
+ IDS_OPTIONS_SETTINGS_ACTIVATE));
+ localized_strings->SetString("buyplan_button",
+ l10n_util::GetStringUTF16(
+ IDS_OPTIONS_SETTINGS_BUY_PLAN));
localized_strings->SetString("wifiNetworkTabLabel",
l10n_util::GetStringUTF16(
@@ -140,9 +155,9 @@ void InternetOptionsHandler::GetLocalizedValues(
localized_strings->SetString("inetCertPass",
l10n_util::GetStringUTF16(
IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_PRIVATE_KEY_PASSWORD));
- localized_strings->SetString("inetPass",
+ localized_strings->SetString("inetPassProtected",
l10n_util::GetStringUTF16(
- IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_PASSPHRASE));
+ IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_NET_PROTECTED));
localized_strings->SetString("inetRememberNetwork",
l10n_util::GetStringUTF16(
IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_AUTO_CONNECT));
@@ -155,6 +170,26 @@ void InternetOptionsHandler::GetLocalizedValues(
localized_strings->SetString("inetShowPass",
l10n_util::GetStringUTF16(
IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_SHOWPASSWORD));
+ localized_strings->SetString("inetSecurityNone",
+ l10n_util::GetStringFUTF16(
+ IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_SECURITY_SELECT,
+ l10n_util::GetStringUTF16(
+ IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_SECURITY_NONE)));
+ localized_strings->SetString("inetSecurityWEP",
+ l10n_util::GetStringFUTF16(
+ IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_SECURITY_SELECT,
+ l10n_util::GetStringUTF16(
+ IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_SECURITY_WEP)));
+ localized_strings->SetString("inetSecurityWPA",
+ l10n_util::GetStringFUTF16(
+ IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_SECURITY_SELECT,
+ l10n_util::GetStringUTF16(
+ IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_SECURITY_WPA)));
+ localized_strings->SetString("inetSecurityRSN",
+ l10n_util::GetStringFUTF16(
+ IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_SECURITY_SELECT,
+ l10n_util::GetStringUTF16(
+ IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_SECURITY_RSN)));
localized_strings->SetString("inetPassPrompt",
l10n_util::GetStringUTF16(
IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_PASSWORD));
@@ -244,7 +279,7 @@ void InternetOptionsHandler::GetLocalizedValues(
l10n_util::GetStringFUTF16(
IDS_STATUSBAR_NETWORK_DEVICE_DISABLE,
l10n_util::GetStringUTF16(IDS_STATUSBAR_NETWORK_DEVICE_WIFI)));
- localized_strings->SetString("enableCellular",
+ localized_strings->SetString("enableCellular",
l10n_util::GetStringFUTF16(
IDS_STATUSBAR_NETWORK_DEVICE_ENABLE,
l10n_util::GetStringUTF16(IDS_STATUSBAR_NETWORK_DEVICE_CELLULAR)));
@@ -256,6 +291,8 @@ void InternetOptionsHandler::GetLocalizedValues(
l10n_util::GetStringUTF16(
IDS_OPTIONS_SETTINGS_INTERNET_CONTROL_TITLE));
+ localized_strings->SetString("detailsInternetOk",
+ l10n_util::GetStringUTF16(IDS_OK));
localized_strings->SetString("detailsInternetDismiss",
l10n_util::GetStringUTF16(IDS_CANCEL));
@@ -265,6 +302,8 @@ void InternetOptionsHandler::GetLocalizedValues(
chromeos::NetworkLibrary* cros =
chromeos::CrosLibrary::Get()->GetNetworkLibrary();
+ localized_strings->SetBoolean("wifiAvailable", cros->wifi_available());
+ localized_strings->SetBoolean("wifiEnabled", cros->wifi_enabled());
localized_strings->SetBoolean("cellularAvailable",
cros->cellular_available());
localized_strings->SetBoolean("cellularEnabled", cros->cellular_enabled());
@@ -291,7 +330,7 @@ void InternetOptionsHandler::RegisterMessages() {
NewCallback(this, &InternetOptionsHandler::DisableWifiCallback));
dom_ui_->RegisterMessageCallback("enableCellular",
NewCallback(this, &InternetOptionsHandler::EnableCellularCallback));
- dom_ui_->RegisterMessageCallback("disablCellular",
+ dom_ui_->RegisterMessageCallback("disableCellular",
NewCallback(this, &InternetOptionsHandler::DisableCellularCallback));
dom_ui_->RegisterMessageCallback("buyDataPlan",
NewCallback(this, &InternetOptionsHandler::BuyDataPlanCallback));
@@ -324,15 +363,16 @@ void InternetOptionsHandler::DisableCellularCallback(const ListValue* args) {
}
void InternetOptionsHandler::BuyDataPlanCallback(const ListValue* args) {
- Browser* browser = BrowserList::GetLastActive();
+ if (!dom_ui_)
+ return;
+ Browser* browser = BrowserList::FindBrowserWithFeature(
+ dom_ui_->GetProfile(), Browser::FEATURE_TABSTRIP);
if (browser)
browser->OpenMobilePlanTabAndActivate();
}
-void InternetOptionsHandler::NetworkChanged(chromeos::NetworkLibrary* cros) {
- if (!dom_ui_)
- return;
-
+void InternetOptionsHandler::RefreshNetworkData(
+ chromeos::NetworkLibrary* cros) {
DictionaryValue dictionary;
dictionary.Set("wiredList", GetWiredList());
dictionary.Set("wirelessList", GetWirelessList());
@@ -345,20 +385,60 @@ void InternetOptionsHandler::NetworkChanged(chromeos::NetworkLibrary* cros) {
L"options.InternetOptions.refreshNetworkData", dictionary);
}
-void InternetOptionsHandler::CellularDataPlanChanged(
+void InternetOptionsHandler::OnNetworkManagerChanged(
+ chromeos::NetworkLibrary* cros) {
+ if (!dom_ui_)
+ return;
+ MonitorActiveNetwork(cros);
+ RefreshNetworkData(cros);
+}
+
+void InternetOptionsHandler::OnNetworkChanged(
+ chromeos::NetworkLibrary* cros,
+ const chromeos::Network* network) {
+ if (dom_ui_)
+ RefreshNetworkData(cros);
+}
+
+// Add an observer for the active network, if any, so
+// that we can dynamically display the correct icon for
+// that network's signal strength.
+// TODO(ers) Ideally, on this page we'd monitor all networks for
+// signal strength changes, not just the active network.
+void InternetOptionsHandler::MonitorActiveNetwork(
+ chromeos::NetworkLibrary* cros) {
+ const chromeos::Network* network = cros->active_network();
+ if (active_network_.empty() || network == NULL ||
+ active_network_ != network->service_path()) {
+ if (!active_network_.empty()) {
+ cros->RemoveNetworkObserver(active_network_, this);
+ }
+ if (network != NULL) {
+ cros->AddNetworkObserver(network->service_path(), this);
+ }
+ }
+ if (network != NULL)
+ active_network_ = network->service_path();
+ else
+ active_network_ = "";
+}
+
+void InternetOptionsHandler::OnCellularDataPlanChanged(
chromeos::NetworkLibrary* obj) {
if (!dom_ui_)
return;
- const chromeos::CellularNetwork cellular = obj->cellular_network();
- const chromeos::CellularDataPlanList& plans = cellular.GetDataPlans();
+ chromeos::CellularNetwork* cellular = obj->cellular_network();
+ if (!cellular)
+ return;
+ const chromeos::CellularDataPlanVector& plans = cellular->GetDataPlans();
DictionaryValue connection_plans;
ListValue* plan_list = new ListValue();
- for (chromeos::CellularDataPlanList::const_iterator iter = plans.begin();
+ for (chromeos::CellularDataPlanVector::const_iterator iter = plans.begin();
iter != plans.end();
++iter) {
plan_list->Append(CellularDataPlanToDictionary(*iter));
}
- connection_plans.SetString("servicePath", cellular.service_path());
+ connection_plans.SetString("servicePath", cellular->service_path());
connection_plans.Set("plans", plan_list);
dom_ui_->CallJavascriptFunction(
L"options.InternetOptions.updateCellularPlans", connection_plans);
@@ -380,9 +460,8 @@ DictionaryValue* InternetOptionsHandler::CellularDataPlanToDictionary(
case chromeos::CELLULAR_DATA_PLAN_UNLIMITED: {
description = l10n_util::GetStringFUTF16(
IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_PURCHASE_UNLIMITED_DATA,
- WideToUTF16(base::TimeFormatFriendlyDate(
- base::Time::FromInternalValue(plan.plan_start_time *
- base::Time::kMicrosecondsPerSecond))));
+ WideToUTF16(base::TimeFormatFriendlyDate(plan.plan_start_time)));
+
remaining = l10n_util::GetStringUTF16(
IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_UNLIMITED);
break;
@@ -394,8 +473,7 @@ DictionaryValue* InternetOptionsHandler::CellularDataPlanToDictionary(
GetByteDisplayUnits(plan.plan_data_bytes),
true),
WideToUTF16(base::TimeFormatFriendlyDate(
- base::Time::FromInternalValue(plan.plan_start_time *
- base::Time::kMicrosecondsPerSecond))));
+ plan.plan_start_time)));
remaining = FormatBytes(plan.plan_data_bytes - plan.data_bytes_used,
GetByteDisplayUnits(plan.plan_data_bytes - plan.data_bytes_used),
true);
@@ -408,8 +486,7 @@ DictionaryValue* InternetOptionsHandler::CellularDataPlanToDictionary(
GetByteDisplayUnits(plan.plan_data_bytes),
true),
WideToUTF16(base::TimeFormatFriendlyDate(
- base::Time::FromInternalValue(plan.plan_start_time *
- base::Time::kMicrosecondsPerSecond))));
+ plan.plan_start_time)));
remaining = FormatBytes(plan.plan_data_bytes - plan.data_bytes_used,
GetByteDisplayUnits(plan.plan_data_bytes - plan.data_bytes_used),
true);
@@ -417,10 +494,7 @@ DictionaryValue* InternetOptionsHandler::CellularDataPlanToDictionary(
}
}
string16 expiration = TimeFormat::TimeRemaining(
- base::TimeDelta::FromSeconds(
- plan.plan_end_time - (base::Time::Now().ToInternalValue() /
- base::Time::kMicrosecondsPerSecond)));
-
+ plan.plan_end_time - base::Time::Now());
plan_dict->SetString("name", plan.plan_name);
plan_dict->SetString("planSummary", description);
plan_dict->SetString("dataRemaining", remaining);
@@ -433,7 +507,8 @@ string16 InternetOptionsHandler::GetPlanWarning(
const chromeos::CellularDataPlan& plan) {
if (plan.plan_type == chromeos::CELLULAR_DATA_PLAN_UNLIMITED) {
// Time based plan. Show nearing expiration and data expiration.
- int64 time_left = plan.plan_end_time - plan.update_time;
+ int64 time_left = base::TimeDelta(
+ plan.plan_end_time - plan.update_time).InSeconds();
if (time_left <= 0) {
return l10n_util::GetStringFUTF16(
IDS_NETWORK_MINUTES_REMAINING_MESSAGE, ASCIIToUTF16("0"));
@@ -459,79 +534,57 @@ string16 InternetOptionsHandler::GetPlanWarning(
}
void InternetOptionsHandler::SetDetailsCallback(const ListValue* args) {
-
std::string service_path;
+ std::string remember;
- if (!args->GetString(0, &service_path)) {
+ if (args->GetSize() < 2 ||
+ !args->GetString(0, &service_path) ||
+ !args->GetString(1, &remember)) {
NOTREACHED();
return;
}
- chromeos::NetworkLibrary* cros =
- chromeos::CrosLibrary::Get()->GetNetworkLibrary();
- chromeos::WifiNetwork network;
-
- if (cros->FindWifiNetworkByPath(service_path, &network)) {
- bool changed = false;
- if (network.encrypted()) {
- if (network.encryption() == chromeos::SECURITY_8021X) {
- std::string certpath;
- std::string ident;
- std::string certpass;
- bool remember;
-
- if (args->GetSize() != 5 ||
- !args->GetBoolean(1, &remember) ||
- !args->GetString(2, &ident) ||
- !args->GetString(3, &certpath) ||
- !args->GetString(4, &certpass)) {
- NOTREACHED();
- return;
- }
- bool auto_connect = remember;
- if (auto_connect != network.auto_connect()) {
- network.set_auto_connect(auto_connect);
- changed = true;
- }
- if (ident != network.identity()) {
- network.set_identity(ident);
- changed = true;
- }
- if (certpass != network.passphrase()) {
- network.set_passphrase(certpass);
- changed = true;
- }
- if (certpath != network.cert_path()) {
- network.set_cert_path(certpath);
- changed = true;
- }
- } else {
- std::string password;
- std::string remember;
-
- if (args->GetSize() != 5 ||
- !args->GetString(1, &remember) ||
- !args->GetString(4, &password)) {
- NOTREACHED();
- return;
- }
+ if (!chromeos::OwnershipService::GetSharedInstance()->CurrentUserIsOwner()) {
+ LOG(WARNING) << "Non-owner tried to change a network.";
+ return;
+ }
- bool auto_connect = (remember == "true");
- if (auto_connect != network.auto_connect()) {
- network.set_auto_connect(auto_connect);
- changed = true;
- }
- if (password != network.passphrase()) {
- network.set_passphrase(password);
- changed = true;
- }
+ chromeos::NetworkLibrary* cros =
+ chromeos::CrosLibrary::Get()->GetNetworkLibrary();
+ chromeos::WifiNetwork* network = cros->FindWifiNetworkByPath(service_path);
+ if (!network)
+ return;
+ bool changed = false;
+ if (network->encrypted()) {
+ if (network->encrypted() &&
+ network->encryption() == chromeos::SECURITY_8021X) {
+ std::string ident;
+ std::string certpath;
+
+ if (!args->GetString(2, &ident) ||
+ !args->GetString(3, &certpath)) {
+ NOTREACHED();
+ return;
+ }
+ if (ident != network->identity()) {
+ network->set_identity(ident);
+ changed = true;
+ }
+ if (certpath != network->cert_path()) {
+ network->set_cert_path(certpath);
+ changed = true;
}
- }
- if (changed) {
- chromeos::CrosLibrary::Get()->GetNetworkLibrary()->SaveWifiNetwork(
- network);
}
}
+
+ bool auto_connect = remember == "true";
+ if (auto_connect != network->auto_connect()) {
+ network->set_auto_connect(auto_connect);
+ changed = true;
+ }
+
+ if (changed)
+ cros->SaveWifiNetwork(network);
}
// Parse 'path' to determine if the certificate is stored in a pkcs#11 device.
@@ -552,12 +605,13 @@ bool InternetOptionsHandler::is_certificate_in_pkcs11(const std::string& path) {
}
void InternetOptionsHandler::PopulateDictionaryDetails(
- const chromeos::Network& net, chromeos::NetworkLibrary* cros) {
+ const chromeos::Network* net, chromeos::NetworkLibrary* cros) {
+ DCHECK(net);
DictionaryValue dictionary;
- chromeos::ConnectionType type = net.type();
+ chromeos::ConnectionType type = net->type();
std::string hardware_address;
chromeos::NetworkIPConfigVector ipconfigs =
- cros->GetIPConfigs(net.device_path(), &hardware_address);
+ cros->GetIPConfigs(net->device_path(), &hardware_address);
scoped_ptr<ListValue> ipconfig_list(new ListValue());
for (chromeos::NetworkIPConfigVector::const_iterator it = ipconfigs.begin();
it != ipconfigs.end(); ++it) {
@@ -571,75 +625,78 @@ void InternetOptionsHandler::PopulateDictionaryDetails(
}
dictionary.Set("ipconfigs", ipconfig_list.release());
dictionary.SetInteger("type", type);
- dictionary.SetString("servicePath", net.service_path());
- dictionary.SetBoolean("connecting", net.connecting());
- dictionary.SetBoolean("connected", net.connected());
- dictionary.SetString("connectionState", net.GetStateString());
+ dictionary.SetString("servicePath", net->service_path());
+ dictionary.SetBoolean("connecting", net->connecting());
+ dictionary.SetBoolean("connected", net->connected());
+ dictionary.SetString("connectionState", net->GetStateString());
if (type == chromeos::TYPE_WIFI) {
- chromeos::WifiNetwork wireless;
- if (!cros->FindWifiNetworkByPath(net.service_path(), &wireless)) {
- LOG(WARNING) << "Cannot find network " << net.service_path();
+ chromeos::WifiNetwork* wireless =
+ cros->FindWifiNetworkByPath(net->service_path());
+ if (!wireless) {
+ LOG(WARNING) << "Cannot find network " << net->service_path();
} else {
- dictionary.SetString("ssid", wireless.name());
- dictionary.SetBoolean("autoConnect",wireless.auto_connect());
- if (wireless.encrypted()) {
+ dictionary.SetString("ssid", wireless->name());
+ dictionary.SetBoolean("autoConnect", wireless->auto_connect());
+ if (wireless->encrypted()) {
dictionary.SetBoolean("encrypted", true);
- if (wireless.encryption() == chromeos::SECURITY_8021X) {
+ if (wireless->encryption() == chromeos::SECURITY_8021X) {
bool certificate_in_pkcs11 =
- is_certificate_in_pkcs11(wireless.cert_path());
+ is_certificate_in_pkcs11(wireless->cert_path());
if (certificate_in_pkcs11) {
dictionary.SetBoolean("certInPkcs", true);
} else {
dictionary.SetBoolean("certInPkcs", false);
}
- dictionary.SetString("certPath",wireless.cert_path());
- dictionary.SetString("ident",wireless.identity());
+ dictionary.SetString("certPath", wireless->cert_path());
+ dictionary.SetString("ident", wireless->identity());
dictionary.SetBoolean("certNeeded", true);
- dictionary.SetString("certPass",wireless.passphrase());
+ dictionary.SetString("certPass", wireless->passphrase());
} else {
dictionary.SetBoolean("certNeeded", false);
- dictionary.SetString("pass", wireless.passphrase());
}
} else {
dictionary.SetBoolean("encrypted", false);
}
}
} else if (type == chromeos::TYPE_CELLULAR) {
- chromeos::CellularNetwork cellular;
- if (!cros->FindCellularNetworkByPath(net.service_path(), &cellular)) {
- LOG(WARNING) << "Cannot find network " << net.service_path();
+ chromeos::CellularNetwork* cellular =
+ cros->FindCellularNetworkByPath(net->service_path());
+ if (!cellular) {
+ LOG(WARNING) << "Cannot find network " << net->service_path();
} else {
// Cellular network / connection settings.
- dictionary.SetString("serviceName", cellular.service_name());
+ dictionary.SetString("serviceName", cellular->service_name());
dictionary.SetString("networkTechnology",
- cellular.GetNetworkTechnologyString());
- dictionary.SetString("operatorName", cellular.operator_name());
- dictionary.SetString("operatorCode", cellular.operator_code());
+ cellular->GetNetworkTechnologyString());
+ dictionary.SetString("operatorName", cellular->operator_name());
+ dictionary.SetString("operatorCode", cellular->operator_code());
dictionary.SetString("activationState",
- cellular.GetActivationStateString());
+ cellular->GetActivationStateString());
dictionary.SetString("roamingState",
- cellular.GetRoamingStateString());
+ cellular->GetRoamingStateString());
dictionary.SetString("restrictedPool",
- cellular.restricted_pool() ?
+ cellular->restricted_pool() ?
l10n_util::GetStringUTF8(IDS_CONFIRM_MESSAGEBOX_YES_BUTTON_LABEL) :
l10n_util::GetStringUTF8(IDS_CONFIRM_MESSAGEBOX_NO_BUTTON_LABEL));
- dictionary.SetString("errorState", cellular.GetErrorString());
+ dictionary.SetString("errorState", cellular->GetErrorString());
+ dictionary.SetString("supportUrl",
+ cellular->payment_url());
// Device settings.
- dictionary.SetString("manufacturer", cellular.manufacturer());
- dictionary.SetString("modelId", cellular.model_id());
- dictionary.SetString("firmwareRevision", cellular.firmware_revision());
- dictionary.SetString("hardwareRevision", cellular.hardware_revision());
- dictionary.SetString("lastUpdate", cellular.last_update());
+ dictionary.SetString("manufacturer", cellular->manufacturer());
+ dictionary.SetString("modelId", cellular->model_id());
+ dictionary.SetString("firmwareRevision", cellular->firmware_revision());
+ dictionary.SetString("hardwareRevision", cellular->hardware_revision());
+ dictionary.SetString("lastUpdate", cellular->last_update());
dictionary.SetString("prlVersion", StringPrintf("%u",
- cellular.prl_version()));
- dictionary.SetString("meid", cellular.meid());
- dictionary.SetString("imei", cellular.imei());
- dictionary.SetString("mdn", cellular.mdn());
- dictionary.SetString("imsi", cellular.imsi());
- dictionary.SetString("esn", cellular.esn());
- dictionary.SetString("min", cellular.min());
-
- dictionary.SetBoolean("gsm", cellular.is_gsm());
+ cellular->prl_version()));
+ dictionary.SetString("meid", cellular->meid());
+ dictionary.SetString("imei", cellular->imei());
+ dictionary.SetString("mdn", cellular->mdn());
+ dictionary.SetString("imsi", cellular->imsi());
+ dictionary.SetString("esn", cellular->esn());
+ dictionary.SetString("min", cellular->min());
+
+ dictionary.SetBoolean("gsm", cellular->is_gsm());
}
}
if (!hardware_address.empty()) {
@@ -651,24 +708,7 @@ void InternetOptionsHandler::PopulateDictionaryDetails(
L"options.InternetOptions.showDetailedInfo", dictionary);
}
-void InternetOptionsHandler::PopupWirelessPassword(
- const chromeos::WifiNetwork& network) {
- DictionaryValue dictionary;
- dictionary.SetString("servicePath",network.service_path());
- if (network.encryption() == chromeos::SECURITY_8021X) {
- dictionary.SetBoolean("certNeeded", true);
- dictionary.SetString("ident", network.identity());
- dictionary.SetString("cert", network.cert_path());
- } else {
- dictionary.SetBoolean("certNeeded", false);
- dictionary.SetString("pass", network.passphrase());
- }
- dom_ui_->CallJavascriptFunction(
- L"options.InternetOptions.showPasswordEntry", dictionary);
-}
-
void InternetOptionsHandler::LoginCallback(const ListValue* args) {
-
std::string service_path;
std::string password;
@@ -681,61 +721,72 @@ void InternetOptionsHandler::LoginCallback(const ListValue* args) {
chromeos::NetworkLibrary* cros =
chromeos::CrosLibrary::Get()->GetNetworkLibrary();
- chromeos::WifiNetwork network;
-
- if (cros->FindWifiNetworkByPath(service_path, &network)) {
+ chromeos::WifiNetwork* network = cros->FindWifiNetworkByPath(service_path);
+ if (network) {
cros->ConnectToWifiNetwork(
network, password, std::string(), std::string());
} else {
- // Must be an "other" login
- cros->ConnectToWifiNetwork(
- service_path, password, std::string(), std::string(), true);
+ // Network disappeared while the user is connecting to it.
+ // TODO(chocobo): Display error message.
+ LOG(WARNING) << "Cannot find network to connect " << service_path;
}
}
void InternetOptionsHandler::LoginCertCallback(const ListValue* args) {
-
std::string service_path;
std::string identity;
std::string certpath;
- std::string password;
-
- if (args->GetSize() != 4 ||
+ if (args->GetSize() < 3 ||
!args->GetString(0, &service_path) ||
!args->GetString(1, &certpath) ||
- !args->GetString(2, &identity) ||
- !args->GetString(3, &password)) {
- NOTREACHED();
+ !args->GetString(2, &identity)) {
return;
}
chromeos::NetworkLibrary* cros =
chromeos::CrosLibrary::Get()->GetNetworkLibrary();
- chromeos::WifiNetwork network;
-
- if (cros->FindWifiNetworkByPath(service_path, &network)) {
- cros->ConnectToWifiNetwork(
- network, password, identity, certpath);
- } else {
- // TODO(dhg): Send error back to UI
+ chromeos::WifiNetwork* network =
+ cros->FindWifiNetworkByPath(service_path);
+ if (!network)
+ return;
+ // If password does not come from the input, use one saved with the
+ // network details.
+ std::string password;
+ if (args->GetSize() != 4 || !args->GetString(3, &password)) {
+ password = network->passphrase();
}
+ cros->ConnectToWifiNetwork(
+ network, password, identity, certpath);
}
void InternetOptionsHandler::LoginToOtherCallback(const ListValue* args) {
+ std::string security;
std::string ssid;
std::string password;
- if (args->GetSize() != 2 ||
- !args->GetString(0, &ssid) ||
- !args->GetString(1, &password)) {
+ if (args->GetSize() != 3 ||
+ !args->GetString(0, &security) ||
+ !args->GetString(1, &ssid) ||
+ !args->GetString(2, &password)) {
NOTREACHED();
return;
}
+ chromeos::ConnectionSecurity sec = chromeos::SECURITY_UNKNOWN;
+ if (security == "none") {
+ sec = chromeos::SECURITY_NONE;
+ } else if (security == "wep") {
+ sec = chromeos::SECURITY_WEP;
+ } else if (security == "wpa") {
+ sec = chromeos::SECURITY_WPA;
+ } else if (security == "rsn") {
+ sec = chromeos::SECURITY_RSN;
+ }
+
chromeos::NetworkLibrary* cros =
chromeos::CrosLibrary::Get()->GetNetworkLibrary();
- cros->ConnectToWifiNetwork(
- ssid, password, std::string(), std::string(), true);
+ cros->ConnectToWifiNetwork(sec, ssid, password, std::string(), std::string(),
+ true);
}
void InternetOptionsHandler::ButtonClickCallback(const ListValue* args) {
@@ -750,25 +801,35 @@ void InternetOptionsHandler::ButtonClickCallback(const ListValue* args) {
return;
}
+ bool is_owner =
+ chromeos::OwnershipService::GetSharedInstance()->CurrentUserIsOwner();
+
int type = atoi(str_type.c_str());
chromeos::NetworkLibrary* cros =
chromeos::CrosLibrary::Get()->GetNetworkLibrary();
if (type == chromeos::TYPE_ETHERNET) {
- const chromeos::EthernetNetwork& ether = cros->ethernet_network();
+ chromeos::EthernetNetwork* ether = cros->ethernet_network();
PopulateDictionaryDetails(ether, cros);
} else if (type == chromeos::TYPE_WIFI) {
- chromeos::WifiNetwork network;
+ chromeos::WifiNetwork* network;
if (command == "forget") {
- cros->ForgetWirelessNetwork(service_path);
- } else if (cros->FindWifiNetworkByPath(service_path, &network)) {
+ if (!is_owner) {
+ LOG(WARNING) << "Non-owner tried to forget a network.";
+ return;
+ }
+ cros->ForgetWifiNetwork(service_path);
+ } else if ((network = cros->FindWifiNetworkByPath(service_path))) {
if (command == "connect") {
// Connect to wifi here. Open password page if appropriate.
- if (network.encrypted()) {
- if (network.encryption() == chromeos::SECURITY_8021X) {
+ if (network->encrypted() && !network->auto_connect()) {
+ if (network->encryption() == chromeos::SECURITY_8021X) {
PopulateDictionaryDetails(network, cros);
} else {
- PopupWirelessPassword(network);
+ DictionaryValue dictionary;
+ dictionary.SetString("servicePath", network->service_path());
+ dom_ui_->CallJavascriptFunction(
+ L"options.InternetOptions.showPasswordEntry", dictionary);
}
} else {
cros->ConnectToWifiNetwork(
@@ -781,12 +842,17 @@ void InternetOptionsHandler::ButtonClickCallback(const ListValue* args) {
}
}
} else if (type == chromeos::TYPE_CELLULAR) {
- chromeos::CellularNetwork cellular;
- if (cros->FindCellularNetworkByPath(service_path, &cellular)) {
+ chromeos::CellularNetwork* cellular =
+ cros->FindCellularNetworkByPath(service_path);
+ if (cellular) {
if (command == "connect") {
cros->ConnectToCellularNetwork(cellular);
} else if (command == "disconnect") {
cros->DisconnectFromWirelessNetwork(cellular);
+ } else if (command == "activate") {
+ Browser* browser = BrowserList::GetLastActive();
+ if (browser)
+ browser->OpenMobilePlanTabAndActivate();
} else if (command == "options") {
PopulateDictionaryDetails(cellular, cros);
}
@@ -806,27 +872,35 @@ void InternetOptionsHandler::RefreshCellularPlanCallback(
}
chromeos::NetworkLibrary* cros =
chromeos::CrosLibrary::Get()->GetNetworkLibrary();
- chromeos::CellularNetwork cellular;
- if (cros->FindCellularNetworkByPath(service_path, &cellular)) {
+ chromeos::CellularNetwork* cellular =
+ cros->FindCellularNetworkByPath(service_path);
+ if (cellular)
cros->RefreshCellularDataPlans(cellular);
- } else {
- NOTREACHED();
- }
}
ListValue* InternetOptionsHandler::GetNetwork(const std::string& service_path,
const SkBitmap& icon, const std::string& name, bool connecting,
- bool connected, int connection_type, bool remembered) {
+ bool connected, chromeos::ConnectionType connection_type, bool remembered,
+ chromeos::ActivationState activation_state, bool restricted_ip) {
ListValue* network = new ListValue();
- int s = IDS_STATUSBAR_NETWORK_DEVICE_DISCONNECTED;
+ int connection_state = IDS_STATUSBAR_NETWORK_DEVICE_DISCONNECTED;
if (connecting)
- s = IDS_STATUSBAR_NETWORK_DEVICE_CONNECTING;
+ connection_state = IDS_STATUSBAR_NETWORK_DEVICE_CONNECTING;
else if (connected)
- s = IDS_STATUSBAR_NETWORK_DEVICE_CONNECTED;
- string16 status = l10n_util::GetStringUTF16(s);
-
+ connection_state = IDS_STATUSBAR_NETWORK_DEVICE_CONNECTED;
+ std::string status = l10n_util::GetStringUTF8(connection_state);
+ if (connection_type == chromeos::TYPE_CELLULAR) {
+ if (activation_state == chromeos::ACTIVATION_STATE_ACTIVATED &&
+ restricted_ip && connected) {
+ status = l10n_util::GetStringUTF8(IDS_OPTIONS_SETTINGS_NO_PLAN_LABEL);
+ } else if (activation_state != chromeos::ACTIVATION_STATE_ACTIVATED) {
+ status.append(" / ");
+ status.append(
+ chromeos::CellularNetwork::ActivationStateToString(activation_state));
+ }
+ }
// service path
network->Append(Value::CreateStringValue(service_path));
// name
@@ -834,7 +908,7 @@ ListValue* InternetOptionsHandler::GetNetwork(const std::string& service_path,
// status
network->Append(Value::CreateStringValue(status));
// type
- network->Append(Value::CreateIntegerValue(connection_type));
+ network->Append(Value::CreateIntegerValue(static_cast<int>(connection_type)));
// connected
network->Append(Value::CreateBooleanValue(connected));
// connecting
@@ -844,6 +918,11 @@ ListValue* InternetOptionsHandler::GetNetwork(const std::string& service_path,
dom_ui_util::GetImageDataUrl(icon)));
// remembered
network->Append(Value::CreateBooleanValue(remembered));
+ // activation_state
+ network->Append(Value::CreateIntegerValue(
+ static_cast<int>(activation_state)));
+ // restricted
+ network->Append(Value::CreateBooleanValue(restricted_ip));
return network;
}
@@ -855,22 +934,26 @@ ListValue* InternetOptionsHandler::GetWiredList() {
// If ethernet is not enabled, then don't add anything.
if (cros->ethernet_enabled()) {
- const chromeos::EthernetNetwork& ethernet_network =
+ chromeos::EthernetNetwork* ethernet_network =
cros->ethernet_network();
SkBitmap icon = *rb.GetBitmapNamed(IDR_STATUSBAR_WIRED_BLACK);
- if (!ethernet_network.connecting() &&
- !ethernet_network.connected()) {
+ if (!ethernet_network || (!ethernet_network->connecting() &&
+ !ethernet_network->connected())) {
icon = chromeos::NetworkMenu::IconForDisplay(icon,
*rb.GetBitmapNamed(IDR_STATUSBAR_NETWORK_DISCONNECTED));
}
- list->Append(GetNetwork(
- ethernet_network.service_path(),
- icon,
- l10n_util::GetStringUTF8(IDS_STATUSBAR_NETWORK_DEVICE_ETHERNET),
- ethernet_network.connecting(),
- ethernet_network.connected(),
- chromeos::TYPE_ETHERNET,
- false));
+ if (ethernet_network) {
+ list->Append(GetNetwork(
+ ethernet_network->service_path(),
+ icon,
+ l10n_util::GetStringUTF8(IDS_STATUSBAR_NETWORK_DEVICE_ETHERNET),
+ ethernet_network->connecting(),
+ ethernet_network->connected(),
+ chromeos::TYPE_ETHERNET,
+ false,
+ chromeos::ACTIVATION_STATE_UNKNOWN,
+ false));
+ }
}
return list;
}
@@ -885,48 +968,54 @@ ListValue* InternetOptionsHandler::GetWirelessList() {
for (chromeos::WifiNetworkVector::const_iterator it =
wifi_networks.begin(); it != wifi_networks.end(); ++it) {
SkBitmap icon = chromeos::NetworkMenu::IconForNetworkStrength(
- it->strength(), true);
- if (it->encrypted()) {
+ (*it)->strength(), true);
+ if ((*it)->encrypted()) {
icon = chromeos::NetworkMenu::IconForDisplay(icon,
*rb.GetBitmapNamed(IDR_STATUSBAR_NETWORK_SECURE));
}
list->Append(GetNetwork(
- it->service_path(),
+ (*it)->service_path(),
icon,
- it->name(),
- it->connecting(),
- it->connected(),
+ (*it)->name(),
+ (*it)->connecting(),
+ (*it)->connected(),
chromeos::TYPE_WIFI,
+ false,
+ chromeos::ACTIVATION_STATE_UNKNOWN,
false));
}
- const chromeos::CellularNetworkVector& cellular_networks =
+ const chromeos::CellularNetworkVector cellular_networks =
cros->cellular_networks();
for (chromeos::CellularNetworkVector::const_iterator it =
cellular_networks.begin(); it != cellular_networks.end(); ++it) {
SkBitmap icon = chromeos::NetworkMenu::IconForNetworkStrength(
- it->strength(), true);
- SkBitmap badge = *rb.GetBitmapNamed(IDR_STATUSBAR_NETWORK_3G);
+ (*it)->strength(), true);
+ SkBitmap badge = chromeos::NetworkMenu::BadgeForNetworkTechnology(*it);
icon = chromeos::NetworkMenu::IconForDisplay(icon, badge);
list->Append(GetNetwork(
- it->service_path(),
+ (*it)->service_path(),
icon,
- it->name(),
- it->connecting(),
- it->connected(),
+ (*it)->name(),
+ (*it)->connecting(),
+ (*it)->connected(),
chromeos::TYPE_CELLULAR,
- false));
+ false,
+ (*it)->activation_state(),
+ (*it)->restricted_pool()));
}
// Add "Other..." if wifi is enabled.
if (cros->wifi_enabled()) {
list->Append(GetNetwork(
kOtherNetworksFakePath,
- SkBitmap(),
+ *rb.GetBitmapNamed(IDR_STATUSBAR_NETWORK_BARS0_BLACK),
l10n_util::GetStringUTF8(IDS_OPTIONS_SETTINGS_OTHER_NETWORKS),
false,
false,
chromeos::TYPE_WIFI,
+ false,
+ chromeos::ACTIVATION_STATE_UNKNOWN,
false));
}
@@ -943,37 +1032,21 @@ ListValue* InternetOptionsHandler::GetRememberedList() {
cros->remembered_wifi_networks();
for (chromeos::WifiNetworkVector::const_iterator it =
wifi_networks.begin(); it != wifi_networks.end(); ++it) {
- SkBitmap icon = *rb.GetBitmapNamed(IDR_STATUSBAR_NETWORK_BARS0);
- if (it->encrypted()) {
+ SkBitmap icon = *rb.GetBitmapNamed(IDR_STATUSBAR_NETWORK_BARS0_BLACK);
+ if ((*it)->encrypted()) {
icon = chromeos::NetworkMenu::IconForDisplay(icon,
*rb.GetBitmapNamed(IDR_STATUSBAR_NETWORK_SECURE));
}
list->Append(GetNetwork(
- it->service_path(),
+ (*it)->service_path(),
icon,
- it->name(),
- it->connecting(),
- it->connected(),
+ (*it)->name(),
+ (*it)->connecting(),
+ (*it)->connected(),
chromeos::TYPE_WIFI,
- true));
- }
-
- const chromeos::CellularNetworkVector& cellular_networks =
- cros->remembered_cellular_networks();
- for (chromeos::CellularNetworkVector::const_iterator it =
- cellular_networks.begin(); it != cellular_networks.end(); ++it) {
- SkBitmap icon = *rb.GetBitmapNamed(IDR_STATUSBAR_NETWORK_BARS0);
- SkBitmap badge = *rb.GetBitmapNamed(IDR_STATUSBAR_NETWORK_3G);
- icon = chromeos::NetworkMenu::IconForDisplay(icon, badge);
- list->Append(GetNetwork(
- it->service_path(),
- icon,
- it->name(),
- it->connecting(),
- it->connected(),
- chromeos::TYPE_CELLULAR,
- true));
+ true,
+ chromeos::ACTIVATION_STATE_UNKNOWN,
+ false));
}
-
return list;
}
diff --git a/chrome/browser/chromeos/dom_ui/internet_options_handler.h b/chrome/browser/chromeos/dom_ui/internet_options_handler.h
index f960121..bce82ad 100644
--- a/chrome/browser/chromeos/dom_ui/internet_options_handler.h
+++ b/chrome/browser/chromeos/dom_ui/internet_options_handler.h
@@ -16,8 +16,11 @@ class WindowDelegate;
}
// ChromeOS internet options page UI handler.
-class InternetOptionsHandler : public OptionsPageUIHandler,
- public chromeos::NetworkLibrary::Observer {
+class InternetOptionsHandler
+ : public OptionsPageUIHandler,
+ public chromeos::NetworkLibrary::NetworkManagerObserver,
+ public chromeos::NetworkLibrary::NetworkObserver,
+ public chromeos::NetworkLibrary::CellularDataPlanObserver {
public:
InternetOptionsHandler();
virtual ~InternetOptionsHandler();
@@ -28,9 +31,13 @@ class InternetOptionsHandler : public OptionsPageUIHandler,
// DOMMessageHandler implementation.
virtual void RegisterMessages();
- // NetworkLibrary::Observer implementation.
- virtual void NetworkChanged(chromeos::NetworkLibrary* obj);
- virtual void CellularDataPlanChanged(chromeos::NetworkLibrary* obj);
+ // NetworkLibrary::NetworkManagerObserver implementation.
+ virtual void OnNetworkManagerChanged(chromeos::NetworkLibrary* network_lib);
+ // NetworkLibrary::NetworkObserver implementation.
+ virtual void OnNetworkChanged(chromeos::NetworkLibrary* network_lib,
+ const chromeos::Network* network);
+ // NetworkLibrary::CellularDataPlanObserver implementation.
+ virtual void OnCellularDataPlanChanged(chromeos::NetworkLibrary* network_lib);
private:
// Passes data needed to show details overlay for network.
@@ -56,11 +63,9 @@ class InternetOptionsHandler : public OptionsPageUIHandler,
// Populates the ui with the details of the given device path. This forces
// an overlay to be displayed in the UI.
- void PopulateDictionaryDetails(const chromeos::Network& net,
+ void PopulateDictionaryDetails(const chromeos::Network* net,
chromeos::NetworkLibrary* cros);
- void PopupWirelessPassword(const chromeos::WifiNetwork& network);
-
// Converts CellularDataPlan structure into dictionary for JS. Formats
// plan settings into human readable texts.
DictionaryValue* CellularDataPlanToDictionary(
@@ -72,7 +77,8 @@ class InternetOptionsHandler : public OptionsPageUIHandler,
// Creates the map of a network
ListValue* GetNetwork(const std::string& service_path, const SkBitmap& icon,
const std::string& name, bool connecting, bool connected,
- int connection_type, bool remembered);
+ chromeos::ConnectionType connection_type, bool remembered,
+ chromeos::ActivationState activation_state, bool restricted_ip);
// Creates the map of wired networks
ListValue* GetWiredList();
@@ -80,6 +86,13 @@ class InternetOptionsHandler : public OptionsPageUIHandler,
ListValue* GetWirelessList();
// Creates the map of remembered networks
ListValue* GetRememberedList();
+ // Refresh the display of network information
+ void RefreshNetworkData(chromeos::NetworkLibrary* cros);
+ // Monitor the active network, if any
+ void MonitorActiveNetwork(chromeos::NetworkLibrary* cros);
+
+ // If any network is currently active, this is its service path
+ std::string active_network_;
DISALLOW_COPY_AND_ASSIGN(InternetOptionsHandler);
};
diff --git a/chrome/browser/chromeos/dom_ui/keyboard_overlay_ui.cc b/chrome/browser/chromeos/dom_ui/keyboard_overlay_ui.cc
new file mode 100644
index 0000000..91b7a37
--- /dev/null
+++ b/chrome/browser/chromeos/dom_ui/keyboard_overlay_ui.cc
@@ -0,0 +1,282 @@
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/chromeos/dom_ui/keyboard_overlay_ui.h"
+
+#include "app/l10n_util.h"
+#include "app/resource_bundle.h"
+#include "base/callback.h"
+#include "base/values.h"
+#include "base/weak_ptr.h"
+#include "chrome/browser/browser_thread.h"
+#include "chrome/browser/dom_ui/chrome_url_data_manager.h"
+#include "chrome/common/jstemplate_builder.h"
+#include "chrome/common/url_constants.h"
+#include "grit/browser_resources.h"
+#include "grit/generated_resources.h"
+
+#if defined(OS_CHROMEOS)
+#include "chrome/browser/chromeos/cros/cros_library.h"
+#endif
+
+class KeyboardOverlayUIHTMLSource : public ChromeURLDataManager::DataSource {
+ public:
+ KeyboardOverlayUIHTMLSource();
+
+ // Called when the keyboard overlay has requested a resource underneath
+ // the path we registered.
+ virtual void StartDataRequest(const std::string& path,
+ bool is_off_the_record,
+ int request_id);
+ virtual std::string GetMimeType(const std::string&) const {
+ return "text/html";
+ }
+
+ private:
+ ~KeyboardOverlayUIHTMLSource() {}
+
+ DISALLOW_COPY_AND_ASSIGN(KeyboardOverlayUIHTMLSource);
+};
+
+
+// The handler for Javascript messages related to the "keyboardoverlay" view.
+class KeyboardOverlayHandler
+ : public DOMMessageHandler,
+ public base::SupportsWeakPtr<KeyboardOverlayHandler> {
+ public:
+ KeyboardOverlayHandler();
+ virtual ~KeyboardOverlayHandler();
+
+ // DOMMessageHandler implementation.
+ virtual DOMMessageHandler* Attach(DOMUI* dom_ui);
+ virtual void RegisterMessages();
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(KeyboardOverlayHandler);
+};
+
+////////////////////////////////////////////////////////////////////////////////
+//
+// KeyboardOverlayUIHTMLSource
+//
+////////////////////////////////////////////////////////////////////////////////
+
+KeyboardOverlayUIHTMLSource::KeyboardOverlayUIHTMLSource()
+ : DataSource(chrome::kChromeUIKeyboardOverlayHost,
+ MessageLoop::current()) {
+}
+
+void KeyboardOverlayUIHTMLSource::StartDataRequest(const std::string& path,
+ bool is_off_the_record,
+ int request_id) {
+ DictionaryValue localized_strings;
+ localized_strings.SetString("keyboardOverlayTitle",
+ l10n_util::GetStringUTF16(IDS_KEYBOARD_OVERLAY_TITLE));
+ localized_strings.SetString("keyboardOverlayInstructions",
+ l10n_util::GetStringUTF16(IDS_KEYBOARD_OVERLAY_INSTRUCTIONS));
+ localized_strings.SetString("keyboardOverlayActivateLastTab",
+ l10n_util::GetStringUTF16(IDS_KEYBOARD_OVERLAY_ACTIVATE_LAST_TAB));
+ localized_strings.SetString("keyboardOverlayActivateNextTab",
+ l10n_util::GetStringUTF16(IDS_KEYBOARD_OVERLAY_ACTIVATE_NEXT_TAB));
+ localized_strings.SetString("keyboardOverlayActivatePreviousTab",
+ l10n_util::GetStringUTF16(IDS_KEYBOARD_OVERLAY_ACTIVATE_PREVIOUS_TAB));
+ localized_strings.SetString("keyboardOverlayActivateTab1",
+ l10n_util::GetStringUTF16(IDS_KEYBOARD_OVERLAY_ACTIVATE_TAB_1));
+ localized_strings.SetString("keyboardOverlayActivateTab2",
+ l10n_util::GetStringUTF16(IDS_KEYBOARD_OVERLAY_ACTIVATE_TAB_2));
+ localized_strings.SetString("keyboardOverlayActivateTab3",
+ l10n_util::GetStringUTF16(IDS_KEYBOARD_OVERLAY_ACTIVATE_TAB_3));
+ localized_strings.SetString("keyboardOverlayActivateTab4",
+ l10n_util::GetStringUTF16(IDS_KEYBOARD_OVERLAY_ACTIVATE_TAB_4));
+ localized_strings.SetString("keyboardOverlayActivateTab5",
+ l10n_util::GetStringUTF16(IDS_KEYBOARD_OVERLAY_ACTIVATE_TAB_5));
+ localized_strings.SetString("keyboardOverlayActivateTab6",
+ l10n_util::GetStringUTF16(IDS_KEYBOARD_OVERLAY_ACTIVATE_TAB_6));
+ localized_strings.SetString("keyboardOverlayActivateTab7",
+ l10n_util::GetStringUTF16(IDS_KEYBOARD_OVERLAY_ACTIVATE_TAB_7));
+ localized_strings.SetString("keyboardOverlayActivateTab8",
+ l10n_util::GetStringUTF16(IDS_KEYBOARD_OVERLAY_ACTIVATE_TAB_8));
+ localized_strings.SetString("keyboardOverlayAddWwwAndComAndOpenAddress",
+ l10n_util::GetStringUTF16(
+ IDS_KEYBOARD_OVERLAY_ADD_WWW_AND_COM_AND_OPEN_ADDRESS));
+ localized_strings.SetString("keyboardOverlayBookmarkCurrentPage",
+ l10n_util::GetStringUTF16(IDS_KEYBOARD_OVERLAY_BOOKMARK_CURRENT_PAGE));
+ localized_strings.SetString("keyboardOverlayBookmarkAllTabs",
+ l10n_util::GetStringUTF16(IDS_KEYBOARD_OVERLAY_BOOKMARK_ALL_TABS));
+ localized_strings.SetString("keyboardOverlayCloseTab",
+ l10n_util::GetStringUTF16(IDS_KEYBOARD_OVERLAY_CLOSE_TAB));
+ localized_strings.SetString("keyboardOverlayCloseWindow",
+ l10n_util::GetStringUTF16(IDS_KEYBOARD_OVERLAY_CLOSE_WINDOW));
+ localized_strings.SetString("keyboardOverlayDeleteWord",
+ l10n_util::GetStringUTF16(IDS_KEYBOARD_OVERLAY_DELETE_WORD));
+ localized_strings.SetString("keyboardOverlayDeveloperTools",
+ l10n_util::GetStringUTF16(IDS_KEYBOARD_OVERLAY_DEVELOPER_TOOLS));
+ localized_strings.SetString("keyboardOverlayFindAgain",
+ l10n_util::GetStringUTF16(IDS_KEYBOARD_OVERLAY_FIND_AGAIN));
+ localized_strings.SetString("keyboardOverlayFindPrevious",
+ l10n_util::GetStringUTF16(IDS_KEYBOARD_OVERLAY_FIND_PREVIOUS));
+ localized_strings.SetString("keyboardOverlayFindPrevious",
+ l10n_util::GetStringUTF16(IDS_KEYBOARD_OVERLAY_FIND_PREVIOUS));
+ localized_strings.SetString("keyboardOverlayFindText",
+ l10n_util::GetStringUTF16(IDS_KEYBOARD_OVERLAY_FIND_TEXT));
+ localized_strings.SetString("keyboardOverlayFocusAddressBar",
+ l10n_util::GetStringUTF16(IDS_KEYBOARD_OVERLAY_FOCUS_ADDRESS_BAR));
+ localized_strings.SetString("keyboardOverlayFocusAddressBar",
+ l10n_util::GetStringUTF16(IDS_KEYBOARD_OVERLAY_FOCUS_ADDRESS_BAR));
+ localized_strings.SetString("keyboardOverlayFocusAddressBarInSearchMode",
+ l10n_util::GetStringUTF16(
+ IDS_KEYBOARD_OVERLAY_FOCUS_ADDRESS_BAR_IN_SEARCH_MODE));
+ localized_strings.SetString("keyboardOverlayDomInspector",
+ l10n_util::GetStringUTF16(IDS_KEYBOARD_OVERLAY_DOM_INSPECTOR));
+ localized_strings.SetString("keyboardOverlayDownloads",
+ l10n_util::GetStringUTF16(IDS_KEYBOARD_OVERLAY_DOWNLOADS));
+ localized_strings.SetString("keyboardOverlayTaskManager",
+ l10n_util::GetStringUTF16(IDS_KEYBOARD_OVERLAY_TASK_MANAGER));
+ localized_strings.SetString("keyboardOverlayBack",
+ l10n_util::GetStringUTF16(IDS_KEYBOARD_OVERLAY_BACK));
+ localized_strings.SetString("keyboardOverlayForward",
+ l10n_util::GetStringUTF16(IDS_KEYBOARD_OVERLAY_FORWARD));
+ localized_strings.SetString("keyboardOverlayForward",
+ l10n_util::GetStringUTF16(IDS_KEYBOARD_OVERLAY_FORWARD));
+ localized_strings.SetString("keyboardOverlayHistory",
+ l10n_util::GetStringUTF16(IDS_KEYBOARD_OVERLAY_HISTORY));
+ localized_strings.SetString("keyboardOverlayNewTab",
+ l10n_util::GetStringUTF16(IDS_KEYBOARD_OVERLAY_NEW_TAB));
+ localized_strings.SetString("keyboardOverlayOpenAddressInNewTab",
+ l10n_util::GetStringUTF16(IDS_KEYBOARD_OVERLAY_OPEN_ADDRESS_IN_NEW_TAB));
+ localized_strings.SetString("keyboardOverlayNewIncognitoWindow",
+ l10n_util::GetStringUTF16(IDS_KEYBOARD_OVERLAY_NEW_INCOGNITO_WINDOW));
+ localized_strings.SetString("keyboardOverlayNewWindow",
+ l10n_util::GetStringUTF16(IDS_KEYBOARD_OVERLAY_NEW_WINDOW));
+ localized_strings.SetString("keyboardOverlayPasteAsPlainText",
+ l10n_util::GetStringUTF16(IDS_KEYBOARD_OVERLAY_PASTE_AS_PLAIN_TEXT));
+ localized_strings.SetString("keyboardOverlayPrint",
+ l10n_util::GetStringUTF16(IDS_KEYBOARD_OVERLAY_PRINT));
+ localized_strings.SetString("keyboardOverlayReloadCurrentPage",
+ l10n_util::GetStringUTF16(IDS_KEYBOARD_OVERLAY_RELOAD_CURRENT_PAGE));
+ localized_strings.SetString("keyboardOverlayReopenLastClosedTab",
+ l10n_util::GetStringUTF16(IDS_KEYBOARD_OVERLAY_REOPEN_LAST_CLOSED_TAB));
+ localized_strings.SetString("keyboardOverlayResetZoom",
+ l10n_util::GetStringUTF16(IDS_KEYBOARD_OVERLAY_RESET_ZOOM));
+ localized_strings.SetString("keyboardOverlaySelectWordAtATime",
+ l10n_util::GetStringUTF16(IDS_KEYBOARD_OVERLAY_SELECT_WORD_AT_A_TIME));
+ localized_strings.SetString("keyboardOverlayToggleBookmarkBar",
+ l10n_util::GetStringUTF16(IDS_KEYBOARD_OVERLAY_TOGGLE_BOOKMARK_BAR));
+ localized_strings.SetString("keyboardOverlayViewSource",
+ l10n_util::GetStringUTF16(IDS_KEYBOARD_OVERLAY_VIEW_SOURCE));
+ localized_strings.SetString("keyboardOverlayZoomIn",
+ l10n_util::GetStringUTF16(IDS_KEYBOARD_OVERLAY_ZOOM_IN));
+ localized_strings.SetString("keyboardOverlayZoomOut",
+ l10n_util::GetStringUTF16(IDS_KEYBOARD_OVERLAY_ZOOM_OUT));
+ localized_strings.SetString("keyboardOverlayResetZoom",
+ l10n_util::GetStringUTF16(IDS_KEYBOARD_OVERLAY_RESET_ZOOM));
+ localized_strings.SetString("keyboardOverlayFocusAddressBarInSearchMode",
+ l10n_util::GetStringUTF16(
+ IDS_KEYBOARD_OVERLAY_FOCUS_ADDRESS_BAR_IN_SEARCH_MODE));
+ localized_strings.SetString("keyboardOverlayFullScreen",
+ l10n_util::GetStringUTF16(IDS_KEYBOARD_OVERLAY_FULL_SCREEN));
+ localized_strings.SetString("keyboardOverlayTakeScreenshot",
+ l10n_util::GetStringUTF16(IDS_KEYBOARD_OVERLAY_TAKE_SCREENSHOT));
+ localized_strings.SetString("keyboardOverlayHome",
+ l10n_util::GetStringUTF16(IDS_KEYBOARD_OVERLAY_HOME));
+ localized_strings.SetString("keyboardOverlayEnd",
+ l10n_util::GetStringUTF16(IDS_KEYBOARD_OVERLAY_END));
+ localized_strings.SetString("keyboardOverlayNextWindow",
+ l10n_util::GetStringUTF16(IDS_KEYBOARD_OVERLAY_NEXT_WINDOW));
+ localized_strings.SetString("keyboardOverlayContentBrowser",
+ l10n_util::GetStringUTF16(IDS_KEYBOARD_OVERLAY_CONTENT_BROWSER));
+ localized_strings.SetString("keyboardOverlayPageUp",
+ l10n_util::GetStringUTF16(IDS_KEYBOARD_OVERLAY_PAGE_UP));
+ localized_strings.SetString("keyboardOverlayPageDown",
+ l10n_util::GetStringUTF16(IDS_KEYBOARD_OVERLAY_PAGE_DOWN));
+ localized_strings.SetString("keyboardOverlayPreviousWindow",
+ l10n_util::GetStringUTF16(IDS_KEYBOARD_OVERLAY_PREVIOUS_WINDOW));
+ localized_strings.SetString("keyboardOverlayUseExternalMonitor",
+ l10n_util::GetStringUTF16(IDS_KEYBOARD_OVERLAY_USE_EXTERNAL_MONITOR));
+ localized_strings.SetString("keyboardOverlayReloadIgnoringCache",
+ l10n_util::GetStringUTF16(IDS_KEYBOARD_OVERLAY_RELOAD_IGNORING_CACHE));
+ localized_strings.SetString("keyboardOverlaySave",
+ l10n_util::GetStringUTF16(IDS_KEYBOARD_OVERLAY_SAVE));
+ localized_strings.SetString("keyboardOverlayScrollUpOnePage",
+ l10n_util::GetStringUTF16(IDS_KEYBOARD_OVERLAY_SCROLL_UP_ONE_PAGE));
+ localized_strings.SetString("keyboardOverlaySettings",
+ l10n_util::GetStringUTF16(IDS_KEYBOARD_OVERLAY_SETTINGS));
+ localized_strings.SetString("keyboardOverlaySignOut",
+ l10n_util::GetStringUTF16(IDS_KEYBOARD_OVERLAY_SIGN_OUT));
+ localized_strings.SetString("keyboardOverlayUndo",
+ l10n_util::GetStringUTF16(IDS_KEYBOARD_OVERLAY_UNDO));
+ localized_strings.SetString("keyboardOverlayWordMove",
+ l10n_util::GetStringUTF16(IDS_KEYBOARD_OVERLAY_WORD_MOVE));
+ localized_strings.SetString("keyboardOverlaySelectAll",
+ l10n_util::GetStringUTF16(IDS_KEYBOARD_OVERLAY_SELECT_ALL));
+ localized_strings.SetString("keyboardOverlaySelectPreviousInputMethod",
+ l10n_util::GetStringUTF16(
+ IDS_KEYBOARD_OVERLAY_SELECT_PREVIOUS_INPUT_METHOD));
+ localized_strings.SetString("keyboardOverlayCycleThroughInputMethods",
+ l10n_util::GetStringUTF16(
+ IDS_KEYBOARD_OVERLAY_CYCLE_THROUGH_INPUT_METHODS));
+ localized_strings.SetString("keyboardOverlayCloseWindow",
+ l10n_util::GetStringUTF16(IDS_KEYBOARD_OVERLAY_CLOSE_WINDOW));
+ localized_strings.SetString("keyboardOverlayViewKeyboardOverlay",
+ l10n_util::GetStringUTF16(IDS_KEYBOARD_OVERLAY_VIEW_KEYBOARD_OVERLAY));
+ localized_strings.SetString("keyboardOverlayCut",
+ l10n_util::GetStringUTF16(IDS_KEYBOARD_OVERLAY_CUT));
+ localized_strings.SetString("keyboardOverlayCopy",
+ l10n_util::GetStringUTF16(IDS_KEYBOARD_OVERLAY_COPY));
+ localized_strings.SetString("keyboardOverlayPaste",
+ l10n_util::GetStringUTF16(IDS_KEYBOARD_OVERLAY_PASTE));
+ localized_strings.SetString("keyboardOverlayHelp",
+ l10n_util::GetStringUTF16(IDS_KEYBOARD_OVERLAY_HELP));
+
+ static const base::StringPiece keyboard_overlay_html(
+ ResourceBundle::GetSharedInstance().GetRawDataResource(
+ IDR_KEYBOARD_OVERLAY_HTML));
+ const std::string full_html = jstemplate_builder::GetI18nTemplateHtml(
+ keyboard_overlay_html, &localized_strings);
+
+ scoped_refptr<RefCountedBytes> html_bytes(new RefCountedBytes);
+ html_bytes->data.resize(full_html.size());
+ std::copy(full_html.begin(), full_html.end(), html_bytes->data.begin());
+
+ SendResponse(request_id, html_bytes);
+}
+
+////////////////////////////////////////////////////////////////////////////////
+//
+// KeyboardOverlayHandler
+//
+////////////////////////////////////////////////////////////////////////////////
+KeyboardOverlayHandler::KeyboardOverlayHandler() {
+}
+
+KeyboardOverlayHandler::~KeyboardOverlayHandler() {
+}
+
+DOMMessageHandler* KeyboardOverlayHandler::Attach(DOMUI* dom_ui) {
+ return DOMMessageHandler::Attach(dom_ui);
+}
+
+void KeyboardOverlayHandler::RegisterMessages() {
+}
+
+////////////////////////////////////////////////////////////////////////////////
+//
+// KeyboardOverlayUI
+//
+////////////////////////////////////////////////////////////////////////////////
+
+KeyboardOverlayUI::KeyboardOverlayUI(TabContents* contents)
+ : HtmlDialogUI(contents) {
+ KeyboardOverlayHandler* handler = new KeyboardOverlayHandler();
+ AddMessageHandler((handler)->Attach(this));
+ KeyboardOverlayUIHTMLSource* html_source = new KeyboardOverlayUIHTMLSource();
+
+ // Set up the chrome://keyboardoverlay/ source.
+ BrowserThread::PostTask(
+ BrowserThread::IO, FROM_HERE,
+ NewRunnableMethod(
+ Singleton<ChromeURLDataManager>::get(),
+ &ChromeURLDataManager::AddDataSource,
+ make_scoped_refptr(html_source)));
+}
diff --git a/chrome/browser/chromeos/dom_ui/keyboard_overlay_ui.h b/chrome/browser/chromeos/dom_ui/keyboard_overlay_ui.h
new file mode 100644
index 0000000..8d112cf
--- /dev/null
+++ b/chrome/browser/chromeos/dom_ui/keyboard_overlay_ui.h
@@ -0,0 +1,24 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_CHROMEOS_DOM_UI_KEYBOARD_OVERLAY_UI_H_
+#define CHROME_BROWSER_CHROMEOS_DOM_UI_KEYBOARD_OVERLAY_UI_H_
+#pragma once
+
+#include <string>
+
+#include "chrome/browser/dom_ui/html_dialog_ui.h"
+
+class Browser;
+class Profile;
+
+class KeyboardOverlayUI : public HtmlDialogUI {
+ public:
+ explicit KeyboardOverlayUI(TabContents* contents);
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(KeyboardOverlayUI);
+};
+
+#endif // CHROME_BROWSER_CHROMEOS_DOM_UI_KEYBOARD_OVERLAY_UI_H_
diff --git a/chrome/browser/chromeos/dom_ui/labs_handler.cc b/chrome/browser/chromeos/dom_ui/labs_handler.cc
index 3a9a239..da605aa 100644
--- a/chrome/browser/chromeos/dom_ui/labs_handler.cc
+++ b/chrome/browser/chromeos/dom_ui/labs_handler.cc
@@ -31,11 +31,6 @@ void LabsHandler::GetLocalizedValues(
localized_strings->SetString("advanced_filesystem",
l10n_util::GetStringUTF16(IDS_OPTIONS_SETTINGS_ADVANCEDFS_DESCRIPTION));
- localized_strings->SetString("talk_title",
- l10n_util::GetStringUTF16(IDS_OPTIONS_SETTINGS_SECTION_TITLE_TALK));
- localized_strings->SetString("talk",
- l10n_util::GetStringUTF16(IDS_OPTIONS_SETTINGS_TALK_DESCRIPTION));
-
localized_strings->SetString("side_tabs_title",
l10n_util::GetStringUTF16(IDS_OPTIONS_SETTINGS_SECTION_TITLE_SIDE_TABS));
localized_strings->SetString("side_tabs",
diff --git a/chrome/browser/chromeos/dom_ui/language_options_handler.cc b/chrome/browser/chromeos/dom_ui/language_options_handler.cc
index 0ef8582..05570bc 100644
--- a/chrome/browser/chromeos/dom_ui/language_options_handler.cc
+++ b/chrome/browser/chromeos/dom_ui/language_options_handler.cc
@@ -12,7 +12,7 @@
#include "app/l10n_util.h"
#include "base/utf_string_conversions.h"
#include "base/values.h"
-#include "chrome/app/chrome_dll_resource.h"
+#include "chrome/app/chrome_command_ids.h"
#include "chrome/browser/browser.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chromeos/cros/cros_library.h"
@@ -56,8 +56,8 @@ void LanguageOptionsHandler::GetLocalizedValues(
localized_strings->SetString("ok_button", l10n_util::GetStringUTF16(IDS_OK));
localized_strings->SetString("remove_button",
l10n_util::GetStringUTF16(IDS_OPTIONS_SETTINGS_LANGUAGES_REMOVE_BUTTON));
- localized_strings->SetString("restart_button",
- l10n_util::GetStringUTF16(IDS_OPTIONS_SETTINGS_LANGUAGES_RESTART_BUTTON));
+ localized_strings->SetString("sign_out_button",
+ l10n_util::GetStringUTF16(IDS_OPTIONS_SETTINGS_LANGUAGES_SIGN_OUT_BUTTON));
localized_strings->SetString("add_language_instructions",
l10n_util::GetStringUTF16(
IDS_OPTIONS_SETTINGS_LANGUAGES_ADD_LANGUAGE_INSTRUCTIONS));
@@ -84,7 +84,7 @@ void LanguageOptionsHandler::GetLocalizedValues(
l10n_util::GetStringFUTF16(
IDS_OPTIONS_SETTINGS_LANGUAGES_DISPLAY_IN_THIS_LANGUAGE,
l10n_util::GetStringUTF16(IDS_PRODUCT_OS_NAME)));
- localized_strings->SetString("restart_required",
+ localized_strings->SetString("sign_out_required",
l10n_util::GetStringUTF16(IDS_OPTIONS_RESTART_REQUIRED));
localized_strings->SetString("this_language_is_currently_in_use",
l10n_util::GetStringFUTF16(
@@ -130,8 +130,8 @@ void LanguageOptionsHandler::RegisterMessages() {
&LanguageOptionsHandler::SpellCheckLanguageChangeCallback));
dom_ui_->RegisterMessageCallback("uiLanguageChange",
NewCallback(this, &LanguageOptionsHandler::UiLanguageChangeCallback));
- dom_ui_->RegisterMessageCallback("uiLanguageRestart",
- NewCallback(this, &LanguageOptionsHandler::RestartCallback));
+ dom_ui_->RegisterMessageCallback("uiLanguageSignOut",
+ NewCallback(this, &LanguageOptionsHandler::SignOutCallback));
}
ListValue* LanguageOptionsHandler::GetInputMethodList(
@@ -303,13 +303,11 @@ void LanguageOptionsHandler::SpellCheckLanguageChangeCallback(
UserMetrics::RecordComputedAction(action);
}
-void LanguageOptionsHandler::RestartCallback(const ListValue* args) {
- UserMetrics::RecordAction(UserMetricsAction("LanguageOptions_Restart"));
+void LanguageOptionsHandler::SignOutCallback(const ListValue* args) {
+ UserMetrics::RecordAction(UserMetricsAction("LanguageOptions_SignOut"));
Browser* browser = Browser::GetBrowserForController(
&dom_ui_->tab_contents()->controller(), NULL);
- // TODO(kochi): For ChromiumOS, just exiting means browser restart.
- // Implement browser restart for Chromium Win/Linux/Mac.
if (browser)
browser->ExecuteCommand(IDC_EXIT);
}
diff --git a/chrome/browser/chromeos/dom_ui/language_options_handler.h b/chrome/browser/chromeos/dom_ui/language_options_handler.h
index bd1c78a..ecb8d34 100644
--- a/chrome/browser/chromeos/dom_ui/language_options_handler.h
+++ b/chrome/browser/chromeos/dom_ui/language_options_handler.h
@@ -84,8 +84,8 @@ class LanguageOptionsHandler : public OptionsPageUIHandler {
// |args| will contain the language code as string (ex. "fr").
void SpellCheckLanguageChangeCallback(const ListValue* args);
- // Called when the restart button is clicked.
- void RestartCallback(const ListValue* args);
+ // Called when the sign out button is clicked.
+ void SignOutCallback(const ListValue* args);
DISALLOW_COPY_AND_ASSIGN(LanguageOptionsHandler);
};
diff --git a/chrome/browser/chromeos/dom_ui/menu_ui.cc b/chrome/browser/chromeos/dom_ui/menu_ui.cc
index d7a73b8..8ffd2a8 100644
--- a/chrome/browser/chromeos/dom_ui/menu_ui.cc
+++ b/chrome/browser/chromeos/dom_ui/menu_ui.cc
@@ -26,7 +26,6 @@
#include "chrome/common/url_constants.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/jstemplate_builder.h"
-#include "chrome/common/net/url_fetcher.h"
#include "gfx/canvas_skia.h"
#include "gfx/favicon_size.h"
#include "gfx/font.h"
@@ -125,7 +124,7 @@ const std::string& GetImageDataUrlForRadio(bool on) {
* same source/css files.
*/
std::string GetMenuUIHTMLSourceFromString(
- const chromeos::MenuUI& menu_ui,
+ const chromeos::MenuSourceDelegate* delegate,
const base::StringPiece& menu_template,
const std::string& menu_class,
int menu_source_id,
@@ -170,7 +169,8 @@ std::string GetMenuUIHTMLSourceFromString(
SET_INTEGER_PROPERTY(scroll_arrow_height);
SET_INTEGER_PROPERTY(label_to_accelerator_padding);
- menu_ui.AddCustomConfigValues(&value_config);
+ if (delegate)
+ delegate->AddCustomConfigValues(&value_config);
std::string json_config;
base::JSONWriter::Write(&value_config, false, &json_config);
@@ -196,16 +196,15 @@ std::string GetMenuUIHTMLSourceFromString(
ResourceBundle::GetSharedInstance().GetRawDataResource(menu_css_id));
strings.SetString("menu_css", menu_css.as_string());
}
-
- menu_ui.AddLocalizedStrings(&strings);
+ if (delegate)
+ delegate->AddLocalizedStrings(&strings);
return jstemplate_builder::GetI18nTemplateHtml(menu_template, &strings);
}
-class MenuUIHTMLSource : public ChromeURLDataManager::DataSource,
- public URLFetcher::Delegate {
+class MenuUIHTMLSource : public ChromeURLDataManager::DataSource {
public:
- MenuUIHTMLSource(const chromeos::MenuUI& menu_ui,
+ MenuUIHTMLSource(const chromeos::MenuSourceDelegate* delegate,
const std::string& source_name,
const std::string& menu_class,
int menu_source_id,
@@ -220,19 +219,11 @@ class MenuUIHTMLSource : public ChromeURLDataManager::DataSource,
return "text/html";
}
- // URLFetcher::Delegate implements:
- virtual void OnURLFetchComplete(const URLFetcher* source,
- const GURL& url,
- const URLRequestStatus& status,
- int response_code,
- const ResponseCookies& cookies,
- const std::string& data);
-
private:
virtual ~MenuUIHTMLSource() {}
// The menu ui the source is created for.
- const chromeos::MenuUI& menu_ui_;
+ scoped_ptr<const chromeos::MenuSourceDelegate> delegate_;
// The name of JS Menu class to use.
const std::string menu_class_;
@@ -243,9 +234,6 @@ class MenuUIHTMLSource : public ChromeURLDataManager::DataSource,
// The resource id of the CSS file of the menu subclass.
int menu_css_id_;
-#ifndef NDEBUG
- int request_id_;
-#endif
DISALLOW_COPY_AND_ASSIGN(MenuUIHTMLSource);
};
@@ -317,45 +305,30 @@ class MenuHandler : public chromeos::MenuHandlerBase,
//
////////////////////////////////////////////////////////////////////////////////
-MenuUIHTMLSource::MenuUIHTMLSource(const chromeos::MenuUI& menu_ui,
+MenuUIHTMLSource::MenuUIHTMLSource(const chromeos::MenuSourceDelegate* delegate,
const std::string& source_name,
const std::string& menu_class,
int menu_source_id,
int menu_css_id)
: DataSource(source_name, MessageLoop::current()),
- menu_ui_(menu_ui),
+ delegate_(delegate),
menu_class_(menu_class),
menu_source_id_(menu_source_id),
menu_css_id_(menu_css_id)
-#ifndef NDEBUG
- , request_id_(-1)
-#endif
{
- // Important !
- // Don't call any method on menu_ui. MenuUI object is not yet initialized
}
void MenuUIHTMLSource::StartDataRequest(const std::string& path,
bool is_off_the_record,
int request_id) {
-#ifndef NDEBUG
- std::string url = CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
- switches::kDOMUIMenuUrl);
- if (!url.empty()) {
- request_id_ = request_id;
- URLFetcher* fetcher = new URLFetcher(GURL(url), URLFetcher::GET, this);
- fetcher->set_request_context(menu_ui_.GetProfile()->GetRequestContext());
- fetcher->Start();
- return;
- }
-#endif
static const base::StringPiece menu_template(
ResourceBundle::GetSharedInstance().GetRawDataResource(IDR_MENU_HTML));
// The resource string should be pure code and should not contain
// i18n string.
const std::string menu_html = GetMenuUIHTMLSourceFromString(
- menu_ui_, menu_template, menu_class_, menu_source_id_, menu_css_id_);
+ delegate_.get(), menu_template, menu_class_,
+ menu_source_id_, menu_css_id_);
scoped_refptr<RefCountedBytes> html_bytes(new RefCountedBytes);
@@ -366,30 +339,6 @@ void MenuUIHTMLSource::StartDataRequest(const std::string& path,
SendResponse(request_id, html_bytes);
}
-void MenuUIHTMLSource::OnURLFetchComplete(const URLFetcher* source,
- const GURL& url,
- const URLRequestStatus& status,
- int response_code,
- const ResponseCookies& cookies,
- const std::string& data) {
-#ifndef NDEBUG
- // This should not be called in release build.
- const std::string menu_html = GetMenuUIHTMLSourceFromString(
- menu_ui_, data, menu_class_, menu_source_id_, menu_css_id_);
-
- scoped_refptr<RefCountedBytes> html_bytes(new RefCountedBytes);
-
- // TODO(oshima): Eliminate boilerplate code. See http://crbug.com/57583 .
- html_bytes->data.resize(menu_html.size());
- std::copy(menu_html.begin(), menu_html.end(),
- html_bytes->data.begin());
- SendResponse(request_id_, html_bytes);
-
- delete source;
-#endif
-}
-
-
////////////////////////////////////////////////////////////////////////////////
//
// MenuHandler
@@ -639,9 +588,6 @@ void MenuUI::ModelUpdated(const menus::MenuModel* model) {
break;
default:
// TODO(oshima): We don't support BUTTOM_ITEM for now.
- // I haven't decided how to implement zoom/cut&paste
- // stuff, but may do somethign similar to what linux_views
- // does.
NOTREACHED();
continue;
}
@@ -689,12 +635,12 @@ DictionaryValue* MenuUI::CreateMenuItem(const menus::MenuModel* model,
// static
ChromeURLDataManager::DataSource* MenuUI::CreateMenuUIHTMLSource(
- const MenuUI& menu_ui,
+ const MenuSourceDelegate* delegate,
const std::string& source_name,
const std::string& menu_class,
int menu_source_id,
int menu_css_id) {
- return new MenuUIHTMLSource(menu_ui,
+ return new MenuUIHTMLSource(delegate,
source_name,
menu_class,
menu_source_id,
@@ -703,12 +649,12 @@ ChromeURLDataManager::DataSource* MenuUI::CreateMenuUIHTMLSource(
// static
bool MenuUI::IsEnabled() {
- return !CommandLine::ForCurrentProcess()->HasSwitch(
- switches::kDisableDOMUIMenu);
+ return CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kEnableDOMUIMenu);
}
ChromeURLDataManager::DataSource* MenuUI::CreateDataSource() {
- return CreateMenuUIHTMLSource(*this,
+ return CreateMenuUIHTMLSource(NULL,
chrome::kChromeUIMenu,
"Menu" /* class name */,
kNoExtraResource,
diff --git a/chrome/browser/chromeos/dom_ui/menu_ui.h b/chrome/browser/chromeos/dom_ui/menu_ui.h
index 151c324..9f8c5db 100644
--- a/chrome/browser/chromeos/dom_ui/menu_ui.h
+++ b/chrome/browser/chromeos/dom_ui/menu_ui.h
@@ -21,6 +21,20 @@ namespace chromeos {
class DOMUIMenuControl;
+// MenuSourceDelegate class allows subclass to injects specific values
+// to menu javascript code.
+class MenuSourceDelegate {
+ public:
+ virtual ~MenuSourceDelegate() {}
+ // Subclass can add extra parameters or replaces default configuration.
+ virtual void AddCustomConfigValues(DictionaryValue* config) const {};
+
+ // Subclass can add their values to |localized_strings| and those values
+ // are used by JS template builder and could be accessed via JS class
+ // LocalStrings.
+ virtual void AddLocalizedStrings(DictionaryValue* localized_strings) const {}
+};
+
class MenuUI : public DOMUI {
public:
explicit MenuUI(TabContents* contents);
@@ -36,21 +50,11 @@ class MenuUI : public DOMUI {
int* max_icon_width,
bool* has_accel) const;
- // Subclass can add extra parameters or replaces default configuration.
- virtual void AddCustomConfigValues(DictionaryValue* config) const {};
-
- // Subclass can add their values to |localized_strings| and those values
- // are used by JS template builder and could be accessed via JS class
- // LocalStrings.
- virtual void AddLocalizedStrings(DictionaryValue* localized_strings) const {};
-
// A utility function which creates a concrete html file from
// template file |menu_resource_id| and |menu_css_id| for given |menu_class|.
// The resource_name is the host part of DOMUI's url.
- // Caution: This calls MenuUI::GetProfile() when creating the data source,
- // thus, it has to be initialized.
static ChromeURLDataManager::DataSource* CreateMenuUIHTMLSource(
- const MenuUI& menu_ui,
+ const MenuSourceDelegate* delegate,
const std::string& source_name,
const std::string& menu_class,
int menu_source_res_id,
diff --git a/chrome/browser/chromeos/dom_ui/mobile_setup_ui.cc b/chrome/browser/chromeos/dom_ui/mobile_setup_ui.cc
index 879d333..d021ab3 100644
--- a/chrome/browser/chromeos/dom_ui/mobile_setup_ui.cc
+++ b/chrome/browser/chromeos/dom_ui/mobile_setup_ui.cc
@@ -1,9 +1,10 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2006-2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/chromeos/dom_ui/mobile_setup_ui.h"
+#include <algorithm>
#include <map>
#include <string>
@@ -12,6 +13,7 @@
#include "base/callback.h"
#include "base/file_util.h"
#include "base/json/json_reader.h"
+#include "base/json/json_writer.h"
#include "base/logging.h"
#include "base/string_piece.h"
#include "base/string_util.h"
@@ -26,8 +28,11 @@
#include "chrome/browser/chromeos/cros/network_library.h"
#include "chrome/browser/chromeos/cros/system_library.h"
#include "chrome/browser/dom_ui/chrome_url_data_manager.h"
+#include "chrome/browser/prefs/pref_service.h"
+#include "chrome/browser/profile.h"
#include "chrome/browser/tab_contents/tab_contents.h"
#include "chrome/common/jstemplate_builder.h"
+#include "chrome/common/pref_names.h"
#include "chrome/common/url_constants.h"
#include "googleurl/src/gurl.h"
#include "grit/browser_resources.h"
@@ -38,21 +43,12 @@
namespace {
// Host page JS API function names.
+const char kJsApiStartActivation[] = "startActivation";
const char kJsApiCloseTab[] = "closeTab";
const char kJsApiSetTransactionStatus[] = "setTransactionStatus";
const wchar_t kJsDeviceStatusChangedHandler[] =
- L"handler.MobileSetup.deviceStateChanged";
-
-// Collular device states that are reported to DOM UI layer.
-const char kStateUnknown[] = "unknown";
-const char kStateConnecting[] = "connecting";
-const char kStateError[] = "error";
-const char kStateNeedsPayment[] = "payment";
-const char kStateActivating[] = "activating";
-const char kStateDisconnected[] = "disconnected";
-const char kStateConnected[] = "connected";
-const char kFailedPayment[] = "failed_payment";
+ L"mobile.MobileSetup.deviceStateChanged";
// Error codes matching codes defined in the cellular config file.
const char kErrorDefault[] = "default";
@@ -73,6 +69,20 @@ const char kCellularConfigPath[] =
const char kVersionField[] = "version";
const char kErrorsField[] = "errors";
+chromeos::CellularNetwork* GetCellularNetwork() {
+ chromeos::NetworkLibrary* lib = chromeos::CrosLibrary::Get()->
+ GetNetworkLibrary();
+ if (lib->cellular_networks().begin() != lib->cellular_networks().end()) {
+ return *(lib->cellular_networks().begin());
+ }
+ return NULL;
+}
+
+chromeos::CellularNetwork* GetCellularNetwork(const std::string& service_path) {
+ return chromeos::CrosLibrary::Get()->
+ GetNetworkLibrary()->FindCellularNetworkByPath(service_path);
+}
+
} // namespace
class CellularConfigDocument {
@@ -96,7 +106,7 @@ static std::map<std::string, std::string> error_messages_;
class MobileSetupUIHTMLSource : public ChromeURLDataManager::DataSource {
public:
- MobileSetupUIHTMLSource();
+ explicit MobileSetupUIHTMLSource(const std::string& service_path);
// Called when the network layer has requested a resource underneath
// the path we registered.
@@ -108,17 +118,20 @@ class MobileSetupUIHTMLSource : public ChromeURLDataManager::DataSource {
}
private:
- ~MobileSetupUIHTMLSource() {}
+ virtual ~MobileSetupUIHTMLSource() {}
+ std::string service_path_;
DISALLOW_COPY_AND_ASSIGN(MobileSetupUIHTMLSource);
};
// The handler for Javascript messages related to the "register" view.
-class MobileSetupHandler : public DOMMessageHandler,
- public chromeos::NetworkLibrary::Observer,
- public base::SupportsWeakPtr<MobileSetupHandler> {
+class MobileSetupHandler
+ : public DOMMessageHandler,
+ public chromeos::NetworkLibrary::NetworkManagerObserver,
+ public chromeos::NetworkLibrary::NetworkObserver,
+ public base::SupportsWeakPtr<MobileSetupHandler> {
public:
- MobileSetupHandler();
+ explicit MobileSetupHandler(const std::string& service_path);
virtual ~MobileSetupHandler();
// Init work after Attach.
@@ -128,34 +141,103 @@ class MobileSetupHandler : public DOMMessageHandler,
virtual DOMMessageHandler* Attach(DOMUI* dom_ui);
virtual void RegisterMessages();
- // NetworkLibrary::Observer implementation.
- virtual void NetworkChanged(chromeos::NetworkLibrary* obj);
+ // NetworkLibrary::NetworkManagerObserver implementation.
+ virtual void OnNetworkManagerChanged(chromeos::NetworkLibrary* obj);
+ // NetworkLibrary::NetworkObserver implementation.
+ virtual void OnNetworkChanged(chromeos::NetworkLibrary* obj,
+ const chromeos::Network* network);
private:
+ typedef enum PlanActivationState {
+ PLAN_ACTIVATION_PAGE_LOADING = -1,
+ PLAN_ACTIVATION_START = 0,
+ PLAN_ACTIVATION_INITIATING_ACTIVATION = 1,
+ PLAN_ACTIVATION_RECONNECTING = 2,
+ PLAN_ACTIVATION_SHOWING_PAYMENT = 3,
+ PLAN_ACTIVATION_DONE = 4,
+ PLAN_ACTIVATION_ERROR = 5,
+ } PlanActivationState;
+
+ class TaskProxy : public base::RefCountedThreadSafe<TaskProxy> {
+ public:
+ explicit TaskProxy(const base::WeakPtr<MobileSetupHandler>& handler)
+ : handler_(handler) {
+ }
+ TaskProxy(const base::WeakPtr<MobileSetupHandler>& handler,
+ const std::string& status)
+ : handler_(handler), status_(status) {
+ }
+ void HandleStartActivation() {
+ if (handler_)
+ handler_->StartActivation();
+ }
+ void HandleSetTransactionStatus() {
+ if (handler_)
+ handler_->SetTransactionStatus(status_);
+ }
+ private:
+ base::WeakPtr<MobileSetupHandler> handler_;
+ std::string status_;
+ DISALLOW_COPY_AND_ASSIGN(TaskProxy);
+ };
+
// Handlers for JS DOMUI messages.
void HandleCloseTab(const ListValue* args);
void HandleSetTransactionStatus(const ListValue* args);
+ void HandleStartActivation(const ListValue* args);
+ void SetTransactionStatus(const std::string& status);
+ void StartActivation();
// Sends message to host registration page with system/user info data.
void SendDeviceInfo();
+ // Verify the state of cellular network and modify internal state.
+ void EvaluateCellularNetwork(chromeos::CellularNetwork* network);
+ // Check the current cellular network for error conditions.
+ bool GotActivationError(const chromeos::CellularNetwork* network,
+ std::string* error);
+ void ChangeState(chromeos::CellularNetwork* network,
+ PlanActivationState new_state,
+ const std::string& error_description);
+ // Prepares network devices for cellular activation process.
+ void SetupActivationProcess(chromeos::CellularNetwork* network);
+ // Resets network devices after cellular activation process.
+ // |network| should be NULL if the activation process failed.
+ void CompleteActivation(chromeos::CellularNetwork* network);
+ // Control routines for handling other types of connections during
+ // cellular activation.
+ void ReEnableOtherConnections();
+
// Converts the currently active CellularNetwork device into a JS object.
- static bool GetDeviceInfo(DictionaryValue* value);
+ static void GetDeviceInfo(const chromeos::CellularNetwork* network,
+ DictionaryValue* value);
static bool ShouldReportDeviceState(std::string* state, std::string* error);
// Performs activation state cellular device evaluation.
// Returns false if device activation failed. In this case |error|
// will contain error message to be reported to DOM UI.
- static bool CheckForActivationError(chromeos::CellularNetwork network,
- std::string* error);
+ static bool EvaluateCellularDeviceState(bool* report_status,
+ std::string* state,
+ std::string* error);
// Return error message for a given code.
static std::string GetErrorMessage(const std::string& code);
static void LoadCellularConfig();
+ static const char* GetStateDescription(PlanActivationState state);
+
static scoped_ptr<CellularConfigDocument> cellular_config_;
TabContents* tab_contents_;
+ // Internal handler state.
+ PlanActivationState state_;
+ std::string service_path_;
+ // Flags that control if wifi and ethernet connection needs to be restored
+ // after the activation of cellular network.
+ bool reenable_wifi_;
+ bool reenable_ethernet_;
+ bool reenable_cert_check_;
+ bool transaction_complete_signalled_;
DISALLOW_COPY_AND_ASSIGN(MobileSetupHandler);
};
@@ -184,13 +266,13 @@ bool CellularConfigDocument::LoadFromFile(const FilePath& config_path) {
scoped_ptr<Value> root(base::JSONReader::Read(config, true));
DCHECK(root.get() != NULL);
if (!root.get() || root->GetType() != Value::TYPE_DICTIONARY) {
- VLOG(1) << "Bad cellular config file";
+ LOG(WARNING) << "Bad cellular config file";
return false;
}
DictionaryValue* root_dict = static_cast<DictionaryValue*>(root.get());
if (!root_dict->GetString(kVersionField, &version_)) {
- VLOG(1) << "Cellular config file missing version";
+ LOG(WARNING) << "Cellular config file missing version";
return false;
}
DictionaryValue* errors = NULL;
@@ -201,7 +283,7 @@ bool CellularConfigDocument::LoadFromFile(const FilePath& config_path) {
++keys) {
std::string value;
if (!errors->GetString(*keys, &value)) {
- VLOG(1) << "Bad cellular config error value";
+ LOG(WARNING) << "Bad cellular config error value";
error_map_.clear();
return false;
}
@@ -217,17 +299,22 @@ bool CellularConfigDocument::LoadFromFile(const FilePath& config_path) {
//
////////////////////////////////////////////////////////////////////////////////
-MobileSetupUIHTMLSource::MobileSetupUIHTMLSource()
- : DataSource(chrome::kChromeUIMobileSetupHost, MessageLoop::current()) {
+MobileSetupUIHTMLSource::MobileSetupUIHTMLSource(
+ const std::string& service_path)
+ : DataSource(chrome::kChromeUIMobileSetupHost, MessageLoop::current()),
+ service_path_(service_path) {
}
void MobileSetupUIHTMLSource::StartDataRequest(const std::string& path,
bool is_off_the_record,
int request_id) {
+ const chromeos::CellularNetwork* network = GetCellularNetwork(service_path_);
+
DictionaryValue strings;
strings.SetString("title", l10n_util::GetStringUTF16(IDS_MOBILE_SETUP_TITLE));
strings.SetString("connecting_header",
- l10n_util::GetStringUTF16(IDS_MOBILE_CONNECTING_HEADER));
+ l10n_util::GetStringFUTF16(IDS_MOBILE_CONNECTING_HEADER,
+ network ? UTF8ToUTF16(network->name()) : string16()));
strings.SetString("error_header",
l10n_util::GetStringUTF16(IDS_MOBILE_ERROR_HEADER));
strings.SetString("activating_header",
@@ -256,11 +343,22 @@ void MobileSetupUIHTMLSource::StartDataRequest(const std::string& path,
// MobileSetupHandler
//
////////////////////////////////////////////////////////////////////////////////
-MobileSetupHandler::MobileSetupHandler() : tab_contents_(NULL) {
+MobileSetupHandler::MobileSetupHandler(const std::string& service_path)
+ : tab_contents_(NULL),
+ state_(PLAN_ACTIVATION_PAGE_LOADING),
+ service_path_(service_path),
+ reenable_wifi_(false),
+ reenable_ethernet_(false),
+ reenable_cert_check_(false),
+ transaction_complete_signalled_(false) {
}
MobileSetupHandler::~MobileSetupHandler() {
- chromeos::CrosLibrary::Get()->GetNetworkLibrary()->RemoveObserver(this);
+ chromeos::NetworkLibrary* lib =
+ chromeos::CrosLibrary::Get()->GetNetworkLibrary();
+ lib->RemoveNetworkManagerObserver(this);
+ lib->RemoveObserverForAllNetworks(this);
+ ReEnableOtherConnections();
}
DOMMessageHandler* MobileSetupHandler::Attach(DOMUI* dom_ui) {
@@ -269,149 +367,418 @@ DOMMessageHandler* MobileSetupHandler::Attach(DOMUI* dom_ui) {
void MobileSetupHandler::Init(TabContents* contents) {
tab_contents_ = contents;
- chromeos::CrosLibrary::Get()->GetNetworkLibrary()->AddObserver(this);
-
- // TODO(zelidrag): We might want to move this to another thread.
LoadCellularConfig();
+ SetupActivationProcess(GetCellularNetwork(service_path_));
}
void MobileSetupHandler::RegisterMessages() {
+ dom_ui_->RegisterMessageCallback(kJsApiStartActivation,
+ NewCallback(this, &MobileSetupHandler::HandleStartActivation));
dom_ui_->RegisterMessageCallback(kJsApiCloseTab,
NewCallback(this, &MobileSetupHandler::HandleCloseTab));
dom_ui_->RegisterMessageCallback(kJsApiSetTransactionStatus,
NewCallback(this, &MobileSetupHandler::HandleSetTransactionStatus));
}
-void MobileSetupHandler::NetworkChanged(chromeos::NetworkLibrary* cros) {
- if (!dom_ui_)
- return;
- DictionaryValue device;
- GetDeviceInfo(&device);
- std::string state, error;
- if (!ShouldReportDeviceState(&state, &error))
+void MobileSetupHandler::OnNetworkManagerChanged(
+ chromeos::NetworkLibrary* cros) {
+ if (state_ == PLAN_ACTIVATION_PAGE_LOADING)
return;
+ // Note that even though we get here when the service has
+ // reappeared after disappearing earlier in the activation
+ // process, there's no need to re-establish the NetworkObserver,
+ // because the service path remains the same.
+ EvaluateCellularNetwork(GetCellularNetwork(service_path_));
+}
- device.SetString("state", state);
- if (error.length())
- device.SetString("error", error);
- dom_ui_->CallJavascriptFunction(
- kJsDeviceStatusChangedHandler, device);
+void MobileSetupHandler::OnNetworkChanged(chromeos::NetworkLibrary* cros,
+ const chromeos::Network* network) {
+ if (state_ == PLAN_ACTIVATION_PAGE_LOADING)
+ return;
+ DCHECK(network && network->type() == chromeos::TYPE_CELLULAR);
+ EvaluateCellularNetwork(
+ static_cast<chromeos::CellularNetwork*>(
+ const_cast<chromeos::Network*>(network)));
}
void MobileSetupHandler::HandleCloseTab(const ListValue* args) {
- Browser* browser = BrowserList::GetLastActive();
+ if (!dom_ui_)
+ return;
+ Browser* browser = BrowserList::FindBrowserWithFeature(
+ dom_ui_->GetProfile(), Browser::FEATURE_TABSTRIP);
if (browser)
browser->CloseTabContents(tab_contents_);
}
+void MobileSetupHandler::HandleStartActivation(const ListValue* args) {
+ scoped_refptr<TaskProxy> task = new TaskProxy(AsWeakPtr());
+ BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
+ NewRunnableMethod(task.get(), &TaskProxy::HandleStartActivation));
+}
+
void MobileSetupHandler::HandleSetTransactionStatus(const ListValue* args) {
const size_t kSetTransactionStatusParamCount = 1;
if (args->GetSize() != kSetTransactionStatusParamCount)
return;
-
// Get change callback function name.
std::string status;
if (!args->GetString(0, &status))
return;
+ scoped_refptr<TaskProxy> task = new TaskProxy(AsWeakPtr(), status);
+ BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
+ NewRunnableMethod(task.get(), &TaskProxy::HandleSetTransactionStatus));
+}
- chromeos::NetworkLibrary* network_lib =
- chromeos::CrosLibrary::Get()->GetNetworkLibrary();
- const chromeos::CellularNetworkVector& cell_networks =
- network_lib->cellular_networks();
- if (!cell_networks.size())
+void MobileSetupHandler::StartActivation() {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ chromeos::CellularNetwork* network = GetCellularNetwork(service_path_);
+ if (!network) {
+ ChangeState(NULL, PLAN_ACTIVATION_ERROR, std::string());
return;
+ }
+ // Start monitoring network property changes.
+ chromeos::NetworkLibrary* lib =
+ chromeos::CrosLibrary::Get()->GetNetworkLibrary();
+ lib->AddNetworkManagerObserver(this);
+ lib->RemoveObserverForAllNetworks(this);
+ lib->AddNetworkObserver(network->service_path(), this);
+ state_ = PLAN_ACTIVATION_START;
+ EvaluateCellularNetwork(network);
+}
- // We assume only one cellular network will come from flimflam for now.
- const chromeos::CellularNetwork& network = *(cell_networks.begin());
+void MobileSetupHandler::SetTransactionStatus(const std::string& status) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ // The payment is received, try to reconnect and check the status all over
+ // again.
+ if (LowerCaseEqualsASCII(status, "ok") &&
+ state_ == PLAN_ACTIVATION_SHOWING_PAYMENT) {
+ if (transaction_complete_signalled_) {
+ LOG(WARNING) << "Transaction completion signaled more than once!?";
+ return;
+ }
+ transaction_complete_signalled_ = true;
+ state_ = PLAN_ACTIVATION_START;
+ chromeos::CellularNetwork* network = GetCellularNetwork();
+ if (network &&
+ network->activation_state() == chromeos::ACTIVATION_STATE_ACTIVATED) {
+ chromeos::CrosLibrary::Get()->GetNetworkLibrary()->
+ DisconnectFromWirelessNetwork(network);
+ } else {
+ EvaluateCellularNetwork(network);
+ }
+ }
+}
+
+void MobileSetupHandler::EvaluateCellularNetwork(
+ chromeos::CellularNetwork* network) {
+ if (!dom_ui_)
+ return;
- if (LowerCaseEqualsASCII(status, "OK")) {
- network.StartActivation();
+ PlanActivationState new_state = state_;
+ if (network) {
+ LOG(INFO) << "Cellular:\n service=" << network->GetStateString().c_str()
+ << "\n ui=" << GetStateDescription(state_)
+ << "\n activation=" << network->GetActivationStateString().c_str()
+ << "\n restricted=" << (network->restricted_pool() ? "yes" : "no")
+ << "\n error=" << network->GetErrorString().c_str()
+ << "\n setvice_path=" << network->service_path().c_str();
} else {
- DictionaryValue value;
- value.SetString("state", kFailedPaymentError);
- dom_ui_->CallJavascriptFunction(kJsDeviceStatusChangedHandler, value);
+ LOG(WARNING) << "Cellular service lost";
}
+ switch (state_) {
+ case PLAN_ACTIVATION_START:
+ if (network) {
+ switch (network->activation_state()) {
+ case chromeos::ACTIVATION_STATE_ACTIVATED:
+ if (network->failed_or_disconnected()) {
+ new_state = PLAN_ACTIVATION_RECONNECTING;
+ } else if (network->connection_state() == chromeos::STATE_READY) {
+ if (network->restricted_pool()) {
+ new_state = PLAN_ACTIVATION_SHOWING_PAYMENT;
+ } else {
+ new_state = PLAN_ACTIVATION_DONE;
+ }
+ }
+ break;
+ case chromeos::ACTIVATION_STATE_UNKNOWN:
+ case chromeos::ACTIVATION_STATE_NOT_ACTIVATED:
+ case chromeos::ACTIVATION_STATE_PARTIALLY_ACTIVATED:
+ if (network->failed_or_disconnected()) {
+ new_state = PLAN_ACTIVATION_INITIATING_ACTIVATION;
+ } else if (network->connected()) {
+ LOG(INFO) << "Disconnecting from " <<
+ network->service_path().c_str();
+ chromeos::CrosLibrary::Get()->GetNetworkLibrary()->
+ DisconnectFromWirelessNetwork(network);
+ // Disconnect will force networks to be reevaluated, so
+ // we don't want to continue processing on this path anymore.
+ return;
+ }
+ break;
+ default:
+ new_state = PLAN_ACTIVATION_INITIATING_ACTIVATION;
+ break;
+ }
+ }
+ break;
+ case PLAN_ACTIVATION_INITIATING_ACTIVATION:
+ if (network) {
+ switch (network->activation_state()) {
+ case chromeos::ACTIVATION_STATE_ACTIVATED:
+ if (network->failed_or_disconnected()) {
+ new_state = PLAN_ACTIVATION_RECONNECTING;
+ } else if (network->connection_state() == chromeos::STATE_READY) {
+ if (network->restricted_pool()) {
+ new_state = PLAN_ACTIVATION_SHOWING_PAYMENT;
+ } else {
+ new_state = PLAN_ACTIVATION_DONE;
+ }
+ }
+ break;
+ case chromeos::ACTIVATION_STATE_PARTIALLY_ACTIVATED:
+ if (network->connected())
+ new_state = PLAN_ACTIVATION_SHOWING_PAYMENT;
+ else
+ new_state = PLAN_ACTIVATION_RECONNECTING;
+ break;
+ case chromeos::ACTIVATION_STATE_NOT_ACTIVATED:
+ // Wait in this state until activation state changes.
+ break;
+ case chromeos::ACTIVATION_STATE_ACTIVATING:
+ break;
+ default:
+ break;
+ }
+ }
+ break;
+ case PLAN_ACTIVATION_RECONNECTING:
+ // Wait until the service shows up and gets activated.
+ if (network) {
+ switch (network->activation_state()) {
+ case chromeos::ACTIVATION_STATE_ACTIVATED:
+ if (network->connection_state() == chromeos::STATE_READY) {
+ if (network->restricted_pool()) {
+ new_state = PLAN_ACTIVATION_SHOWING_PAYMENT;
+ } else {
+ new_state = PLAN_ACTIVATION_DONE;
+ }
+ }
+ break;
+ case chromeos::ACTIVATION_STATE_PARTIALLY_ACTIVATED:
+ if (network->connected()) {
+ if (network->restricted_pool())
+ new_state = PLAN_ACTIVATION_SHOWING_PAYMENT;
+ }
+ break;
+ default:
+ break;
+ }
+ }
+ break;
+ case PLAN_ACTIVATION_PAGE_LOADING:
+ break;
+ // Just ignore all signals until the site confirms payment.
+ case PLAN_ACTIVATION_SHOWING_PAYMENT:
+ // Activation completed/failed, ignore network changes.
+ case PLAN_ACTIVATION_DONE:
+ case PLAN_ACTIVATION_ERROR:
+ break;
+ }
+
+ std::string error_description;
+ if (GotActivationError(network, &error_description)) {
+ new_state = PLAN_ACTIVATION_ERROR;
+ }
+ ChangeState(network, new_state, error_description);
}
-bool MobileSetupHandler::ShouldReportDeviceState(std::string* state,
- std::string* error) {
- DCHECK(state);
- DCHECK(error);
- chromeos::NetworkLibrary* network_lib =
- chromeos::CrosLibrary::Get()->GetNetworkLibrary();
+// Debugging helper function, will take it out at the end.
+const char* MobileSetupHandler::GetStateDescription(
+ PlanActivationState state) {
+ switch (state) {
+ case PLAN_ACTIVATION_PAGE_LOADING:
+ return "PAGE_LOADING";
+ case PLAN_ACTIVATION_START:
+ return "ACTIVATION_START";
+ case PLAN_ACTIVATION_INITIATING_ACTIVATION:
+ return "INITIATING_ACTIVATION";
+ case PLAN_ACTIVATION_RECONNECTING:
+ return "RECONNECTING";
+ case PLAN_ACTIVATION_SHOWING_PAYMENT:
+ return "SHOWING_PAYMENT";
+ case PLAN_ACTIVATION_DONE:
+ return "DONE";
+ case PLAN_ACTIVATION_ERROR:
+ return "ERROR";
+ }
+ return "UNKNOWN";
+}
+
+
+void MobileSetupHandler::CompleteActivation(
+ chromeos::CellularNetwork* network) {
+ // Remove observers, we are done with this page.
+ chromeos::NetworkLibrary* lib = chromeos::CrosLibrary::Get()->
+ GetNetworkLibrary();
+ // If we have successfully activated the connection, set autoconnect flag.
+ if (network) {
+ network->set_auto_connect(true);
+ lib->SaveCellularNetwork(network);
+ }
+ lib->RemoveNetworkManagerObserver(this);
+ lib->RemoveObserverForAllNetworks(this);
+ // Reactivate other types of connections if we have
+ // shut them down previously.
+ ReEnableOtherConnections();
+}
+
+
+void MobileSetupHandler::ChangeState(chromeos::CellularNetwork* network,
+ PlanActivationState new_state,
+ const std::string& error_description) {
+ static bool first_time = true;
+ if (state_ == new_state && !first_time)
+ return;
+ LOG(INFO) << "Activation state flip old = " <<
+ GetStateDescription(state_) << ", new = " <<
+ GetStateDescription(new_state);
+ first_time = false;
+ state_ = new_state;
+ DictionaryValue device_dict;
+
+ // Signal to JS layer that the state is changing.
+ if (network)
+ GetDeviceInfo(network, &device_dict);
+ device_dict.SetInteger("state", new_state);
+ if (error_description.length())
+ device_dict.SetString("error", error_description);
+ dom_ui_->CallJavascriptFunction(
+ kJsDeviceStatusChangedHandler, device_dict);
+
+ // Decide what to do with network object as a result of the new state.
+ switch (new_state) {
+ case PLAN_ACTIVATION_START:
+ break;
+ case PLAN_ACTIVATION_INITIATING_ACTIVATION:
+ DCHECK(network);
+ LOG(INFO) << "Activating service " << network->service_path().c_str();
+ if (!network->StartActivation())
+ new_state = PLAN_ACTIVATION_ERROR;
+ break;
+ case PLAN_ACTIVATION_RECONNECTING: {
+ DCHECK(network);
+ if (network) {
+ chromeos::CrosLibrary::Get()->GetNetworkLibrary()->
+ ConnectToCellularNetwork(network);
+ }
+ break;
+ }
+ case PLAN_ACTIVATION_PAGE_LOADING:
+ return;
+ case PLAN_ACTIVATION_SHOWING_PAYMENT:
+ // Fix for fix SSL for the walled gardens where cert chain verification
+ // might not work.
+ break;
+ case PLAN_ACTIVATION_DONE:
+ DCHECK(network);
+ CompleteActivation(network);
+ break;
+ case PLAN_ACTIVATION_ERROR: {
+ CompleteActivation(NULL);
+ break;
+ }
+ default:
+ break;
+ }
+}
- const chromeos::CellularNetworkVector& cell_networks =
- network_lib->cellular_networks();
- // No cellular network present? Treat as network is disconnected.
- // This could be transient state that is the result of activation process.
- if (!cell_networks.size()) {
- *state = kStateDisconnected;
- return true;
+void MobileSetupHandler::ReEnableOtherConnections() {
+ chromeos::NetworkLibrary* lib = chromeos::CrosLibrary::Get()->
+ GetNetworkLibrary();
+ if (reenable_ethernet_) {
+ reenable_ethernet_ = false;
+ lib->EnableEthernetNetworkDevice(true);
}
- const chromeos::CellularNetwork& network = cell_networks.at(0);
-
- // First, check if device activation / plan payment failed.
- // It's slightly more complex than just single state check
- // that we are doing for other states below.
- if (!CheckForActivationError(network, error)) {
- *state = kStateError;
- return true;
+ if (reenable_wifi_) {
+ reenable_wifi_ = false;
+ lib->EnableWifiNetworkDevice(true);
+ }
+
+ PrefService* prefs = dom_ui_->GetProfile()->GetPrefs();
+ if (reenable_cert_check_) {
+ reenable_cert_check_ = false;
+ prefs->SetBoolean(prefs::kCertRevocationCheckingEnabled,
+ reenable_cert_check_);
}
+}
+
- switch (network.activation_state()) {
- case chromeos::ACTIVATION_STATE_UNKNOWN:
- case chromeos::ACTIVATION_STATE_NOT_ACTIVATED:
- // If this page is shown, I assume that we have already kicked off the
- // process of starting the activation even though the device status
- // reporting might not have caught up with us yet.
- *state = kStateConnecting;
- return true;
- case chromeos::ACTIVATION_STATE_PARTIALLY_ACTIVATED:
- case chromeos::ACTIVATION_STATE_ACTIVATING:
- *state = kStateActivating;
- return true;
- case chromeos::ACTIVATION_STATE_ACTIVATED:
- *state = kStateConnected;
- return true;
+void MobileSetupHandler::SetupActivationProcess(
+ chromeos::CellularNetwork* network) {
+ if (!network)
+ return;
+
+ // Disable SSL cert checks since we will be doing this in
+ // restricted pool.
+ PrefService* prefs = dom_ui_->GetProfile()->GetPrefs();
+ if (!reenable_cert_check_ &&
+ prefs->GetBoolean(
+ prefs::kCertRevocationCheckingEnabled)) {
+ reenable_cert_check_ = true;
+ prefs->SetBoolean(prefs::kCertRevocationCheckingEnabled, false);
}
- // We don't report states that we don't understand to DOM UI.
- *state = kStateUnknown;
- return false;
+ chromeos::NetworkLibrary* lib = chromeos::CrosLibrary::Get()->
+ GetNetworkLibrary();
+ // Disable autoconnect to cellular network.
+ network->set_auto_connect(false);
+ lib->SaveCellularNetwork(network);
+
+ // Disable ethernet and wifi.
+ if (!reenable_ethernet_ && lib->ethernet_enabled()) {
+ reenable_ethernet_ = true;
+ lib->EnableEthernetNetworkDevice(false);
+ }
+ if (!reenable_wifi_ && lib->wifi_enabled()) {
+ reenable_wifi_ = true;
+ lib->EnableWifiNetworkDevice(false);
+ }
}
-bool MobileSetupHandler::CheckForActivationError(
- chromeos::CellularNetwork network, std::string* error) {
+bool MobileSetupHandler::GotActivationError(
+ const chromeos::CellularNetwork* network, std::string* error) {
+ if (!network)
+ return false;
bool got_error = false;
const char* error_code = kErrorDefault;
- // This is the magic of error selecting based
- if (network.connection_state() == chromeos::STATE_FAILURE &&
- network.error() == chromeos::ERROR_AAA_FAILED ) {
- if (network.activation_state() ==
+ // This is the magic for detection of errors in during activation process.
+ if (network->connection_state() == chromeos::STATE_FAILURE &&
+ network->error() == chromeos::ERROR_AAA_FAILED ) {
+ if (network->activation_state() ==
chromeos::ACTIVATION_STATE_PARTIALLY_ACTIVATED) {
error_code = kErrorBadConnectionPartial;
- } else if (network.activation_state() ==
+ } else if (network->activation_state() ==
chromeos::ACTIVATION_STATE_ACTIVATED) {
- if (network.roaming_state() == chromeos::ROAMING_STATE_HOME) {
+ if (network->roaming_state() == chromeos::ROAMING_STATE_HOME) {
error_code = kErrorBadConnectionActivated;
- } else if (network.roaming_state() == chromeos::ROAMING_STATE_ROAMING) {
+ } else if (network->roaming_state() == chromeos::ROAMING_STATE_ROAMING) {
error_code = kErrorRoamingOnConnection;
}
}
got_error = true;
- } else if (network.connection_state() ==
+ } else if (network->connection_state() ==
chromeos::STATE_ACTIVATION_FAILURE) {
- if (network.error() == chromeos::ERROR_NEED_EVDO) {
- if (network.activation_state() ==
+ if (network->error() == chromeos::ERROR_NEED_EVDO) {
+ if (network->activation_state() ==
chromeos::ACTIVATION_STATE_PARTIALLY_ACTIVATED)
error_code = kErrorNoEVDO;
- } else if (network.error() == chromeos::ERROR_NEED_HOME_NETWORK) {
- if (network.activation_state() ==
+ } else if (network->error() == chromeos::ERROR_NEED_HOME_NETWORK) {
+ if (network->activation_state() ==
chromeos::ACTIVATION_STATE_NOT_ACTIVATED) {
error_code = kErrorRoamingActivation;
- } else if (network.activation_state() ==
+ } else if (network->activation_state() ==
chromeos::ACTIVATION_STATE_PARTIALLY_ACTIVATED) {
error_code = kErrorRoamingPartiallyActivated;
}
@@ -422,29 +789,16 @@ bool MobileSetupHandler::CheckForActivationError(
if (got_error)
*error = GetErrorMessage(error_code);
- return !got_error;
+ return got_error;
}
-bool MobileSetupHandler::GetDeviceInfo(DictionaryValue* value) {
- DCHECK(value);
- chromeos::NetworkLibrary* network_lib =
- chromeos::CrosLibrary::Get()->GetNetworkLibrary();
-
- const chromeos::CellularNetworkVector& cell_networks =
- network_lib->cellular_networks();
- if (!cell_networks.size()) {
- return false;
- }
-
- const chromeos::CellularNetwork& network = *(cell_networks.begin());
- value->SetString("carrier", UTF8ToUTF16(network.name()));
- value->SetString("payment_url", UTF8ToUTF16(network.payment_url()));
- value->SetString("MEID", UTF8ToUTF16(network.meid()));
- value->SetString("IMEI", UTF8ToUTF16(network.imei()));
- value->SetString("IMSI", UTF8ToUTF16(network.imsi()));
- value->SetString("ESN", UTF8ToUTF16(network.esn()));
- value->SetString("MDN", UTF8ToUTF16(network.mdn()));
- return true;
+void MobileSetupHandler::GetDeviceInfo(const chromeos::CellularNetwork* network,
+ DictionaryValue* value) {
+ value->SetString("carrier", network->name());
+ value->SetString("payment_url", network->payment_url());
+ value->SetString("MEID", network->meid());
+ value->SetString("IMEI", network->imei());
+ value->SetString("MDN", network->mdn());
}
std::string MobileSetupHandler::GetErrorMessage(const std::string& code) {
@@ -464,7 +818,7 @@ void MobileSetupHandler::LoadCellularConfig() {
scoped_ptr<CellularConfigDocument> config(new CellularConfigDocument());
bool config_loaded = config->LoadFromFile(config_path);
if (config_loaded) {
- VLOG(1) << "Cellular config file loaded: " << kCellularConfigPath;
+ LOG(INFO) << "Cellular config file loaded: " << kCellularConfigPath;
// lock
cellular_config_.reset(config.release());
} else {
@@ -481,11 +835,14 @@ void MobileSetupHandler::LoadCellularConfig() {
//
////////////////////////////////////////////////////////////////////////////////
-MobileSetupUI::MobileSetupUI(TabContents* contents) : DOMUI(contents){
- MobileSetupHandler* handler = new MobileSetupHandler();
+MobileSetupUI::MobileSetupUI(TabContents* contents) : DOMUI(contents) {
+ const chromeos::CellularNetwork* network = GetCellularNetwork();
+ std::string service_path = network ? network->service_path() : std::string();
+ MobileSetupHandler* handler = new MobileSetupHandler(service_path);
AddMessageHandler((handler)->Attach(this));
handler->Init(contents);
- MobileSetupUIHTMLSource* html_source = new MobileSetupUIHTMLSource();
+ MobileSetupUIHTMLSource* html_source =
+ new MobileSetupUIHTMLSource(service_path);
// Set up the chrome://mobilesetup/ source.
BrowserThread::PostTask(
diff --git a/chrome/browser/chromeos/dom_ui/network_menu_ui.cc b/chrome/browser/chromeos/dom_ui/network_menu_ui.cc
index bd366c3..30df58f 100644
--- a/chrome/browser/chromeos/dom_ui/network_menu_ui.cc
+++ b/chrome/browser/chromeos/dom_ui/network_menu_ui.cc
@@ -8,7 +8,7 @@
#include "base/values.h"
#include "base/string_number_conversions.h"
#include "base/string_util.h"
-#include "chrome/app/chrome_dll_resource.h"
+#include "chrome/app/chrome_command_ids.h"
#include "chrome/browser/browser_thread.h"
#include "chrome/browser/chromeos/status/network_menu.h"
#include "chrome/browser/chromeos/views/domui_menu_widget.h"
@@ -23,6 +23,22 @@
namespace {
+class NetworkMenuSourceDelegate : public chromeos::MenuSourceDelegate {
+ public:
+ virtual void AddLocalizedStrings(DictionaryValue* localized_strings) const {
+ DCHECK(localized_strings);
+
+ localized_strings->SetString("reconnect", l10n_util::GetStringUTF16(
+ IDS_NETWORK_RECONNECT_TITLE));
+ localized_strings->SetString("remeber_this_network",
+ l10n_util::GetStringUTF16(IDS_NETWORK_REMEMBER_THIS_NETWORK_TITLE));
+ localized_strings->SetString("ssid_prompt",
+ l10n_util::GetStringUTF16(IDS_NETWORK_SSID_HINT));
+ localized_strings->SetString("pass_prompt",
+ l10n_util::GetStringUTF16(IDS_NETWORK_PASSWORD_HINT));
+ }
+};
+
////////////////////////////////////////////////////////////////////////////////
//
// MenuHandler
@@ -91,7 +107,7 @@ NetworkMenuUI::NetworkMenuUI(TabContents* contents)
: chromeos::MenuUI(
contents,
ALLOW_THIS_IN_INITIALIZER_LIST(
- CreateMenuUIHTMLSource(*this,
+ CreateMenuUIHTMLSource(new NetworkMenuSourceDelegate(),
chrome::kChromeUINetworkMenu,
"NetworkMenu",
IDR_NETWORK_MENU_JS,
@@ -109,23 +125,6 @@ NetworkMenuUI::NetworkMenuUI(TabContents* contents)
make_scoped_refptr(theme)));
}
-void NetworkMenuUI::AddCustomConfigValues(DictionaryValue* config) const {
-}
-
-void NetworkMenuUI::AddLocalizedStrings(
- DictionaryValue* localized_strings) const {
- DCHECK(localized_strings);
-
- localized_strings->SetString("reconnect", l10n_util::GetStringUTF16(
- IDS_NETWORK_RECONNECT_TITLE));
- localized_strings->SetString("remeber_this_network",
- l10n_util::GetStringUTF16(IDS_NETWORK_REMEMBER_THIS_NETWORK_TITLE));
- localized_strings->SetString("ssid_prompt",
- l10n_util::GetStringUTF16(IDS_NETWORK_SSID_HINT));
- localized_strings->SetString("pass_prompt",
- l10n_util::GetStringUTF16(IDS_NETWORK_PASSWORD_HINT));
-}
-
bool NetworkMenuUI::ModelAction(const menus::MenuModel* model,
const ListValue* values) {
const NetworkMenu* network_menu = static_cast<const NetworkMenu*>(model);
@@ -186,6 +185,7 @@ DictionaryValue* NetworkMenuUI::CreateMenuItem(const menus::MenuModel* model,
item->SetString("status", info.status);
item->SetString("message", info.message);
item->SetString("ip_address", info.ip_address);
+ item->SetString("passphrase", info.passphrase);
item->SetBoolean("need_passphrase", info.need_passphrase);
item->SetBoolean("remembered", info.remembered);
return item;
diff --git a/chrome/browser/chromeos/dom_ui/network_menu_ui.h b/chrome/browser/chromeos/dom_ui/network_menu_ui.h
index 67027c8..70a3a4d 100644
--- a/chrome/browser/chromeos/dom_ui/network_menu_ui.h
+++ b/chrome/browser/chromeos/dom_ui/network_menu_ui.h
@@ -35,8 +35,6 @@ class NetworkMenuUI : public MenuUI {
const char* type,
int* max_icon_width,
bool* has_accel) const;
- virtual void AddCustomConfigValues(DictionaryValue* config) const;
- virtual void AddLocalizedStrings(DictionaryValue* localized_strings) const;
// A convenient factory method to create Menu2 for the network menu.
static views::Menu2* CreateMenu2(menus::MenuModel* model);
diff --git a/chrome/browser/chromeos/dom_ui/system_info_ui.cc b/chrome/browser/chromeos/dom_ui/system_info_ui.cc
index d795122..d9a70da 100644
--- a/chrome/browser/chromeos/dom_ui/system_info_ui.cc
+++ b/chrome/browser/chromeos/dom_ui/system_info_ui.cc
@@ -94,7 +94,7 @@ void SystemInfoUIHTMLSource::StartDataRequest(const std::string& path,
chromeos::CrosLibrary::Get()->GetSyslogsLibrary();
if (syslogs_lib) {
syslogs_lib->RequestSyslogs(
- false,
+ false, false,
&consumer_,
NewCallback(this, &SystemInfoUIHTMLSource::SyslogsComplete));
}
diff --git a/chrome/browser/chromeos/dom_ui/system_settings_provider.cc b/chrome/browser/chromeos/dom_ui/system_settings_provider.cc
index cd17c0d..a376cf0 100644
--- a/chrome/browser/chromeos/dom_ui/system_settings_provider.cc
+++ b/chrome/browser/chromeos/dom_ui/system_settings_provider.cc
@@ -67,7 +67,7 @@ SystemSettingsProvider::~SystemSettingsProvider() {
STLDeleteElements(&timezones_);
}
-void SystemSettingsProvider::Set(const std::string& path, Value* in_value) {
+void SystemSettingsProvider::DoSet(const std::string& path, Value* in_value) {
if (path == kSystemTimezone) {
string16 value;
if (!in_value || !in_value->IsType(Value::TYPE_STRING) ||
diff --git a/chrome/browser/chromeos/dom_ui/system_settings_provider.h b/chrome/browser/chromeos/dom_ui/system_settings_provider.h
index df97c46..816ea2c 100644
--- a/chrome/browser/chromeos/dom_ui/system_settings_provider.h
+++ b/chrome/browser/chromeos/dom_ui/system_settings_provider.h
@@ -24,7 +24,6 @@ class SystemSettingsProvider : public CrosSettingsProvider,
virtual ~SystemSettingsProvider();
// CrosSettingsProvider overrides.
- virtual void Set(const std::string& path, Value* in_value);
virtual bool Get(const std::string& path, Value** out_value) const;
virtual bool HandlesSetting(const std::string& path);
@@ -35,6 +34,8 @@ class SystemSettingsProvider : public CrosSettingsProvider,
ListValue* GetTimezoneList();
private:
+ // CrosSettingsProvider overrides.
+ virtual void DoSet(const std::string& path, Value* in_value);
// Gets timezone name.
static string16 GetTimezoneName(const icu::TimeZone& timezone);
diff --git a/chrome/browser/chromeos/dom_ui/wrench_menu_ui.cc b/chrome/browser/chromeos/dom_ui/wrench_menu_ui.cc
index d5f7a6c..cbc9c82 100644
--- a/chrome/browser/chromeos/dom_ui/wrench_menu_ui.cc
+++ b/chrome/browser/chromeos/dom_ui/wrench_menu_ui.cc
@@ -10,7 +10,7 @@
#include "base/utf_string_conversions.h"
#include "base/values.h"
#include "base/weak_ptr.h"
-#include "chrome/app/chrome_dll_resource.h"
+#include "chrome/app/chrome_command_ids.h"
#include "chrome/browser/browser.h"
#include "chrome/browser/browser_list.h"
#include "chrome/browser/chromeos/views/domui_menu_widget.h"
@@ -24,6 +24,30 @@
#include "grit/generated_resources.h"
#include "views/controls/menu/menu_2.h"
+namespace {
+
+class WrenchMenuSourceDelegate : public chromeos::MenuSourceDelegate {
+ public:
+ virtual void AddCustomConfigValues(DictionaryValue* config) const {
+ // Resources that are necessary to build wrench menu.
+ config->SetInteger("IDC_CUT", IDC_CUT);
+ config->SetInteger("IDC_COPY", IDC_COPY);
+ config->SetInteger("IDC_PASTE", IDC_PASTE);
+ config->SetInteger("IDC_ZOOM_MINUS", IDC_ZOOM_MINUS);
+ config->SetInteger("IDC_ZOOM_PLUS", IDC_ZOOM_PLUS);
+ config->SetInteger("IDC_FULLSCREEN", IDC_FULLSCREEN);
+
+ config->SetString("IDS_EDIT2", WideToUTF8(l10n_util::GetString(IDS_EDIT2)));
+ config->SetString("IDS_ZOOM_MENU2",
+ WideToUTF8(l10n_util::GetString(IDS_ZOOM_MENU2)));
+ config->SetString("IDS_CUT", WideToUTF8(l10n_util::GetString(IDS_CUT)));
+ config->SetString("IDS_COPY", WideToUTF8(l10n_util::GetString(IDS_COPY)));
+ config->SetString("IDS_PASTE", WideToUTF8(l10n_util::GetString(IDS_PASTE)));
+ }
+};
+
+} // namespace
+
namespace chromeos {
////////////////////////////////////////////////////////////////////////////////
@@ -36,7 +60,7 @@ WrenchMenuUI::WrenchMenuUI(TabContents* contents)
: chromeos::MenuUI(
contents,
ALLOW_THIS_IN_INITIALIZER_LIST(
- CreateMenuUIHTMLSource(*this,
+ CreateMenuUIHTMLSource(new WrenchMenuSourceDelegate(),
chrome::kChromeUIWrenchMenu,
"WrenchMenu" /* class name */,
IDR_WRENCH_MENU_JS,
@@ -50,23 +74,6 @@ void WrenchMenuUI::ModelUpdated(const menus::MenuModel* new_model) {
UpdateZoomControls();
}
-void WrenchMenuUI::AddCustomConfigValues(DictionaryValue* config) const {
- // Resources that are necessary to build wrench menu.
- config->SetInteger("IDC_CUT", IDC_CUT);
- config->SetInteger("IDC_COPY", IDC_COPY);
- config->SetInteger("IDC_PASTE", IDC_PASTE);
- config->SetInteger("IDC_ZOOM_MINUS", IDC_ZOOM_MINUS);
- config->SetInteger("IDC_ZOOM_PLUS", IDC_ZOOM_PLUS);
- config->SetInteger("IDC_FULLSCREEN", IDC_FULLSCREEN);
-
- config->SetString("IDS_EDIT2", WideToUTF8(l10n_util::GetString(IDS_EDIT2)));
- config->SetString("IDS_ZOOM_MENU2",
- WideToUTF8(l10n_util::GetString(IDS_ZOOM_MENU2)));
- config->SetString("IDS_CUT", WideToUTF8(l10n_util::GetString(IDS_CUT)));
- config->SetString("IDS_COPY", WideToUTF8(l10n_util::GetString(IDS_COPY)));
- config->SetString("IDS_PASTE", WideToUTF8(l10n_util::GetString(IDS_PASTE)));
-}
-
void WrenchMenuUI::Observe(NotificationType type,
const NotificationSource& source,
const NotificationDetails& details) {
diff --git a/chrome/browser/chromeos/dom_ui/wrench_menu_ui.h b/chrome/browser/chromeos/dom_ui/wrench_menu_ui.h
index cb0cd80..c12528c 100644
--- a/chrome/browser/chromeos/dom_ui/wrench_menu_ui.h
+++ b/chrome/browser/chromeos/dom_ui/wrench_menu_ui.h
@@ -31,7 +31,6 @@ class WrenchMenuUI : public MenuUI,
// MenuUI overrides:
virtual void ModelUpdated(const menus::MenuModel* new_model);
- virtual void AddCustomConfigValues(DictionaryValue* config) const;
// NotificationObserver:
virtual void Observe(NotificationType type,