#include "chromeos/network/network_state_handler.h"
#include "chromeos/network/network_state_handler_observer.h"
#include "content/public/browser/browser_thread.h"
+#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/url_data_source.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_ui.h"
}
// Converts the network properties into a JS object.
-void GetDeviceInfo(const DictionaryValue& properties, DictionaryValue* value) {
+void GetDeviceInfo(const base::DictionaryValue& properties,
+ base::DictionaryValue* value) {
std::string name;
properties.GetStringWithoutPathExpansion(shill::kNameProperty, &name);
- bool activate_over_non_cellular_networks = false;
- properties.GetBooleanWithoutPathExpansion(
- shill::kActivateOverNonCellularNetworkProperty,
- &activate_over_non_cellular_networks);
- const DictionaryValue* payment_dict;
+ std::string activation_type;
+ properties.GetStringWithoutPathExpansion(
+ shill::kActivationTypeProperty,
+ &activation_type);
+ const base::DictionaryValue* payment_dict;
std::string payment_url, post_method, post_data;
if (properties.GetDictionaryWithoutPathExpansion(
shill::kPaymentPortalProperty, &payment_dict)) {
shill::kPaymentPortalPostData, &post_data);
}
- value->SetBoolean("activate_over_non_cellular_network",
- activate_over_non_cellular_networks);
+ value->SetString("activation_type", activation_type);
value->SetString("carrier", name);
value->SetString("payment_url", payment_url);
if (LowerCaseEqualsASCII(post_method, "post") && !post_data.empty())
value->SetString("MDN", device->mdn());
}
+void SetActivationStateAndError(MobileActivator::PlanActivationState state,
+ const std::string& error_description,
+ base::DictionaryValue* value) {
+ value->SetInteger("state", state);
+ if (!error_description.empty())
+ value->SetString("error", error_description);
+}
+
} // namespace
class MobileSetupUIHTMLSource : public content::URLDataSource {
virtual void StartDataRequest(
const std::string& path,
int render_process_id,
- int render_view_id,
+ int render_frame_id,
const content::URLDataSource::GotDataCallback& callback) OVERRIDE;
virtual std::string GetMimeType(const std::string&) const OVERRIDE {
return "text/html";
scoped_ptr<base::DictionaryValue> error_data);
// Handlers for JS WebUI messages.
- void HandleSetTransactionStatus(const ListValue* args);
- void HandleStartActivation(const ListValue* args);
- void HandlePaymentPortalLoad(const ListValue* args);
- void HandleGetDeviceInfo(const ListValue* args);
+ void HandleSetTransactionStatus(const base::ListValue* args);
+ void HandleStartActivation(const base::ListValue* args);
+ void HandlePaymentPortalLoad(const base::ListValue* args);
+ void HandleGetDeviceInfo(const base::ListValue* args);
// NetworkStateHandlerObserver implementation.
virtual void NetworkConnectionStateChanged(
void MobileSetupUIHTMLSource::StartDataRequest(
const std::string& path,
int render_process_id,
- int render_view_id,
+ int render_frame_id,
const content::URLDataSource::GotDataCallback& callback) {
NetworkHandler::Get()->network_configuration_handler()->GetProperties(
path,
const content::URLDataSource::GotDataCallback& callback,
const std::string& service_path,
const base::DictionaryValue& properties) {
- const DictionaryValue* payment_dict;
+ const base::DictionaryValue* payment_dict;
std::string name, usage_url, activation_state, payment_url;
if (!properties.GetStringWithoutPathExpansion(
shill::kNameProperty, &name) ||
}
NET_LOG_EVENT("Starting mobile setup", service_path);
- DictionaryValue strings;
+ base::DictionaryValue strings;
strings.SetString("connecting_header",
l10n_util::GetStringFUTF16(IDS_MOBILE_CONNECTING_HEADER,
- UTF8ToUTF16(name)));
+ base::UTF8ToUTF16(name)));
strings.SetString("error_header",
l10n_util::GetStringUTF16(IDS_MOBILE_ERROR_HEADER));
strings.SetString("activating_header",
DCHECK_EQ(TYPE_ACTIVATION, type_);
if (!web_ui())
return;
+
+ if (!network) {
+ base::DictionaryValue device_dict;
+ SetActivationStateAndError(state, error_description, &device_dict);
+ web_ui()->CallJavascriptFunction(kJsDeviceStatusChangedCallback,
+ device_dict);
+ return;
+ }
+
NetworkHandler::Get()->network_configuration_handler()->GetProperties(
network->path(),
base::Bind(&MobileSetupHandler::GetPropertiesAndCallStatusChanged,
const std::string& error_description,
const std::string& service_path,
const base::DictionaryValue& properties) {
- DictionaryValue device_dict;
+ base::DictionaryValue device_dict;
GetDeviceInfo(properties, &device_dict);
- device_dict.SetInteger("state", state);
- if (error_description.length())
- device_dict.SetString("error", error_description);
- web_ui()->CallJavascriptFunction(
- kJsDeviceStatusChangedCallback, device_dict);
+ SetActivationStateAndError(state, error_description, &device_dict);
+ web_ui()->CallJavascriptFunction(kJsDeviceStatusChangedCallback, device_dict);
}
void MobileSetupHandler::RegisterMessages() {
base::Unretained(this)));
}
-void MobileSetupHandler::HandleStartActivation(const ListValue* args) {
+void MobileSetupHandler::HandleStartActivation(const base::ListValue* args) {
DCHECK_EQ(TYPE_UNDETERMINED, type_);
if (!web_ui())
MobileActivator::GetInstance()->InitiateActivation(path.substr(1));
}
-void MobileSetupHandler::HandleSetTransactionStatus(const ListValue* args) {
+void MobileSetupHandler::HandleSetTransactionStatus(
+ const base::ListValue* args) {
DCHECK_EQ(TYPE_ACTIVATION, type_);
if (!web_ui())
return;
LowerCaseEqualsASCII(status, kJsApiResultOK));
}
-void MobileSetupHandler::HandlePaymentPortalLoad(const ListValue* args) {
+void MobileSetupHandler::HandlePaymentPortalLoad(const base::ListValue* args) {
// Only activation flow webui is interested in these events.
if (type_ != TYPE_ACTIVATION || !web_ui())
return;
LowerCaseEqualsASCII(result, kJsApiResultOK));
}
-void MobileSetupHandler::HandleGetDeviceInfo(const ListValue* args) {
+void MobileSetupHandler::HandleGetDeviceInfo(const base::ListValue* args) {
DCHECK_NE(TYPE_ACTIVATION, type_);
if (!web_ui())
return;
void MobileSetupHandler::GetPropertiesAndCallGetDeviceInfo(
const std::string& service_path,
const base::DictionaryValue& properties) {
- DictionaryValue device_info;
+ base::DictionaryValue device_info;
GetDeviceInfo(properties, &device_info);
web_ui()->CallJavascriptFunction(kJsGetDeviceInfoCallback, device_info);
}
NET_LOG_ERROR("MobileActivator GetProperties Failed: " + error_name,
service_path);
// Invoke |callback_name| with an empty dictionary.
- DictionaryValue device_dict;
+ base::DictionaryValue device_dict;
web_ui()->CallJavascriptFunction(callback_name, device_dict);
}
}
void MobileSetupUI::DidCommitProvisionalLoadForFrame(
- int64 frame_id,
- const string16& frame_unique_name,
- bool is_main_frame,
+ content::RenderFrameHost* render_frame_host,
const GURL& url,
- content::PageTransition transition_type,
- content::RenderViewHost* render_view_host) {
- if (frame_unique_name != UTF8ToUTF16("paymentForm"))
+ content::PageTransition transition_type) {
+ if (render_frame_host->GetFrameName() != "paymentForm")
return;
web_ui()->CallJavascriptFunction(
}
void MobileSetupUI::DidFailProvisionalLoad(
- int64 frame_id,
- const string16& frame_unique_name,
- bool is_main_frame,
+ content::RenderFrameHost* render_frame_host,
const GURL& validated_url,
int error_code,
- const string16& error_description,
- content::RenderViewHost* render_view_host) {
- if (frame_unique_name != UTF8ToUTF16("paymentForm"))
+ const base::string16& error_description) {
+ if (render_frame_host->GetFrameName() != "paymentForm")
return;
base::FundamentalValue result_value(-error_code);