1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "chrome/browser/ui/webui/chromeos/mobile_setup_ui.h"
11 #include "base/bind.h"
12 #include "base/bind_helpers.h"
13 #include "base/json/json_writer.h"
14 #include "base/logging.h"
15 #include "base/memory/ref_counted_memory.h"
16 #include "base/memory/weak_ptr.h"
17 #include "base/message_loop/message_loop.h"
18 #include "base/metrics/histogram.h"
19 #include "base/strings/string_piece.h"
20 #include "base/strings/string_util.h"
21 #include "base/strings/utf_string_conversions.h"
22 #include "base/values.h"
23 #include "chrome/browser/chromeos/mobile/mobile_activator.h"
24 #include "chrome/browser/profiles/profile.h"
25 #include "chrome/browser/ui/browser_list.h"
26 #include "chrome/common/pref_names.h"
27 #include "chrome/common/render_messages.h"
28 #include "chrome/common/url_constants.h"
29 #include "chromeos/network/device_state.h"
30 #include "chromeos/network/network_configuration_handler.h"
31 #include "chromeos/network/network_event_log.h"
32 #include "chromeos/network/network_state.h"
33 #include "chromeos/network/network_state_handler.h"
34 #include "chromeos/network/network_state_handler_observer.h"
35 #include "content/public/browser/browser_thread.h"
36 #include "content/public/browser/url_data_source.h"
37 #include "content/public/browser/web_contents.h"
38 #include "content/public/browser/web_ui.h"
39 #include "content/public/browser/web_ui_message_handler.h"
40 #include "grit/browser_resources.h"
41 #include "grit/chromium_strings.h"
42 #include "grit/generated_resources.h"
43 #include "grit/locale_settings.h"
44 #include "third_party/cros_system_api/dbus/service_constants.h"
45 #include "ui/base/l10n/l10n_util.h"
46 #include "ui/base/resource/resource_bundle.h"
47 #include "ui/base/webui/jstemplate_builder.h"
48 #include "ui/base/webui/web_ui_util.h"
51 using chromeos::MobileActivator
;
52 using chromeos::NetworkHandler
;
53 using chromeos::NetworkState
;
54 using content::BrowserThread
;
55 using content::RenderViewHost
;
56 using content::WebContents
;
57 using content::WebUIMessageHandler
;
61 // Host page JS API function names.
62 const char kJsApiStartActivation
[] = "startActivation";
63 const char kJsApiSetTransactionStatus
[] = "setTransactionStatus";
64 const char kJsApiPaymentPortalLoad
[] = "paymentPortalLoad";
65 const char kJsGetDeviceInfo
[] = "getDeviceInfo";
66 const char kJsApiResultOK
[] = "ok";
68 const char kJsDeviceStatusChangedCallback
[] =
69 "mobile.MobileSetup.deviceStateChanged";
70 const char kJsPortalFrameLoadFailedCallback
[] =
71 "mobile.MobileSetup.portalFrameLoadError";
72 const char kJsPortalFrameLoadCompletedCallback
[] =
73 "mobile.MobileSetup.portalFrameLoadCompleted";
74 const char kJsGetDeviceInfoCallback
[] =
75 "mobile.MobileSetupPortal.onGotDeviceInfo";
76 const char kJsConnectivityChangedCallback
[] =
77 "mobile.MobileSetupPortal.onConnectivityChanged";
79 void DataRequestFailed(
80 const std::string
& service_path
,
81 const content::URLDataSource::GotDataCallback
& callback
) {
82 NET_LOG_ERROR("Data Request Failed for Mobile Setup", service_path
);
83 scoped_refptr
<base::RefCountedBytes
> html_bytes(new base::RefCountedBytes
);
84 callback
.Run(html_bytes
.get());
87 // Converts the network properties into a JS object.
88 void GetDeviceInfo(const base::DictionaryValue
& properties
,
89 base::DictionaryValue
* value
) {
91 properties
.GetStringWithoutPathExpansion(shill::kNameProperty
, &name
);
92 bool activate_over_non_cellular_networks
= false;
93 properties
.GetBooleanWithoutPathExpansion(
94 shill::kActivateOverNonCellularNetworkProperty
,
95 &activate_over_non_cellular_networks
);
96 const base::DictionaryValue
* payment_dict
;
97 std::string payment_url
, post_method
, post_data
;
98 if (properties
.GetDictionaryWithoutPathExpansion(
99 shill::kPaymentPortalProperty
, &payment_dict
)) {
100 payment_dict
->GetStringWithoutPathExpansion(
101 shill::kPaymentPortalURL
, &payment_url
);
102 payment_dict
->GetStringWithoutPathExpansion(
103 shill::kPaymentPortalMethod
, &post_method
);
104 payment_dict
->GetStringWithoutPathExpansion(
105 shill::kPaymentPortalPostData
, &post_data
);
108 value
->SetBoolean("activate_over_non_cellular_network",
109 activate_over_non_cellular_networks
);
110 value
->SetString("carrier", name
);
111 value
->SetString("payment_url", payment_url
);
112 if (LowerCaseEqualsASCII(post_method
, "post") && !post_data
.empty())
113 value
->SetString("post_data", post_data
);
115 // Use the cached DeviceState properties.
116 std::string device_path
;
117 if (!properties
.GetStringWithoutPathExpansion(
118 shill::kDeviceProperty
, &device_path
) ||
119 device_path
.empty()) {
122 const chromeos::DeviceState
* device
=
123 NetworkHandler::Get()->network_state_handler()->GetDeviceState(
128 value
->SetString("MEID", device
->meid());
129 value
->SetString("IMEI", device
->imei());
130 value
->SetString("MDN", device
->mdn());
133 void SetActivationStateAndError(MobileActivator::PlanActivationState state
,
134 const std::string
& error_description
,
135 base::DictionaryValue
* value
) {
136 value
->SetInteger("state", state
);
137 if (!error_description
.empty())
138 value
->SetString("error", error_description
);
143 class MobileSetupUIHTMLSource
: public content::URLDataSource
{
145 MobileSetupUIHTMLSource();
147 // content::URLDataSource implementation.
148 virtual std::string
GetSource() const OVERRIDE
;
149 virtual void StartDataRequest(
150 const std::string
& path
,
151 int render_process_id
,
153 const content::URLDataSource::GotDataCallback
& callback
) OVERRIDE
;
154 virtual std::string
GetMimeType(const std::string
&) const OVERRIDE
{
157 virtual bool ShouldAddContentSecurityPolicy() const OVERRIDE
{
162 virtual ~MobileSetupUIHTMLSource() {}
164 void GetPropertiesAndStartDataRequest(
165 const content::URLDataSource::GotDataCallback
& callback
,
166 const std::string
& service_path
,
167 const base::DictionaryValue
& properties
);
168 void GetPropertiesFailure(
169 const content::URLDataSource::GotDataCallback
& callback
,
170 const std::string
& service_path
,
171 const std::string
& error_name
,
172 scoped_ptr
<base::DictionaryValue
> error_data
);
174 base::WeakPtrFactory
<MobileSetupUIHTMLSource
> weak_ptr_factory_
;
176 DISALLOW_COPY_AND_ASSIGN(MobileSetupUIHTMLSource
);
179 // The handler for Javascript messages related to the "register" view.
180 class MobileSetupHandler
181 : public WebUIMessageHandler
,
182 public MobileActivator::Observer
,
183 public chromeos::NetworkStateHandlerObserver
,
184 public base::SupportsWeakPtr
<MobileSetupHandler
> {
186 MobileSetupHandler();
187 virtual ~MobileSetupHandler();
189 // WebUIMessageHandler implementation.
190 virtual void RegisterMessages() OVERRIDE
;
195 // The network is not yet activated, and the webui is in activation flow.
197 // The network is activated, the webui displays network portal.
199 // Same as TYPE_PORTAL, but the network technology is LTE. The webui is
200 // additionally aware of network manager state and whether the portal can be
205 // MobileActivator::Observer.
206 virtual void OnActivationStateChanged(
207 const NetworkState
* network
,
208 MobileActivator::PlanActivationState new_state
,
209 const std::string
& error_description
) OVERRIDE
;
211 // Callbacks for NetworkConfigurationHandler::GetProperties.
212 void GetPropertiesAndCallStatusChanged(
213 MobileActivator::PlanActivationState state
,
214 const std::string
& error_description
,
215 const std::string
& service_path
,
216 const base::DictionaryValue
& properties
);
217 void GetPropertiesAndCallGetDeviceInfo(
218 const std::string
& service_path
,
219 const base::DictionaryValue
& properties
);
220 void GetPropertiesFailure(
221 const std::string
& service_path
,
222 const std::string
& callback_name
,
223 const std::string
& error_name
,
224 scoped_ptr
<base::DictionaryValue
> error_data
);
226 // Handlers for JS WebUI messages.
227 void HandleSetTransactionStatus(const base::ListValue
* args
);
228 void HandleStartActivation(const base::ListValue
* args
);
229 void HandlePaymentPortalLoad(const base::ListValue
* args
);
230 void HandleGetDeviceInfo(const base::ListValue
* args
);
232 // NetworkStateHandlerObserver implementation.
233 virtual void NetworkConnectionStateChanged(
234 const NetworkState
* network
) OVERRIDE
;
235 virtual void DefaultNetworkChanged(
236 const NetworkState
* default_network
) OVERRIDE
;
238 // Updates |lte_portal_reachable_| for lte network |network| and notifies
239 // webui of the new state if the reachability changed or |force_notification|
241 void UpdatePortalReachability(const NetworkState
* network
,
242 bool force_notification
);
244 // Sends message to host registration page with system/user info data.
245 void SendDeviceInfo();
247 // Type of the mobilesetup webui deduced from received messages.
249 // Whether portal page for lte networks can be reached in current network
250 // connection state. This value is reflected in portal webui for lte networks.
251 // Initial value is true.
252 bool lte_portal_reachable_
;
253 base::WeakPtrFactory
<MobileSetupHandler
> weak_ptr_factory_
;
255 DISALLOW_COPY_AND_ASSIGN(MobileSetupHandler
);
258 ////////////////////////////////////////////////////////////////////////////////
260 // MobileSetupUIHTMLSource
262 ////////////////////////////////////////////////////////////////////////////////
264 MobileSetupUIHTMLSource::MobileSetupUIHTMLSource()
265 : weak_ptr_factory_(this) {
268 std::string
MobileSetupUIHTMLSource::GetSource() const {
269 return chrome::kChromeUIMobileSetupHost
;
272 void MobileSetupUIHTMLSource::StartDataRequest(
273 const std::string
& path
,
274 int render_process_id
,
276 const content::URLDataSource::GotDataCallback
& callback
) {
277 NetworkHandler::Get()->network_configuration_handler()->GetProperties(
279 base::Bind(&MobileSetupUIHTMLSource::GetPropertiesAndStartDataRequest
,
280 weak_ptr_factory_
.GetWeakPtr(),
282 base::Bind(&MobileSetupUIHTMLSource::GetPropertiesFailure
,
283 weak_ptr_factory_
.GetWeakPtr(),
287 void MobileSetupUIHTMLSource::GetPropertiesAndStartDataRequest(
288 const content::URLDataSource::GotDataCallback
& callback
,
289 const std::string
& service_path
,
290 const base::DictionaryValue
& properties
) {
291 const base::DictionaryValue
* payment_dict
;
292 std::string name
, usage_url
, activation_state
, payment_url
;
293 if (!properties
.GetStringWithoutPathExpansion(
294 shill::kNameProperty
, &name
) ||
295 !properties
.GetStringWithoutPathExpansion(
296 shill::kUsageURLProperty
, &usage_url
) ||
297 !properties
.GetStringWithoutPathExpansion(
298 shill::kActivationStateProperty
, &activation_state
) ||
299 !properties
.GetDictionaryWithoutPathExpansion(
300 shill::kPaymentPortalProperty
, &payment_dict
) ||
301 !payment_dict
->GetStringWithoutPathExpansion(
302 shill::kPaymentPortalURL
, &payment_url
)) {
303 DataRequestFailed(service_path
, callback
);
307 if (payment_url
.empty() && usage_url
.empty() &&
308 activation_state
!= shill::kActivationStateActivated
) {
309 DataRequestFailed(service_path
, callback
);
313 NET_LOG_EVENT("Starting mobile setup", service_path
);
314 base::DictionaryValue strings
;
316 strings
.SetString("connecting_header",
317 l10n_util::GetStringFUTF16(IDS_MOBILE_CONNECTING_HEADER
,
318 base::UTF8ToUTF16(name
)));
319 strings
.SetString("error_header",
320 l10n_util::GetStringUTF16(IDS_MOBILE_ERROR_HEADER
));
321 strings
.SetString("activating_header",
322 l10n_util::GetStringUTF16(IDS_MOBILE_ACTIVATING_HEADER
));
323 strings
.SetString("completed_header",
324 l10n_util::GetStringUTF16(IDS_MOBILE_COMPLETED_HEADER
));
325 strings
.SetString("please_wait",
326 l10n_util::GetStringUTF16(IDS_MOBILE_PLEASE_WAIT
));
327 strings
.SetString("completed_text",
328 l10n_util::GetStringUTF16(IDS_MOBILE_COMPLETED_TEXT
));
329 strings
.SetString("portal_unreachable_header",
330 l10n_util::GetStringUTF16(IDS_MOBILE_NO_CONNECTION_HEADER
));
331 strings
.SetString("invalid_device_info_header",
332 l10n_util::GetStringUTF16(IDS_MOBILE_INVALID_DEVICE_INFO_HEADER
));
333 strings
.SetString("title", l10n_util::GetStringUTF16(IDS_MOBILE_SETUP_TITLE
));
334 strings
.SetString("close_button",
335 l10n_util::GetStringUTF16(IDS_CLOSE
));
336 strings
.SetString("cancel_button",
337 l10n_util::GetStringUTF16(IDS_CANCEL
));
338 strings
.SetString("ok_button",
339 l10n_util::GetStringUTF16(IDS_OK
));
340 webui::SetFontAndTextDirection(&strings
);
342 // The webui differs based on whether the network is activated or not. If the
343 // network is activated, the webui goes straight to portal. Otherwise the
344 // webui is used for activation flow.
345 std::string full_html
;
346 if (activation_state
== shill::kActivationStateActivated
) {
347 static const base::StringPiece
html_for_activated(
348 ResourceBundle::GetSharedInstance().GetRawDataResource(
349 IDR_MOBILE_SETUP_PORTAL_PAGE_HTML
));
350 full_html
= webui::GetI18nTemplateHtml(html_for_activated
, &strings
);
352 static const base::StringPiece
html_for_non_activated(
353 ResourceBundle::GetSharedInstance().GetRawDataResource(
354 IDR_MOBILE_SETUP_PAGE_HTML
));
355 full_html
= webui::GetI18nTemplateHtml(html_for_non_activated
, &strings
);
358 callback
.Run(base::RefCountedString::TakeString(&full_html
));
361 void MobileSetupUIHTMLSource::GetPropertiesFailure(
362 const content::URLDataSource::GotDataCallback
& callback
,
363 const std::string
& service_path
,
364 const std::string
& error_name
,
365 scoped_ptr
<base::DictionaryValue
> error_data
) {
366 DataRequestFailed(service_path
, callback
);
369 ////////////////////////////////////////////////////////////////////////////////
371 // MobileSetupHandler
373 ////////////////////////////////////////////////////////////////////////////////
374 MobileSetupHandler::MobileSetupHandler()
375 : type_(TYPE_UNDETERMINED
),
376 lte_portal_reachable_(true),
377 weak_ptr_factory_(this) {
380 MobileSetupHandler::~MobileSetupHandler() {
381 if (type_
== TYPE_ACTIVATION
) {
382 MobileActivator::GetInstance()->RemoveObserver(this);
383 MobileActivator::GetInstance()->TerminateActivation();
384 } else if (type_
== TYPE_PORTAL_LTE
) {
385 NetworkHandler::Get()->network_state_handler()->RemoveObserver(this,
390 void MobileSetupHandler::OnActivationStateChanged(
391 const NetworkState
* network
,
392 MobileActivator::PlanActivationState state
,
393 const std::string
& error_description
) {
394 DCHECK_EQ(TYPE_ACTIVATION
, type_
);
399 base::DictionaryValue device_dict
;
400 SetActivationStateAndError(state
, error_description
, &device_dict
);
401 web_ui()->CallJavascriptFunction(kJsDeviceStatusChangedCallback
,
406 NetworkHandler::Get()->network_configuration_handler()->GetProperties(
408 base::Bind(&MobileSetupHandler::GetPropertiesAndCallStatusChanged
,
409 weak_ptr_factory_
.GetWeakPtr(),
412 base::Bind(&MobileSetupHandler::GetPropertiesFailure
,
413 weak_ptr_factory_
.GetWeakPtr(),
415 kJsDeviceStatusChangedCallback
));
418 void MobileSetupHandler::GetPropertiesAndCallStatusChanged(
419 MobileActivator::PlanActivationState state
,
420 const std::string
& error_description
,
421 const std::string
& service_path
,
422 const base::DictionaryValue
& properties
) {
423 base::DictionaryValue device_dict
;
424 GetDeviceInfo(properties
, &device_dict
);
425 SetActivationStateAndError(state
, error_description
, &device_dict
);
426 web_ui()->CallJavascriptFunction(kJsDeviceStatusChangedCallback
, device_dict
);
429 void MobileSetupHandler::RegisterMessages() {
430 web_ui()->RegisterMessageCallback(kJsApiStartActivation
,
431 base::Bind(&MobileSetupHandler::HandleStartActivation
,
432 base::Unretained(this)));
433 web_ui()->RegisterMessageCallback(kJsApiSetTransactionStatus
,
434 base::Bind(&MobileSetupHandler::HandleSetTransactionStatus
,
435 base::Unretained(this)));
436 web_ui()->RegisterMessageCallback(kJsApiPaymentPortalLoad
,
437 base::Bind(&MobileSetupHandler::HandlePaymentPortalLoad
,
438 base::Unretained(this)));
439 web_ui()->RegisterMessageCallback(kJsGetDeviceInfo
,
440 base::Bind(&MobileSetupHandler::HandleGetDeviceInfo
,
441 base::Unretained(this)));
444 void MobileSetupHandler::HandleStartActivation(const base::ListValue
* args
) {
445 DCHECK_EQ(TYPE_UNDETERMINED
, type_
);
450 std::string path
= web_ui()->GetWebContents()->GetURL().path();
454 LOG(WARNING
) << "Starting activation for service " << path
;
456 type_
= TYPE_ACTIVATION
;
457 MobileActivator::GetInstance()->AddObserver(this);
458 MobileActivator::GetInstance()->InitiateActivation(path
.substr(1));
461 void MobileSetupHandler::HandleSetTransactionStatus(
462 const base::ListValue
* args
) {
463 DCHECK_EQ(TYPE_ACTIVATION
, type_
);
467 const size_t kSetTransactionStatusParamCount
= 1;
468 if (args
->GetSize() != kSetTransactionStatusParamCount
)
470 // Get change callback function name.
472 if (!args
->GetString(0, &status
))
475 MobileActivator::GetInstance()->OnSetTransactionStatus(
476 LowerCaseEqualsASCII(status
, kJsApiResultOK
));
479 void MobileSetupHandler::HandlePaymentPortalLoad(const base::ListValue
* args
) {
480 // Only activation flow webui is interested in these events.
481 if (type_
!= TYPE_ACTIVATION
|| !web_ui())
484 const size_t kPaymentPortalLoadParamCount
= 1;
485 if (args
->GetSize() != kPaymentPortalLoadParamCount
)
487 // Get change callback function name.
489 if (!args
->GetString(0, &result
))
492 MobileActivator::GetInstance()->OnPortalLoaded(
493 LowerCaseEqualsASCII(result
, kJsApiResultOK
));
496 void MobileSetupHandler::HandleGetDeviceInfo(const base::ListValue
* args
) {
497 DCHECK_NE(TYPE_ACTIVATION
, type_
);
501 std::string path
= web_ui()->GetWebContents()->GetURL().path();
505 chromeos::NetworkStateHandler
* nsh
=
506 NetworkHandler::Get()->network_state_handler();
507 // TODO: Figure out why the path has an extra '/' in the front. (e.g. It is
508 // '//service/5' instead of '/service/5'.
509 const NetworkState
* network
= nsh
->GetNetworkState(path
.substr(1));
511 web_ui()->GetWebContents()->Close();
515 // If this is the initial call, update the network status and start observing
516 // network changes, but only for LTE networks. The other networks should
517 // ignore network status.
518 if (type_
== TYPE_UNDETERMINED
) {
519 if (network
->network_technology() == shill::kNetworkTechnologyLte
||
520 network
->network_technology() == shill::kNetworkTechnologyLteAdvanced
) {
521 type_
= TYPE_PORTAL_LTE
;
522 nsh
->AddObserver(this, FROM_HERE
);
523 // Update the network status and notify the webui. This is the initial
524 // network state so the webui should be notified no matter what.
525 UpdatePortalReachability(network
,
526 true /* force notification */);
529 // For non-LTE networks network state is ignored, so report the portal is
530 // reachable, so it gets shown.
531 web_ui()->CallJavascriptFunction(kJsConnectivityChangedCallback
,
532 base::FundamentalValue(true));
536 NetworkHandler::Get()->network_configuration_handler()->GetProperties(
538 base::Bind(&MobileSetupHandler::GetPropertiesAndCallGetDeviceInfo
,
539 weak_ptr_factory_
.GetWeakPtr()),
540 base::Bind(&MobileSetupHandler::GetPropertiesFailure
,
541 weak_ptr_factory_
.GetWeakPtr(),
543 kJsGetDeviceInfoCallback
));
546 void MobileSetupHandler::GetPropertiesAndCallGetDeviceInfo(
547 const std::string
& service_path
,
548 const base::DictionaryValue
& properties
) {
549 base::DictionaryValue device_info
;
550 GetDeviceInfo(properties
, &device_info
);
551 web_ui()->CallJavascriptFunction(kJsGetDeviceInfoCallback
, device_info
);
554 void MobileSetupHandler::GetPropertiesFailure(
555 const std::string
& service_path
,
556 const std::string
& callback_name
,
557 const std::string
& error_name
,
558 scoped_ptr
<base::DictionaryValue
> error_data
) {
559 NET_LOG_ERROR("MobileActivator GetProperties Failed: " + error_name
,
561 // Invoke |callback_name| with an empty dictionary.
562 base::DictionaryValue device_dict
;
563 web_ui()->CallJavascriptFunction(callback_name
, device_dict
);
566 void MobileSetupHandler::DefaultNetworkChanged(
567 const NetworkState
* default_network
) {
571 std::string path
= web_ui()->GetWebContents()->GetURL().path().substr(1);
575 const NetworkState
* network
=
576 NetworkHandler::Get()->network_state_handler()->GetNetworkState(path
);
578 LOG(ERROR
) << "Service path lost";
579 web_ui()->GetWebContents()->Close();
583 UpdatePortalReachability(network
, false /* do not force notification */);
586 void MobileSetupHandler::NetworkConnectionStateChanged(
587 const NetworkState
* network
) {
591 std::string path
= web_ui()->GetWebContents()->GetURL().path().substr(1);
592 if (path
.empty() || path
!= network
->path())
595 UpdatePortalReachability(network
, false /* do not force notification */);
598 void MobileSetupHandler::UpdatePortalReachability(
599 const NetworkState
* network
,
600 bool force_notification
) {
603 DCHECK_EQ(type_
, TYPE_PORTAL_LTE
);
605 chromeos::NetworkStateHandler
* nsh
=
606 NetworkHandler::Get()->network_state_handler();
607 bool portal_reachable
=
608 (network
->IsConnectedState() ||
609 (nsh
->DefaultNetwork() &&
610 nsh
->DefaultNetwork()->connection_state() == shill::kStateOnline
));
612 if (force_notification
|| portal_reachable
!= lte_portal_reachable_
) {
613 web_ui()->CallJavascriptFunction(kJsConnectivityChangedCallback
,
614 base::FundamentalValue(portal_reachable
));
617 lte_portal_reachable_
= portal_reachable
;
620 ////////////////////////////////////////////////////////////////////////////////
624 ////////////////////////////////////////////////////////////////////////////////
626 MobileSetupUI::MobileSetupUI(content::WebUI
* web_ui
)
627 : WebUIController(web_ui
) {
628 web_ui
->AddMessageHandler(new MobileSetupHandler());
629 MobileSetupUIHTMLSource
* html_source
= new MobileSetupUIHTMLSource();
631 // Set up the chrome://mobilesetup/ source.
632 Profile
* profile
= Profile::FromWebUI(web_ui
);
633 content::URLDataSource::Add(profile
, html_source
);
635 content::WebContentsObserver::Observe(web_ui
->GetWebContents());
638 void MobileSetupUI::DidCommitProvisionalLoadForFrame(
640 const base::string16
& frame_unique_name
,
643 content::PageTransition transition_type
,
644 content::RenderViewHost
* render_view_host
) {
645 if (frame_unique_name
!= base::UTF8ToUTF16("paymentForm"))
648 web_ui()->CallJavascriptFunction(
649 kJsPortalFrameLoadCompletedCallback
);
652 void MobileSetupUI::DidFailProvisionalLoad(
654 const base::string16
& frame_unique_name
,
656 const GURL
& validated_url
,
658 const base::string16
& error_description
,
659 content::RenderViewHost
* render_view_host
) {
660 if (frame_unique_name
!= base::UTF8ToUTF16("paymentForm"))
663 base::FundamentalValue
result_value(-error_code
);
664 web_ui()->CallJavascriptFunction(kJsPortalFrameLoadFailedCallback
,