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" | |
20 #include "chrome/browser/chromeos/sim_dialog_delegate.h" | 19 #include "chrome/browser/chromeos/sim_dialog_delegate.h" |
21 #include "chrome/browser/profiles/profile.h" | 20 #include "chrome/browser/profiles/profile.h" |
22 #include "chrome/common/url_constants.h" | 21 #include "chrome/common/url_constants.h" |
23 #include "chromeos/network/device_state.h" | 22 #include "chromeos/network/device_state.h" |
24 #include "chromeos/network/network_device_handler.h" | 23 #include "chromeos/network/network_device_handler.h" |
25 #include "chromeos/network/network_event_log.h" | 24 #include "chromeos/network/network_event_log.h" |
26 #include "chromeos/network/network_state_handler.h" | 25 #include "chromeos/network/network_state_handler.h" |
27 #include "chromeos/network/network_state_handler_observer.h" | 26 #include "chromeos/network/network_state_handler_observer.h" |
28 #include "content/public/browser/browser_thread.h" | 27 #include "content/public/browser/browser_thread.h" |
29 #include "content/public/browser/notification_service.h" | |
30 #include "content/public/browser/url_data_source.h" | 28 #include "content/public/browser/url_data_source.h" |
31 #include "content/public/browser/web_contents.h" | 29 #include "content/public/browser/web_contents.h" |
32 #include "content/public/browser/web_ui.h" | 30 #include "content/public/browser/web_ui.h" |
33 #include "content/public/browser/web_ui_message_handler.h" | 31 #include "content/public/browser/web_ui_message_handler.h" |
34 #include "grit/browser_resources.h" | 32 #include "grit/browser_resources.h" |
35 #include "grit/generated_resources.h" | 33 #include "grit/generated_resources.h" |
36 #include "third_party/cros_system_api/dbus/service_constants.h" | 34 #include "third_party/cros_system_api/dbus/service_constants.h" |
37 #include "ui/base/l10n/l10n_util.h" | 35 #include "ui/base/l10n/l10n_util.h" |
38 #include "ui/base/resource/resource_bundle.h" | 36 #include "ui/base/resource/resource_bundle.h" |
39 #include "ui/base/webui/jstemplate_builder.h" | 37 #include "ui/base/webui/jstemplate_builder.h" |
40 #include "ui/base/webui/web_ui_util.h" | 38 #include "ui/base/webui/web_ui_util.h" |
41 | 39 |
42 using content::BrowserThread; | 40 using content::BrowserThread; |
43 using content::WebContents; | 41 using content::WebContents; |
44 using content::WebUIMessageHandler; | 42 using content::WebUIMessageHandler; |
45 | 43 |
46 namespace { | 44 namespace { |
47 | 45 |
48 // JS API callbacks names. | 46 // JS API callbacks names. |
49 const char kJsApiCancel[] = "cancel"; | |
50 const char kJsApiChangePinCode[] = "changePinCode"; | 47 const char kJsApiChangePinCode[] = "changePinCode"; |
51 const char kJsApiEnterPinCode[] = "enterPinCode"; | 48 const char kJsApiEnterPinCode[] = "enterPinCode"; |
52 const char kJsApiEnterPukCode[] = "enterPukCode"; | 49 const char kJsApiEnterPukCode[] = "enterPukCode"; |
53 const char kJsApiProceedToPukInput[] = "proceedToPukInput"; | 50 const char kJsApiProceedToPukInput[] = "proceedToPukInput"; |
54 const char kJsApiSimStatusInitialize[] = "simStatusInitialize"; | 51 const char kJsApiSimStatusInitialize[] = "simStatusInitialize"; |
55 | 52 |
56 // Page JS API function names. | 53 // Page JS API function names. |
57 const char kJsApiSimStatusChanged[] = "mobile.SimUnlock.simStateChanged"; | 54 const char kJsApiSimStatusChanged[] = "mobile.SimUnlock.simStateChanged"; |
58 | 55 |
59 // SIM state variables which are passed to the page. | 56 // SIM state variables which are passed to the page. |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 } | 152 } |
156 | 153 |
157 TaskProxy(const base::WeakPtr<SimUnlockHandler>& handler, | 154 TaskProxy(const base::WeakPtr<SimUnlockHandler>& handler, |
158 const std::string& code, | 155 const std::string& code, |
159 SimUnlockCode code_type) | 156 SimUnlockCode code_type) |
160 : handler_(handler), | 157 : handler_(handler), |
161 code_(code), | 158 code_(code), |
162 code_type_(code_type) { | 159 code_type_(code_type) { |
163 } | 160 } |
164 | 161 |
165 void HandleCancel() { | |
166 if (handler_) | |
167 handler_->CancelDialog(); | |
168 } | |
169 | |
170 void HandleEnterCode() { | 162 void HandleEnterCode() { |
171 if (handler_) | 163 if (handler_) |
172 handler_->EnterCode(code_, code_type_); | 164 handler_->EnterCode(code_, code_type_); |
173 } | 165 } |
174 | 166 |
175 void HandleInitialize() { | 167 void HandleInitialize() { |
176 if (handler_) | 168 if (handler_) |
177 handler_->InitializeSimStatus(); | 169 handler_->InitializeSimStatus(); |
178 } | 170 } |
179 | 171 |
(...skipping 14 matching lines...) Expand all Loading... |
194 | 186 |
195 // Pending code type. | 187 // Pending code type. |
196 SimUnlockCode code_type_; | 188 SimUnlockCode code_type_; |
197 | 189 |
198 DISALLOW_COPY_AND_ASSIGN(TaskProxy); | 190 DISALLOW_COPY_AND_ASSIGN(TaskProxy); |
199 }; | 191 }; |
200 | 192 |
201 // Returns the cellular device that this dialog currently corresponds to. | 193 // Returns the cellular device that this dialog currently corresponds to. |
202 const DeviceState* GetCellularDevice(); | 194 const DeviceState* GetCellularDevice(); |
203 | 195 |
204 // Processing for the cases when dialog was cancelled. | |
205 void CancelDialog(); | |
206 | |
207 // Pass PIN/PUK code to shill and check status. | 196 // Pass PIN/PUK code to shill and check status. |
208 void EnterCode(const std::string& code, SimUnlockCode code_type); | 197 void EnterCode(const std::string& code, SimUnlockCode code_type); |
209 | 198 |
210 // Methods to invoke shill PIN/PUK D-Bus operations. | 199 // Methods to invoke shill PIN/PUK D-Bus operations. |
211 void ChangeRequirePin(bool require_pin, const std::string& pin); | 200 void ChangeRequirePin(bool require_pin, const std::string& pin); |
212 void EnterPin(const std::string& pin); | 201 void EnterPin(const std::string& pin); |
213 void ChangePin(const std::string& old_pin, const std::string& new_pin); | 202 void ChangePin(const std::string& old_pin, const std::string& new_pin); |
214 void UnblockPin(const std::string& puk, const std::string& new_pin); | 203 void UnblockPin(const std::string& puk, const std::string& new_pin); |
215 void PinOperationSuccessCallback(const std::string& operation_name); | 204 void PinOperationSuccessCallback(const std::string& operation_name); |
216 void PinOperationErrorCallback(const std::string& operation_name, | 205 void PinOperationErrorCallback(const std::string& operation_name, |
217 const std::string& error_name, | 206 const std::string& error_name, |
218 scoped_ptr<base::DictionaryValue> error_data); | 207 scoped_ptr<base::DictionaryValue> error_data); |
219 | 208 |
220 // Called when an asynchronous PIN operation has completed. | 209 // Called when an asynchronous PIN operation has completed. |
221 void OnPinOperationCompleted(PinOperationError error); | 210 void OnPinOperationCompleted(PinOperationError error); |
222 | 211 |
223 // Single handler for PIN/PUK code operations. | 212 // Single handler for PIN/PUK code operations. |
224 void HandleEnterCode(SimUnlockCode code_type, const std::string& code); | 213 void HandleEnterCode(SimUnlockCode code_type, const std::string& code); |
225 | 214 |
226 // Handlers for JS WebUI messages. | 215 // Handlers for JS WebUI messages. |
227 void HandleCancel(const base::ListValue* args); | |
228 void HandleChangePinCode(const base::ListValue* args); | 216 void HandleChangePinCode(const base::ListValue* args); |
229 void HandleEnterPinCode(const base::ListValue* args); | 217 void HandleEnterPinCode(const base::ListValue* args); |
230 void HandleEnterPukCode(const base::ListValue* args); | 218 void HandleEnterPukCode(const base::ListValue* args); |
231 void HandleProceedToPukInput(const base::ListValue* args); | 219 void HandleProceedToPukInput(const base::ListValue* args); |
232 void HandleSimStatusInitialize(const base::ListValue* args); | 220 void HandleSimStatusInitialize(const base::ListValue* args); |
233 | 221 |
234 // Initialize current SIM card status, passes that to page. | 222 // Initialize current SIM card status, passes that to page. |
235 void InitializeSimStatus(); | 223 void InitializeSimStatus(); |
236 | 224 |
237 // Notifies SIM Security tab handler that RequirePin preference change | |
238 // has been ended (either updated or cancelled). | |
239 void NotifyOnRequirePinChangeEnded(bool new_value); | |
240 | |
241 // Notifies observers that the EnterPin or EnterPuk dialog has been | |
242 // completed (either cancelled or with entry of PIN/PUK). | |
243 void NotifyOnEnterPinEnded(bool cancelled); | |
244 | |
245 // Checks whether SIM card is in PUK locked state and proceeds to PUK input. | 225 // Checks whether SIM card is in PUK locked state and proceeds to PUK input. |
246 void ProceedToPukInput(); | 226 void ProceedToPukInput(); |
247 | 227 |
248 // Processes current SIM card state and update internal state/page. | 228 // Processes current SIM card state and update internal state/page. |
249 void ProcessSimCardState(const DeviceState* cellular); | 229 void ProcessSimCardState(const DeviceState* cellular); |
250 | 230 |
251 // Updates page with the current state/SIM card info/error. | 231 // Updates page with the current state/SIM card info/error. |
252 void UpdatePage(const DeviceState* cellular, const std::string& error_msg); | 232 void UpdatePage(const DeviceState* cellular, const std::string& error_msg); |
253 | 233 |
254 // Dialog internal state. | 234 // Dialog internal state. |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
288 | 268 |
289 void SimUnlockUIHTMLSource::StartDataRequest( | 269 void SimUnlockUIHTMLSource::StartDataRequest( |
290 const std::string& path, | 270 const std::string& path, |
291 int render_process_id, | 271 int render_process_id, |
292 int render_frame_id, | 272 int render_frame_id, |
293 const content::URLDataSource::GotDataCallback& callback) { | 273 const content::URLDataSource::GotDataCallback& callback) { |
294 base::DictionaryValue strings; | 274 base::DictionaryValue strings; |
295 strings.SetString("title", | 275 strings.SetString("title", |
296 l10n_util::GetStringUTF16(IDS_SIM_UNLOCK_ENTER_PIN_TITLE)); | 276 l10n_util::GetStringUTF16(IDS_SIM_UNLOCK_ENTER_PIN_TITLE)); |
297 strings.SetString("ok", l10n_util::GetStringUTF16(IDS_OK)); | 277 strings.SetString("ok", l10n_util::GetStringUTF16(IDS_OK)); |
298 strings.SetString("cancel", l10n_util::GetStringUTF16(IDS_CANCEL)); | |
299 strings.SetString("enterPinTitle", | 278 strings.SetString("enterPinTitle", |
300 l10n_util::GetStringUTF16(IDS_SIM_UNLOCK_ENTER_PIN_TITLE)); | 279 l10n_util::GetStringUTF16(IDS_SIM_UNLOCK_ENTER_PIN_TITLE)); |
301 strings.SetString("enterPinMessage", | 280 strings.SetString("enterPinMessage", |
302 l10n_util::GetStringUTF16(IDS_SIM_ENTER_PIN_MESSAGE)); | 281 l10n_util::GetStringUTF16(IDS_SIM_ENTER_PIN_MESSAGE)); |
303 strings.SetString("enterPinTriesMessage", | 282 strings.SetString("enterPinTriesMessage", |
304 l10n_util::GetStringUTF16(IDS_SIM_UNLOCK_ENTER_PIN_TRIES_MESSAGE)); | 283 l10n_util::GetStringUTF16(IDS_SIM_UNLOCK_ENTER_PIN_TRIES_MESSAGE)); |
305 strings.SetString("incorrectPinTriesMessage", | 284 strings.SetString("incorrectPinTriesMessage", |
306 l10n_util::GetStringUTF16(IDS_SIM_UNLOCK_INCORRECT_PIN_TRIES_MESSAGE)); | 285 l10n_util::GetStringUTF16(IDS_SIM_UNLOCK_INCORRECT_PIN_TRIES_MESSAGE)); |
307 strings.SetString("incorrectPinTitle", | 286 strings.SetString("incorrectPinTitle", |
308 l10n_util::GetStringUTF16(IDS_SIM_UNLOCK_INCORRECT_PIN_TITLE)); | 287 l10n_util::GetStringUTF16(IDS_SIM_UNLOCK_INCORRECT_PIN_TITLE)); |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
366 ->GetTechnologyState(NetworkTypePattern::Cellular()) != | 345 ->GetTechnologyState(NetworkTypePattern::Cellular()) != |
367 NetworkStateHandler::TECHNOLOGY_UNAVAILABLE) | 346 NetworkStateHandler::TECHNOLOGY_UNAVAILABLE) |
368 GetNetworkStateHandler()->AddObserver(this, FROM_HERE); | 347 GetNetworkStateHandler()->AddObserver(this, FROM_HERE); |
369 } | 348 } |
370 | 349 |
371 SimUnlockHandler::~SimUnlockHandler() { | 350 SimUnlockHandler::~SimUnlockHandler() { |
372 GetNetworkStateHandler()->RemoveObserver(this, FROM_HERE); | 351 GetNetworkStateHandler()->RemoveObserver(this, FROM_HERE); |
373 } | 352 } |
374 | 353 |
375 void SimUnlockHandler::RegisterMessages() { | 354 void SimUnlockHandler::RegisterMessages() { |
376 web_ui()->RegisterMessageCallback(kJsApiCancel, | |
377 base::Bind(&SimUnlockHandler::HandleCancel, | |
378 base::Unretained(this))); | |
379 web_ui()->RegisterMessageCallback(kJsApiChangePinCode, | 355 web_ui()->RegisterMessageCallback(kJsApiChangePinCode, |
380 base::Bind(&SimUnlockHandler::HandleChangePinCode, | 356 base::Bind(&SimUnlockHandler::HandleChangePinCode, |
381 base::Unretained(this))); | 357 base::Unretained(this))); |
382 web_ui()->RegisterMessageCallback(kJsApiEnterPinCode, | 358 web_ui()->RegisterMessageCallback(kJsApiEnterPinCode, |
383 base::Bind(&SimUnlockHandler::HandleEnterPinCode, | 359 base::Bind(&SimUnlockHandler::HandleEnterPinCode, |
384 base::Unretained(this))); | 360 base::Unretained(this))); |
385 web_ui()->RegisterMessageCallback(kJsApiEnterPukCode, | 361 web_ui()->RegisterMessageCallback(kJsApiEnterPukCode, |
386 base::Bind(&SimUnlockHandler::HandleEnterPukCode, | 362 base::Bind(&SimUnlockHandler::HandleEnterPukCode, |
387 base::Unretained(this))); | 363 base::Unretained(this))); |
388 web_ui()->RegisterMessageCallback(kJsApiProceedToPukInput, | 364 web_ui()->RegisterMessageCallback(kJsApiProceedToPukInput, |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
421 VLOG(1) << "OnPinOperationCompleted, error: " << error; | 397 VLOG(1) << "OnPinOperationCompleted, error: " << error; |
422 const DeviceState* cellular = GetCellularDevice(); | 398 const DeviceState* cellular = GetCellularDevice(); |
423 if (!cellular) { | 399 if (!cellular) { |
424 VLOG(1) << "Cellular device disappeared. Dismissing dialog."; | 400 VLOG(1) << "Cellular device disappeared. Dismissing dialog."; |
425 ProcessSimCardState(NULL); | 401 ProcessSimCardState(NULL); |
426 return; | 402 return; |
427 } | 403 } |
428 if (state_ == SIM_NOT_LOCKED_ASK_PIN && error == PIN_ERROR_NONE) { | 404 if (state_ == SIM_NOT_LOCKED_ASK_PIN && error == PIN_ERROR_NONE) { |
429 CHECK(dialog_mode_ == SimDialogDelegate::SIM_DIALOG_SET_LOCK_ON || | 405 CHECK(dialog_mode_ == SimDialogDelegate::SIM_DIALOG_SET_LOCK_ON || |
430 dialog_mode_ == SimDialogDelegate::SIM_DIALOG_SET_LOCK_OFF); | 406 dialog_mode_ == SimDialogDelegate::SIM_DIALOG_SET_LOCK_OFF); |
431 // Async change RequirePin operation has finished OK. | |
432 NotifyOnRequirePinChangeEnded( | |
433 dialog_mode_ == SimDialogDelegate::SIM_DIALOG_SET_LOCK_ON); | |
434 // Dialog will close itself. | 407 // Dialog will close itself. |
435 state_ = SIM_ABSENT_NOT_LOCKED; | 408 state_ = SIM_ABSENT_NOT_LOCKED; |
436 } else if (state_ == SIM_NOT_LOCKED_CHANGE_PIN && error == PIN_ERROR_NONE) { | 409 } else if (state_ == SIM_NOT_LOCKED_CHANGE_PIN && error == PIN_ERROR_NONE) { |
437 CHECK(dialog_mode_ == SimDialogDelegate::SIM_DIALOG_CHANGE_PIN); | 410 CHECK(dialog_mode_ == SimDialogDelegate::SIM_DIALOG_CHANGE_PIN); |
438 // Dialog will close itself. | 411 // Dialog will close itself. |
439 state_ = SIM_ABSENT_NOT_LOCKED; | 412 state_ = SIM_ABSENT_NOT_LOCKED; |
440 } | 413 } |
441 // If previous EnterPIN was last PIN attempt and SIMLock state was already | 414 // If previous EnterPIN was last PIN attempt and SIMLock state was already |
442 // processed by OnNetworkDeviceChanged, let dialog stay on | 415 // processed by OnNetworkDeviceChanged, let dialog stay on |
443 // NO_PIN_RETRIES_LEFT step. | 416 // NO_PIN_RETRIES_LEFT step. |
444 if (!(state_ == SIM_LOCKED_NO_PIN_TRIES_LEFT && error == PIN_ERROR_BLOCKED)) | 417 if (!(state_ == SIM_LOCKED_NO_PIN_TRIES_LEFT && error == PIN_ERROR_BLOCKED)) |
445 ProcessSimCardState(cellular); | 418 ProcessSimCardState(cellular); |
446 if (dialog_mode_ == SimDialogDelegate::SIM_DIALOG_UNLOCK && | |
447 state_ == SIM_ABSENT_NOT_LOCKED) | |
448 NotifyOnEnterPinEnded(false); | |
449 } | 419 } |
450 | 420 |
451 const DeviceState* SimUnlockHandler::GetCellularDevice() { | 421 const DeviceState* SimUnlockHandler::GetCellularDevice() { |
452 return GetNetworkStateHandler()->GetDeviceState(cellular_device_path_); | 422 return GetNetworkStateHandler()->GetDeviceState(cellular_device_path_); |
453 } | 423 } |
454 | 424 |
455 void SimUnlockHandler::CancelDialog() { | |
456 if (dialog_mode_ == SimDialogDelegate::SIM_DIALOG_SET_LOCK_ON || | |
457 dialog_mode_ == SimDialogDelegate::SIM_DIALOG_SET_LOCK_OFF) { | |
458 // When async change RequirePin operation is performed, | |
459 // dialog UI controls such as Cancel button are disabled. | |
460 // If dialog was cancelled that means RequirePin preference hasn't been | |
461 // changed and is not in process of changing at the moment. | |
462 NotifyOnRequirePinChangeEnded( | |
463 !(dialog_mode_ == SimDialogDelegate::SIM_DIALOG_SET_LOCK_ON)); | |
464 } else if (dialog_mode_ == SimDialogDelegate::SIM_DIALOG_UNLOCK) { | |
465 NotifyOnEnterPinEnded(true); | |
466 } | |
467 } | |
468 | |
469 void SimUnlockHandler::EnterCode(const std::string& code, | 425 void SimUnlockHandler::EnterCode(const std::string& code, |
470 SimUnlockCode code_type) { | 426 SimUnlockCode code_type) { |
471 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 427 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
472 | 428 |
473 pending_pin_operation_ = true; | 429 pending_pin_operation_ = true; |
474 | 430 |
475 switch (code_type) { | 431 switch (code_type) { |
476 case CODE_PIN: | 432 case CODE_PIN: |
477 if (dialog_mode_ == SimDialogDelegate::SIM_DIALOG_SET_LOCK_ON || | 433 if (dialog_mode_ == SimDialogDelegate::SIM_DIALOG_SET_LOCK_ON || |
478 dialog_mode_ == SimDialogDelegate::SIM_DIALOG_SET_LOCK_OFF) { | 434 dialog_mode_ == SimDialogDelegate::SIM_DIALOG_SET_LOCK_OFF) { |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
598 if (error_name == NetworkDeviceHandler::kErrorIncorrectPin || | 554 if (error_name == NetworkDeviceHandler::kErrorIncorrectPin || |
599 error_name == NetworkDeviceHandler::kErrorPinRequired) | 555 error_name == NetworkDeviceHandler::kErrorPinRequired) |
600 pin_error = PIN_ERROR_INCORRECT_CODE; | 556 pin_error = PIN_ERROR_INCORRECT_CODE; |
601 else if (error_name == NetworkDeviceHandler::kErrorPinBlocked) | 557 else if (error_name == NetworkDeviceHandler::kErrorPinBlocked) |
602 pin_error = PIN_ERROR_BLOCKED; | 558 pin_error = PIN_ERROR_BLOCKED; |
603 else | 559 else |
604 pin_error = PIN_ERROR_UNKNOWN; | 560 pin_error = PIN_ERROR_UNKNOWN; |
605 OnPinOperationCompleted(pin_error); | 561 OnPinOperationCompleted(pin_error); |
606 } | 562 } |
607 | 563 |
608 void SimUnlockHandler::NotifyOnEnterPinEnded(bool cancelled) { | |
609 content::NotificationService::current()->Notify( | |
610 chrome::NOTIFICATION_ENTER_PIN_ENDED, | |
611 content::NotificationService::AllSources(), | |
612 content::Details<bool>(&cancelled)); | |
613 } | |
614 | |
615 void SimUnlockHandler::NotifyOnRequirePinChangeEnded(bool new_value) { | |
616 content::NotificationService::current()->Notify( | |
617 chrome::NOTIFICATION_REQUIRE_PIN_SETTING_CHANGE_ENDED, | |
618 content::NotificationService::AllSources(), | |
619 content::Details<bool>(&new_value)); | |
620 } | |
621 | |
622 void SimUnlockHandler::HandleCancel(const base::ListValue* args) { | |
623 const size_t kEnterCodeParamCount = 0; | |
624 if (args->GetSize() != kEnterCodeParamCount) { | |
625 NOTREACHED(); | |
626 return; | |
627 } | |
628 scoped_refptr<TaskProxy> task = new TaskProxy(AsWeakPtr()); | |
629 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | |
630 base::Bind(&TaskProxy::HandleCancel, task.get())); | |
631 } | |
632 | |
633 void SimUnlockHandler::HandleChangePinCode(const base::ListValue* args) { | 564 void SimUnlockHandler::HandleChangePinCode(const base::ListValue* args) { |
634 const size_t kChangePinParamCount = 2; | 565 const size_t kChangePinParamCount = 2; |
635 std::string pin; | 566 std::string pin; |
636 std::string new_pin; | 567 std::string new_pin; |
637 if (args->GetSize() != kChangePinParamCount || | 568 if (args->GetSize() != kChangePinParamCount || |
638 !args->GetString(0, &pin) || | 569 !args->GetString(0, &pin) || |
639 !args->GetString(1, &new_pin)) { | 570 !args->GetString(1, &new_pin)) { |
640 NOTREACHED(); | 571 NOTREACHED(); |
641 return; | 572 return; |
642 } | 573 } |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
828 SimUnlockHandler* handler = new SimUnlockHandler(); | 759 SimUnlockHandler* handler = new SimUnlockHandler(); |
829 web_ui->AddMessageHandler(handler); | 760 web_ui->AddMessageHandler(handler); |
830 SimUnlockUIHTMLSource* html_source = new SimUnlockUIHTMLSource(); | 761 SimUnlockUIHTMLSource* html_source = new SimUnlockUIHTMLSource(); |
831 | 762 |
832 // Set up the chrome://sim-unlock/ source. | 763 // Set up the chrome://sim-unlock/ source. |
833 Profile* profile = Profile::FromWebUI(web_ui); | 764 Profile* profile = Profile::FromWebUI(web_ui); |
834 content::URLDataSource::Add(profile, html_source); | 765 content::URLDataSource::Add(profile, html_source); |
835 } | 766 } |
836 | 767 |
837 } // namespace chromeos | 768 } // namespace chromeos |
OLD | NEW |