OLD | NEW |
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/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/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
11 #include "base/bind_helpers.h" | 11 #include "base/bind_helpers.h" |
12 #include "base/location.h" | 12 #include "base/location.h" |
13 #include "base/logging.h" | 13 #include "base/logging.h" |
14 #include "base/memory/ref_counted_memory.h" | 14 #include "base/memory/ref_counted_memory.h" |
15 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
16 #include "base/message_loop/message_loop.h" | 16 #include "base/message_loop/message_loop.h" |
17 #include "base/strings/string_piece.h" | 17 #include "base/strings/string_piece.h" |
18 #include "base/values.h" | 18 #include "base/values.h" |
19 #include "chrome/browser/chrome_notification_types.h" | 19 #include "chrome/browser/chrome_notification_types.h" |
20 #include "chrome/browser/chromeos/sim_dialog_delegate.h" | 20 #include "chrome/browser/chromeos/sim_dialog_delegate.h" |
21 #include "chrome/browser/profiles/profile.h" | 21 #include "chrome/browser/profiles/profile.h" |
22 #include "chrome/common/url_constants.h" | 22 #include "chrome/common/url_constants.h" |
23 #include "chromeos/network/device_state.h" | 23 #include "chromeos/network/device_state.h" |
24 #include "chromeos/network/network_device_handler.h" | 24 #include "chromeos/network/network_device_handler.h" |
25 #include "chromeos/network/network_event_log.h" | 25 #include "chromeos/network/network_event_log.h" |
26 #include "chromeos/network/network_state_handler.h" | 26 #include "chromeos/network/network_state_handler.h" |
27 #include "chromeos/network/network_state_handler_observer.h" | 27 #include "chromeos/network/network_state_handler_observer.h" |
| 28 #include "chromeos/network/shill_property_util.h" |
28 #include "content/public/browser/browser_thread.h" | 29 #include "content/public/browser/browser_thread.h" |
29 #include "content/public/browser/notification_service.h" | 30 #include "content/public/browser/notification_service.h" |
30 #include "content/public/browser/url_data_source.h" | 31 #include "content/public/browser/url_data_source.h" |
31 #include "content/public/browser/web_contents.h" | 32 #include "content/public/browser/web_contents.h" |
32 #include "content/public/browser/web_ui.h" | 33 #include "content/public/browser/web_ui.h" |
33 #include "content/public/browser/web_ui_message_handler.h" | 34 #include "content/public/browser/web_ui_message_handler.h" |
34 #include "grit/browser_resources.h" | 35 #include "grit/browser_resources.h" |
35 #include "grit/generated_resources.h" | 36 #include "grit/generated_resources.h" |
36 #include "third_party/cros_system_api/dbus/service_constants.h" | 37 #include "third_party/cros_system_api/dbus/service_constants.h" |
37 #include "ui/base/l10n/l10n_util.h" | 38 #include "ui/base/l10n/l10n_util.h" |
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
356 callback.Run(base::RefCountedString::TakeString(&full_html)); | 357 callback.Run(base::RefCountedString::TakeString(&full_html)); |
357 } | 358 } |
358 | 359 |
359 // SimUnlockHandler ------------------------------------------------------------ | 360 // SimUnlockHandler ------------------------------------------------------------ |
360 | 361 |
361 SimUnlockHandler::SimUnlockHandler() | 362 SimUnlockHandler::SimUnlockHandler() |
362 : state_(SIM_UNLOCK_LOADING), | 363 : state_(SIM_UNLOCK_LOADING), |
363 dialog_mode_(SimDialogDelegate::SIM_DIALOG_UNLOCK), | 364 dialog_mode_(SimDialogDelegate::SIM_DIALOG_UNLOCK), |
364 pending_pin_operation_(false), | 365 pending_pin_operation_(false), |
365 weak_ptr_factory_(this) { | 366 weak_ptr_factory_(this) { |
366 if (GetNetworkStateHandler()->GetTechnologyState(flimflam::kTypeCellular) | 367 if (GetNetworkStateHandler() |
367 != NetworkStateHandler::TECHNOLOGY_UNAVAILABLE) | 368 ->GetTechnologyState(NetworkTypePattern::Cellular()) != |
| 369 NetworkStateHandler::TECHNOLOGY_UNAVAILABLE) |
368 GetNetworkStateHandler()->AddObserver(this, FROM_HERE); | 370 GetNetworkStateHandler()->AddObserver(this, FROM_HERE); |
369 } | 371 } |
370 | 372 |
371 SimUnlockHandler::~SimUnlockHandler() { | 373 SimUnlockHandler::~SimUnlockHandler() { |
372 GetNetworkStateHandler()->RemoveObserver(this, FROM_HERE); | 374 GetNetworkStateHandler()->RemoveObserver(this, FROM_HERE); |
373 } | 375 } |
374 | 376 |
375 void SimUnlockHandler::RegisterMessages() { | 377 void SimUnlockHandler::RegisterMessages() { |
376 web_ui()->RegisterMessageCallback(kJsApiCancel, | 378 web_ui()->RegisterMessageCallback(kJsApiCancel, |
377 base::Bind(&SimUnlockHandler::HandleCancel, | 379 base::Bind(&SimUnlockHandler::HandleCancel, |
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
699 scoped_refptr<TaskProxy> task = new TaskProxy(AsWeakPtr()); | 701 scoped_refptr<TaskProxy> task = new TaskProxy(AsWeakPtr()); |
700 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | 702 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
701 base::Bind(&TaskProxy::HandleInitialize, task.get())); | 703 base::Bind(&TaskProxy::HandleInitialize, task.get())); |
702 } | 704 } |
703 | 705 |
704 void SimUnlockHandler::InitializeSimStatus() { | 706 void SimUnlockHandler::InitializeSimStatus() { |
705 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 707 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
706 // TODO(armansito): For now, we're initializing the device path to the first | 708 // TODO(armansito): For now, we're initializing the device path to the first |
707 // available cellular device. We should try to obtain a specific device here, | 709 // available cellular device. We should try to obtain a specific device here, |
708 // as there can be multiple cellular devices present. | 710 // as there can be multiple cellular devices present. |
709 const DeviceState* cellular_device = GetNetworkStateHandler()-> | 711 const DeviceState* cellular_device = |
710 GetDeviceStateByType(flimflam::kTypeCellular); | 712 GetNetworkStateHandler() |
| 713 ->GetDeviceStateByType(NetworkTypePattern::Cellular()); |
711 if (cellular_device) { | 714 if (cellular_device) { |
712 cellular_device_path_ = cellular_device->path(); | 715 cellular_device_path_ = cellular_device->path(); |
713 sim_lock_type_ = cellular_device->sim_lock_type(); | 716 sim_lock_type_ = cellular_device->sim_lock_type(); |
714 } | 717 } |
715 ProcessSimCardState(cellular_device); | 718 ProcessSimCardState(cellular_device); |
716 } | 719 } |
717 | 720 |
718 void SimUnlockHandler::ProceedToPukInput() { | 721 void SimUnlockHandler::ProceedToPukInput() { |
719 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 722 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
720 ProcessSimCardState(GetCellularDevice()); | 723 ProcessSimCardState(GetCellularDevice()); |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
827 SimUnlockHandler* handler = new SimUnlockHandler(); | 830 SimUnlockHandler* handler = new SimUnlockHandler(); |
828 web_ui->AddMessageHandler(handler); | 831 web_ui->AddMessageHandler(handler); |
829 SimUnlockUIHTMLSource* html_source = new SimUnlockUIHTMLSource(); | 832 SimUnlockUIHTMLSource* html_source = new SimUnlockUIHTMLSource(); |
830 | 833 |
831 // Set up the chrome://sim-unlock/ source. | 834 // Set up the chrome://sim-unlock/ source. |
832 Profile* profile = Profile::FromWebUI(web_ui); | 835 Profile* profile = Profile::FromWebUI(web_ui); |
833 content::URLDataSource::Add(profile, html_source); | 836 content::URLDataSource::Add(profile, html_source); |
834 } | 837 } |
835 | 838 |
836 } // namespace chromeos | 839 } // namespace chromeos |
OLD | NEW |