Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/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 |
| (...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 395 const std::string& service_path) | 395 const std::string& service_path) |
| 396 : DataSource(chrome::kChromeUIMobileSetupHost, MessageLoop::current()), | 396 : DataSource(chrome::kChromeUIMobileSetupHost, MessageLoop::current()), |
| 397 service_path_(service_path) { | 397 service_path_(service_path) { |
| 398 } | 398 } |
| 399 | 399 |
| 400 void MobileSetupUIHTMLSource::StartDataRequest(const std::string& path, | 400 void MobileSetupUIHTMLSource::StartDataRequest(const std::string& path, |
| 401 bool is_incognito, | 401 bool is_incognito, |
| 402 int request_id) { | 402 int request_id) { |
| 403 chromeos::CellularNetwork* network = GetCellularNetwork(service_path_); | 403 chromeos::CellularNetwork* network = GetCellularNetwork(service_path_); |
| 404 DCHECK(network); | 404 DCHECK(network); |
| 405 if (!network->SupportsActivation()) { | |
| 406 scoped_refptr<RefCountedBytes> html_bytes(new RefCountedBytes); | |
| 407 SendResponse(request_id, html_bytes); | |
| 408 return; | |
| 409 } | |
| 405 DictionaryValue strings; | 410 DictionaryValue strings; |
| 406 strings.SetString("title", l10n_util::GetStringUTF16(IDS_MOBILE_SETUP_TITLE)); | 411 strings.SetString("title", l10n_util::GetStringUTF16(IDS_MOBILE_SETUP_TITLE)); |
| 407 strings.SetString("connecting_header", | 412 strings.SetString("connecting_header", |
| 408 l10n_util::GetStringFUTF16(IDS_MOBILE_CONNECTING_HEADER, | 413 l10n_util::GetStringFUTF16(IDS_MOBILE_CONNECTING_HEADER, |
| 409 network ? UTF8ToUTF16(network->name()) : string16())); | 414 network ? UTF8ToUTF16(network->name()) : string16())); |
| 410 strings.SetString("error_header", | 415 strings.SetString("error_header", |
| 411 l10n_util::GetStringUTF16(IDS_MOBILE_ERROR_HEADER)); | 416 l10n_util::GetStringUTF16(IDS_MOBILE_ERROR_HEADER)); |
| 412 strings.SetString("activating_header", | 417 strings.SetString("activating_header", |
| 413 l10n_util::GetStringUTF16(IDS_MOBILE_ACTIVATING_HEADER)); | 418 l10n_util::GetStringUTF16(IDS_MOBILE_ACTIVATING_HEADER)); |
| 414 strings.SetString("completed_header", | 419 strings.SetString("completed_header", |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 464 lib->Unlock(); | 469 lib->Unlock(); |
| 465 ReEnableOtherConnections(); | 470 ReEnableOtherConnections(); |
| 466 } | 471 } |
| 467 | 472 |
| 468 WebUIMessageHandler* MobileSetupHandler::Attach(WebUI* web_ui) { | 473 WebUIMessageHandler* MobileSetupHandler::Attach(WebUI* web_ui) { |
| 469 return WebUIMessageHandler::Attach(web_ui); | 474 return WebUIMessageHandler::Attach(web_ui); |
| 470 } | 475 } |
| 471 | 476 |
| 472 void MobileSetupHandler::Init(TabContents* contents) { | 477 void MobileSetupHandler::Init(TabContents* contents) { |
| 473 tab_contents_ = contents; | 478 tab_contents_ = contents; |
| 474 LoadCellularConfig(); | 479 LoadCellularConfig(); |
|
zel
2011/07/07 16:30:56
you can probably do all this before you load the c
Nikita (slow)
2011/07/07 16:49:14
Done. At some point I've thought to use some error
| |
| 480 chromeos::CellularNetwork* network = GetCellularNetwork(service_path_); | |
| 481 if (!network || !network->SupportsActivation()) | |
| 482 return; | |
| 475 if (!chromeos::CrosLibrary::Get()->GetNetworkLibrary()->IsLocked()) | 483 if (!chromeos::CrosLibrary::Get()->GetNetworkLibrary()->IsLocked()) |
| 476 SetupActivationProcess(GetCellularNetwork(service_path_)); | 484 SetupActivationProcess(network); |
| 477 else | 485 else |
| 478 already_running_ = true; | 486 already_running_ = true; |
| 479 } | 487 } |
| 480 | 488 |
| 481 void MobileSetupHandler::RegisterMessages() { | 489 void MobileSetupHandler::RegisterMessages() { |
| 482 web_ui_->RegisterMessageCallback(kJsApiStartActivation, | 490 web_ui_->RegisterMessageCallback(kJsApiStartActivation, |
| 483 NewCallback(this, &MobileSetupHandler::HandleStartActivation)); | 491 NewCallback(this, &MobileSetupHandler::HandleStartActivation)); |
| 484 web_ui_->RegisterMessageCallback(kJsApiSetTransactionStatus, | 492 web_ui_->RegisterMessageCallback(kJsApiSetTransactionStatus, |
| 485 NewCallback(this, &MobileSetupHandler::HandleSetTransactionStatus)); | 493 NewCallback(this, &MobileSetupHandler::HandleSetTransactionStatus)); |
| 486 } | 494 } |
| (...skipping 833 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1320 std::string service_path = network ? network->service_path() : std::string(); | 1328 std::string service_path = network ? network->service_path() : std::string(); |
| 1321 MobileSetupHandler* handler = new MobileSetupHandler(service_path); | 1329 MobileSetupHandler* handler = new MobileSetupHandler(service_path); |
| 1322 AddMessageHandler((handler)->Attach(this)); | 1330 AddMessageHandler((handler)->Attach(this)); |
| 1323 handler->Init(contents); | 1331 handler->Init(contents); |
| 1324 MobileSetupUIHTMLSource* html_source = | 1332 MobileSetupUIHTMLSource* html_source = |
| 1325 new MobileSetupUIHTMLSource(service_path); | 1333 new MobileSetupUIHTMLSource(service_path); |
| 1326 | 1334 |
| 1327 // Set up the chrome://mobilesetup/ source. | 1335 // Set up the chrome://mobilesetup/ source. |
| 1328 contents->profile()->GetChromeURLDataManager()->AddDataSource(html_source); | 1336 contents->profile()->GetChromeURLDataManager()->AddDataSource(html_source); |
| 1329 } | 1337 } |
| OLD | NEW |