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

Side by Side Diff: chrome/browser/ui/webui/chromeos/mobile_setup_ui.cc

Issue 22611005: Switch over MobileActivator to use Network*Handler (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: add activation handler files Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/webui/chromeos/mobile_setup_ui.h" 5 #include "chrome/browser/ui/webui/chromeos/mobile_setup_ui.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 10
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/bind_helpers.h" 12 #include "base/bind_helpers.h"
13 #include "base/json/json_writer.h" 13 #include "base/json/json_writer.h"
14 #include "base/logging.h" 14 #include "base/logging.h"
15 #include "base/memory/ref_counted_memory.h" 15 #include "base/memory/ref_counted_memory.h"
16 #include "base/message_loop/message_loop.h" 16 #include "base/message_loop/message_loop.h"
17 #include "base/metrics/histogram.h" 17 #include "base/metrics/histogram.h"
18 #include "base/strings/string_piece.h" 18 #include "base/strings/string_piece.h"
19 #include "base/strings/string_util.h" 19 #include "base/strings/string_util.h"
20 #include "base/strings/utf_string_conversions.h" 20 #include "base/strings/utf_string_conversions.h"
21 #include "base/values.h" 21 #include "base/values.h"
22 #include "chrome/browser/chromeos/cros/network_library.h" 22 #include "chrome/browser/chromeos/cros/network_library.h"
stevenjb 2013/08/14 02:28:31 Remove
gauravsh 2013/08/14 21:42:29 Done.
23 #include "chrome/browser/chromeos/mobile/mobile_activator.h" 23 #include "chrome/browser/chromeos/mobile/mobile_activator.h"
24 #include "chrome/browser/profiles/profile.h" 24 #include "chrome/browser/profiles/profile.h"
25 #include "chrome/browser/ui/browser_list.h" 25 #include "chrome/browser/ui/browser_list.h"
26 #include "chrome/common/pref_names.h" 26 #include "chrome/common/pref_names.h"
27 #include "chrome/common/render_messages.h" 27 #include "chrome/common/render_messages.h"
28 #include "chrome/common/url_constants.h" 28 #include "chrome/common/url_constants.h"
29 #include "chromeos/network/device_state.h"
30 #include "chromeos/network/network_state.h"
31 #include "chromeos/network/network_state_handler.h"
32 #include "chromeos/network/network_state_handler_observer.h"
29 #include "content/public/browser/browser_thread.h" 33 #include "content/public/browser/browser_thread.h"
30 #include "content/public/browser/render_view_host_observer.h" 34 #include "content/public/browser/render_view_host_observer.h"
31 #include "content/public/browser/url_data_source.h" 35 #include "content/public/browser/url_data_source.h"
32 #include "content/public/browser/web_contents.h" 36 #include "content/public/browser/web_contents.h"
33 #include "content/public/browser/web_ui.h" 37 #include "content/public/browser/web_ui.h"
34 #include "content/public/browser/web_ui_message_handler.h" 38 #include "content/public/browser/web_ui_message_handler.h"
35 #include "grit/browser_resources.h" 39 #include "grit/browser_resources.h"
36 #include "grit/chromium_strings.h" 40 #include "grit/chromium_strings.h"
37 #include "grit/generated_resources.h" 41 #include "grit/generated_resources.h"
38 #include "grit/locale_settings.h" 42 #include "grit/locale_settings.h"
43 #include "third_party/cros_system_api/dbus/service_constants.h"
39 #include "ui/base/l10n/l10n_util.h" 44 #include "ui/base/l10n/l10n_util.h"
40 #include "ui/base/resource/resource_bundle.h" 45 #include "ui/base/resource/resource_bundle.h"
41 #include "ui/webui/jstemplate_builder.h" 46 #include "ui/webui/jstemplate_builder.h"
42 #include "ui/webui/web_ui_util.h" 47 #include "ui/webui/web_ui_util.h"
43 #include "url/gurl.h" 48 #include "url/gurl.h"
44 49
45 using chromeos::CellularNetwork;
46 using chromeos::MobileActivator; 50 using chromeos::MobileActivator;
47 using chromeos::NetworkLibrary; 51 using chromeos::NetworkHandler;
52 using chromeos::NetworkState;
48 using content::BrowserThread; 53 using content::BrowserThread;
49 using content::RenderViewHost; 54 using content::RenderViewHost;
50 using content::WebContents; 55 using content::WebContents;
51 using content::WebUIMessageHandler; 56 using content::WebUIMessageHandler;
52 57
53 namespace { 58 namespace {
54 59
55 // Host page JS API function names. 60 // Host page JS API function names.
56 const char kJsApiStartActivation[] = "startActivation"; 61 const char kJsApiStartActivation[] = "startActivation";
57 const char kJsApiSetTransactionStatus[] = "setTransactionStatus"; 62 const char kJsApiSetTransactionStatus[] = "setTransactionStatus";
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 private: 143 private:
139 virtual ~MobileSetupUIHTMLSource() {} 144 virtual ~MobileSetupUIHTMLSource() {}
140 145
141 DISALLOW_COPY_AND_ASSIGN(MobileSetupUIHTMLSource); 146 DISALLOW_COPY_AND_ASSIGN(MobileSetupUIHTMLSource);
142 }; 147 };
143 148
144 // The handler for Javascript messages related to the "register" view. 149 // The handler for Javascript messages related to the "register" view.
145 class MobileSetupHandler 150 class MobileSetupHandler
146 : public WebUIMessageHandler, 151 : public WebUIMessageHandler,
147 public MobileActivator::Observer, 152 public MobileActivator::Observer,
148 public NetworkLibrary::NetworkManagerObserver, 153 public chromeos::NetworkStateHandlerObserver,
149 public base::SupportsWeakPtr<MobileSetupHandler> { 154 public base::SupportsWeakPtr<MobileSetupHandler> {
150 public: 155 public:
151 MobileSetupHandler(); 156 MobileSetupHandler();
152 virtual ~MobileSetupHandler(); 157 virtual ~MobileSetupHandler();
153 158
154 // WebUIMessageHandler implementation. 159 // WebUIMessageHandler implementation.
155 virtual void RegisterMessages() OVERRIDE; 160 virtual void RegisterMessages() OVERRIDE;
156 161
157 private: 162 private:
158 enum Type { 163 enum Type {
159 TYPE_UNDETERMINED, 164 TYPE_UNDETERMINED,
160 // The network is not yet activated, and the webui is in activation flow. 165 // The network is not yet activated, and the webui is in activation flow.
161 TYPE_ACTIVATION, 166 TYPE_ACTIVATION,
162 // The network is activated, the webui displays network portal. 167 // The network is activated, the webui displays network portal.
163 TYPE_PORTAL, 168 TYPE_PORTAL,
164 // Same as TYPE_PORTAL, but the network technology is LTE. The webui is 169 // Same as TYPE_PORTAL, but the network technology is LTE. The webui is
165 // additionally aware of network manager state and whether the portal can be 170 // additionally aware of network manager state and whether the portal can be
166 // reached. 171 // reached.
167 TYPE_PORTAL_LTE 172 TYPE_PORTAL_LTE
168 }; 173 };
169 174
170 // Changes internal state. 175 // MobileActivator::Observer.
171 virtual void OnActivationStateChanged( 176 virtual void OnActivationStateChanged(
172 CellularNetwork* network, 177 const NetworkState* network,
173 MobileActivator::PlanActivationState new_state, 178 MobileActivator::PlanActivationState new_state,
174 const std::string& error_description) OVERRIDE; 179 const std::string& error_description) OVERRIDE;
175 180
176 // Handlers for JS WebUI messages. 181 // Handlers for JS WebUI messages.
177 void HandleSetTransactionStatus(const ListValue* args); 182 void HandleSetTransactionStatus(const ListValue* args);
178 void HandleStartActivation(const ListValue* args); 183 void HandleStartActivation(const ListValue* args);
179 void HandlePaymentPortalLoad(const ListValue* args); 184 void HandlePaymentPortalLoad(const ListValue* args);
180 void HandleGetDeviceInfo(const ListValue* args); 185 void HandleGetDeviceInfo(const ListValue* args);
181 186
182 // NetworkLibrary::NetworkManagerObserver implementation. 187 // NetworkStateHandlerObserver implementation.
183 virtual void OnNetworkManagerChanged(NetworkLibrary* network_lib) OVERRIDE; 188 virtual void NetworkManagerChanged() OVERRIDE;
189 virtual void DefaultNetworkChanged(
190 const NetworkState* default_network) OVERRIDE;
184 191
185 // Updates |lte_portal_reachable_| for lte network |network| and notifies 192 // Updates |lte_portal_reachable_| for lte network |network| and notifies
186 // webui of the new state if the reachability changed or |force_notification| 193 // webui of the new state if the reachability changed or |force_notification|
187 // is set. 194 // is set.
188 void UpdatePortalReachability(NetworkLibrary* network_lib, 195 void UpdatePortalReachability(const NetworkState* network,
189 CellularNetwork* network,
190 bool force_notification); 196 bool force_notification);
191 197
192 // Sends message to host registration page with system/user info data. 198 // Sends message to host registration page with system/user info data.
193 void SendDeviceInfo(); 199 void SendDeviceInfo();
194 200
195 // Converts the currently active CellularNetwork device into a JS object. 201 // Converts the currently active CellularNetwork device into a JS object.
196 static void GetDeviceInfo(CellularNetwork* network, 202 static void GetDeviceInfo(const NetworkState* network,
197 DictionaryValue* value); 203 DictionaryValue* value);
198 204
199 // Type of the mobilesetup webui deduced from received messages. 205 // Type of the mobilesetup webui deduced from received messages.
200 Type type_; 206 Type type_;
201 // Whether portal page for lte networks can be reached in current network 207 // Whether portal page for lte networks can be reached in current network
202 // connection state. This value is reflected in portal webui for lte networks. 208 // connection state. This value is reflected in portal webui for lte networks.
203 // Initial value is true. 209 // Initial value is true.
204 bool lte_portal_reachable_; 210 bool lte_portal_reachable_;
205 211
206 DISALLOW_COPY_AND_ASSIGN(MobileSetupHandler); 212 DISALLOW_COPY_AND_ASSIGN(MobileSetupHandler);
(...skipping 10 matching lines...) Expand all
217 223
218 std::string MobileSetupUIHTMLSource::GetSource() const { 224 std::string MobileSetupUIHTMLSource::GetSource() const {
219 return chrome::kChromeUIMobileSetupHost; 225 return chrome::kChromeUIMobileSetupHost;
220 } 226 }
221 227
222 void MobileSetupUIHTMLSource::StartDataRequest( 228 void MobileSetupUIHTMLSource::StartDataRequest(
223 const std::string& path, 229 const std::string& path,
224 int render_process_id, 230 int render_process_id,
225 int render_view_id, 231 int render_view_id,
226 const content::URLDataSource::GotDataCallback& callback) { 232 const content::URLDataSource::GotDataCallback& callback) {
227 CellularNetwork* network = NULL; 233 const NetworkState* network = NULL;
228 if (!path.empty()) { 234 if (!path.empty()) {
229 network = NetworkLibrary::Get()-> FindCellularNetworkByPath(path); 235 network = NetworkHandler::Get()->network_state_handler()->GetNetworkState(
236 path);
230 } 237 }
231 238
232 if (!network || (!network->SupportsActivation() && !network->activated())) { 239 if (!network ||
240 (network->payment_url().empty() && network->usage_url().empty() &&
241 network->activation_state() != flimflam::kActivationStateActivated)) {
233 LOG(WARNING) << "Can't find device to activate for service path " << path; 242 LOG(WARNING) << "Can't find device to activate for service path " << path;
234 scoped_refptr<base::RefCountedBytes> html_bytes(new base::RefCountedBytes); 243 scoped_refptr<base::RefCountedBytes> html_bytes(new base::RefCountedBytes);
235 callback.Run(html_bytes.get()); 244 callback.Run(html_bytes.get());
236 return; 245 return;
237 } 246 }
238 247
239 LOG(WARNING) << "Starting mobile setup for " << path; 248 LOG(WARNING) << "Starting mobile setup for " << path;
240 DictionaryValue strings; 249 DictionaryValue strings;
241 250
242 strings.SetString("connecting_header", 251 strings.SetString("connecting_header",
(...skipping 19 matching lines...) Expand all
262 strings.SetString("cancel_button", 271 strings.SetString("cancel_button",
263 l10n_util::GetStringUTF16(IDS_CANCEL)); 272 l10n_util::GetStringUTF16(IDS_CANCEL));
264 strings.SetString("ok_button", 273 strings.SetString("ok_button",
265 l10n_util::GetStringUTF16(IDS_OK)); 274 l10n_util::GetStringUTF16(IDS_OK));
266 webui::SetFontAndTextDirection(&strings); 275 webui::SetFontAndTextDirection(&strings);
267 276
268 // The webui differs based on whether the network is activated or not. If the 277 // The webui differs based on whether the network is activated or not. If the
269 // network is activated, the webui goes straight to portal. Otherwise the 278 // network is activated, the webui goes straight to portal. Otherwise the
270 // webui is used for activation flow. 279 // webui is used for activation flow.
271 std::string full_html; 280 std::string full_html;
272 if (network->activated()) { 281 if (network->activation_state() == flimflam::kActivationStateActivated) {
273 static const base::StringPiece html_for_activated( 282 static const base::StringPiece html_for_activated(
274 ResourceBundle::GetSharedInstance().GetRawDataResource( 283 ResourceBundle::GetSharedInstance().GetRawDataResource(
275 IDR_MOBILE_SETUP_PORTAL_PAGE_HTML)); 284 IDR_MOBILE_SETUP_PORTAL_PAGE_HTML));
276 full_html = webui::GetI18nTemplateHtml(html_for_activated, &strings); 285 full_html = webui::GetI18nTemplateHtml(html_for_activated, &strings);
277 } else { 286 } else {
278 static const base::StringPiece html_for_non_activated( 287 static const base::StringPiece html_for_non_activated(
279 ResourceBundle::GetSharedInstance().GetRawDataResource( 288 ResourceBundle::GetSharedInstance().GetRawDataResource(
280 IDR_MOBILE_SETUP_PAGE_HTML)); 289 IDR_MOBILE_SETUP_PAGE_HTML));
281 full_html = webui::GetI18nTemplateHtml(html_for_non_activated, &strings); 290 full_html = webui::GetI18nTemplateHtml(html_for_non_activated, &strings);
282 } 291 }
283 292
284 callback.Run(base::RefCountedString::TakeString(&full_html)); 293 callback.Run(base::RefCountedString::TakeString(&full_html));
285 } 294 }
286 295
287 //////////////////////////////////////////////////////////////////////////////// 296 ////////////////////////////////////////////////////////////////////////////////
288 // 297 //
289 // MobileSetupHandler 298 // MobileSetupHandler
290 // 299 //
291 //////////////////////////////////////////////////////////////////////////////// 300 ////////////////////////////////////////////////////////////////////////////////
292 MobileSetupHandler::MobileSetupHandler() 301 MobileSetupHandler::MobileSetupHandler()
293 : type_(TYPE_UNDETERMINED), 302 : type_(TYPE_UNDETERMINED),
294 lte_portal_reachable_(true) { 303 lte_portal_reachable_(true) {
295 } 304 }
296 305
297 MobileSetupHandler::~MobileSetupHandler() { 306 MobileSetupHandler::~MobileSetupHandler() {
298 if (type_ == TYPE_ACTIVATION) { 307 if (type_ == TYPE_ACTIVATION) {
299 MobileActivator::GetInstance()->RemoveObserver(this); 308 MobileActivator::GetInstance()->RemoveObserver(this);
300 MobileActivator::GetInstance()->TerminateActivation(); 309 MobileActivator::GetInstance()->TerminateActivation();
301 } else if (type_ == TYPE_PORTAL_LTE) { 310 } else if (type_ == TYPE_PORTAL_LTE) {
302 NetworkLibrary::Get()->RemoveNetworkManagerObserver(this); 311 NetworkHandler::Get()->network_state_handler()->RemoveObserver(this,
312 FROM_HERE);
303 } 313 }
304 } 314 }
305 315
306 void MobileSetupHandler::OnActivationStateChanged( 316 void MobileSetupHandler::OnActivationStateChanged(
307 CellularNetwork* network, 317 const NetworkState* network,
308 MobileActivator::PlanActivationState state, 318 MobileActivator::PlanActivationState state,
309 const std::string& error_description) { 319 const std::string& error_description) {
310 DCHECK_EQ(TYPE_ACTIVATION, type_); 320 DCHECK_EQ(TYPE_ACTIVATION, type_);
311 if (!web_ui()) 321 if (!web_ui())
312 return; 322 return;
313 323
314 DictionaryValue device_dict; 324 DictionaryValue device_dict;
315 if (network) 325 if (network)
316 GetDeviceInfo(network, &device_dict); 326 GetDeviceInfo(network, &device_dict);
317 device_dict.SetInteger("state", state); 327 device_dict.SetInteger("state", state);
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 399
390 void MobileSetupHandler::HandleGetDeviceInfo(const ListValue* args) { 400 void MobileSetupHandler::HandleGetDeviceInfo(const ListValue* args) {
391 DCHECK_NE(TYPE_ACTIVATION, type_); 401 DCHECK_NE(TYPE_ACTIVATION, type_);
392 if (!web_ui()) 402 if (!web_ui())
393 return; 403 return;
394 404
395 std::string path = web_ui()->GetWebContents()->GetURL().path(); 405 std::string path = web_ui()->GetWebContents()->GetURL().path();
396 if (path.empty()) 406 if (path.empty())
397 return; 407 return;
398 408
399 NetworkLibrary* network_lib = NetworkLibrary::Get(); 409 chromeos::NetworkStateHandler* nsh =
400 CellularNetwork* network = 410 NetworkHandler::Get()->network_state_handler();
401 network_lib->FindCellularNetworkByPath(path.substr(1)); 411 const NetworkState* network = nsh->GetNetworkState(path.substr(1));
stevenjb 2013/08/14 02:28:31 the path.substr(1) should probably be assigned to
gauravsh 2013/08/14 21:42:29 The path is of the form //service/5, so the path.s
stevenjb 2013/08/14 21:58:35 I do not. We should at least add some sort of comm
armansito 2013/08/14 22:46:34 The URL should be obtained from the service in que
gauravsh 2013/08/15 01:46:35 Done.
402 if (!network) { 412 if (!network) {
403 web_ui()->GetWebContents()->Close(); 413 web_ui()->GetWebContents()->Close();
404 return; 414 return;
405 } 415 }
406 416
407 // If this is the initial call, update the network status and start observing 417 // If this is the initial call, update the network status and start observing
408 // network changes, but only for LTE networks. The other networks should 418 // network changes, but only for LTE networks. The other networks should
409 // ignore network status. 419 // ignore network status.
410 if (type_ == TYPE_UNDETERMINED) { 420 if (type_ == TYPE_UNDETERMINED) {
411 if (network->network_technology() == chromeos::NETWORK_TECHNOLOGY_LTE || 421 if (network->network_technology() == flimflam::kNetworkTechnologyLte ||
412 network->network_technology() == 422 network->network_technology() ==
413 chromeos::NETWORK_TECHNOLOGY_LTE_ADVANCED) { 423 flimflam::kNetworkTechnologyLteAdvanced) {
414 type_ = TYPE_PORTAL_LTE; 424 type_ = TYPE_PORTAL_LTE;
415 network_lib->AddNetworkManagerObserver(this); 425 nsh->AddObserver(this, FROM_HERE);
416 // Update the network status and notify the webui. This is the initial 426 // Update the network status and notify the webui. This is the initial
417 // network state so the webui should be notified no matter what. 427 // network state so the webui should be notified no matter what.
418 UpdatePortalReachability(network_lib, 428 UpdatePortalReachability(network, true /*force notification*/);
419 network,
420 true /*force notification*/);
421 } else { 429 } else {
422 type_ = TYPE_PORTAL; 430 type_ = TYPE_PORTAL;
423 // For non-LTE networks network state is ignored, so report the portal is 431 // For non-LTE networks network state is ignored, so report the portal is
424 // reachable, so it gets shown. 432 // reachable, so it gets shown.
425 web_ui()->CallJavascriptFunction(kJsConnectivityChangedCallback, 433 web_ui()->CallJavascriptFunction(kJsConnectivityChangedCallback,
426 base::FundamentalValue(true)); 434 base::FundamentalValue(true));
427 } 435 }
428 } 436 }
429 437
430 DictionaryValue device_info; 438 DictionaryValue device_info;
431 GetDeviceInfo(network, &device_info); 439 GetDeviceInfo(network, &device_info);
432 web_ui()->CallJavascriptFunction(kJsGetDeviceInfoCallback, device_info); 440 web_ui()->CallJavascriptFunction(kJsGetDeviceInfoCallback, device_info);
433 } 441 }
434 442
435 void MobileSetupHandler::OnNetworkManagerChanged(NetworkLibrary* network_lib) { 443 void MobileSetupHandler::NetworkManagerChanged() {
436 if (!web_ui()) 444 if (!web_ui())
437 return; 445 return;
438 446
439 std::string path = web_ui()->GetWebContents()->GetURL().path(); 447 std::string path = web_ui()->GetWebContents()->GetURL().path();
440 if (path.empty()) 448 if (path.empty())
441 return; 449 return;
442 450
443 CellularNetwork* network = 451 const NetworkState* network =
444 network_lib->FindCellularNetworkByPath(path.substr(1)); 452 NetworkHandler::Get()->network_state_handler()->GetNetworkState(
453 path.substr(1));
445 if (!network) { 454 if (!network) {
446 LOG(ERROR) << "Service path lost"; 455 LOG(ERROR) << "Service path lost";
447 web_ui()->GetWebContents()->Close(); 456 web_ui()->GetWebContents()->Close();
448 return; 457 return;
449 } 458 }
450 459
451 UpdatePortalReachability(network_lib, network, false /*force notification*/); 460 UpdatePortalReachability(network, false /*force notification*/);
armansito 2013/08/14 00:49:51 The inline comment here makes me think that "false
gauravsh 2013/08/14 21:42:29 Done.
452 } 461 }
453 462
454 void MobileSetupHandler::UpdatePortalReachability(NetworkLibrary* network_lib, 463 void MobileSetupHandler::DefaultNetworkChanged(
455 CellularNetwork* network, 464 const NetworkState* default_network) {
456 bool force_notification) { 465 NetworkManagerChanged();
466 }
467
468 void MobileSetupHandler::UpdatePortalReachability(
469 const NetworkState* network,
470 bool force_notification) {
457 DCHECK(web_ui()); 471 DCHECK(web_ui());
458 472
459 DCHECK_EQ(type_, TYPE_PORTAL_LTE); 473 DCHECK_EQ(type_, TYPE_PORTAL_LTE);
460 474
461 bool portal_reachable = network->connected() || 475 chromeos::NetworkStateHandler* nsh =
462 (network_lib->connected_network() && 476 NetworkHandler::Get()->network_state_handler();
463 network_lib->connected_network()->online()); 477 bool portal_reachable =
478 (network->IsConnectedState() ||
479 (nsh->DefaultNetwork() &&
480 nsh->DefaultNetwork()->connection_state() == flimflam::kStateOnline));
464 481
465 if (force_notification || portal_reachable != lte_portal_reachable_) { 482 if (force_notification || portal_reachable != lte_portal_reachable_) {
466 web_ui()->CallJavascriptFunction(kJsConnectivityChangedCallback, 483 web_ui()->CallJavascriptFunction(kJsConnectivityChangedCallback,
467 base::FundamentalValue(portal_reachable)); 484 base::FundamentalValue(portal_reachable));
468 } 485 }
469 486
470 lte_portal_reachable_ = portal_reachable; 487 lte_portal_reachable_ = portal_reachable;
471 } 488 }
472 489
473 void MobileSetupHandler::GetDeviceInfo(CellularNetwork* network, 490 void MobileSetupHandler::GetDeviceInfo(const NetworkState* network,
474 DictionaryValue* value) { 491 DictionaryValue* value) {
475 DCHECK(network); 492 DCHECK(network);
476 chromeos::NetworkLibrary* cros = 493 chromeos::NetworkLibrary* cros =
477 chromeos::NetworkLibrary::Get(); 494 chromeos::NetworkLibrary::Get();
478 if (!cros) 495 if (!cros)
479 return; 496 return;
stevenjb 2013/08/14 02:28:31 Remove
gauravsh 2013/08/14 21:42:29 Done.
480 value->SetBoolean("activate_over_non_cellular_network", 497 value->SetBoolean("activate_over_non_cellular_network",
481 network->activate_over_non_cellular_network()); 498 network->activate_over_non_cellular_networks());
482 value->SetString("carrier", network->name()); 499 value->SetString("carrier", network->name());
483 value->SetString("payment_url", network->payment_url()); 500 value->SetString("payment_url", network->payment_url());
484 if (network->using_post() && network->post_data().length()) 501 if (network->post_method() == "post" && !network->post_data().empty())
485 value->SetString("post_data", network->post_data()); 502 value->SetString("post_data", network->post_data());
486 503
487 const chromeos::NetworkDevice* device = 504 const chromeos::DeviceState* device =
488 cros->FindNetworkDeviceByPath(network->device_path()); 505 NetworkHandler::Get()->network_state_handler()->GetDeviceState(
506 network->device_path());
489 if (device) { 507 if (device) {
490 value->SetString("MEID", device->meid()); 508 value->SetString("MEID", device->meid());
491 value->SetString("IMEI", device->imei()); 509 value->SetString("IMEI", device->imei());
492 value->SetString("MDN", device->mdn()); 510 value->SetString("MDN", device->mdn());
493 } 511 }
494 } 512 }
495 513
496 //////////////////////////////////////////////////////////////////////////////// 514 ////////////////////////////////////////////////////////////////////////////////
497 // 515 //
498 // MobileSetupUI 516 // MobileSetupUI
499 // 517 //
500 //////////////////////////////////////////////////////////////////////////////// 518 ////////////////////////////////////////////////////////////////////////////////
501 519
502 MobileSetupUI::MobileSetupUI(content::WebUI* web_ui) 520 MobileSetupUI::MobileSetupUI(content::WebUI* web_ui)
503 : WebUIController(web_ui) { 521 : WebUIController(web_ui) {
504 web_ui->AddMessageHandler(new MobileSetupHandler()); 522 web_ui->AddMessageHandler(new MobileSetupHandler());
505 MobileSetupUIHTMLSource* html_source = new MobileSetupUIHTMLSource(); 523 MobileSetupUIHTMLSource* html_source = new MobileSetupUIHTMLSource();
506 524
507 // Set up the chrome://mobilesetup/ source. 525 // Set up the chrome://mobilesetup/ source.
508 Profile* profile = Profile::FromWebUI(web_ui); 526 Profile* profile = Profile::FromWebUI(web_ui);
509 content::URLDataSource::Add(profile, html_source); 527 content::URLDataSource::Add(profile, html_source);
510 } 528 }
511 529
512 void MobileSetupUI::RenderViewCreated(RenderViewHost* host) { 530 void MobileSetupUI::RenderViewCreated(RenderViewHost* host) {
513 // Destroyed by the corresponding RenderViewHost 531 // Destroyed by the corresponding RenderViewHost
514 new PortalFrameLoadObserver(AsWeakPtr(), host); 532 new PortalFrameLoadObserver(AsWeakPtr(), host);
515 } 533 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698