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/sim_unlock_ui.h" | 5 #include "chrome/browser/ui/webui/chromeos/sim_unlock_ui.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
343 web_ui_->RegisterMessageCallback(kJsApiEnterPukCode, | 343 web_ui_->RegisterMessageCallback(kJsApiEnterPukCode, |
344 NewCallback(this, &SimUnlockHandler::HandleEnterPukCode)); | 344 NewCallback(this, &SimUnlockHandler::HandleEnterPukCode)); |
345 web_ui_->RegisterMessageCallback(kJsApiProceedToPukInput, | 345 web_ui_->RegisterMessageCallback(kJsApiProceedToPukInput, |
346 NewCallback(this, &SimUnlockHandler::HandleProceedToPukInput)); | 346 NewCallback(this, &SimUnlockHandler::HandleProceedToPukInput)); |
347 web_ui_->RegisterMessageCallback(kJsApiSimStatusInitialize, | 347 web_ui_->RegisterMessageCallback(kJsApiSimStatusInitialize, |
348 NewCallback(this, &SimUnlockHandler::HandleSimStatusInitialize)); | 348 NewCallback(this, &SimUnlockHandler::HandleSimStatusInitialize)); |
349 } | 349 } |
350 | 350 |
351 void SimUnlockHandler::OnNetworkDeviceChanged(NetworkLibrary* cros, | 351 void SimUnlockHandler::OnNetworkDeviceChanged(NetworkLibrary* cros, |
352 const NetworkDevice* device) { | 352 const NetworkDevice* device) { |
353 chromeos::SIMLockState lock_state = device->sim_lock_state(); | 353 chromeos::SimLockState lock_state = device->sim_lock_state(); |
354 int retries_left = device->sim_retries_left(); | 354 int retries_left = device->sim_retries_left(); |
355 VLOG(1) << "OnNetworkDeviceChanged, lock: " << lock_state | 355 VLOG(1) << "OnNetworkDeviceChanged, lock: " << lock_state |
356 << ", retries: " << retries_left; | 356 << ", retries: " << retries_left; |
357 ProcessSimCardState(GetCellularDevice()); | 357 ProcessSimCardState(GetCellularDevice()); |
358 } | 358 } |
359 | 359 |
360 void SimUnlockHandler::OnPinOperationCompleted(NetworkLibrary* cros, | 360 void SimUnlockHandler::OnPinOperationCompleted(NetworkLibrary* cros, |
361 PinOperationError error) { | 361 PinOperationError error) { |
362 DCHECK(cros); | 362 DCHECK(cros); |
363 const NetworkDevice* cellular = cros->FindCellularDevice(); | 363 const NetworkDevice* cellular = cros->FindCellularDevice(); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
400 } | 400 } |
401 } | 401 } |
402 | 402 |
403 void SimUnlockHandler::EnterCode(const std::string& code, | 403 void SimUnlockHandler::EnterCode(const std::string& code, |
404 SimUnlockCode code_type) { | 404 SimUnlockCode code_type) { |
405 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 405 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
406 NetworkLibrary* lib = chromeos::CrosLibrary::Get()->GetNetworkLibrary(); | 406 NetworkLibrary* lib = chromeos::CrosLibrary::Get()->GetNetworkLibrary(); |
407 CHECK(lib); | 407 CHECK(lib); |
408 | 408 |
409 const NetworkDevice* cellular = GetCellularDevice(); | 409 const NetworkDevice* cellular = GetCellularDevice(); |
410 chromeos::SIMLockState lock_state = cellular->sim_lock_state(); | 410 chromeos::SimLockState lock_state = cellular->sim_lock_state(); |
411 | 411 |
412 switch (code_type) { | 412 switch (code_type) { |
413 case CODE_PIN: | 413 case CODE_PIN: |
414 if (dialog_mode_ == SimDialogDelegate::SIM_DIALOG_SET_LOCK_ON || | 414 if (dialog_mode_ == SimDialogDelegate::SIM_DIALOG_SET_LOCK_ON || |
415 dialog_mode_ == SimDialogDelegate::SIM_DIALOG_SET_LOCK_OFF) { | 415 dialog_mode_ == SimDialogDelegate::SIM_DIALOG_SET_LOCK_OFF) { |
416 if (lock_state != chromeos::SIM_UNLOCKED) { | 416 if (lock_state != chromeos::SIM_UNLOCKED) { |
417 // If SIM is locked/absent, change RequirePin UI is not accessible. | 417 // If SIM is locked/absent, change RequirePin UI is not accessible. |
418 NOTREACHED() << | 418 NOTREACHED() << |
419 "Changing RequirePin pref on locked / uninitialized SIM."; | 419 "Changing RequirePin pref on locked / uninitialized SIM."; |
420 } | 420 } |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
541 | 541 |
542 void SimUnlockHandler::ProceedToPukInput() { | 542 void SimUnlockHandler::ProceedToPukInput() { |
543 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 543 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
544 ProcessSimCardState(GetCellularDevice()); | 544 ProcessSimCardState(GetCellularDevice()); |
545 } | 545 } |
546 | 546 |
547 void SimUnlockHandler::ProcessSimCardState( | 547 void SimUnlockHandler::ProcessSimCardState( |
548 const chromeos::NetworkDevice* cellular) { | 548 const chromeos::NetworkDevice* cellular) { |
549 std::string error_msg; | 549 std::string error_msg; |
550 if (cellular) { | 550 if (cellular) { |
551 chromeos::SIMLockState lock_state = cellular->sim_lock_state(); | 551 chromeos::SimLockState lock_state = cellular->sim_lock_state(); |
552 int retries_left = cellular->sim_retries_left(); | 552 int retries_left = cellular->sim_retries_left(); |
553 VLOG(1) << "Current state: " << state_ << " lock_state: " << lock_state | 553 VLOG(1) << "Current state: " << state_ << " lock_state: " << lock_state |
554 << " retries: " << retries_left; | 554 << " retries: " << retries_left; |
555 switch (state_) { | 555 switch (state_) { |
556 case SIM_UNLOCK_LOADING: | 556 case SIM_UNLOCK_LOADING: |
557 if (lock_state == chromeos::SIM_LOCKED_PIN) { | 557 if (lock_state == chromeos::SIM_LOCKED_PIN) { |
558 state_ = SIM_LOCKED_PIN; | 558 state_ = SIM_LOCKED_PIN; |
559 } else if (lock_state == chromeos::SIM_LOCKED_PUK) { | 559 } else if (lock_state == chromeos::SIM_LOCKED_PUK) { |
560 if (retries_left > 0) | 560 if (retries_left > 0) |
561 state_ = SIM_LOCKED_PUK; | 561 state_ = SIM_LOCKED_PUK; |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
654 AddMessageHandler((handler)->Attach(this)); | 654 AddMessageHandler((handler)->Attach(this)); |
655 handler->Init(contents); | 655 handler->Init(contents); |
656 SimUnlockUIHTMLSource* html_source = new SimUnlockUIHTMLSource(); | 656 SimUnlockUIHTMLSource* html_source = new SimUnlockUIHTMLSource(); |
657 | 657 |
658 // Set up the chrome://sim-unlock/ source. | 658 // Set up the chrome://sim-unlock/ source. |
659 Profile* profile = Profile::FromBrowserContext(contents->browser_context()); | 659 Profile* profile = Profile::FromBrowserContext(contents->browser_context()); |
660 profile->GetChromeURLDataManager()->AddDataSource(html_source); | 660 profile->GetChromeURLDataManager()->AddDataSource(html_source); |
661 } | 661 } |
662 | 662 |
663 } // namespace chromeos | 663 } // namespace chromeos |
OLD | NEW |